在当前项目中,大多数传递工件被标记为"提供" (由于一些"最佳实践和#34;项目架构 - 我无法改变这种行为)。但是我需要获得他们的完整列表以使项目活跃起来。
如何计算完整的工件列表,包括提供的? 如何覆盖"提供"传递神器的范围?
好。我的案例有一个样本:
<!-- sample of my pom is so:-->
<project>
.....
<group>rd-service</group>
<artifactId>rd-service</artifactId>
.....
<dependencies>
.....
<!--link to the problem artifact -->
<dependency>
<groupId>third-party-lib-group</groupId>
<artifactId>third-party-lib-artifact</artifactId>
<scope>compile</scope>
</dependency>
</dependencies>
</project>
<!--problem artifact looks like so -->
<project>
.....
<group>third-party-lib-group</group>
<artifactId>third-party-lib-artifact</artifactId>
.....
<dependencies>
.....
<!--How I can calculate automatically whole dependencies
which looks like this and its transitive
dependencies too?
Author of spring-context-customized can't do it by himself. -->
<dependency>
<groupId>org.springframework.fork</groupId>
<artifactId>spring-context-customized</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
对问题here
的另一种看法答案 0 :(得分:0)
我找到了这样的解决方案https://stackoverflow.com/a/22411538/1458394并做了一些改进(不错,但需要进行一些改进)deps-resolver.sh
:
#!/bin/sh
if [ "$#" -ne 5 ]; then
echo "Usage: $0 <groupId> <artifactId> <version> <scope> <type>"
exit
fi
echo $1 $2 $3 $4
echo "<dependency><groupId>$1</groupId><artifactId>$2</artifactId><version>$3</version><scope>compile</scope><type>$5</type></dependency>">>shared-libs-all.mvn
POM_DIR="`echo "$1" | tr . /`/$2/$3"
POM_PATH="$POM_DIR/$2-$3.pom"
excludeClassifiers=client
excludeGroupIds=org.apache.openjpa,javax.jms,javax.ejb,javax.servlet,com.ibm.ws,org.hibernate.javax.persistence,org.jboss.spec.javax.transaction,javax.mail,javax.activation,taglibs
excludeArtifactIds=
excludeScope=''
#echo -DexcludeClassifiers="$excludeClassifiers" -DexcludeGroupIds="$excludeGroupIds" -DexcludeArtifactIds="$excludeArtifactIds" -DexcludeScope="$excludeScope"
#mkdir -p "$HOME/.m2/repository/$POM_DIR"
#wget -q -O "$HOME/.m2/repository/$POM_PATH" "http://repo.maven.apache.org/maven2/$POM_PATH"
mvn -f "$HOME/.m2/repository/$POM_PATH" dependency:resolve -DexcludeClassifiers="$excludeClassifiers" -DexcludeGroupIds="$excludeGroupIds" -DexcludeArtifactIds="$excludeArtifactIds" -DexcludeScope="$excludeScope" -o -DincludeParents=true|egrep $4|awk '{split($0,a," "); print(a[2]);}'|awk '{split($0,a,":"); printf("./deps-resolver.sh %s\t%s\t%s\t%s\t%s\n", a[1],a[2],a[4],"provided",a[3]);}'|sh
然后再做
cat shared-libs-all.mvn|grep -v 'rd-service'|sort|uniq>shared-libs-prepared.mvn
并获得整个(以及超过需要的)传递依赖项的列表。
答案 1 :(得分:-1)
dependency:list
为您提供(传递和非传递)依赖关系的完整列表,包括provided
依赖关系。<dependencyManagement>
。 dependencyManagement中的条目会覆盖传递依赖项的版本和范围(因此请确保选择正确的版本)。