简体   繁体   中英

How to bind SASS plugin goal to tomcat7 deploy phase (maven)

I am developing a webapp running on Tomcat7, and using maven for dependencies/automated builds. Yesterday I started using the sass-maven-plugin , which is great. Its goal sass:update-stylesheets processes sass files and outputs css. Unfortunately, I can't have it executed during the webapp packaging. I am pretty new to maven too, so I might have missed something. Here's my understanding :

  • when I type mvn tomcat7:deploy , maven executes the deploy goal defined in the tomcat7 plugin
  • this plugin goes through some phases of the development lifecycle. More specifically, as mentioned in the doc , it "invokes the execution of the lifecycle phase package prior to executing itself."
  • if I map the goal sass:update-stylesheets to the package phase in <build><executions/></build> , it should be executed everytime I deploy/redeploy my app.

When I run mvn sass:update-stylesheets independently of tomcat7:deploy, everything is smooth. sass-maven-plugin gets the .scss files from src/main/resources, processes them and places the output in src/main/webapp/resources, where I want it to be to be deployed with my webapp. Unfortunately, if I don't run the command prior to tomcat7:deploy , I don't get any css for my pages. What did I get wrong? Also, is there any way I could map the sass:update-stylesheets to the phase process-resources , for instance, which would make more sense? Lastly, if this all works, will Eclipse's incremental build pick it up?

Here's my pom.xml (the relevant parts)

    ...

    <pluginManagement>
        <plugins>
            <plugin>
                <groupId>org.apache.tomcat.maven</groupId>
                <artifactId>tomcat7-maven-plugin</artifactId>
                <version>2.2</version>
                <configuration>
                    ...
                </configuration>
            </plugin>

            <!-- SASS processing -->
            <plugin>
                <groupId>org.jasig.maven</groupId>
                <artifactId>sass-maven-plugin</artifactId>
                <version>1.1.1</version>
                <executions>
                    <execution>
                        <id>generate-css</id>
                        <phase>package</phase>
                        <goals>
                            <goal>update-stylesheets</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <useCompass>true</useCompass>
                    <resources>
                        <resource>
                            <source>
                                <directory>${basedir}/src/main/resources</directory>
                            </source>
                            <destination>${basedir}/src/main/webapp/resources</destination>
                        </resource>
                    </resources>
                </configuration>
            </plugin>


        </plugins>
    </pluginManagement>
</build>

Thanks in advance for your help.

You have configured the stuff in the plugin management section. Please move the execution and it's binding to the build section (that is, out of the pluginManagement's plugins section into build's plugins section).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM