How to push to local and remote Maven repository using uploadArchives?

情到浓时终转凉″ 提交于 2019-12-12 06:32:12

问题


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.


回答1:


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).



来源:https://stackoverflow.com/questions/21836032/how-to-push-to-local-and-remote-maven-repository-using-uploadarchives

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!