Maven: Get repository URL of a dependency

爱⌒轻易说出口 提交于 2019-12-20 03:09:31

问题


I want do display the URL to a JAR that was deployed to our maven repo at the end of my build job. (Basically the "link" where the dependency - the JAR - can be downloaded from the repository server)

So how to display the remote repository URL of a dependency on command line?


回答1:


I suggest you to compose the URL from the parameters in the very pom. Example:

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-antrun-plugin</artifactId>
            <version>1.8</version>
            <executions>
                <execution>
                    <id>deploy-message</id>
                    <phase>deploy</phase>
                    <goals>
                        <goal>run</goal>
                    </goals>
                    <configuration>
                        <tasks>
                            <echo>deploying to url=${project.distributionManagement.repository.url}/${project.groupId}/${project.artifactId}/${project.version}/${project.artifactId}-${project.version}.jar</echo>
                        </tasks>
                    </configuration>
                </execution>
            </executions>
        </plugin>

(This message will appear at the same time the deploy is being performed, but you can set it to whatever phase you want. Or include it into a Maven profile.)



来源:https://stackoverflow.com/questions/39506740/maven-get-repository-url-of-a-dependency

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