hybris's maven doesn't download transitive

2019-07-11 03:58发布

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?

标签: maven hybris
1条回答
爷、活的狠高调
2楼-- · 2019-07-11 04:28

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).

查看更多
登录 后发表回答