java – 确定maven deploy-file的存储库URL
发布时间:2020-12-15 02:18:46 所属栏目:Java 来源:网络整理
导读:我正在使用Maven来构建一个特定的项目,并且在POM中我正在使用maven shade插件构建3个主要工件的不同变体(我正在创建具有包含的日志框架的各种组合的超级罐). shade插件创建具有替代工件ID的罐子以及它们各自的依赖性减少的poms. 我现在的挑战是如何将这些新
我正在使用Maven来构建一个特定的项目,并且在POM中我正在使用maven shade插件构建3个主要工件的不同变体(我正在创建具有包含的日志框架的各种组合的超级罐). shade插件创建具有替代工件ID的罐子以及它们各自的依赖性减少的poms.
我现在的挑战是如何将这些新工件部署到我的远程存储库.我正在使用maven安装插件将它们安装到我的本地存储库,但是maven deploy插件需要显式配置存储库URL.我想要发生的是插件采用默认部署使用的任何远程仓库,无论是快照还是发布仓库还是我通过命令行传递的另一个repo URL.我希望找到一些maven属性,比如${project.remoterepo.url}等同于已解决的回购.当部署目标已经这样做时,必须显式配置远程URL似乎很愚蠢. 任何建议表示赞赏谢谢! 解决方法
这就是我根据版本模式自动选择SNAPSHOT或RELEASE repro所做的事情:(我知道这是一种代码味道,但是ASF不愿意包含你的代码,因为我有可能解决我的要求)
<properties> <deploy.repositoryUrl>.. url release repo ..</deploy.repositoryUrl> <deploy.repositoryId>.. id release repo ..</deploy.repositoryId> <deploy.repositorySnapshotUrl>.. snapshot repo ..</deploy.repositorySnapshotUrl> <deploy.repositorySnapshotId>.. id snapshot repo ..</deploy.repositorySnapshotId> </properties> <build> <plugins> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>build-helper-maven-plugin</artifactId> <version>3.0.0</version> <executions> <execution> <!-- sets the isSnapshot property to true if SNAPSHOT was used --> <id>build-helper-regex-is-snapshot-used</id> <phase>validate</phase> <goals> <goal>regex-property</goal> </goals> <configuration> <name>isSnapshot</name> <value>${project.version}</value> <regex>.*-SNAPSHOT</regex> <replacement>true</replacement> <failIfNoMatch>false</failIfNoMatch> </configuration> </execution> </executions> </plugin> <!-- set the properties deploy.Url and deploy.Id during validation to either the snapshot repository or the release repository depending on the version pattern.--> <plugin> <groupId>org.codehaus.gmaven</groupId> <artifactId>gmaven-plugin</artifactId> <version>1.5</version> <executions> <execution> <phase>validate</phase> <goals> <goal>execute</goal> </goals> <configuration> <source><![CDATA[ pom.properties['deploy.Url']=pom.properties['isSnapshot'].equals('true') ? pom.properties['deploy.repositorySnapshotUrl'] : pom.properties['deploy.repositoryUrl']; pom.properties['deploy.Id']=pom.properties['isSnapshot'].equals('true') ? pom.properties['deploy.repositorySnapshotId'] : pom.properties['deploy.repositoryId']; ]]></source> </configuration> </execution> </executions> </plugin> ... <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-deploy-plugin</artifactId> <version>3.0.0-M1</version> <configuration> <skip>true</skip> </configuration> <executions> <execution> <id>DeployToArtifactory</id> <phase>deploy</phase> <goals> <goal>deploy-file</goal> </goals> <configuration> <url>${deploy.Url}</url> <repositoryId>${deploy.Id}</repositoryId> <file>target/${project.build.finalName}.${project.packaging}</file> <groupId>${project.groupId}</groupId> <artifactId>${project.artifactId}</artifactId> <version>${project.version}</version> <packaging>jar</packaging> <classifier>resources</classifier> <pomFile>${project.build.directory}/pom/pom.xml</pomFile> </configuration> </execution> </executions> </plugin> </plugins> </build> (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |