0

私はmavenで働いています。

このリンクにあるように: http://maven.apache.org/plugins/maven-dependency-plugin/examples/copying-artifacts.html (2番目のケース) 、アーティファクトが依存関係としてリストされている場合、存在するタグを削除できます. artifactItem のバージョンは、依存関係からのバージョンにデフォルト設定されるためです。

ただし、プロファイルを使用する場合はこの限りではありません。

依存関係を追加する 2 つのプロファイルを使用しています。私のポンはこのようなものです:

<profile>
        <id>buildDependency</id>
        <activation>
            <activeByDefault>true</activeByDefault>
            <property>
                <name>maven.dependency</name>
                <value>true</value>
            </property>
        </activation>
        <dependencies>
            <dependency>
                <groupId>com.marshy</groupId>
                <artifactId>marshy1</artifactId>
                <version>1.1.0.5</version>
            </dependency>

ここから値を取得するという考えからタグを削除すると、「.......の依存関係を収集できませんでした」というエラーがスローされます。

これをプロファイルで機能させるにはどうすればよいですか?

4

1 に答える 1

0

例を編集して、プロファイルの依存関係タグ内で junit の依存関係を指定しました。この例を参照してくださいpom.xml。これを行う際に問題は発生しなかったため、pom に別の問題がある可能性があります (一部のみを投稿しただけです)。

<project>
    <modelVersion>4.0.0</modelVersion>

    <artifactId>build-dependency-example</artifactId>
    <groupId>org.example</groupId>
    <version>1.0.0-SNAPSHOT</version>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <version>2.10</version>
                <executions>
                    <execution>
                        <id>copy</id>
                        <phase>package</phase>
                        <goals>
                            <goal>copy</goal>
                        </goals>
                        <configuration>
                            <artifactItems>
                                <artifactItem>
                                    <groupId>junit</groupId>
                                    <artifactId>junit</artifactId>
                                    <overWrite>false</overWrite>
                                    <outputDirectory>${project.build.directory}/alternateLocation</outputDirectory>
                                    <destFileName>optional-new-name.jar</destFileName>
                                </artifactItem>
                            </artifactItems>
                            <outputDirectory>${project.build.directory}/wars</outputDirectory>
                            <overWriteReleases>false</overWriteReleases>
                            <overWriteSnapshots>true</overWriteSnapshots>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <profile>
            <id>buildDependency</id>
            <activation>
                <activeByDefault>true</activeByDefault>
                <property>
                    <name>maven.dependency</name>
                    <value>true</value>
                </property>
            </activation>
            <dependencies>
                <dependency>
                    <groupId>junit</groupId>
                    <artifactId>junit</artifactId>
                    <version>3.8.1</version>
                    <scope>test</scope>
                </dependency>
            </dependencies>
        </profile>
    </profiles>

</project>
于 2015-02-03T12:14:02.590 に答える