禁用LESS的自动编译

时间:2015-01-07 19:59:12

标签: css eclipse maven less

我在Eclipse环境中。我希望只有在通过mvn包显式调用时才能编译。目前,只要我在less文件中进行任何更改,它就会将更改传播到CSS。我该怎么做才能避免这种行为?

<plugin>
  <groupId>org.lesscss</groupId>
  <artifactId>lesscss-maven-plugin</artifactId>
  <version>1.7.0.1.1</version>
  <configuration>
    <watch>false</watch>
    <sourceDirectory>src/main/webapp/css</sourceDirectory>
    <outputDirectory>src/main/webapp/css</outputDirectory>
    <compress>true</compress>
    <force>true</force>
    </configuration>
  <executions>
    <execution>
      <goals>
        <goal>compile</goal>
      </goals>
      <phase>package</phase>
    </execution>
  </executions>
</plugin>

也发布了此问题here

3 个答案:

答案 0 :(得分:0)

您需要定义要在哪个maven phase执行插件,基本上在phase标记下添加execution标记。请看以下示例:http://maven.apache.org/guides/mini/guide-configuring-plugins.html#Using_the_executions_Tag

答案 1 :(得分:0)

作为一种解决方法,我在配置文件中封装了LESS插件。在服务器端,我调用该配置文件进行LESS编译

mvn package -pless_compile

答案 2 :(得分:0)

M2Eclipse是一个Eclipse插件,它为Maven提供紧密集成。它确定应该执行插件的人和时间。每个插件都可以存储生命周期映射元数据,其中包含基于其决策的数据(请参阅M2E compatible maven plugins)。默认情况下,此插件在增量构建时调用:

<lifecycleMappingMetadata>
    <pluginExecutions>
        <pluginExecution>
            <pluginExecutionFilter>
                <goals>
                    <goal>compile</goal>
                </goals>
            </pluginExecutionFilter>
            <action>
                <execute>
                    <runOnIncremental>true</runOnIncremental>
                    <runOnConfiguration>false</runOnConfiguration>
                </execute>
            </action>
        </pluginExecution>
    </pluginExecutions>
</lifecycleMappingMetadata>

如果要禁用自动编译,则需要将以下条目添加到pom.xml

<pluginManagement>
   <plugins>
      <plugin>
         <groupId>org.eclipse.m2e</groupId>
         <artifactId>lifecycle-mapping</artifactId>
         <version>1.0.0</version>
         <configuration>
            <lifecycleMappingMetadata>
               <pluginExecutions>
                  <pluginExecution>
                     <pluginExecutionFilter>
                        <groupId>org.lesscss</groupId>
                        <artifactId>lesscss-maven-plugin</artifactId>
                        <versionRange>[0,)</versionRange>
                        <goals>
                           <goal>compile</goal>
                        </goals>
                     </pluginExecutionFilter>
                     <action>
                        <ignore />
                     </action>
                  </pluginExecution>
               </pluginExecutions>
            </lifecycleMappingMetadata>
         </configuration>
      </plugin>
   </plugins>
</pluginManagement>