Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/maven/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/ant/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在maven antrun插件中调用foreach_Maven_Ant_Ant Contrib_Maven Antrun Plugin - Fatal编程技术网

在maven antrun插件中调用foreach

在maven antrun插件中调用foreach,maven,ant,ant-contrib,maven-antrun-plugin,Maven,Ant,Ant Contrib,Maven Antrun Plugin,我正在尝试设置maven,以便在我的web项目中的目录上执行较少的CSS预处理器。基本流程是: Maven调用Maven antrun插件 Ant contrib在目录中循环,查找所有.less文件并调用目标 目标执行Rhino,后者执行的转换文件更少 为此,我有以下XML: <plugin> <groupId>org.apache.maven.plugins</groupId> <arti

我正在尝试设置maven,以便在我的web项目中的目录上执行较少的CSS预处理器。基本流程是:

  • Maven调用Maven antrun插件
  • Ant contrib
    在目录中循环,查找所有.less文件并调用目标
  • 目标执行Rhino,后者执行的转换文件更少
  • 为此,我有以下XML:

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-antrun-plugin</artifactId>
                <version>1.7</version>
                <executions>
                    <execution>
                        <phase>compile</phase>
                        <configuration>
                            <target name="processLessFile">
                                <!-- ... -->
                            </target>
                            <target name="main">
                                <taskdef resource="net/sf/antcontrib/antcontrib.properties" classpathref="maven.plugin.classpath"/>
                                <property name="css.dir" location="src/main/webapp/css"/>
                                <foreach param="file" target="processLessFile">
                                    <fileset dir="${css.dir}">
                                        <filename name="**/*.less" />
                                    </fileset>
                                </foreach>
                            </target>
                        </configuration>
                        <goals>
                            <goal>run</goal>
                        </goals>
                    </execution>
                </executions>
                <dependencies>
                    <dependency>
                        <groupId>ant</groupId>
                        <artifactId>ant-contrib</artifactId>
                        <version>1.0b2</version>
                    </dependency>
                </dependencies>
            </plugin>
    
    
    org.apache.maven.plugins
    maven antrun插件
    1.7
    编译
    跑
    蚂蚁
    抗辩人
    1.0b2
    
    我遇到的问题是,“主”目标开始执行,但在
    中失败:

    [ERROR]无法执行goal org.apache.maven.plugins:maven-antrun-plugin:1.7:run(默认)on-project-model-web项目:发生Ant BuildException:执行此行时发生以下错误:
    [错误]/Users/../pom.xml:4:意外元素”{http://maven.apache.org/POM/4.0.0}项目“{antlib:org.apache.tools.ant}项目
    [错误]蚂蚁部分周围……@6:50 in/Users/../target/antrun/build-main.xml
    [错误]->[帮助1]
    

    看起来Ant中的某些内容导致它尝试读取POM文件,可能是在寻找目标。我看到这两个目标都被生成到文件target/antrun/build-main.xml和target/antrun/build-processLessFile.xml中,所以它应该在这个目录中查找。

    您知道我认为应该解决您的问题的方法

    ant插件似乎不支持多个目标节的声明。您可以检查生成的ANT脚本,看看我在说什么:

    target/antrun/build-main.xml
    
    深入挖掘以下州:

    此插件的目的不是提供污染POM的方法,因此鼓励您将所有Ant任务移动到build.xml文件中,并使用Ant的任务从POM调用它

    措辞严厉,但建议是合理的。我建议将您的ANT逻辑移动到一个专用文件中,并按如下方式调用它:

            <plugin>
                <artifactId>maven-antrun-plugin</artifactId>
                <version>1.7</version>
                <executions>
                    <execution>
                        <phase>compile</phase>
                        <configuration>
                            <target>
                                <ant antfile="${basedir}/src/main/ant/build.xml"/>
                            </target>
                        </configuration>
                        <goals>
                            <goal>run</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
    
    
    maven antrun插件
    1.7
    编译
    跑
    
    你指的是ant contrib而不是ant collab,是吗?谢谢,我一直打错了。会的,但我正在尝试在添加新依赖项之前在公司内部Maven repo上使用软件。
            <plugin>
                <artifactId>maven-antrun-plugin</artifactId>
                <version>1.7</version>
                <executions>
                    <execution>
                        <phase>compile</phase>
                        <configuration>
                            <target>
                                <ant antfile="${basedir}/src/main/ant/build.xml"/>
                            </target>
                        </configuration>
                        <goals>
                            <goal>run</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>