【问题标题】:OSGi: how to use PuTTY scp with maven-bundle-pluginOSGi:如何将 PuTTY scp 与 maven-bundle-plugin 一起使用
【发布时间】:2014-02-11 07:51:46
【问题描述】:

我想将我的 maven 编译的 OSGi 包部署到我的远程 OSGi 存储库。我在 Windows 7 上并使用来自 eclipse 的 maven-bundle-plugin (2.3.7)。该存储库位于 linux 上,可通过 ssh 访问。

我已在settings.xml 中配置为使用plinkpscp(腻子工具)来完成ssh 工作。 在<distributionManagement>我设置了repository url,以scpexe://开头

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

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

执行部署时,(在 maven 部署阶段成功完成后),我收到错误。

[ERROR] 未能执行目标 org.apache.felix:maven-bundle-plugin:2.3.7:deploy (default-deploy) on 项目引导程序:传输失败:退出代码:1 - 'scp' 未被识别为 内部或外部命令,可运行的程序或批处理文件。
-> [帮助 1]

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

如何配置 maven-bundle-plugin 以使用 PuTTY 的 pscp 上传 OBR 数据?

【问题讨论】:

    标签: maven osgi putty maven-bundle-plugin obr


    【解决方案1】:

    我最终找到了一个可行的解决方案:

    1. 不要使用外部 ssh 工具 (PuTTY),而只能使用 maven-internal ssh/scp 实现
    2. 因此,使用 wagon-ssh(不是 wagon-ssh-external)
    3. 将用户名、私钥位置和密码添加到 settings.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>
    

    【讨论】:

      猜你喜欢
      • 2013-08-19
      • 2013-02-10
      • 2011-05-21
      • 2011-06-18
      • 2010-11-25
      • 2012-04-20
      • 2013-02-19
      • 2016-07-20
      • 2023-03-07
      相关资源
      最近更新 更多