maven 自定义原型发布到存储库
maven custom archetype publishing to repository
我已经创建了一个自定义的 Maven 原型。现在我想把它推送到一个私有存储库,这样它也可以被其他项目成员使用。同时我需要把这个列在eclipse/otherIDE中。您能否告知如何实现这一目标。非常感谢任何帮助。
您可以使用以下 pom 文件作为参考来构建您的 jar 文件并将其分发到内部存储库。
<?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>
<groupId>com.project</groupId>
<artifactId>myJar</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<properties>
<tbx.localrepository.ext>http://artifacts.project.net/artifactory/myProject</tbx.localrepository.ext>
</properties>
<distributionManagement>
<repository>
<id>com.localrepository.ext</id>
<name>Intranet Maven Repository for Extensions</name>
<url>${com.localrepository.ext}</url>
</repository>
</distributionManagement>
<repositories>
<repository>
<id>com.localrepository.ext</id>
<name>Intranet Maven Repository for Extensions</name>
<url>${com.localrepository.ext}</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</snapshots>
</repository>
<repository>
<id>central</id>
<url>https://repo1.maven.org/maven2</url>
</repository>
</repositories>
<dependencies>
<!--//add dependencies-->
</dependencies>
<build>
<!-- Final jar name-->
<finalName>myJar</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>${jdk.version}</source>
<target>${jdk.version}</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>3.0.2</version>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.1.1</version>
</plugin>
</plugins>
</build>
</project>
当有人需要使用 jar 文件时,可以在该特定项目的 pom.xml
文件中指定,详细信息如下。
<dependency>
<groupId>com.project</groupId>
<artifactId>myJar</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
我已经创建了一个自定义的 Maven 原型。现在我想把它推送到一个私有存储库,这样它也可以被其他项目成员使用。同时我需要把这个列在eclipse/otherIDE中。您能否告知如何实现这一目标。非常感谢任何帮助。
您可以使用以下 pom 文件作为参考来构建您的 jar 文件并将其分发到内部存储库。
<?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>
<groupId>com.project</groupId>
<artifactId>myJar</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<properties>
<tbx.localrepository.ext>http://artifacts.project.net/artifactory/myProject</tbx.localrepository.ext>
</properties>
<distributionManagement>
<repository>
<id>com.localrepository.ext</id>
<name>Intranet Maven Repository for Extensions</name>
<url>${com.localrepository.ext}</url>
</repository>
</distributionManagement>
<repositories>
<repository>
<id>com.localrepository.ext</id>
<name>Intranet Maven Repository for Extensions</name>
<url>${com.localrepository.ext}</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</snapshots>
</repository>
<repository>
<id>central</id>
<url>https://repo1.maven.org/maven2</url>
</repository>
</repositories>
<dependencies>
<!--//add dependencies-->
</dependencies>
<build>
<!-- Final jar name-->
<finalName>myJar</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>${jdk.version}</source>
<target>${jdk.version}</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>3.0.2</version>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.1.1</version>
</plugin>
</plugins>
</build>
</project>
当有人需要使用 jar 文件时,可以在该特定项目的 pom.xml
文件中指定,详细信息如下。
<dependency>
<groupId>com.project</groupId>
<artifactId>myJar</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>