Disable auto compilation of LESS

2019-08-14 06:09发布

I am in Eclipse environment. I want LESS to compile only when explicitly invoked via mvn package. At the moment, as soon as I make any changes in my less file it propagates the change to CSS. What should I do to avoid this behaviour?

<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>

also posted this issue here

3条回答
我命由我不由天
2楼-- · 2019-08-14 06:29

As a workaround I have encapsulated LESS plugin inside a profile. On server side I invoke that profile to do LESS compilation

mvn package -pless_compile
查看更多
我想做一个坏孩纸
3楼-- · 2019-08-14 06:39

M2Eclipse is an Eclipse plugin which provides tight integration for Maven. It determines who and when plugins should be executed. Each plugin can store lifecycle mapping metadata with data on which it based its decision (see M2E compatible maven plugins). By default this plugin is called on incremental builds:

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

If you want to disable automatic compilation, then you need to add the following entry to your 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>
查看更多
啃猪蹄的小仙女
4楼-- · 2019-08-14 06:39

You need to define in which maven phase you want to execute your plugin, basically adding the phase tag under the execution tag. Take look to the following examples: http://maven.apache.org/guides/mini/guide-configuring-plugins.html#Using_the_executions_Tag.

查看更多
登录 后发表回答