1

Maven によってビルドされた jar を、リポジトリではなく、リモート ホストのディレクトリにコピーしようとしています。ここで user1050755 の回答を試しました Maven-antrun-plugin を使用する展開に Mavenを使用し、wagon-ssh プラグインも試しました。以下は、私の pom.xml からの適切な抜粋です。

<build>
        <extensions>
            <extension>
                <groupId>org.apache.maven.wagon</groupId>
                <artifactId>wagon-ssh</artifactId>
                <version>2.9</version>
            </extension>
        </extensions>
        <plugins>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>wagon-maven-plugin</artifactId>
                <version>1.0</version>
                <executions>
                    <execution>
                        <id>xd</id>
                        <phase>deploy</phase>
                        <goals>
                            <goal>upload</goal>
                        </goals>
                        <configuration>
                            <fromDir>target</fromDir>
                            <includes>xml-to-json-transformer-0.0.1-SNAPSHOT.jar</includes>
                                <excludes/>
                                <url>scp://spade.innoimm.local</url>
                                <toDir>/opt/xd/custom-modules/processor</toDir>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                    <artifactId>maven-antrun-plugin</artifactId>
                    <executions>
                        <execution>
                            <id>scp</id>
                            <phase>deploy</phase>
                            <configuration>
                                <tasks>
                                    <scp todir="root@spade:/opt/xd/custom-modules/processor"
                                         sftp="true"
                                         keyfile="C:\MerucurioVagrant\repo\mercurio-vagrant\insecure_private_key.ppk"
                                         failonerror="false"
                                         verbose="true"
                                         passphrase="nopass"
                                    >
                                        <fileset dir="target">
                                            <include
                                                name="xml-to-json-transformer-0.0.1-SNAPSHOT.jar"/>
                                        </fileset>
                                    </scp>
                                </tasks>
                            </configuration>
                            <goals>
                                <goal>run</goal>
                            </goals>
                        </execution>
                    </executions>
                    <dependencies>
                        <dependency>
                            <groupId>org.apache.ant</groupId>
                            <artifactId>ant-jsch</artifactId>
                            <version>1.9.4</version>
                        </dependency>
                    </dependencies>
                </plugin>
        </plugins>
    </build>

両方のプラグインで同じエラーが発生します

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project xml-to-json-transformer: Deployment failed: repository element was not specified in the POM inside distributionManagement element or in -DaltDeploymentRepository=id::layout::url parameter -> [Help 1]

しかし、リポジトリにデプロイしたくありません。antrun-plugin を使用すると、制限なしでファイルをリモート ホストにコピーできると思っていましたが、何が足りないのでしょうか?

4

3 に答える 3

1

フェーズ デプロイを使用するため、distributionManagement または altDeploymentRepository が必要です。この場合、2 つの解決策があります。

  1. 次のように展開フェーズをスキップします。

    <plugin>
       <groupId>org.apache.maven.plugins</groupId>
       <artifactId>maven-deploy-plugin</artifactId>
       <version>X.Y</version>
       <configuration>
          <skip>true</skip>
       </configuration>
    </plugin>
    
  2. 変化する

    <phase>deploy</phase>
    

    <phase>install</phase> 
于 2015-11-18T14:21:47.367 に答える
0

この問題は解決しましたか?

Apache Maven 3.2.5 を使用する Windows プラットフォームで同じ問題に直面しました

その理由は、maven が settings.xml で <server> 構成を検出できないためです。

だから私の解決策は以下です。

  1. url に ssh アカウントを追加します。
    <構成>
        <url>scp://root@192.168.56.102</url>
    </設定>

  1. mvn デプロイ

次に、コマンドラインでパスワードを入力します。

今、私はより良い解決策を見つけようとしています。

そうだといい...

于 2015-11-20T11:49:22.260 に答える