我正在使用一个自定义Maven 3打包插件来处理一些非java工件,并且在传递依赖性的过程中遇到问题。我已经定义了三个项目, model , model-impl 和 cli ,其依赖关系如下:
cli
model-impl
model
我的自定义生命周期插件正在每个项目中调用,我可以成功构建模型和 model-impl 。对于每个项目,预期的工件都存储在我的本地存储库中。然而, cli 失败了,因为我没有将 model 作为我的Mojo中的依赖项。我不完全确定这是我的代码中的问题,因为即使使用 mvn依赖:dependency-tree 也不会显示完整的依赖关系层次结构:
[INFO] Scanning for projects...
[INFO]
[INFO] ----------------------< com.corp.nodes:myproj-cli >-----------------------
[INFO] Building myproj Test 1.0.0-SNAPSHOT
[INFO] --------------------------------[ myproj ]--------------------------------
[INFO]
[INFO] --- maven-dependency-plugin:2.8:tree (default-cli) @ myproj-cli ---
[INFO] com.corp.nodes:myproj-cli:myproj:1.0.0-SNAPSHOT
[INFO] \- com.corp.:myproj-model-impl:myproj:1.0.0-SNAPSHOT:compile
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
在这里,我希望每个项目都能看到一个包含三个级别的树。
这是我的自定义插件中定义的components.xml:
<component-set>
<components>
<component>
<role>org.apache.maven.lifecycle.mapping.LifecycleMapping</role>
<role-hint>myproj</role-hint>
<implementation>
org.apache.maven.lifecycle.mapping.DefaultLifecycleMapping
</implementation>
<configuration>
<phases>
<initialize>com.corp.maven:myproj-plugin:unpackageDependencies</initialize>
<process-resources>org.apache.maven.plugins:maven-resources-plugin:resources</process-resources>
<compile>com.corp.maven:myproj-plugin:compile</compile>
<process-test-resources>org.apache.maven.plugins:maven-resources-plugin:testResources</process-test-resources>
<test-compile>org.apache.maven.plugins:maven-compiler-plugin:testCompile</test-compile>
<test>org.apache.maven.plugins:maven-surefire-plugin:test</test>
<package>com.corp.maven:myproj-plugin:package</package>
<install>org.apache.maven.plugins:maven-install-plugin:install</install>
<deploy>org.apache.maven.plugins:maven-deploy-plugin:deploy</deploy>
</phases>
</configuration>
</component>
<component>
<role>org.apache.maven.artifact.handler.ArtifactHandler</role>
<role-hint>myproj</role-hint>
<implementation>org.apache.maven.artifact.handler.DefaultArtifactHandler</implementation>
<configuration>
<type>myproj</type>
<extension>myproj</extension>
<packaging>myproj</packaging>
<addedToClasspath>true</addedToClasspath>
<includesDependencies>true</includesDependencies>
</configuration>
</component>
</components>
</component-set>
所有项目POM的包装都设置为 myproj ,并且所有依赖项的类型都设置为 myproj 。这是 cli 项目的pom:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.corp.arthur.nodes</groupId>
<artifactId>myproj-cli</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>myproj</packaging>
<name>myproj Test</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>com.corp.arthur</groupId>
<artifactId>myproj-model-impl</artifactId>
<version>1.0.0-SNAPSHOT</version>
<type>myproj</type>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>com.corp.maven</groupId>
<artifactId>myproj-plugin</artifactId>
<version>1.0.0-SNAPSHOT</version>
<extensions>true</extensions>
</plugin>
</plugins>
</build>
</project>
impl 项目的POM看起来很相似。任何想法都是我错过的?
答案 0 :(得分:2)
最后通过追踪.img-smiley
{
background-color: red;
-webkit-mask-image: url("data:image/svg+xml;base64,PHN2ZyB2ZXJzaW9uPSIxLjEiIGlkPSJMYXllcl8xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB4PSIwcHgiIHk9IjBweCIgd2lkdGg9IjgwcHgiIGhlaWdodD0iODBweCIgdmlld0JveD0iMzIgLTMyIDgwIDgwIiBlbmFibGUtY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MjMuM2MwLTAuOSwwLjctMS43LDEuNy0xLjdzMS43LDAuNywxLjcsMS43QzUxLjctMTA3OCwzOS43LTEwNjYsMjUtMTA2NiBNMTAtMTExMWM0LjYsMCw4LjMsMy43LDguMyw4LjMNCgkJCQkJYzAsMC45LTAuNywxLjctMS43LDEuN2MtMC45LDAtMS43LTAuNy0xLjctMS43YzAtMi44LTIuMi01LTUtNWMtMi44LDAtNSwyLjItNSw1YzAsMC45LTAuNywxLjctMS43LDEuN3MtMS43LTAuNy0xLjctMS43DQoJCQkJCUMxLjctMTEwNy4zLDUuNC0xMTExLDEwLTExMTEgTTQwLTExMTFjNC42LDAsOC4zLDMuNyw4LjMsOC4zYzAsMC45LTAuNywxLjctMS43LDEuN2MtMC45LDAtMS43LTAuNy0xLjctMS43YzAtMi44LTIuMi01LTUtNQ0KCQkJCQlzLTUsMi4yLTUsNWMwLDAuOS0wLjcsMS43LTEuNywxLjdjLTAuOSwwLTEuNy0wLjctMS43LTEuN0MzMS43LTExMDcuMywzNS40LTExMTEsNDAtMTExMSBNMjUtMTEzNmMtMjIuMSwwLTQwLDE3LjktNDAsNDANCgkJCQkJczE3LjksNDAsNDAsNDBzNDAtMTcuOSw0MC00MFM0Ny4xLTExMzYsMjUtMTEzNiIvPg0KCQkJPC9nPg0KCQk8L2c+DQoJPC9nPg0KPC9nPg0KPC9zdmc+DQo=");
height:80px;
width:80px;
display:block;
}
.img-smiley:hover{
background:green;
}
类的来源找出了发生了什么。结果我需要在components.xml中将DefaultDependencyCollector
设置为 false 。发生的事情是依赖收集器看到标志是真的,这意味着依赖项包含在工件中,因此没有通过它们进行递归。如果设置为false,它会递归,我会得到预期的行为。
includesDependencies
答案 1 :(得分:0)
在尝试通过maven将我的android lib包含到我的另一个项目时,我一直在努力解决类似的问题。我的研究表明,库的pom文件不包含在maven库中,对于像我这样的一些案例 - 我有一个.aar文件。因此,您的项目构建系统对这些传递依赖项一无所知。我的解决方案是手动将它们指向我的Gradle文件。您可以在this topic中更具体地熟悉这一点。