Question

I came across gradle publishToMavenLocal as part of the "maven-publish" plugin which installs a build into the local ~/.m2 folder. Since I am still using gradle uploadArchives I wonder if there is something similar which would allow to choose between local and remote deployment?

A manual way to configure the local Maven repository is the following:

uploadArchives {
    repositories {
        mavenDeployer {
            repository url: 'file://' + new File(
                System.getProperty('user.home'), '.m2/repository').absolutePath
        }
    }
}

task install(dependsOn: uploadArchives)

I also came up with the idea that whenever the build is uploaded to the remote repository it is installed to the local repository as well. But I am not sure if it is wanted to automate this - comments are welcome.

Was it helpful?

Solution

Once you have applied the maven plugin, all you need to do to install to the local Maven repository is to execute gradle install (without any further declarations in the build script). Installation can be fine-tuned via mavenInstaller (instead of mavenDeployer for an external repository).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top