MattCheely / requirejs-maven-plugin

Maven plugin for RequireJS optimization
GNU Lesser General Public License v2.1
66 stars 21 forks source link

need a skip flag in the OptimizeMojo #2

Closed davidjnelson closed 12 years ago

davidjnelson commented 12 years ago

Hi Matthew,

Sometimes we need to run mvn test and waiting for optimize to run takes forever. A skip flag here would be perfect.

If you want me to add this and submit a pull request let me know. The painful part for me is getting it in maven. We have a private maven repo for modified open source code but it's kind of a pain to use.

Thanks, David

MattCheely commented 12 years ago

Hi David,

I'd be glad to add the feature if needed, but you can get a similar effect with profiles. If your plugin's default execution has an id of optimize, then you could use a profile like this to conditionally disable the plugin:

        <profile>
            <id>skip-optimize</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>com.github.mcheely</groupId>
                        <artifactId>requirejs-maven-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>optimize</id>
                                <phase>none</phase>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>

Does that work for your use case? If not let me know, and I'll add a config option.

davidjnelson commented 12 years ago

Hi Matthew,

Thank you so much! This is great. I had a hard time getting profiles to work previously and thought they wouldn't work for this use case. However, your help here was what got it working for me.

However, to get it working for my use case I had to do it slightly differently.

I removed the plugin from the regular build, and added it only to its own build profile. So by default it is off:

    <profile>
       <id>optimize</id>
       <build>
           <plugins>
              <plugin>
                <groupId>com.github.mcheely</groupId>
                <artifactId>requirejs-maven-plugin</artifactId>
                <executions>
                  <execution>
                    <goals>
                      <goal>optimize</goal>
                    </goals>
                  </execution>
                </executions>
                <configuration>
                    <configFile>
                        ${basedir}/requirejs-build/app.build.js
                    </configFile>
                    <optimizerFile>
                        ${basedir}/requirejs-build/r.js
                    </optimizerFile>
                    <filterConfig>
                        false
                    </filterConfig>
                </configuration>
              </plugin>
           </plugins>
       </build>
   </profile>

Then, in my continuous integration server (teamcity) I just pass:

-P optimize

and it works great!

Thanks Matthew!!

MattCheely commented 12 years ago

Glad I could help!

davidjnelson commented 12 years ago

You're awesome man!