Skip to content

Commit 70d8275

Browse files
committed
Fix #21 : add <m2e.wro4j.wtp.integration> Maven property to disable m2e-wtp integration
Signed-off-by: Fred Bricon <[email protected]>
1 parent 45b408a commit 70d8275

File tree

19 files changed

+121
-9
lines changed

19 files changed

+121
-9
lines changed

org.jboss.tools.m2e.wro4j.core/src/org/jboss/tools/m2e/wro4j/internal/Wro4jBuildParticipant.java

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,13 @@
1515
import java.util.Arrays;
1616
import java.util.Collection;
1717
import java.util.List;
18+
import java.util.Properties;
1819
import java.util.Set;
1920
import java.util.regex.Matcher;
2021
import java.util.regex.Pattern;
2122

2223
import org.apache.maven.plugin.MojoExecution;
24+
import org.apache.maven.project.MavenProject;
2325
import org.codehaus.plexus.util.Scanner;
2426
import org.codehaus.plexus.util.xml.Xpp3Dom;
2527
import org.codehaus.plexus.util.xml.Xpp3DomUtils;
@@ -30,6 +32,7 @@
3032
import org.eclipse.core.runtime.CoreException;
3133
import org.eclipse.core.runtime.IPath;
3234
import org.eclipse.core.runtime.IProgressMonitor;
35+
import org.eclipse.core.runtime.NullProgressMonitor;
3336
import org.eclipse.core.runtime.Path;
3437
import org.eclipse.m2e.core.MavenPlugin;
3538
import org.eclipse.m2e.core.embedder.IMaven;
@@ -47,6 +50,8 @@
4750
*/
4851
public 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 {

org.jboss.tools.m2e.wro4j.tests/projects/p4-173/pom.xml renamed to org.jboss.tools.m2e.wro4j.tests/projects/p4-176/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
33
<modelVersion>4.0.0</modelVersion>
44
<groupId>foo.bar</groupId>
5-
<artifactId>p4-171</artifactId>
5+
<artifactId>p4-176</artifactId>
66
<version>0.0.1-SNAPSHOT</version>
77
<packaging>war</packaging>
88
<properties>
@@ -13,7 +13,7 @@
1313
<plugin>
1414
<groupId>ro.isdc.wro4j</groupId>
1515
<artifactId>wro4j-maven-plugin</artifactId>
16-
<version>1.7.3</version>
16+
<version>1.7.6</version>
1717
<executions>
1818
<execution>
1919
<phase>compile</phase>
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3+
<modelVersion>4.0.0</modelVersion>
4+
<groupId>foo.bar</groupId>
5+
<artifactId>disable-wtp</artifactId>
6+
<version>0.0.1-SNAPSHOT</version>
7+
<packaging>war</packaging>
8+
<properties>
9+
<m2e.wro4j.wtp.integration>false</m2e.wro4j.wtp.integration>
10+
</properties>
11+
<build>
12+
<plugins>
13+
<plugin>
14+
<groupId>ro.isdc.wro4j</groupId>
15+
<artifactId>wro4j-maven-plugin</artifactId>
16+
<version>1.7.6</version>
17+
<executions>
18+
<execution>
19+
<phase>compile</phase>
20+
<goals>
21+
<goal>run</goal>
22+
</goals>
23+
</execution>
24+
</executions>
25+
<configuration>
26+
<destinationFolder>${project.build.directory}/${project.build.finalName}/resources</destinationFolder>
27+
<targetGroups>testCase</targetGroups>
28+
</configuration>
29+
</plugin>
30+
<plugin>
31+
<groupId>org.apache.maven.plugins</groupId>
32+
<artifactId>maven-compiler-plugin</artifactId>
33+
<version>3.1</version>
34+
<configuration>
35+
<target>1.6</target>
36+
<source>1.6</source>
37+
</configuration>
38+
</plugin>
39+
</plugins>
40+
</build>
41+
</project>

0 commit comments

Comments
 (0)