我制作了一个原型,它对我的一个项目具有托管依赖关系。
每当使用我的原型创建新项目时,是否有可能告诉原型始终使用该依赖项的最新发行版本?使用RELEASE
对我不起作用,因为我不想每次构建项目时都更改版本。
<?xml version="1.0" encoding="utf-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>${groupId}</groupId>
<artifactId>${artifactId}</artifactId>
<version>${version}</version>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>com.mycompany.someproject</groupId>
<artifactId>someDependency</artifactId>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.mycompany.myproject</groupId>
<artifactId>myArtifact</artifactId>
<version>LATEST</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
</project>
I read this https://stackoverflow.com/questions/973081/maven-update-dependencies-in-pom问题,但使用 maven-versions-plugin 的建议解决方案似乎不适合,原因有两个。首先,我想在创建项目时更改版本,其次我不想更改所有依赖项的版本,而只想更改一个。
Edit:上面是来自 archetype-resources 的 pom.xml (已更新),下面是来自我的 archetype-project 本身的 pom.xml 。
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.mycompany.maven.archetype.be</groupId>
<artifactId>maven-archetype-be-_moduleList</artifactId>
<version>1.3-SNAPSHOT</version>
<relativePath>../maven-archetype-be</relativePath>
</parent>
<artifactId>archetype-be-api</artifactId>
<packaging>maven-archetype</packaging>
<dependencies />
<name>archetype-be-api</name>
</project>
EDIT2:
RELEASE
and LATEST
似乎在托管依赖项中根本不起作用。任何人都可以确认或禁用该声明吗?
你可以把
<dependency>
<groupId>com.mycompany.myproject</groupId>
<artifactId>my-artifact</artifactId>
<version>LATEST</version>
<type>pom</type>
<scope>import</scope>
</dependency>
LATEST
将解析最新的可用版本并通过-U
当你建造时
或者如果您不想指定-U
每次您都可以配置您的settings.xml
in ~/.m2
就像是
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
http://maven.apache.org/xsd/settings-1.0.0.xsd">
...
<profiles>
<profile>
...
<repositories>
<repository>
<id>codehausSnapshots</id>
<name>Codehaus Snapshots</name>
<releases>
<enabled>false</enabled>
<updatePolicy>always</updatePolicy> // <-- this will update each release artifact from this repository each time
<checksumPolicy>warn</checksumPolicy>
</releases>
<url>http://snapshots.maven.codehaus.org/maven2</url>
<layout>default</layout>
</repository>
</repositories>
<pluginRepositories>
...
</pluginRepositories>
...
</profile>
</profiles>
...
</settings>
当您运行 mvn 从原型项目生成项目时,您仍然可以指定 LATEST,例如
mvn archetype:generate
-DarchetypeGroupId=you_archetype_group_id
-DarchetypeArtifactId=sample-spring-mvc-archetype
-DarchetypeVersion=LATEST -DgroupId=new.project.id
-DartifactId=sample
-DarchetypeRepository=path_to_maven_repo_with_archetype_jar
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)