Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/359.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 接下来的第2部分——使用Maven只对JAR进行签名并将其部署到Maven Central。构建和编译完全使用Ant完成_Java_Maven_Ant - Fatal编程技术网

Java 接下来的第2部分——使用Maven只对JAR进行签名并将其部署到Maven Central。构建和编译完全使用Ant完成

Java 接下来的第2部分——使用Maven只对JAR进行签名并将其部署到Maven Central。构建和编译完全使用Ant完成,java,maven,ant,Java,Maven,Ant,这是对: 多亏了对前面问题的回答,以及sonatype支持人员的一些建议,我才有了我的第一个“非失败”。以下是mvn部署的当前输出: [INFO] Scanning for projects... [INFO] [INFO] ------------------------------------------------------------------------ [INFO] Building XBN-Java 0.1.2-SNAPSHOT [INFO] ----------------

这是对:


多亏了对前面问题的回答,以及sonatype支持人员的一些建议,我才有了我的第一个“非失败”。以下是mvn部署的当前输出:

[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] ------------------------------------------------------------------------
根据此日志,以下文件已上载到

  • 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
    (所有文件都有
    md5
    sha1
    版本)
  • 0.1.2-SNAPSHOT/maven metadata.xml
  • 0.1.2-SNAPSHOT/xbnjava-0.1.2-20140716.174151-1.pom
所以,我不明白为什么日志上说发送了
20140717
文件,但服务器实际上包含
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>
(POM是

R:\jeffy\programming\sandbox\xbnjava\pom.xml
罐子在里面

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

那么,下一步是什么让POM成功

  • 识别jar文件
  • 签名(并提示我输入公钥密码短语,对吗?),然后
  • 把他们推到Maven
  • 下面是我更新的
    settings.xml
    pom.xml

    (sonatype的支持人员还建议考虑a,这完全避免了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>
    
    
    ossrh
    一颗平常心
    我的\u SONATYPE\u DOT\u COM\u密码
    
    POM:

    
    4.0.0
    com.github.aliteralmind
    xbnjava
    聚甲醛
    0.1.2-快照
    XBN Java
    https://github.com/aliteralmind/xbnjava
    2014
    杰夫·爱普斯坦
    XBN Java是一个通用后端(服务器端,非GUI)编程实用程序的集合,具有RegexReplacer和FilteredLine迭代器。XBN-java是CODELET的基础http://codelet.aliteralmind.com).
    org.sonatype.oss
    oss父级
    7.
    较低通用公共许可证(LGPL)3.0版
    https://www.gnu.org/licenses/lgpl-3.0.txt
    Apache软件许可证(ASL)2.0版
    http://www.apache.org/licenses/LICENSE-2.0.txt
    杰夫·爱普斯坦
    一颗平常心-github@yahoo.com
    首席开发者
    GitHub问题跟踪器
    https://github.com/aliteralmind/xbnjava/issues
    ossrh
    https://oss.sonatype.org/content/repositories/snapshots
    scm:git:git@github.com:aliteralmind/xbnjava.git
    scm:git:git@github.com:aliteralmind/xbnjava.git
    scm:git:git@github.com:aliteralmind/xbnjava.git
    1.7
    ../build/${project.artifactId}-${project.version}/download/${project.artifactId}-${project.version}
    释放标志伪影
    释放
    真的
    org.codehaus.mojo
    构建助手maven插件
    1.8
    附加工件
    包裹
    附加工件
    ${jarprefix}.jar
    罐子
    ${jarprefix}-javadoc.jar
    罐子
    javadoc
    ${jarprefix}-sources.jar
    罐子
    来源
    
    您正在将工件附加到
    发布标志工件
    配置文件中,该配置文件在运行“mvn deploy”命令时可能已禁用。尝试运行
    mvn deploy-Drelease=true
    或将
    release-sign-artifacts
    配置文件移动到main.pom部分。不确定您是否需要单独的配置文件

    时间戳很好。这就是Maven存储库存储快照的方式


    Maven具有陡峭的学习曲线,但一旦你理解了基本概念,它就会起作用。

    这就是我所做的改变,如以下所示:

    原件:

    <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>
    
    
    释放标志伪影
    释放
    真的
    org.codehaus.mojo
    构建助手maven插件
    1.8
    附加工件
    包裹
    附加工件
    ${jarprefix}.jar
    罐子
    ${jarprefix}-javadoc.jar
    
    <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>aliteralmind-github@yahoo.com</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:git@github.com:aliteralmind/xbnjava.git</connection>
          <url>scm:git:git@github.com:aliteralmind/xbnjava.git</url>
          <developerConnection>scm:git:git@github.com: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>
    
    <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>