一份可以发布jar包到MAVEN中央仓库的POM
【2017-01-03 更新】将基础的pom抽离成一个项目无关的parent pom,euler-framework的pom继承这个parent pom
今天在家折腾了一下怎么把Jar包发布到Maven的中央仓库,基本步骤百毒一堆,但基本上都是让引用sonatype的parent pom,个人感觉这份pom并不好用,于是自己写了一个,同时这个pom也是Spring MVC + Hibernate + Spring Security开发的基本pom,有兴趣的童鞋可以参考一下。
euler-parent/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> <groupId>net.eulerframework</groupId> <artifactId>euler-parent</artifactId> <version>0.0.2-SNAPSHOT</version> <packaging>pom</packaging> <name>net.eulerframework:euler-parent</name> <url>https://eulerproject.io</url> <description>Parent POM for all Euler projects.</description> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> </properties> <profiles> <!-- <profile> <id>java8-doclint-disabled</id> <activation> <jdk>[1.8,)</jdk> </activation> <properties> <javadoc.opts>-Xdoclint:none</javadoc.opts> </properties> </profile> --> <profile> <id>sonatype-oss-release</id> <distributionManagement> <snapshotRepository> <id>sonatype-nexus-snapshots</id> <name>Sonatype Nexus Snapshots</name> <url>https://oss.sonatype.org/content/repositories/snapshots/</url> </snapshotRepository> <repository> <id>sonatype-nexus-staging</id> <name>Nexus Release Repository</name> <url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url> </repository> </distributionManagement> <build> <pluginManagement> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-release-plugin</artifactId> <version>2.1</version> <configuration> <mavenExecutorId>forked-path</mavenExecutorId> <useReleaseProfile>false</useReleaseProfile> <arguments>-Psonatype-oss-release</arguments> </configuration> </plugin> </plugins> </pluginManagement> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-enforcer-plugin</artifactId> <version>1.0</version> <executions> <execution> <id>enforce-maven</id> <goals> <goal>enforce</goal> </goals> <configuration> <rules> <requireMavenVersion> <version>(,2.1.0),(2.1.0,2.2.0),(2.2.0,)</version> <message>Maven 2.1.0 and 2.2.0 produce incorrect GPG signatures and checksums respectively.</message> </requireMavenVersion> </rules> </configuration> </execution> </executions> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-gpg-plugin</artifactId> <version>1.1</version> <executions> <execution> <id>sign-artifacts</id> <phase>verify</phase> <goals> <goal>sign</goal> </goals> </execution> </executions> </plugin> </plugins> </build> </profile> <profile> <id>eulerproject-repo-release</id> <distributionManagement> <repository> <id>releases</id> <url>http://repo.eulerproject.io/content/repositories/maven-releases/</url> </repository> <snapshotRepository> <id>snapshots</id> <url>http://repo.eulerproject.io/content/repositories/maven-snapshots/</url> </snapshotRepository> </distributionManagement> </profile> </profiles> <build> <pluginManagement> <plugins> <!-- This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself. --> <plugin> <groupId>org.eclipse.m2e</groupId> <artifactId>lifecycle-mapping</artifactId> <version>1.0.0</version> <configuration> <lifecycleMappingMetadata> <pluginExecutions> <pluginExecution> <pluginExecutionFilter> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-enforcer-plugin</artifactId> <versionRange>[1.0.0,)</versionRange> <goals> <goal>enforce</goal> </goals> </pluginExecutionFilter> <action> <ignore /> </action> </pluginExecution> </pluginExecutions> </lifecycleMappingMetadata> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-deploy-plugin</artifactId> <version>2.7</version> </plugin> </plugins> </pluginManagement> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-resources-plugin</artifactId> <version>2.7</version> <configuration> <encoding>UTF-8</encoding> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-jar-plugin</artifactId> <version>2.6</version> <configuration> <archive> <addMavenDescriptor>false</addMavenDescriptor> </archive> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-war-plugin</artifactId> <version>2.6</version> <configuration> <archive> <addMavenDescriptor>false</addMavenDescriptor> </archive> </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> <goals> <goal>jar-no-fork</goal> </goals> </execution> </executions> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-javadoc-plugin</artifactId> <version>2.10.4</version> <executions> <execution> <id>attach-javadocs</id> <goals> <goal>jar</goal> </goals> <!-- <configuration> <additionalparam>${javadoc.opts}</additionalparam> </configuration> --> </execution> </executions> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-release-plugin</artifactId> <version>2.5.3</version> </plugin> </plugins> </build> <licenses> <license> <name>MIT License</name> <url>https://opensource.org/licenses/MIT</url> </license> </licenses> <scm> <connection>scm:git:https://github.com/euler-projects/euler-parent.git</connection> <developerConnection>scm:git:git@github.com:euler-projects/euler-parent.git</developerConnection> <url>https://github.com/euler-projects/euler-parent</url> </scm> <developers> <developer> <name>cFrost Sun</name> <email>cfrost@eulerproject.io</email> <organization>Euler Project</organization> <organizationUrl>https://eulerproject.io</organizationUrl> </developer> </developers> </project>
euler-framework/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>net.eulerframework</groupId> <artifactId>euler-parent</artifactId> <version>0.0.2-SNAPSHOT</version> <relativePath></relativePath> </parent> <artifactId>euler-framework</artifactId> <version>0.2.0-SNAPSHOT</version> <packaging>pom</packaging> <name>net.eulerframework:euler-framework</name> <url>https://euler-projects.github.io/euler-framework</url> <description>Parent POM for Euler Framework projects.</description> <modules> <module>euler-web-core</module> <module>euler-web-authentication</module> <module>euler-web-basic</module> <module>euler-web-config-provider</module> </modules> <properties> <jdk.version>1.7</jdk.version> <commons-codec.version>1.10</commons-codec.version> <jsp.version>2.2</jsp.version> <servlet.version>3.0.1</servlet.version> <jstl.version>1.2</jstl.version> <inject.version>1</inject.version> <validation-api.version>1.1.0.Final</validation-api.version> <jta.version>1.1</jta.version> <jaxb-api.version>2.2.12</jaxb-api.version> <java-mail.version>1.5.5</java-mail.version> <springframework.version>4.2.5.RELEASE</springframework.version> <springsecurity.version>4.0.4.RELEASE</springsecurity.version> <springsecurity.oauth.version>2.0.9.RELEASE</springsecurity.oauth.version> <springsecurity.oauth.jwt.version>1.0.4.RELEASE</springsecurity.oauth.jwt.version> <AspectJ.version>1.8.9</AspectJ.version> <jasig.version>3.2.2</jasig.version> <quartz.version>2.2.3</quartz.version> <hibernate.version>5.0.5.Final</hibernate.version> <hibernate.validator.version>5.2.4.Final</hibernate.validator.version> <c3p0.version>0.9.5.2</c3p0.version> <mysqljdbc.version>5.1.38</mysqljdbc.version> <!-- <jersey.version>2.22.2</jersey.version> --> <jackson.version>2.7.3</jackson.version> <slf4j-api.version>1.7.21</slf4j-api.version> <log4j.version>1.2.17</log4j.version> <log4j2.version>2.5</log4j2.version> <jboss.logging.version>3.3.0.Final</jboss.logging.version> <commons-logging.version>1.2</commons-logging.version> <junit.version>3.8.1</junit.version> </properties> <dependencyManagement> <dependencies> <!-- Basic Jars --> <dependency> <groupId>commons-codec</groupId> <artifactId>commons-codec</artifactId> <version>${commons-codec.version}</version> </dependency> <!-- J2EE --> <dependency> <groupId>javax.servlet</groupId> <artifactId>javax.servlet-api</artifactId> <version>${servlet.version}</version> <scope>provided</scope> </dependency> <dependency> <groupId>javax.servlet.jsp</groupId> <artifactId>jsp-api</artifactId> <version>${jsp.version}</version> <scope>provided</scope> </dependency> <dependency> <groupId>javax.servlet</groupId> <artifactId>jstl</artifactId> <version>${jstl.version}</version> </dependency> <dependency> <groupId>javax.inject</groupId> <artifactId>javax.inject</artifactId> <version>${inject.version}</version> </dependency> <dependency> <groupId>javax.validation</groupId> <artifactId>validation-api</artifactId> <version>${validation-api.version}</version> </dependency> <dependency> <groupId>javax.transaction</groupId> <artifactId>jta</artifactId> <version>${jta.version}</version> </dependency> <dependency> <groupId>javax.xml.bind</groupId> <artifactId>jaxb-api</artifactId> <version>${jaxb-api.version}</version> </dependency> <dependency> <groupId>javax.mail</groupId> <artifactId>javax.mail-api</artifactId> <version>${java-mail.version}</version> </dependency> <!-- Spring --> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-context-support</artifactId> <version>${springframework.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-webmvc</artifactId> <version>${springframework.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-orm</artifactId> <version>${springframework.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-oxm</artifactId> <version>${springframework.version}</version> </dependency> <dependency> <groupId>org.aspectj</groupId> <artifactId>aspectjweaver</artifactId> <version>${AspectJ.version}</version> </dependency> <dependency> <groupId>org.quartz-scheduler</groupId> <artifactId>quartz</artifactId> <version>${quartz.version}</version> <exclusions> <exclusion> <groupId>c3p0</groupId> <artifactId>c3p0</artifactId> </exclusion> <exclusion> <groupId>org.slf4j</groupId> <artifactId>slf4j-api</artifactId> </exclusion> </exclusions> </dependency> <!-- Spring Security --> <dependency> <groupId>org.springframework.security</groupId> <artifactId>spring-security-core</artifactId> <version>${springsecurity.version}</version> </dependency> <dependency> <groupId>org.springframework.security</groupId> <artifactId>spring-security-web</artifactId> <version>${springsecurity.version}</version> </dependency> <dependency> <groupId>org.springframework.security</groupId> <artifactId>spring-security-taglibs</artifactId> <version>${springsecurity.version}</version> </dependency> <dependency> <groupId>org.springframework.security</groupId> <artifactId>spring-security-config</artifactId> <version>${springsecurity.version}</version> </dependency> <!-- Spring Security LDAP --> <dependency> <groupId>org.springframework.security</groupId> <artifactId>spring-security-ldap</artifactId> <version>${springsecurity.version}</version> </dependency> <!-- Spring Security CAS --> <dependency> <groupId>org.springframework.security</groupId> <artifactId>spring-security-cas</artifactId> <version>${springsecurity.version}</version> </dependency> <dependency> <groupId>org.jasig.cas.client</groupId> <artifactId>cas-client-core</artifactId> <version>${jasig.version}</version> <exclusions> <exclusion> <groupId>commons-logging</groupId> <artifactId>commons-logging</artifactId> </exclusion> </exclusions> </dependency> <!-- Spring Security OAuth2.0 --> <dependency> <groupId>org.springframework.security.oauth</groupId> <artifactId>spring-security-oauth2</artifactId> <version>${springsecurity.oauth.version}</version> </dependency> <dependency> <groupId>org.springframework.security</groupId> <artifactId>spring-security-jwt</artifactId> <version>${springsecurity.oauth.jwt.version}</version> </dependency> <!-- Hibernate ... --> <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-core</artifactId> <version>${hibernate.version}</version> </dependency> <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-validator</artifactId> <version>${hibernate.validator.version}</version> </dependency> <dependency> <groupId>com.mchange</groupId> <artifactId>c3p0</artifactId> <version>${c3p0.version}</version> </dependency> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>${mysqljdbc.version}</version> </dependency> <!-- Jersey bean-validator与Hibernate5冲突 --> <!-- <dependency> <groupId>org.glassfish.jersey.containers</groupId> <artifactId>jersey-container-servlet</artifactId> <version>${jersey.version}</version> </dependency> <dependency> <groupId>org.glassfish.jersey.ext</groupId> <artifactId>jersey-spring3</artifactId> <version>${jersey.version}</version> <exclusions> <exclusion> <groupId>org.glassfish.hk2.external</groupId> <artifactId>bean-validator</artifactId> </exclusion> </exclusions> </dependency> <dependency> <groupId>org.glassfish.jersey.media</groupId> <artifactId>jersey-media-json-jackson</artifactId> <version>${jersey.version}</version> </dependency> --> <!-- Jackson --> <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-core</artifactId> <version>${jackson.version}</version> </dependency> <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-databind</artifactId> <version>${jackson.version}</version> </dependency> <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-annotations</artifactId> <version>${jackson.version}</version> </dependency> <dependency> <groupId>com.fasterxml.jackson.datatype</groupId> <artifactId>jackson-datatype-jsr310</artifactId> <version>${jackson.version}</version> </dependency> <!-- Too many loggers ... --> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-api</artifactId> <version>${slf4j-api.version}</version> </dependency> <dependency> <groupId>org.apache.logging.log4j</groupId> <artifactId>log4j-core</artifactId> <version>${log4j2.version}</version> </dependency> <dependency> <groupId>log4j</groupId> <artifactId>log4j</artifactId> <version>${log4j.version}</version> </dependency> <dependency> <groupId>org.jboss.logging</groupId> <artifactId>jboss-logging</artifactId> <version>${jboss.logging.version}</version> </dependency> <dependency> <groupId>commons-logging</groupId> <artifactId>commons-logging</artifactId> <version>${commons-logging.version}</version> </dependency> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>${junit.version}</version> <scope>test</scope> </dependency> <dependency> <groupId>net.eulerframework</groupId> <artifactId>euler-cache</artifactId> <version>0.2.0-SNAPSHOT</version> </dependency> <dependency> <groupId>net.eulerframework</groupId> <artifactId>euler-common</artifactId> <version>0.2.0-SNAPSHOT</version> </dependency> </dependencies> </dependencyManagement> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.3</version> <configuration> <source>${jdk.version}</source> <target>${jdk.version}</target> </configuration> </plugin> </plugins> </build> <scm> <connection>scm:git:https://github.com/euler-projects/euler-framework.git</connection> <developerConnection>scm:git:git@github.com:euler-projects/euler-framework.git</developerConnection> <url>https://github.com/euler-projects/euler-framework</url> </scm> </project>
更多关于Euler Framework的资料请访问eulerproject.io