maven - 如何根据Maven Artifact 版本将存档上传到不同的文件夹?

标签 maven gradle nexus android-productflavors

我遇到一些问题,试图弄清楚如何才能将有关Maven Artifact 版本的文件上传到其他文件夹,然后在该文件夹中保存生成的Flavor jars / wars / aars。

例如,我得到了一个带有version 1.0.0groupId com.example的 Artifact 。
问题是,将其上传到 Nexus 时,文件夹结构最终变为com/example/10-flavor1 com/example/10-flavor2

这是我的功课:

uploadArchives {
    repositories {
        mavenDeployer {
            repository(url:"http:/nexus/content/repositories/releases/") {
                authentication(userName: "username", password:"password")
            }

            addFilter('flavor1Release') { artifact, file ->
                artifact.attributes.classifier.equals("flavor1Release")
            }
            addFilter('flavor2Release') { artifact, file ->
                artifact.attributes.classifier.equals("flavor2Release")
            }

            pom('flavor1').artifactId = "artifactExample"
            pom('flavor1').version = "1.0.0"
            pom('flavor1').groupId = "com.example"

            pom('flavor2').artifactId = "artifactExample"
            pom('flavor2').version = "1.0.0"
            pom('flavor2').groupId = "com.example"
        }
    }
}

我想知道是否有一种自定义存储库请求的方法,以便我们可以传递需要为每个 Artifact 创建的确切文件夹。
或任何真的可以做的工作。

最佳答案

这违反了Maven Coordinates groupId:artifactId:version的理念:

The three elements given above point to a specific version of a project letting Maven know who we are dealing with, ...

Coordinates define a unique location for a project. [...] To review, a Maven Coordinate is made up of three components: ...

<packaging>类型不是坐标的一部分,例如:
com.example:artifact1:1.0.0:jar
com.example:artifact2:1.0.0:war
成为存储库文件夹和文件:
+- com/example/artifact1/1.0.0
   +- artifact1-1.0.0.pom
   +- artifact1-1.0.0.jar
+- com/example/artifact2/1.0.0
   +- artifact2-1.0.0.pom
   +- artifact2-1.0.0.war
在您想要的时候:
com.example:artifactExample:1.0.0:jar
com.example:artifactExample:1.0.0:war
变得:
+- com/example/artifactExample/1.0.0
   +- jar
      +- artifactExample-1.0.0.pom
      +- artifactExample-1.0.0.jar
   +- war
      +- artifactExample-1.0.0.pom
      +- artifactExample-1.0.0.war
除了<packaging>类型不是坐标的一部分(并因此成为结果的文件夹结构)之外,我们在那里看到另一个问题:我们将有两个具有相同坐标的POM,而坐标是用于标识的,即唯一的。

关于maven - 如何根据Maven Artifact 版本将存档上传到不同的文件夹?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36865166/

相关文章:

java - 使用 Vaadin 将 Maven 项目部署到 Tomcat

logging - 如何在 gradle 中禁用调试消息

android - 如何在库模块中的代码中获取主要的applicationId?

java - mvn tomcat7 :deploy takes too long to deploy?

java - activemq 5.9.0 在 Windows 和 Maven 中失败

java - 与资源一起部署war文件

gradle - 为什么 gradle 在配置时解析依赖项?

maven - 无法解析Gradle中的jar依赖项

maven - 是否有一个插件可以将 Jenkins 的构建与 Maven (Nexus) Artifact 联系起来

maven - 将签名的jars发布到内部仓库有什么问题吗?