我如何计算工件的整个列表,包括所提供的 [英] How I can calculate whole list of artifacts, including provided
问题描述
在当前项目中,大多数可传递工件都标记为已提供"(由于项目体系结构的某些最佳实践",我无法更改此行为).但是我需要获取他们的完整列表才能使项目生效.
In current project most of transitive artifacts are marked as "provided" (due to some of "best practices" of project architecture - I can't change this behavior). But I need to get whole list of their to make project alive.
我如何计算工件的整个列表,包括所提供的? 如何超越传递工件的提供"范围?
How I can calculate whole list of artifacts, including provided? How to override "provided" scope of transitive artifact?
好的.我的案例有一个例子:
Okay. There is an sample of my case:
<!-- 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>
推荐答案
我找到了这样的解决方案 https://stackoverflow.com/a /22411538/1458394 并进行了一些改进(不错,但是还需要其他一些改进)deps-resolver.sh
:
I found such solution https://stackoverflow.com/a/22411538/1458394 and made some improvements (not bad, but it needs some another improvements) 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
并接收完整(且超过所需)传递依赖的列表.
and receive a list of whole (and more than needed) transitive dependencies.
这篇关于我如何计算工件的整个列表,包括所提供的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!