2014-07-17 34 views
1

完全做到這是一個後續行動:Followup questions: Using Maven to only sign and deploy jars to Maven Central. Build and compilation is done entirely with Ant後續第2部分 - 使用Maven僅對Maven Central簽名和部署瓶子。建立和編譯使用Ant


多虧了答案前面的問題,並從Sonatype的支持人員一些建議,我我剛剛獲得了第一次「非失敗」。下面是電流輸出爲mvn deploy

[INFO] Scanning for projects... 
[INFO] 
[INFO] ------------------------------------------------------------------------ 
[INFO] Building XBN-Java 0.1.2-SNAPSHOT 
[INFO] ------------------------------------------------------------------------ 
[INFO] 
[INFO] --- maven-enforcer-plugin:1.0:enforce (enforce-maven) @ xbnjava --- 
[INFO] 
[INFO] --- maven-install-plugin:2.4:install (default-install) @ xbnjava --- 
[INFO] Installing R:\jeffy\programming\sandbox\xbnjava\pom.xml to C:\Users\jeffy\.m2\repository\com\github\aliteralmind\xbnjava\0.1.2-SNAPSHOT\xbnjava-0.1.2-SNAPSHOT.pom 
[INFO] 
[INFO] --- maven-deploy-plugin:2.7:deploy (default-deploy) @ xbnjava --- 
Downloading: https://oss.sonatype.org/content/repositories/snapshots/com/github/aliteralmind/xbnjava/0.1.2-SNAPSHOT/maven-metadata.xml 
607/607 B 
Downloaded: https://oss.sonatype.org/content/repositories/snapshots/com/github/aliteralmind/xbnjava/0.1.2-SNAPSHOT/maven-metadata.xml (607 B at 0.5 KB/sec) 
Uploading: https://oss.sonatype.org/content/repositories/snapshots/com/github/aliteralmind/xbnjava/0.1.2-SNAPSHOT/xbnjava-0.1.2-20140717.010135-5.pom 
2/4 KB 
4/4 KB 
Uploaded: https://oss.sonatype.org/content/repositories/snapshots/com/github/aliteralmind/xbnjava/0.1.2-SNAPSHOT/xbnjava-0.1.2-20140717.010135-5.pom (4 KB at 11.9 KB/sec) 
Downloading: https://oss.sonatype.org/content/repositories/snapshots/com/github/aliteralmind/xbnjava/maven-metadata.xml 
290/290 B 
Downloaded: https://oss.sonatype.org/content/repositories/snapshots/com/github/aliteralmind/xbnjava/maven-metadata.xml (290 B at 1.5 KB/sec) 
Uploading: https://oss.sonatype.org/content/repositories/snapshots/com/github/aliteralmind/xbnjava/0.1.2-SNAPSHOT/maven-metadata.xml 
607/607 B 
Uploaded: https://oss.sonatype.org/content/repositories/snapshots/com/github/aliteralmind/xbnjava/0.1.2-SNAPSHOT/maven-metadata.xml (607 B at 2.5 KB/sec) 
Uploading: https://oss.sonatype.org/content/repositories/snapshots/com/github/aliteralmind/xbnjava/maven-metadata.xml 
290/290 B 
Uploaded: https://oss.sonatype.org/content/repositories/snapshots/com/github/aliteralmind/xbnjava/maven-metadata.xml (290 B at 1.0 KB/sec) 
[INFO] ------------------------------------------------------------------------ 
[INFO] BUILD SUCCESS 
[INFO] ------------------------------------------------------------------------ 
[INFO] Total time: 4.579 s 
[INFO] Finished at: 2014-07-16T21:01:36-04:00 
[INFO] Final Memory: 7M/19M 
[INFO] ------------------------------------------------------------------------ 

根據這個日誌,下面的文件上傳到

https://oss.sonatype.org/content/repositories/snapshots/com/github/aliteralmind/xbnjava

  • maven-metadata.xml
  • 0.1.2-SNAPSHOT/maven-metadata.xml
  • 0.1.2-SNAPSHOT/xbnjava-0.1.2-20140717.010135-5.pom

在實際看着我的瀏覽器,目錄,我看到這些文件:

  • maven-metadata.xml(所有文件也有md5sha1版)
  • 0.1.2-SNAPSHOT/maven-metadata.xml
  • 0.1.2-SNAPSHOT/xbnjava-0.1.2-20140716.174151-1.pom

所以,我不明白爲什麼日誌說文件被髮送,但服務器實際上盟友包含20140716版本。但還有一個更大的問題,因爲我們的目標是有

  • xbnjava-0.1.2.jar
  • xbnjava-0.1.2-sources.jar
  • xbnjava-0.1.2-javadoc.jar

在服務器上(連同其*.asc同伴)和他們都不是。

在POM,我有這樣的屬性

<properties> 
    <jarprefix>../build/${project.artifactId}-${project.version}/download/${project.artifactId}-${project.version}</jarprefix> 
</properties> 

plugins塊(這是profiles部分的一個子集),它包含三個工件,其中的每一個明確地指向這三個罐中的一個文件

<plugins> 
    <plugin> 
     <groupId>org.codehaus.mojo</groupId> 
     <artifactId>build-helper-maven-plugin</artifactId> 
     <version>1.8</version> 
     <executions> 
     <execution> 
      <id>attach-artifacts</id> 
      <phase>package</phase> 
      <goals> 
       <goal>attach-artifact</goal> 
      </goals> 
      <configuration> 
       <artifacts> 
        <artifact> 
        <file>${jarprefix}.jar</file> 
        <type>jar</type> 
        </artifact> 
        <artifact> 
        <file>${jarprefix}-javadoc.jar</file> 
        <type>jar</type> 
        <classifier>javadoc</classifier> 
        </artifact> 
        <artifact> 
        <file>${jarprefix}-sources.jar</file> 
        <type>jar</type> 
        <classifier>sources</classifier> 
        </artifact> 
       </artifacts> 
      </configuration> 
     </execution> 
     </executions> 
    </plugin> 
</plugins> 

(聚甲醛是

R:\jeffy\programming\sandbox\xbnjava\pom.xml 

個罐子是

R:\jeffy\programming\build\xbnjava-0.1.1\download 

那麼,什麼是讓POM以

  1. 下一步認識的jar文件
  2. 他們簽名(並提示我要我公開密鑰密碼,對吧?)和
  3. 推送給Maven?

以下是我的更新settings.xmlpom.xml

(該Sonatype的支持人員還建議考慮"minimal Maven" idea,這完全避免了POM。這是一個有趣的想法,但我想先通過看到這一點。)

謝謝你對我的幫助。




設置:

<?xml version="1.0" encoding="UTF-8"?> 
<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"> 
    <servers> 
     <server> 
     <id>ossrh</id> 
     <username>aliteralmind</username> 
     <password>MY_SONATYPE_DOT_COM_PASSWORD</password> 
     </server> 
    </servers> 
    <pluginGroups></pluginGroups> 
    <proxies></proxies> 
    <mirrors></mirrors> 
    <profiles></profiles> 
</settings> 

POM:

<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>com.github.aliteralmind</groupId> 
    <artifactId>xbnjava</artifactId> 
    <packaging>pom</packaging> 
    <version>0.1.2-SNAPSHOT</version> 
    <name>XBN-Java</name> 
    <url>https://github.com/aliteralmind/xbnjava</url> 
    <inceptionYear>2014</inceptionYear> 
    <organization> 
     <name>Jeff Epstein</name> 
    </organization> 
    <description>XBN-Java is a collection of generically-useful backend (server side, non-GUI) programming utilities, featuring RegexReplacer and FilteredLineIterator. XBN-Java is the foundation of Codelet (http://codelet.aliteralmind.com).</description> 

    <parent> 
     <groupId>org.sonatype.oss</groupId> 
     <artifactId>oss-parent</artifactId> 
     <version>7</version> 
    </parent> 

    <licenses> 
     <license> 
     <name>Lesser General Public License (LGPL) version 3.0</name> 
     <url>https://www.gnu.org/licenses/lgpl-3.0.txt</url> 
     </license> 
     <license> 
     <name>Apache Software License (ASL) version 2.0</name> 
     <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url> 
     </license> 
    </licenses> 

    <developers> 
     <developer> 
     <name>Jeff Epstein</name> 
     <email>[email protected]</email> 
     <roles> 
      <role>Lead Developer</role> 
     </roles> 
     </developer> 
    </developers> 

    <issueManagement> 
     <system>GitHub Issue Tracker</system> 
     <url>https://github.com/aliteralmind/xbnjava/issues</url> 
    </issueManagement> 

    <distributionManagement> 
     <snapshotRepository> 
     <id>ossrh</id> 
     <url>https://oss.sonatype.org/content/repositories/snapshots</url> 
     </snapshotRepository> 
    </distributionManagement> 

    <scm> 
     <connection>scm:git:[email protected]:aliteralmind/xbnjava.git</connection> 
     <url>scm:git:[email protected]:aliteralmind/xbnjava.git</url> 
     <developerConnection>scm:git:[email protected]:aliteralmind/xbnjava.git</developerConnection> 
    </scm> 

    <properties> 
     <java.version>1.7</java.version> 
     <jarprefix>../build/${project.artifactId}-${project.version}/download/${project.artifactId}-${project.version}</jarprefix> 
    </properties> 

    <profiles> 
     <!-- 
     This profile will sign the JAR file, sources file, and javadocs file using the GPG key on the local machine. 
     See: https://docs.sonatype.org/display/Repository/How+To+Generate+PGP+Signatures+With+Maven 
     --> 
     <profile> 
     <id>release-sign-artifacts</id> 
     <activation> 
      <property> 
       <name>release</name> 
       <value>true</value> 
      </property> 
     </activation> 
     <build> 
      <plugins> 
       <plugin> 
        <groupId>org.codehaus.mojo</groupId> 
        <artifactId>build-helper-maven-plugin</artifactId> 
        <version>1.8</version> 
        <executions> 
        <execution> 
         <id>attach-artifacts</id> 
         <phase>package</phase> 
         <goals> 
          <goal>attach-artifact</goal> 
         </goals> 
         <configuration> 
          <artifacts> 
           <artifact> 
           <file>${jarprefix}.jar</file> 
           <type>jar</type> 
           </artifact> 
           <artifact> 
           <file>${jarprefix}-javadoc.jar</file> 
           <type>jar</type> 
           <classifier>javadoc</classifier> 
           </artifact> 
           <artifact> 
           <file>${jarprefix}-sources.jar</file> 
           <type>jar</type> 
           <classifier>sources</classifier> 
           </artifact> 
          </artifacts> 
         </configuration> 
        </execution> 
        </executions> 
       </plugin> 
      </plugins> 
     </build> 
     </profile> 
    </profiles> 
</project> 
+0

1.爲 「20140717」 的問題,是您在與服務器相同的時區? 2。你是否嘗試用另一臺計算機來查看是否可以下載依賴項? – coolcfan

+0

@coolcfan還沒有準備好回答這個問題,因爲我還沒有上傳我期待的文件(不論日期/時間)... – aliteralmind

+0

@coolcfan其實,它似乎現在就在那裏:https:///oss.sonatype.org/content/repositories/snapshots/com/github/aliteralmind/xbnjava/0.1.2-SNAPSHOT/ – aliteralmind

回答

2

要連接的文物中,當您運行'mvn這可能是禁用release-sign-artifacts簡介部署「命令。嘗試運行mvn deploy -Drelease=true或將release-sign-artifacts配置文件移動到主.pom部分。不知道你需要一個單獨的配置文件。

時間戳很好。這就是Maven倉庫如何存儲SNAPSHOT。

Maven有一個陡峭的學習曲線,但一旦你明白了它只是工作的基本概念。

+0

就是這樣。優秀。我即將寫出一個回答,總結我所做的。現在進入下一期... – aliteralmind

1

這就是我所做的更改,如提出在@AlexeyGavrilov's answer

原文:

<profiles> 
    <!-- 
    This profile will sign the JAR file, sources file, and javadocs file using the GPG key on the local machine. 
    See: http://blog.sonatype.com/2010/01/how-to-generate-pgp-signatures-with-maven/ 
    --> 
    <profile> 
     <id>release-sign-artifacts</id> 
     <activation> 
     <property> 
      <name>release</name> 
      <value>true</value> 
     </property> 
     </activation> 
     <build> 
     <plugins> 
      <plugin> 
       <groupId>org.codehaus.mojo</groupId> 
       <artifactId>build-helper-maven-plugin</artifactId> 
       <version>1.8</version> 
       <executions> 
        <execution> 
        <id>attach-artifacts</id> 
        <phase>package</phase> 
        <goals> 
         <goal>attach-artifact</goal> 
        </goals> 
        <configuration> 
         <artifacts> 
          <artifact> 
           <file>${jarprefix}.jar</file> 
           <type>jar</type> 
          </artifact> 
          <artifact> 
           <file>${jarprefix}-javadoc.jar</file> 
           <type>jar</type> 
           <classifier>javadoc</classifier> 
          </artifact> 
          <artifact> 
           <file>${jarprefix}-sources.jar</file> 
           <type>jar</type> 
           <classifier>sources</classifier> 
          </artifact> 
         </artifacts> 
        </configuration> 
        </execution> 
       </executions> 
      </plugin> 
     </plugins> 
     </build> 
    </profile> 
</profiles> 

新:

<build> 
    <plugins> 
     <plugin> 
     <groupId>org.codehaus.mojo</groupId> 
     <artifactId>build-helper-maven-plugin</artifactId> 
     <version>1.8</version> 
     <executions> 
      <execution> 
       <id>attach-artifacts</id> 
       <phase>package</phase> 
       <goals> 
        <goal>attach-artifact</goal> 
       </goals> 
       <configuration> 
        <artifact> 
         <file>${jarprefix}.jar</file> 
         <type>jar</type> 
        </artifact> 
        <artifact> 
         <file>${jarprefix}-javadoc.jar</file> 
         <type>jar</type> 
         <classifier>javadoc</classifier> 
        </artifact> 
        <artifact> 
         <file>${jarprefix}-sources.jar</file> 
         <type>jar</type> 
         <classifier>sources</classifier> 
        </artifact> 
        </artifacts> 
       </configuration> 
      </execution> 
     </executions> 
     </plugin> 
    </plugins> 
</build> 

<profiles> 
    <!-- 
    This profile will sign the JAR file, sources file, and javadocs file using the GPG key on the local machine. 
    See: http://blog.sonatype.com/2010/01/how-to-generate-pgp-signatures-with-maven/ 
    --> 
    <profile> 
     <id>release-sign-artifacts</id> 
     <activation> 
     <property> 
      <name>release</name> 
      <value>true</value> 
     </property> 
     </activation> 
    </profile>