关闭

Maven中央仓库构建上传心得

174人阅读 评论(0) 收藏 举报
分类:

经过一番努力,终于把自己的构建上传到了Maven的中央仓库,在此记录下自己的心得:

首先,自然是去https://issues.sonatype.org创建自己的申请(Issue),为了填写里面的信息,又去github上注册了自己的地址,由于工作人员是老美,大概每天北京时间晚上10点上班,所以只有跟着他切换模式了...

之后,收到工作人员的询问,是否拥有域名?我查看一下,他也不是每个人都会问,大概是因为我填写的group id 和project url差太多吧!所以暂且推测,project url包含group id中的域名部分,多半就不会被问到了。

经过一番交流,工作人员批准了group id, 他还把group id改成了仅保留域名部分,还是挺周到的。


之后就是要上传了,这里又遇到了问题:由于闲着也没事儿干,就在Joel审批前把component上传了一次,结果收到403错误,无奈,晚上10点又跑去找这个Joel:


这下彻底明白了,重新上传,一切搞定,然后去通知Joel审核发布的组件:


至此,发布成功,2小时后可以使用。在http://search.maven.org/可以搜索到就成了,不过我上传的这段时间服务器在维护,所以比较悲剧的又开始了晚上10点模式,提单继续找Joel,回复如下:


在上传的过程中,maven会要校验源码和java doc,由于我是做公司的项目,不能公开源码,非常头疼,搞了我一两天,想了各种办法,不过最后还是解决了,办法嘛!我只能说:每个组件文件的上传,后一次覆盖前一次的文件,毕竟咱们还是要支持开源的。


最后,把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/maven-v4_0_0.xsd">

	<modelVersion>4.0.0</modelVersion>
	<groupId><span style="font-family: Arial, Helvetica, sans-serif;">groupId</span><span style="font-family: Arial, Helvetica, sans-serif;"></groupId></span>
	<artifactId><span style="font-family: Arial, Helvetica, sans-serif;">artifactId</span><span style="font-family: Arial, Helvetica, sans-serif;"></artifactId></span>
	<packaging>jar</packaging>

	<name>name</name>
	<version>1.0.0</version>
	<url>url</url>
	<description>description</description>

	<licenses>
		<license>
			<name>The Apache Software License, Version 2.0</name>
			<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
			<distribution>repo</distribution>
		</license>
	</licenses>

	<developers>
		<developer>
			<id>zach</id>
			<name>Zach Liu</name>
			<email>email</email>
		</developer>
	</developers>

	<scm>
		<connection>scm:git:git@github.com:xxx/xxx.git</connection>
		<url>git@github.com:xxx/xxxx.git</url>
	</scm>

	<properties>
		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
	</properties>

	<profiles>
		<profile>
			<id>default-profile</id>
			<activation>
				<activeByDefault>true</activeByDefault>
				<file>
					<exists>${java.home}/../lib/tools.jar</exists>
				</file>
			</activation>
			<properties>
				<toolsjar>${java.home}/../lib/tools.jar</toolsjar>
			</properties>
		</profile>

		<profile>
			<id>mac-profile</id>
			<activation>
				<activeByDefault>false</activeByDefault>
				<file>
					<exists>${java.home}/../Classes/classes.jar</exists>
				</file>
			</activation>
			<properties>
				<toolsjar>${java.home}/../Classes/classes.jar</toolsjar>
			</properties>
		</profile>
	</profiles>

	<distributionManagement>
		<snapshotRepository>
			<id>oss</id>
			<url>https://oss.sonatype.org/content/repositories/snapshots</url>
		</snapshotRepository>
		<repository>
			<id>oss</id>
			<url>https://oss.sonatype.org/service/local/staging/deploy/maven2</url>
		</repository>
	</distributionManagement>

	<dependencies>
		<dependency>
			<groupId>dom4j</groupId>
			<artifactId>dom4j</artifactId>
			<version>1.6.1</version>
		</dependency>

		<dependency>
			<groupId>com.google.code.gson</groupId>
			<artifactId>gson</artifactId>
			<version>1.4</version>
			<optional>true</optional>
		</dependency>

		<!-- <dependency> <groupId>javassist</groupId> <artifactId>javassist</artifactId> 
			<version>3.12.1.GA</version> <optional>false</optional> </dependency> -->

		<!-- jsr 305 -->
		<dependency>
			<groupId>com.google.guava</groupId>
			<artifactId>guava</artifactId>
			<!--<version>12.0</version> --> <!-- jdk1.6+ -->
			<version>11.0.2</version> <!-- case: when only jdk1.5 is acceptable -->
		</dependency>

		<dependency>
			<groupId>javax.servlet</groupId>
			<artifactId>servlet-api</artifactId>
			<version>2.5</version>
			<scope>provided</scope>
			<optional>true</optional> <!-- case: when no servlet environment -->
		</dependency>

		<dependency>
			<groupId>sun.jdk</groupId>
			<artifactId>tools</artifactId>
			<version>xxx</version>
			<scope>system</scope>
			<systemPath>${toolsjar}</systemPath>
		</dependency>
	</dependencies>

	<build>
		<finalName>${project.artifactId}-${project.version}</finalName>
		<sourceDirectory>src</sourceDirectory>

		<resources>
			<resource>
				<directory>assets</directory>
			</resource>
		</resources>

		<plugins>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-jar-plugin</artifactId>
				<version>2.6</version>
				<configuration>
					<archive>
						<manifestFile>
							META-INF/MANIFEST.MF
						</manifestFile>
					</archive>
				</configuration>
			</plugin>

			<plugin>
				<artifactId>maven-compiler-plugin</artifactId>
				<version>2.3.2</version>
				<configuration>
					<source>1.6</source>
					<target>1.6</target>
					<encoding>UTF-8</encoding>
				</configuration>
			</plugin>

			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-gpg-plugin</artifactId>
				<version>1.5</version>
				<executions>
					<execution>
						<phase>verify</phase>
						<goals>
							<goal>sign</goal>
						</goals>
					</execution>
				</executions>
			</plugin>
		</plugins>
	</build>

	<!-- <build>
	    <finalName>${project.artifactId}-${project.version}</finalName>
		<sourceDirectory>src-maven</sourceDirectory>
		
		<resources>
			<resource>
				<directory>assets</directory>
			</resource>
		</resources>

		<plugins>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-source-plugin</artifactId>
				<version>2.2.1</version>
				<executions>
					<execution>
						<phase>package</phase>
						<goals>
							<goal>jar-no-fork</goal>
						</goals>
					</execution>
				</executions>
			</plugin>

			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-javadoc-plugin</artifactId>
				<version>2.9.1</version>
				<executions>
					<execution>
						<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.5</version>
				<executions>
					<execution>
						<phase>verify</phase>
						<goals>
							<goal>sign</goal>
						</goals>
					</execution>
				</executions>
			</plugin>
		</plugins>
	</build> -->

</project>






0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:9519次
    • 积分:337
    • 等级:
    • 排名:千里之外
    • 原创:21篇
    • 转载:21篇
    • 译文:0篇
    • 评论:2条
    文章分类
    最新评论