1

maven-deploy-plugin を使用してファイルをデプロイしたいと考えています。現在、私は自分のpomに次のものを持っています:

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-deploy-plugin</artifactId>
            <version>2.7</version>
            <executions>
                <execution>
                    <id>deploy-features-xml</id>
                    <phase>deploy</phase>
                    <goals>
                        <goal>deploy-file</goal>
                    </goals>
                    <configuration>
                        <repositoryId>${project.distributionManagement.snapshotRepository.id}</repositoryId>
                        <url>${project.distributionManagement.snapshotRepository.url}</url>
                        <groupId>${project.groupId}</groupId>
                        <artifactId>${project.artifactId}</artifactId>
                        <version>${project.version}</version>
                        <file>features.xml</file>
                    </configuration>
                </execution>
            </executions>
        </plugin>

バージョンに基づいて、スナップショットとリリース リポジトリを切り替えたい。プロジェクトのバージョンが 1-SNAPSHOT の場合、ファイルはスナップショット リポジトリにデプロイする必要があります。プロジェクトのバージョンが 1.0 の場合、ファイルはリリース リポジトリにデプロイする必要があります。しかし、maven-deploy-plugin はそれをハード コードしますか?

4

2 に答える 2

4

この動作はデフォルトですでに与えられています。ただし、リポジトリ マネージャーを使用する必要があります。mvn deploy を介してアーティファクトを簡単にデプロイできます。通常、SNAPSHOT リリースは SNAPSHOT リポジトリに移動し、リリースの場合はリリース リポジトリに移動します。

于 2013-03-19T09:37:20.373 に答える
2

私がたどり着いた解決策は、build-helper-maven-plugin と maven-resources-plugin を使用することでした。このセットアップは、jar と pom およびプロジェクトと共に、maven リポジトリーで project/xml/features として参照できる xml ファイルをデプロイすることを意味します。

関連する pom プラグイン:

        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>build-helper-maven-plugin</artifactId>
            <executions>
                <execution>
                    <id>attach-artifacts</id>
                    <phase>package</phase>
                    <goals>
                        <goal>attach-artifact</goal>
                    </goals>
                    <configuration>
                        <artifacts>
                            <artifact>
                                <file>target/features/features.xml</file>
                                <type>xml</type>
                                <classifier>features</classifier>
                            </artifact>
                        </artifacts>
                    </configuration>
                </execution>
            </executions>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-resources-plugin</artifactId>
            <executions>
                <execution>
                    <id>copy-features</id>
                    <phase>generate-resources</phase>
                    <goals>
                        <goal>copy-resources</goal>
                    </goals>
                    <configuration>
                        <outputDirectory>target/features</outputDirectory>
                        <resources>
                            <resource>
                                <directory>src/main/features</directory>
                                <filtering>true</filtering>
                            </resource>
                        </resources>
                    </configuration>
                </execution>
            </executions>
        </plugin>
于 2013-03-21T23:31:11.043 に答える