我试图设置修道院 执行LESS CSS 预处理器 在我的网络项目的目录上。 基本流程是 :
- Maven calls maven-antrun-plugin.
- Ant-contrib
<foreach/>
loops through a directory and finds all the .less files and calls a target. - The target executes Rhino, which executes LESS which converts the file.
为此,我有以下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>
我遇到的问题是“ 主” 目标开始执行, 但是在
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-antrun-plugin:1.7:run (default) on project model-web-project: An Ant BuildException has occured: The following error occurred while executing this line:
[ERROR] /Users/.../pom.xml:4: Unexpected element "{http://maven.apache.org/POM/4.0.0}project" {antlib:org.apache.tools.ant}project
[ERROR] around Ant part ...<foreach param="file" target="processLessFile">... @ 6:50 in /Users/.../target/antrun/build-main.xml
[ERROR] -> [Help 1]
Ant 似乎有些东西导致它尝试读取 POM 文件, 可能搜索目标。 我看到两个目标被生成到文件目标/ antrun/ building- main. xml 和目标/ antrun/ building- processLessFile. xml 中, 所以它应该搜索的目录就是这个 。