0

だから私は私のpomにこのスニペットを持っています

<configuration>  
  <target if="csc" >
    <echo>Unzipping md csc help</echo>
  </target> 
  <target unless="csc">
    <echo>Unzipping md help</echo>
  </target>
</configuration>

通常 mvn で実行すると、unless="csc" ターゲットが正しく実行されます。問題は、 -Dcsc=true で実行すると、どのターゲットも実行されないことです。

私は何を間違っていますか?:)

ありがとう

4

2 に答える 2

1

antrun プラグインは、構成内の単一のターゲット要素のみをサポートしているようです。プロパティが設定されているか存在しない場合にアクティブになるMaven プロファイルを使用して、同じ効果を得ることができます。

<profiles>
    <profile>
        <id>property-set</id>
        <activation>
            <property>
                <name>csc</name>
            </property>
        </activation>
        <build>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-antrun-plugin</artifactId>
                    <version>1.6</version>
                    <executions>
                        <execution>
                            <id>antrun-property-set</id>
                            <goals>
                                <goal>run</goal>
                            </goals>
                            <phase>generate-sources</phase>
                            <configuration>
                                <target> 
                                    <echo>property is set</echo>
                                </target>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </build>
    </profile>
    <profile>
        <id>property-not-set</id>
        <activation>
            <property>
                <name>!csc</name>
            </property>
        </activation>
        <build>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-antrun-plugin</artifactId>
                    <version>1.6</version>
                    <executions>
                        <execution>
                            <id>antrun-property-not-set</id>
                            <goals>
                                <goal>run</goal>
                            </goals>
                            <phase>generate-sources</phase>
                            <configuration>
                                <target> 
                                    <echo>property is not set</echo>
                                </target>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </build>
    </profile>
</profiles>
于 2011-04-12T21:36:03.587 に答える
0

アンパックは、maven-dependency プラグインを介して行うことができます。

于 2011-04-12T14:40:31.387 に答える