【发布时间】:2014-10-01 01:20:06
【问题描述】:
项目背景;我的团队有大量的 JNI 项目。由于 JNI 项目本身具有依赖链,因此希望简化构建/发布策略。
使用与此处类似的模型:http://mail-archives.apache.org/mod_mbox/maven-users/200706.mbox/%3C56761.84.233.182.145.1181035390.squirrel@www.sharp.fm%3E 作为原型,效果很好。分发模块添加适当的 jar 并使用分类器。示例最终 jar 将是 CiscoJ-dist-unix-amd64.jar。
我遇到的问题似乎是 install 创建了项目 pom 但尝试在项目中使用分类器 jar,它正在寻找与分类器匹配的 pom 文件;因此从上面寻找 J-dist-unix-amd64.pom。唯一存在的 pom 当然是项目 pom J-dist.pom。
[警告]
com.cisco.ciscossl:CiscoJ-dist:jar:unix-amd64:1.00 的 POM 丢失,没有 可用的依赖信息 [DEBUG] 依赖收集统计信息: {ConflictMarker.analyzeTime=1, ConflictMarker.markTime=0, ConflictMarker.nodeCount=4,ConflictIdSorter.graphTime=0, ConflictIdSorter.topsortTime=1,ConflictIdSorter.conflictIdCount=3, ConflictIdSorter.conflictIdCycleCount=0,ConflictResolver.totalTime=2, ConflictResolver.conflictItemCount=3, DefaultDependencyCollector.collectTime=290, DefaultDependencyCollector.transformTime=6}
在尝试使用架构相关信息进行构建的项目中。
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
</dependency>
<dependency>
<groupId>com.cisco.ciscossl</groupId>
<artifactId>CiscoJ-dist</artifactId>
<classifier>${os.family}-${os.arch}</classifier>
<version>1.00</version>
</dependency>
</dependencies>
据此; http://maven.40175.n5.nabble.com/pom-does-not-get-installed-if-classifier-used-td120388.html;它应该用我的 maven (3.1.1) 版本修复。
项目的Pom文件
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>com.cisco.ciscossl.CiscoJ</groupId>
<artifactId>CiscoJ-dist</artifactId>
<version>1.00</version>
<packaging>jar</packaging>
<parent>
<groupId>com.cisco.ciscossl</groupId>
<artifactId>CiscoJ</artifactId>
<version>1.00</version>
</parent>
<dependencies>
<dependency>
<groupId>${pom.groupId}</groupId>
<artifactId>CiscoJUtils</artifactId>
<version>1.00</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>${pom.groupId}</groupId>
<artifactId>CiscoJCE</artifactId>
<version>1.00</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>${pom.groupId}</groupId>
<artifactId>CiscoJSafeC</artifactId>
<version>1.00</version>
<classifier>${os.family}-${os.arch}</classifier>
<optional>true</optional>
</dependency>
<dependency>
<groupId>${pom.groupId}</groupId>
<artifactId>CiscoJCEJNI</artifactId>
<version>1.00</version>
<classifier>${os.family}-${os.arch}</classifier>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.7.2</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.2</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<id>package-all</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<descriptors>
<descriptor>src/main/assembly/dist-jar.xml</descriptor>
</descriptors>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
汇编器:
<assembly
xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
<id>${os.family}-${os.arch}</id>
<formats>
<format>jar</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<dependencySets>
<dependencySet>
<excludes>
<exclude>org.slf4j:slf4j-simple</exclude>
<exclude>org.slf4j:slf4j-api</exclude>
<exclude>junit:junit</exclude>
</excludes>
<unpack>true</unpack>
<useTransitiveDependencies>false</useTransitiveDependencies>
</dependencySet>
</dependencySets>
</assembly>
我对工件的 maven-install-plugin 安装文件有点搞砸了,但还没有取得多大成功。
【问题讨论】:
-
J-Dist 项目的 pom 是什么样子的?
-
我在查看日志文件和您的评论时确实发现了 1 个错误;我将包装作为 pom 文件而不是 jar。它现在在我们的构建服务器上再次运行......在原始评论的编辑中发布了 pom 文件
-
Pom 错误没有解决问题;上面的 pom 文件是使用的。仍然无法下载不存在的分类器 pom 文件
-
您已经创建了一个 jar 类型的项目 CiscoJ-dist。但是您想将它与分类器一起使用。根据您发布的 pom,我没有看到分类器。仅在 maven-assembly 调用的情况下。那么您可以发布程序集描述符吗?
-
编辑以包括程序集...正如您所指出的,我可能会为分类器配置错误。我正在查看maven.apache.org/plugins/maven-assembly-plugin/… 的文档,并且不推荐使用分类器;推荐使用的是 id。
标签: java maven classification