项目背景;我的团队有大量的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.ciscoss的POM:CiscoJ-dist:jar:unix-amd64:1.00丢失,没有 可用的依赖关系信息[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安装文件搞砸了一下这个工件,虽然没有太大的成功。
答案 0 :(得分:0)
我认为我确定在尝试使用工件的文件中存在无效工件。我相信,看起来它有效,应该使用父项目作为组ID /路径的一部分来访问它。如下......
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
</dependency>
<dependency>
<groupId>com.cisco.ciscossl.CiscoJ</groupId>
<artifactId>CiscoJ-dist</artifactId>
<classifier>${os.family}-${os.arch}</classifier>
<version>1.00</version>
</dependency>
</dependencies>
khmarbaise,非常感谢上述评论。暂时离开,直到进一步确定这不是有效答案。至少现在我可以看到一个有效的依赖树被拿起....
[INFO] Building test-CiscoJ-disk 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-dependency-plugin:2.8:tree (default-cli) @ test-CiscoJ-dist ---
[INFO] com.cisco.ciscossl:test-CiscoJ-dist:jar:0.0.1-SNAPSHOT
[INFO] +- junit:junit:jar:4.11:compile
[INFO] | \- org.hamcrest:hamcrest-core:jar:1.3:compile
[INFO] \- com.cisco.ciscossl.CiscoJ:CiscoJ-dist:jar:unix-amd64:1.00:compile
[INFO] +- org.slf4j:slf4j-simple:jar:1.7.2:compile
[INFO] \- org.slf4j:slf4j-api:jar:1.7.2:compile
[INFO] ------------------------------------------------------------------------