Skip to content Skip to sidebar Skip to footer

Use Gradle To Upload Jar To Local Maven Repository

This question has been asked several times, but somehow I don't get this to work. Gradle is a great tool, but its documentation is anything but great. No examples make it almost im

Solution 1:

I suspect the problem is that you are only editing the POM (via pom.project), instead of configuring the actual Maven coordinates used for installation. Try the following instead:

// best way to set group IDgroup = 'com.example'

install {
    repositories.mavenInstaller {
        // only necessary if artifact ID diverges from project name// the latter defaults to project directory name and can be// configured in settings.gradle
        pom.artifactId = 'myName'// shouldn't be needed as this is the default anyway
        pom.packaging = 'jar'
    }
}

PS: The samples directory in the full Gradle distribution contains many example builds, also for the maven plugin.

Solution 2:

Peter N is CORRECT in the comments of the accepted answer, which works, but shouldn't be the accepted answer.

You should have this in your build.gradle file

apply plugin: "maven"

Then you can just do a

$ ./gradlew install

Or use the built-in task

$ ./gradlew publishToMavenLocal

Both methods install the artifacts in $HOME/.m2/com/example/example/version

Post a Comment for "Use Gradle To Upload Jar To Local Maven Repository"