将jar部署到maven内部存储库

时间:2011-11-09 11:38:48

标签: windows maven-3

我创建了一个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“

访问类型为default的repository localhost(scp:// localhost / commons-logging /)

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

谢谢!

3 个答案:

答案 0 :(得分: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。

答案 1 :(得分:1)

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

答案 2 :(得分:0)

我有同样的问题,通过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和版本。

相关问题