hybris's maven doesn't download transitive dependencies

故事扮演 提交于 2019-12-07 13:01:11

问题


I am trying to set my dependencies in the external-dependencies.xml in Hybris extension. The problem is it just load the libraries I specified in there and doesn't load the dependencies that the libraries need to work with at run-time.

For example Aixs2-kernel loads Axiom-api and impl and adb and so on. And in a normal maven project I don't need to specify each of them one by one.

Is there any way to make Hybris understand to fetch the rest of them?


回答1:


SAP Hybris 6.4+

Yes, you can do this in by overwriting the maven.download.options parameter in an extension project.properties file. It's default value is equal to:

-DoverWriteReleases=true -DoverWriteSnapshots=true -DoverWriteIfNewer=true -DexcludeTransitive=true

If you add to your extension project.properties the line:

maven.download.options=-DoverWriteReleases=true -DoverWriteSnapshots=true -DoverWriteIfNewer=true

SAP Hybris platform will download all dependencies (also transitive). Of course this change will work only for your extension (please don't change content of the project.properties file located in core extensions).


SAP Hybris 6.3 and older

Exclusion of the transitive dependencies is hardcoded in the hybris/bin/platform/resources/ant/mavenTasks.xml file (macro updateLibFolder). The only possible solution is to do a patch in SAP Hybris platform. You can change this code:

<artifact:mvn pom="@{dependencyFile}" fork="true" failonerror="true" mavenVersion="3.2.5">
    <arg value="dependency:copy-dependencies" />
    <arg value="-DoutputDirectory=@{libfolder}" />
    <arg value="-DoverWriteReleases=true" />
    <arg value="-DoverWriteSnapshots=true" />
    <arg value="-DoverWriteIfNewer=true" />
    <arg value="-DexcludeTransitive=true" />
</artifact:mvn>

to:

<artifact:mvn pom="@{dependencyFile}" fork="true" failonerror="true" mavenVersion="3.2.5">
    <arg line="dependency:copy-dependencies -DoutputDirectory=@{libfolder} ${maven.download.options}" />
    <jvmarg line="${env.MAVEN_OPTS} ${env.JAVA_OPTS}" />
</artifact:mvn>

next define a property

maven.download.options=-DoverWriteReleases=true -DoverWriteSnapshots=true -DoverWriteIfNewer=true

in the hybris/bin/platform/project.properties and finally do steps from the solution for 6.4+.


Warning: SAP Hybris platform provides a lot of libraries, so probably some of your transitive dependencies are already available. That is the reason, why downloading of the transitive dependencies are disabled. I think it is a good idea to specify them manually instead of downloading everything (you will avoid problems with the differences of the version).



来源:https://stackoverflow.com/questions/46599669/hybriss-maven-doesnt-download-transitive-dependencies

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!