上傳專案到maven中央倉庫所需配置
阿新 • • 發佈:2018-12-19
pom.xml
<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>cn.takujo</groupId> <artifactId>common-api</artifactId> <version>1.0.0</version> <packaging>jar</packaging> <name>common-api</name> <url>https://gitee.com/takujo_admin/common-api</url> <description>takujoframework common-api</description> <licenses> <license> <name>The Apache Software License, Version 2.0</name> <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url> </license> </licenses> <developers> <developer> <name>takujo</name> <email>@qq.com</email> </developer> </developers> <scm> <connection> scm:git:https://gitee.com/takujo_admin/common-api.git </connection> <developerConnection> scm:git:https://gitee.com/takujo_admin/common-api.git </developerConnection> <url>https://gitee.com/takujo_admin/common-api</url> </scm> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> </properties> <dependencies> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.12</version> <scope>test</scope> </dependency> </dependencies> <profiles> <profile> <id>release</id> <build> <plugins> <plugin> <groupId>org.sonatype.plugins</groupId> <artifactId>nexus-staging-maven-plugin</artifactId> <version>1.6.7</version> <extensions>true</extensions> <configuration> <serverId>伺服器id(在settings.xml中)</serverId> <nexusUrl>https://oss.sonatype.org/</nexusUrl> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-source-plugin</artifactId> <version>3.0.1</version> <executions> <execution> <id>attach-sources</id> <phase>package</phase> <goals> <goal>jar</goal> </goals> </execution> </executions> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-javadoc-plugin</artifactId> <version>2.10.4</version> <configuration> <encoding>UTF-8</encoding> <charset>UTF-8</charset> <docencoding>UTF-8</docencoding> </configuration> <executions> <execution> <id>attach-javadocs</id> <phase>package</phase> <goals> <goal>jar</goal> </goals> </execution> </executions> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-gpg-plugin</artifactId> <version>1.6</version> <executions> <execution> <phase>verify</phase> <goals> <goal>sign</goal> </goals> </execution> </executions> </plugin> <plugin> <artifactId>maven-compiler-plugin</artifactId> <version>3.5.1</version> <configuration> <source>1.8</source> <target>1.8</target> </configuration> </plugin> </plugins> </build> <distributionManagement> <snapshotRepository> <id>伺服器id(在settings.xml中)</id> <url>https://oss.sonatype.org/content/repositories/snapshots/</url> </snapshotRepository> <repository> <id>伺服器id(在settings.xml中)</id> <url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url> </repository> </distributionManagement> </profile> </profiles> </project>
maven conf資料夾中settings.xml加入伺服器配置
<server>
<id>自定義標識id(在pom.xml中引用)</id>
<username>(https://issues.sonatype.org/ 網站註冊的使用者名稱)</username>
<password>(https://issues.sonatype.org/ 網站註冊的密碼)</password>
</server>