-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
202 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,29 @@ | ||
<img src="http://wcm.io/images/[email protected]"/> Maven Eclipse Plugin | ||
<img src="http://wcm.io/images/[email protected]"/> Eclipse Maven Plugin | ||
====== | ||
[![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) | ||
[![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) | ||
[![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) | ||
|
||
The Eclipse Plugin is used to generate Eclipse IDE files (.project, .classpath and the .settings folder) from a POM. | ||
|
||
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. | ||
|
||
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. | ||
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. | ||
|
||
So we maintain a fork of the original plugin here and publish it under Apache 2.0 license within the wcm.io DevOps project. | ||
|
||
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. | ||
Changes since the original Maven Eclipse Plugin 2.10: | ||
|
||
* 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) | ||
* Add support for `filtering` property on additionalConfig files (since 3.1.0) | ||
* Mark test source folders and test dependencies as "test" for Eclipse 4.8 Photon (since 3.1.0) | ||
|
||
To use this in your projects update all your POMs to use | ||
|
||
```xml | ||
<plugin> | ||
<groupId>io.wcm.devops.maven.plugins</groupId> | ||
<artifactId>eclipse-maven-plugin</artifactId> | ||
<version>3.1.0</version> | ||
</plugin> | ||
``` | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,6 +27,7 @@ | |
import java.net.URL; | ||
import java.util.ArrayList; | ||
import java.util.Arrays; | ||
import java.util.Collections; | ||
import java.util.LinkedHashSet; | ||
import java.util.LinkedList; | ||
import java.util.List; | ||
|
@@ -37,6 +38,7 @@ | |
import org.apache.maven.artifact.Artifact; | ||
import org.apache.maven.artifact.handler.ArtifactHandler; | ||
import org.apache.maven.artifact.manager.WagonManager; | ||
import org.apache.maven.execution.MavenSession; | ||
import org.apache.maven.model.Build; | ||
import org.apache.maven.model.Plugin; | ||
import org.apache.maven.model.Resource; | ||
|
@@ -66,6 +68,9 @@ | |
import org.apache.maven.settings.MavenSettingsBuilder; | ||
import org.apache.maven.settings.Proxy; | ||
import org.apache.maven.settings.Settings; | ||
import org.apache.maven.shared.filtering.MavenFilteringException; | ||
import org.apache.maven.shared.filtering.MavenResourcesExecution; | ||
import org.apache.maven.shared.filtering.MavenResourcesFiltering; | ||
import org.apache.maven.wagon.Wagon; | ||
import org.apache.maven.wagon.WagonException; | ||
import org.apache.maven.wagon.observers.Debug; | ||
|
@@ -95,7 +100,7 @@ | |
* @author <a href="mailto:[email protected]">Fabrizio Giustina</a> | ||
* @version $Id$ | ||
*/ | ||
@Mojo( name = "eclipse" ) | ||
@Mojo( name = "eclipse", requiresProject = true ) | ||
@Execute( phase = LifecyclePhase.GENERATE_RESOURCES ) | ||
public class EclipsePlugin | ||
extends AbstractIdeSupportMojo | ||
|
@@ -647,6 +652,11 @@ public class EclipsePlugin | |
@Parameter( property = "eclipse.jeeversion" ) | ||
protected String jeeversion; | ||
|
||
@Component( role = MavenResourcesFiltering.class, hint = "default" ) | ||
protected MavenResourcesFiltering mavenResourcesFiltering; | ||
@Parameter( defaultValue = "${session}" ) | ||
private MavenSession mavenSession; | ||
|
||
protected final boolean isJavaProject() | ||
{ | ||
return isJavaProject; | ||
|
@@ -1337,6 +1347,51 @@ private void writeAdditionalConfig() | |
throw new MojoExecutionException( Messages.getString( "EclipsePlugin.settingsxmlfailure", | ||
e.getMessage() ) ); | ||
} | ||
|
||
// if configured apply resource filtering on the copied resource | ||
if ( projectRelativeFile.exists() && projectRelativeFile.isFile() && file.isFiltering() ) | ||
{ | ||
String encoding = IdeUtils.getCompilerSourceEncoding( project ); | ||
|
||
File outputDir = new File( projectRelativeFile.getParent() + "/_filtered" ); | ||
outputDir.mkdirs(); | ||
|
||
Resource dummyResource = new Resource(); | ||
dummyResource.setDirectory( projectRelativeFile.getParent() ); | ||
dummyResource.setIncludes( Arrays.asList( projectRelativeFile.getName() ) ); | ||
dummyResource.setFiltering( true ); | ||
MavenResourcesExecution exec = new MavenResourcesExecution( | ||
Arrays.asList( dummyResource ), | ||
outputDir, | ||
project, | ||
encoding, | ||
Collections.<String>emptyList(), | ||
Collections.<String>emptyList(), | ||
mavenSession ); | ||
try | ||
{ | ||
mavenResourcesFiltering.filterResources( exec ); | ||
} | ||
catch ( MavenFilteringException ex ) | ||
{ | ||
throw new MojoExecutionException( "Error filtering resource: " | ||
+ projectRelativeFile.getPath(), ex ); | ||
} | ||
|
||
File filteredFile = new File( outputDir, projectRelativeFile.getName() ); | ||
projectRelativeFile.delete(); | ||
try | ||
{ | ||
org.apache.commons.io.FileUtils.moveFile( filteredFile, projectRelativeFile ); | ||
} | ||
catch ( IOException ex ) | ||
{ | ||
throw new MojoExecutionException( "Error moving " + filteredFile.getPath() + " to " | ||
+ projectRelativeFile.getPath(), ex ); | ||
} | ||
outputDir.delete(); | ||
} | ||
|
||
} | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters