【问题标题】:Deploy jar to the maven internal repository将jar部署到maven内部仓库
【发布时间】:2011-12-25 06:06:30
【问题描述】:

我创建了一个 Maven 内部存储库。我有不是使用 maven 创建的 jar,即它们没有 pom.xml 文件。我需要将此 jar 部署到我创建的内部存储库。为此,我使用了 mvn deploy:deploy-file。 以下是我使用过的命令 -

mvn -X deploy:deploy-file -Durl=scp://localhost/my-repo/ -DrepositoryId=localhost -Dfile=temp.jar -DgroupId=com.myorg -DartifactId=temp -Dversion= 1.0 -Dpackaging=jar -Dclassifier=test -DgeneratePom=true -DgeneratePom.description="temp test" -DrepositoryLayout=default -DuniqueVersion=false

我使用的是 windows xp 和 apache-maven-3.0.3。我收到以下错误 -

"[错误] 无法在项目 Standalone-pom 上执行目标 org.apache.maven.plugins:maven-deploy-plugin:2.5:deploy-file (default-cli):无法部署工件/元数据: 没有连接器可用于使用可用工厂 WagonRepositoryConnectorFactory 访问默认类型的存储库 localhost (scp://localhost/commons-logging/)”

我从来没有在 Windows 上使用过 scp,因为我在 linux 机器上工作过,我也不需要安装它来完成这项任务,那么我可以从哪里安装它以及如何克服我面临的错误。请指导我解决这个问题。

谢谢!!

【问题讨论】:

  • 错误已解决,我们只需要将 jar 复制到 maven_install_dir/lib/ext/ 中。以下是 jar 文件 1. jsch-0.1.38.jar 2. plexus-interactivity-api-1.0-alpha-6 3. wagon-ssh-1.0-beta-7 4. wagon-ssh-common-1.0-beta- 7 我们需要这样做,因为我们正在尝试部署一个不是使用 maven 创建的 jar,而且它没有 pom.xml,所以我们不能添加 ... 是执行 wagon-ssh 所需的。因此我们直接将它们添加到 mvn/lib/ext/.

标签: windows maven-3


【解决方案1】:

你没有提到这个存储库是什么。如果有问题的存储库是您的本地计算机存储库,您可以这样做:

mvn install:install-file -DgroupId=javax.transaction -DartifactId=jta -Dpackaging=jar -Dversion=1.0.1B -Dfile=jta-1.0.1B.jar -DgeneratePom=true

如果存储库类似于 Nexus,则使用他们的 UI 上传工件,它会为您创建一个 pom。

【讨论】:

    【解决方案2】:

    我在通过 ssh 将专有的第三方 jar 部署到我们的内部存储库中时遇到了同样的问题。我最终使用了一个小 Ant 脚本,我觉得它比摆弄 Maven 类路径更安全。

    <?xml version="1.0"?>
    <project name="Maven Deploy" xmlns:artifact="antlib:org.apache.maven.artifact.ant">
    
      <property name="repository.id"  value="myrepository"/>
      <property name="repository.url" value="sftp://dev.example.com/var/www/mvn"/>
    
      <target name="init">
        <mkdir dir="target/lib"/>
        <get src="http://repo1.maven.org/maven2/org/apache/maven/maven-ant-tasks/2.1.3/maven-ant-tasks-2.1.3.jar" dest="target/lib" skipexisting="true"/>
        <typedef resource="org/apache/maven/artifact/ant/antlib.xml" uri="antlib:org.apache.maven.artifact.ant" classpath="target/lib/maven-ant-tasks-2.1.3.jar"/>
    
        <artifact:install-provider artifactId="wagon-ssh" version="2.2"/>
      </target>
    
      <target name="deploy" depends="init">
    
        <echo>Deploy a jar to the Maven repository:</echo>
        <input addproperty="groupId"    message="groupId:"/>
        <input addproperty="artifactId" message="artifactId:"/>
        <input addproperty="version"    message="version:"/>
        <input addproperty="file"       message="file:" defaultvalue="${artifactId}-${version}.jar"/>
    
        <artifact:mvn failonerror="true">
          <arg value="org.apache.maven.plugins:maven-deploy-plugin:2.6:deploy-file"/>
          <arg value="-DgroupId=${groupId}"/>
          <arg value="-DartifactId=${artifactId}"/>
          <arg value="-Dversion=${version}"/>
          <arg value="-Durl=${repository.url}"/>
          <arg value="-DrepositoryId=${repository.id}"/>
          <arg value="-Dfile=${file}"/>
        </artifact:mvn>
    
      </target>
    
    </project>
    

    只需键入 ant deploy 并指定文件的 groupId、artifactId 和版本。

    【讨论】:

      【解决方案3】:

      mvn deploy:deploy-file -Durl=scp://d8u.us/home/hd1/public_html/maven2 -DrepositoryId=localhost -Dfile=yourwar.jar -DgroupId=us.d8u -DartifactId=yourwar -Dversion=1.0 -Dpackaging=jar -DgeneratePom=true -DrepositoryLayout=default -DuniqueVersion=false 为我工作。我只需要在我的主目录下创建maven2 目录并为网络用户设置适当的权限,并抄袭Mr. Sierra 的博客,他在那里提供了近乎工作的instructions for my case

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2012-12-01
        • 2018-06-28
        相关资源
        最近更新 更多