OSGI:如何将Putty SCP与Maven-Bundle-Plugin一起使用



我想将Maven汇编成OSGI捆绑包到我的远程OSGI存储库中。我在Windows 7上,使用Eclipse的Maven-Bundle-Plugin(2.3.7)。存储库位于Linux上,可通过SSH访问。

我已经在settings.xml中配置了使用plinkpscp(Putty Tools)进行SSH工作。在<distributionManagement>中,我设置了以scpexe://

开头的存储库URL

maven-deploy目标正常工作,并将jar文件和metadata.xml上传到存储库。

现在,我还希望生产和上传OBR元数据。因此,我添加了Maven-Bundle-Plugin的配置<remoteOBR>my-repository</remoteOBR>(与<distributionManagement>中的存储库是相同的ID。

执行部署时(Maven部署阶段成功完成后),我会得到错误。

[错误]无法执行目标 org.apache.felix:maven-bundle-plugin:2.3.7:部署(默认数据) Project Bootstrapper:转移失败:退出代码:1-'SCP'未被认为是 内部或外部命令,可操作程序或批处理文件。
-> [帮助1]

这意味着maven-bundle-plugin不使用settings.xml中指定的 pscp命令,而是" scp",而" scp",该命令在路径上不可用。

如何使用Putty的PSCP?

我最终找到了一个工作解决方案:

  1. 请勿使用外部SSH工具(PUTTY),而仅使用Maven-Internal SSH/SCP实现
  2. 因此,使用Wagon-SSH(不是Wagon-SSH-External)
  3. 将用户名,私钥位置和密码添加到steratings.xml(可悲的是,不能使用选美,但是必须在settings.xml(beuh)中进行硬码我的密码)

因此,pom看起来像(注意,scp://协议用于URL)

<project>
...
  <distributionManagement>
    <repository>
      <id>my-repository</id>
      <url>scp://repo.myserver.com/path/to/repo/</url>
    </repository>
  </distributionManagement>
...
  <build>
    <plugins>
        <plugin>
            <groupId>org.apache.felix</groupId>
            <artifactId>maven-bundle-plugin</artifactId>
            <version>2.3.7</version>
            <extensions>true</extensions>
            <configuration>
                ...
                <remoteOBR>my-repository</remoteOBR>
            </configuration>
        </plugin>
    </plugins>
    <extensions>
          <extension>
            <groupId>org.apache.maven.wagon</groupId>
             <artifactId>wagon-ssh</artifactId>
             <version>2.5</version>
          </extension>
    </extensions>
  </build>
...

和settings.xml(位于c: users myusernameonwindows .m2 )

<settings>
  <servers>
    <server>
      <id>my-repository</id>
      <username>myUsernameOnRepo</username>
      <privateKey>C:/path/to/private/key/id_rsa</privateKey>
      <passphrase>myPrivateKeyPassphrase</passphrase>
    </server>
  </servers>
</settings>

最新更新