1515import java .util .Arrays ;
1616import java .util .Collection ;
1717import java .util .List ;
18+ import java .util .Properties ;
1819import java .util .Set ;
1920import java .util .regex .Matcher ;
2021import java .util .regex .Pattern ;
2122
2223import org .apache .maven .plugin .MojoExecution ;
24+ import org .apache .maven .project .MavenProject ;
2325import org .codehaus .plexus .util .Scanner ;
2426import org .codehaus .plexus .util .xml .Xpp3Dom ;
2527import org .codehaus .plexus .util .xml .Xpp3DomUtils ;
3032import org .eclipse .core .runtime .CoreException ;
3133import org .eclipse .core .runtime .IPath ;
3234import org .eclipse .core .runtime .IProgressMonitor ;
35+ import org .eclipse .core .runtime .NullProgressMonitor ;
3336import org .eclipse .core .runtime .Path ;
3437import org .eclipse .m2e .core .MavenPlugin ;
3538import org .eclipse .m2e .core .embedder .IMaven ;
4750 */
4851public class Wro4jBuildParticipant extends MojoExecutionBuildParticipant {
4952
53+ private static final String M2E_WRO4J_WTP_INTEGRATION_KEY = "m2e.wro4j.wtp.integration" ;
54+
5055 private static final String CONTEXT_FOLDER = "contextFolder" ;
5156
5257 private static final String TOKEN_SEPARATOR = ",\\ s*" ;
@@ -225,7 +230,7 @@ private void refreshResource(MojoExecution mojoExecution,
225230
226231 private Xpp3Dom customize (Xpp3Dom originalConfiguration , Collection <File > contextFolders ,
227232 File originalDestinationFolder , File originalJsDestinationFolder ,
228- File originalCssDestinationFolder , File originalGroupNameMappingFile ) throws IOException {
233+ File originalCssDestinationFolder , File originalGroupNameMappingFile ) throws IOException , CoreException {
229234 IMavenProjectFacade facade = getMavenProjectFacade ();
230235 if (!"war" .equals (facade .getPackaging ())) {
231236 // Not a war project, we don't know how to customize that
@@ -244,7 +249,7 @@ private Xpp3Dom customize(Xpp3Dom originalConfiguration, Collection<File> contex
244249
245250 IFolder m2eWtpFolder = project .getFolder (relativeTargetPath .append ("m2e-wtp" ));
246251
247- if (!m2eWtpFolder .exists ()) {
252+ if (!m2eWtpFolder .exists () || isWtpIntegrationDisabled ( facade . getMavenProject ( new NullProgressMonitor ())) ) {
248253 // Not a m2e-wtp project, we don't know how to customize either
249254 // TODO Try to support Sonatype's webby instead?
250255 return customConfiguration ;
@@ -271,6 +276,12 @@ private Xpp3Dom customize(Xpp3Dom originalConfiguration, Collection<File> contex
271276 return customConfiguration ;
272277 }
273278
279+ private boolean isWtpIntegrationDisabled (MavenProject mavenProject ) {
280+ Properties properties = mavenProject .getProperties ();
281+ String isWtpIntegrationProperty = properties .getProperty (M2E_WRO4J_WTP_INTEGRATION_KEY , Boolean .TRUE .toString ());
282+ return !Boolean .parseBoolean (isWtpIntegrationProperty );
283+ }
284+
274285 private void customizeLocation (File originalDestinationFolder ,
275286 IFolder webResourcesFolder , IPath defaultOutputPathPrefix ,
276287 Xpp3Dom configuration , String parameterName ) throws IOException {
0 commit comments