Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
454 views
in Technique[技术] by (71.8m points)

Maven: dependency:unpack / how to override artifact dependency?

I am working on a maven project, which depends on some artifact (named here "artifact1"), which is resolved using dependency:unpack:

pom.xml extract:

<project>
  [...]
  <build>
    <plugins>
    [...]
        <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-dependency-plugin</artifactId>
        <version>3.0.0</version>
        
        <executions>
            <execution>
                <id>unpack</id>
                <phase>prepare-package</phase>
                <goals>
                    <goal>unpack</goal>
                </goals>
                <configuration>
                    <artifactItems>
                        <artifactItem>
                            <groupId>com.xxx.xxx</groupId>
                            <artifactId>artifact1</artifactId>
                            <version>100.1.1</version>
                            <type>zip</type>
                            [...]
                        </artifactItem>
                    </artifactItems>
                </configuration>
            </execution>
        </executions>
        </plugin>
    [...]
    </build>
  [...]
</project>

"artifact1" has its own dependencies:

[INFO] +- com.xxx.xxx:artifact1:zip:100.1.1:compile
[INFO] |  - com.xxx.xxx:artifact2:zip:100.1.1:compile
[INFO] |     +- com.xxx.xxx:xxx:artifact3:zip:100.1.1:compile

I am looking for a way to override version of "artifact3" (let us say to version 100.1.2) (without modifying anything on artifact1 project itself)

Expected result, running mvn dependency:tree with pom.xml here above and get dependency tree:

[INFO] +- com.xxx.xxx:artifact1:zip:100.1.1:compile
[INFO] |  - com.xxx.xxx:artifact2:zip:100.1.1:compile
[INFO] |     +- com.xxx.xxx:xxx:artifact3:zip:100.1.2:compile

Do you know if there is any possibiliy to do it?

Thanks in advance


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Basically Maven is a build tool, not a deployment tool. (It has a deploy phase but that's for deploying artifacts to a remote Maven repository, in addition to the local repository on the developer's local machine.)

There are plugins that support deploying of arbitrary files to arbitrary locations (indirectly):

and one that supports deploying directly, but its version 2.0.0 is almost two years old and I experienced things not working with recent Maven versions. But, right now I see that there's a 2.0.1 from just two days ago:

  • Wagon Maven Plugin: "Use this plugin to view and transfer resources between repositories using Maven Wagon."

    (Don't let "between repositories" confuse you. It supports arbitrary files and URLs.)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...