Skip to content

Commit 9027837

Browse files
committed
Merge branch 'release/3.1.0'
2 parents 369cde8 + 587f3eb commit 9027837

7 files changed

Lines changed: 202 additions & 17 deletions

File tree

.gitignore

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
1-
# This is the central .gitignore file for all pro!vision GIT repos. Please do not change it on project-level.
2-
# See https://jira.pvtool.org/confluence/x/IACuBg for details.
3-
41
target/
52
pom.xml.tag
63
pom.xml.releaseBackup
74
pom.xml.versionsBackup
85
pom.xml.next
96
release.properties
107
maven-eclipse.xml
8+
infinitest.filters
119

1210
node_modules/
1311
npm-debug.log
@@ -20,6 +18,7 @@ npm-debug.log
2018
.pmd
2119
.checkstyle
2220
.idea
21+
.vagrant
2322
*.iml
2423
.DS_Store
2524
.rubygems
@@ -28,3 +27,5 @@ npm-debug.log
2827
*.sublime-*
2928
*nbactions*.xml
3029
.temp/
30+
31+
pom-test.xml

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@ script:
3232
# Remove wcm.io artefacts from repository before cache
3333
- rm -rf $HOME/.m2/repository/io/wcm
3434

35-
# exlude release tags like xyz-1.0.0 or xyz-1
35+
# exlude release tags like 1.0.0
3636
branches:
3737
except:
38-
- /^.*\-\d+(\.\d+\.\d+)?(\..*|\-.*)?$/
38+
- /^\d+(\.\d+\.\d+)?(\..*|\-.*)?$/
3939

4040
# Cache Maven Repository
4141
cache:

README.md

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,29 @@
1-
<img src="http://wcm.io/images/favicon-16@2x.png"/> Maven Eclipse Plugin
1+
<img src="http://wcm.io/images/favicon-16@2x.png"/> Eclipse Maven Plugin
22
======
3-
[![Build Status](https://travis-ci.org/wcm-io-devops/maven-eclipse-plugin.png?branch=develop)](https://travis-ci.org/wcm-io-devops/maven-eclipse-plugin)
3+
[![Build Status](https://travis-ci.org/wcm-io-devops/eclipse-maven-plugin.png?branch=develop)](https://travis-ci.org/wcm-io-devops/eclipse-maven-plugin)
44
[![Maven Central](https://maven-badges.herokuapp.com/maven-central/io.wcm.devops.maven.plugins/eclipse-maven-plugin/badge.svg)](https://maven-badges.herokuapp.com/maven-central/io.wcm.devops.maven.plugins/eclipse-maven-plugin)
55

66
The Eclipse Plugin is used to generate Eclipse IDE files (.project, .classpath and the .settings folder) from a POM.
77

88
This is a fork of the original [Maven Eclipse Plugin](https://maven.apache.org/plugins/maven-eclipse-plugin/) which [was retired end of 2015](http://mail-archives.apache.org/mod_mbox/maven-dev/201510.mbox/%3Cop.x55dxii1kdkhrr%40robertscholte.dynamic.ziggo.nl%3E) in favor of the m2e Eclipse integration.
99

10-
In our wcm.io and other Maven-based projects we usually use both m2e Integration and the Maven Eclipse Plugin. The Maven Eclipse Plugin is used to generate project-specific eclipse settings files and further files for Checkstyle, Findbugs and PMD based on a global build tools artifact defined a parent POM like `io.wcm.maven:io.wcm.maven.global-parent`, see [Global Parent](http://wcm.io/tooling/maven/global-parent.html) documentation for details.
10+
In our wcm.io and other Maven-based projects we usually use both m2e Integration and the Eclipse Maven Plugin. The Eclipse Maven Plugin is used to generate project-specific eclipse settings files and further files for Checkstyle, Findbugs and PMD based on a global build tools artifact defined a parent POM like `io.wcm.maven:io.wcm.maven.global-parent`, see [Global Parent](http://wcm.io/tooling/maven/global-parent.html) documentation for details.
1111

1212
So we maintain a fork of the original plugin here and publish it under Apache 2.0 license within the wcm.io DevOps project.
1313

14-
This fork includes the patch from [MECLIPSE-641](https://issues.apache.org/jira/browse/MECLIPSE-641) which was never applied to the original code base, but is important for generating the eclipse project settings.
14+
Changes since the original Maven Eclipse Plugin 2.10:
15+
16+
* Patch from [MECLIPSE-641](https://issues.apache.org/jira/browse/MECLIPSE-641) which was never applied to the original code base, but is important for generating the eclipse project settings (since 3.0.0)
17+
* Add support for `filtering` property on additionalConfig files (since 3.1.0)
18+
* Mark test source folders and test dependencies as "test" for Eclipse 4.8 Photon (since 3.1.0)
1519

1620
To use this in your projects update all your POMs to use
1721

1822
```xml
1923
<plugin>
2024
<groupId>io.wcm.devops.maven.plugins</groupId>
2125
<artifactId>eclipse-maven-plugin</artifactId>
26+
<version>3.1.0</version>
2227
</plugin>
2328
```
2429

pom.xml

Lines changed: 69 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ under the License.
3131

3232
<groupId>io.wcm.devops.maven.plugins</groupId>
3333
<artifactId>eclipse-maven-plugin</artifactId>
34-
<version>3.0.0</version>
34+
<version>3.1.0</version>
3535
<packaging>maven-plugin</packaging>
3636

37-
<name>wcm.io DevOps Maven Eclipse Plugin</name>
37+
<name>wcm.io DevOps Eclipse Maven Plugin</name>
3838
<description>
3939
The Eclipse Plugin is used to generate Eclipse IDE files (.project, .classpath and the .settings folder) from a POM.
4040
</description>
@@ -139,6 +139,16 @@ under the License.
139139
<artifactId>wagon-provider-api</artifactId>
140140
<version>2.1</version>
141141
</dependency>
142+
<dependency>
143+
<groupId>org.apache.maven.shared</groupId>
144+
<artifactId>maven-filtering</artifactId>
145+
<version>3.1.1</version>
146+
</dependency>
147+
<dependency>
148+
<groupId>org.codehaus.plexus</groupId>
149+
<artifactId>plexus-interpolation</artifactId>
150+
<version>1.25</version>
151+
</dependency>
142152
<dependency>
143153
<groupId>commons-io</groupId>
144154
<artifactId>commons-io</artifactId>
@@ -320,6 +330,7 @@ under the License.
320330
<excludes combine.children="append">
321331
<exclude>README-testing.txt</exclude>
322332
<exclude>README.md</exclude>
333+
<exclude>infinitest.filters</exclude>
323334

324335
<!--
325336
These files contain several files for eclipse
@@ -341,22 +352,20 @@ under the License.
341352
<version>2.5.3</version>
342353
<configuration>
343354
<autoVersionSubmodules>true</autoVersionSubmodules>
344-
<useReleaseProfile>false</useReleaseProfile>
345-
<releaseProfiles>release</releaseProfiles>
346355
<goals>deploy</goals>
347356
</configuration>
348357
<dependencies>
349358
<dependency>
350359
<groupId>org.apache.maven.scm</groupId>
351360
<artifactId>maven-scm-provider-gitexe</artifactId>
352-
<version>1.9.4</version>
361+
<version>1.10.0</version>
353362
</dependency>
354363
</dependencies>
355364
</plugin>
356365
<plugin>
357366
<groupId>org.sonatype.plugins</groupId>
358367
<artifactId>nexus-staging-maven-plugin</artifactId>
359-
<version>1.6.6</version>
368+
<version>1.6.8</version>
360369
</plugin>
361370
<plugin>
362371
<groupId>external.atlassian.jgitflow</groupId>
@@ -564,7 +573,7 @@ under the License.
564573
</profile>
565574
<!-- configuration to deploy into maven central -->
566575
<profile>
567-
<id>release</id>
576+
<id>release-profile</id>
568577
<activation>
569578
<property>
570579
<name>performRelease</name>
@@ -612,6 +621,59 @@ under the License.
612621
</plugins>
613622
</build>
614623
</profile>
624+
<!-- This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself. -->
625+
<profile>
626+
<id>only-eclipse</id>
627+
<activation>
628+
<property>
629+
<name>m2e.version</name>
630+
</property>
631+
</activation>
632+
<build>
633+
<pluginManagement>
634+
<plugins>
635+
<plugin>
636+
<groupId>org.eclipse.m2e</groupId>
637+
<artifactId>lifecycle-mapping</artifactId>
638+
<version>1.0.0</version>
639+
<configuration>
640+
<lifecycleMappingMetadata>
641+
<pluginExecutions>
642+
<pluginExecution>
643+
<pluginExecutionFilter>
644+
<groupId>org.apache.maven.plugins</groupId>
645+
<artifactId>maven-plugin-plugin</artifactId>
646+
<versionRange>[3.4,)</versionRange>
647+
<goals>
648+
<goal>descriptor</goal>
649+
<goal>helpmojo</goal>
650+
</goals>
651+
</pluginExecutionFilter>
652+
<action>
653+
<ignore />
654+
</action>
655+
</pluginExecution>
656+
<pluginExecution>
657+
<pluginExecutionFilter>
658+
<groupId>org.apache.rat</groupId>
659+
<artifactId>apache-rat-plugin</artifactId>
660+
<versionRange>[0.11,)</versionRange>
661+
<goals>
662+
<goal>check</goal>
663+
</goals>
664+
</pluginExecutionFilter>
665+
<action>
666+
<ignore />
667+
</action>
668+
</pluginExecution>
669+
</pluginExecutions>
670+
</lifecycleMappingMetadata>
671+
</configuration>
672+
</plugin>
673+
</plugins>
674+
</pluginManagement>
675+
</build>
676+
</profile>
615677
</profiles>
616678

617679
<reporting>

src/main/java/org/apache/maven/plugin/eclipse/EclipseConfigFile.java

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ public class EclipseConfigFile
5252
* @since 2.5
5353
*/
5454
private URL url;
55+
56+
private boolean filtering;
5557

5658
/**
5759
* Getter for <code>content</code>.
@@ -132,4 +134,27 @@ public void setURL( URL url )
132134
{
133135
this.url = url;
134136
}
137+
138+
/**
139+
* Filter resource (replace placeholders)
140+
* @return if true resources is filtered
141+
*
142+
* @since 3.1.0
143+
*/
144+
public boolean isFiltering()
145+
{
146+
return filtering;
147+
}
148+
149+
/**
150+
* Filter resource (replace placeholders)
151+
* @param filtering if true resources is filtered
152+
*
153+
* @since 3.1.0
154+
*/
155+
public void setFiltering( boolean filtering )
156+
{
157+
this.filtering = filtering;
158+
}
159+
135160
}

src/main/java/org/apache/maven/plugin/eclipse/EclipsePlugin.java

Lines changed: 56 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import java.net.URL;
2828
import java.util.ArrayList;
2929
import java.util.Arrays;
30+
import java.util.Collections;
3031
import java.util.LinkedHashSet;
3132
import java.util.LinkedList;
3233
import java.util.List;
@@ -37,6 +38,7 @@
3738
import org.apache.maven.artifact.Artifact;
3839
import org.apache.maven.artifact.handler.ArtifactHandler;
3940
import org.apache.maven.artifact.manager.WagonManager;
41+
import org.apache.maven.execution.MavenSession;
4042
import org.apache.maven.model.Build;
4143
import org.apache.maven.model.Plugin;
4244
import org.apache.maven.model.Resource;
@@ -66,6 +68,9 @@
6668
import org.apache.maven.settings.MavenSettingsBuilder;
6769
import org.apache.maven.settings.Proxy;
6870
import org.apache.maven.settings.Settings;
71+
import org.apache.maven.shared.filtering.MavenFilteringException;
72+
import org.apache.maven.shared.filtering.MavenResourcesExecution;
73+
import org.apache.maven.shared.filtering.MavenResourcesFiltering;
6974
import org.apache.maven.wagon.Wagon;
7075
import org.apache.maven.wagon.WagonException;
7176
import org.apache.maven.wagon.observers.Debug;
@@ -95,7 +100,7 @@
95100
* @author <a href="mailto:fgiust@apache.org">Fabrizio Giustina</a>
96101
* @version $Id$
97102
*/
98-
@Mojo( name = "eclipse" )
103+
@Mojo( name = "eclipse", requiresProject = true )
99104
@Execute( phase = LifecyclePhase.GENERATE_RESOURCES )
100105
public class EclipsePlugin
101106
extends AbstractIdeSupportMojo
@@ -647,6 +652,11 @@ public class EclipsePlugin
647652
@Parameter( property = "eclipse.jeeversion" )
648653
protected String jeeversion;
649654

655+
@Component( role = MavenResourcesFiltering.class, hint = "default" )
656+
protected MavenResourcesFiltering mavenResourcesFiltering;
657+
@Parameter( defaultValue = "${session}" )
658+
private MavenSession mavenSession;
659+
650660
protected final boolean isJavaProject()
651661
{
652662
return isJavaProject;
@@ -1337,6 +1347,51 @@ private void writeAdditionalConfig()
13371347
throw new MojoExecutionException( Messages.getString( "EclipsePlugin.settingsxmlfailure",
13381348
e.getMessage() ) );
13391349
}
1350+
1351+
// if configured apply resource filtering on the copied resource
1352+
if ( projectRelativeFile.exists() && projectRelativeFile.isFile() && file.isFiltering() )
1353+
{
1354+
String encoding = IdeUtils.getCompilerSourceEncoding( project );
1355+
1356+
File outputDir = new File( projectRelativeFile.getParent() + "/_filtered" );
1357+
outputDir.mkdirs();
1358+
1359+
Resource dummyResource = new Resource();
1360+
dummyResource.setDirectory( projectRelativeFile.getParent() );
1361+
dummyResource.setIncludes( Arrays.asList( projectRelativeFile.getName() ) );
1362+
dummyResource.setFiltering( true );
1363+
MavenResourcesExecution exec = new MavenResourcesExecution(
1364+
Arrays.asList( dummyResource ),
1365+
outputDir,
1366+
project,
1367+
encoding,
1368+
Collections.<String>emptyList(),
1369+
Collections.<String>emptyList(),
1370+
mavenSession );
1371+
try
1372+
{
1373+
mavenResourcesFiltering.filterResources( exec );
1374+
}
1375+
catch ( MavenFilteringException ex )
1376+
{
1377+
throw new MojoExecutionException( "Error filtering resource: "
1378+
+ projectRelativeFile.getPath(), ex );
1379+
}
1380+
1381+
File filteredFile = new File( outputDir, projectRelativeFile.getName() );
1382+
projectRelativeFile.delete();
1383+
try
1384+
{
1385+
org.apache.commons.io.FileUtils.moveFile( filteredFile, projectRelativeFile );
1386+
}
1387+
catch ( IOException ex )
1388+
{
1389+
throw new MojoExecutionException( "Error moving " + filteredFile.getPath() + " to "
1390+
+ projectRelativeFile.getPath(), ex );
1391+
}
1392+
outputDir.delete();
1393+
}
1394+
13401395
}
13411396
}
13421397
}

src/main/java/org/apache/maven/plugin/eclipse/writers/EclipseClasspathWriter.java

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,28 @@ public void write()
254254
writer.addAttribute( ATTR_EXCLUDING, excludes );
255255
}
256256

257+
boolean attributeElemOpen = false;
258+
259+
// mark test source folders as "test" (required for eclipse 4.8 photon)
260+
if ( dir.isTest() )
261+
{
262+
if ( !attributeElemOpen )
263+
{
264+
writer.startElement( ATTRIBUTES );
265+
attributeElemOpen = true;
266+
}
267+
268+
writer.startElement( ATTRIBUTE );
269+
writer.addAttribute( VALUE, "true" );
270+
writer.addAttribute( NAME, "test" );
271+
writer.endElement();
272+
}
273+
274+
if ( attributeElemOpen )
275+
{
276+
writer.endElement();
277+
}
278+
257279
writer.endElement();
258280

259281
}
@@ -531,6 +553,21 @@ protected void addDependency( XMLWriter writer, IdeDependency dep )
531553

532554
boolean attributeElemOpen = false;
533555

556+
// mark test dependencies as "test" (required for eclipse 4.8 photon)
557+
if ( dep.isTestDependency() )
558+
{
559+
if ( !attributeElemOpen )
560+
{
561+
writer.startElement( ATTRIBUTES );
562+
attributeElemOpen = true;
563+
}
564+
565+
writer.startElement( ATTRIBUTE );
566+
writer.addAttribute( VALUE, "true" );
567+
writer.addAttribute( NAME, "test" );
568+
writer.endElement();
569+
}
570+
534571
if ( javadocpath != null )
535572
{
536573
if ( !attributeElemOpen )

0 commit comments

Comments
 (0)