diff --git a/.gitignore b/.gitignore index aa5f9f86..30d032fb 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,3 @@ -# This is the central .gitignore file for all pro!vision GIT repos. Please do not change it on project-level. -# See https://jira.pvtool.org/confluence/x/IACuBg for details. - target/ pom.xml.tag pom.xml.releaseBackup @@ -8,6 +5,7 @@ pom.xml.versionsBackup pom.xml.next release.properties maven-eclipse.xml +infinitest.filters node_modules/ npm-debug.log @@ -20,6 +18,7 @@ npm-debug.log .pmd .checkstyle .idea +.vagrant *.iml .DS_Store .rubygems @@ -28,3 +27,5 @@ npm-debug.log *.sublime-* *nbactions*.xml .temp/ + +pom-test.xml diff --git a/.travis.yml b/.travis.yml index 7a16da97..755299a4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -32,10 +32,10 @@ script: # Remove wcm.io artefacts from repository before cache - rm -rf $HOME/.m2/repository/io/wcm -# exlude release tags like xyz-1.0.0 or xyz-1 +# exlude release tags like 1.0.0 branches: except: - - /^.*\-\d+(\.\d+\.\d+)?(\..*|\-.*)?$/ + - /^\d+(\.\d+\.\d+)?(\..*|\-.*)?$/ # Cache Maven Repository cache: diff --git a/README.md b/README.md index bf0530d9..7a0830cb 100644 --- a/README.md +++ b/README.md @@ -1,17 +1,21 @@ - Maven Eclipse Plugin + 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 @@ -19,6 +23,7 @@ To use this in your projects update all your POMs to use io.wcm.devops.maven.plugins eclipse-maven-plugin + 3.1.0 ``` diff --git a/pom.xml b/pom.xml index 2847121b..b4e945e1 100644 --- a/pom.xml +++ b/pom.xml @@ -31,10 +31,10 @@ under the License. io.wcm.devops.maven.plugins eclipse-maven-plugin - 3.0.0 + 3.1.0 maven-plugin - wcm.io DevOps Maven Eclipse Plugin + wcm.io DevOps Eclipse Maven Plugin The Eclipse Plugin is used to generate Eclipse IDE files (.project, .classpath and the .settings folder) from a POM. @@ -139,6 +139,16 @@ under the License. wagon-provider-api 2.1 + + org.apache.maven.shared + maven-filtering + 3.1.1 + + + org.codehaus.plexus + plexus-interpolation + 1.25 + commons-io commons-io @@ -320,6 +330,7 @@ under the License. README-testing.txt README.md + infinitest.filters - release + release-profile performRelease @@ -612,6 +621,59 @@ under the License. + + + only-eclipse + + + m2e.version + + + + + + + org.eclipse.m2e + lifecycle-mapping + 1.0.0 + + + + + + org.apache.maven.plugins + maven-plugin-plugin + [3.4,) + + descriptor + helpmojo + + + + + + + + + org.apache.rat + apache-rat-plugin + [0.11,) + + check + + + + + + + + + + + + + + diff --git a/src/main/java/org/apache/maven/plugin/eclipse/EclipseConfigFile.java b/src/main/java/org/apache/maven/plugin/eclipse/EclipseConfigFile.java index 660e053e..5300992e 100644 --- a/src/main/java/org/apache/maven/plugin/eclipse/EclipseConfigFile.java +++ b/src/main/java/org/apache/maven/plugin/eclipse/EclipseConfigFile.java @@ -52,6 +52,8 @@ public class EclipseConfigFile * @since 2.5 */ private URL url; + + private boolean filtering; /** * Getter for content. @@ -132,4 +134,27 @@ public void setURL( URL url ) { this.url = url; } + + /** + * Filter resource (replace placeholders) + * @return if true resources is filtered + * + * @since 3.1.0 + */ + public boolean isFiltering() + { + return filtering; + } + + /** + * Filter resource (replace placeholders) + * @param filtering if true resources is filtered + * + * @since 3.1.0 + */ + public void setFiltering( boolean filtering ) + { + this.filtering = filtering; + } + } diff --git a/src/main/java/org/apache/maven/plugin/eclipse/EclipsePlugin.java b/src/main/java/org/apache/maven/plugin/eclipse/EclipsePlugin.java index 35c6c8de..905c2788 100644 --- a/src/main/java/org/apache/maven/plugin/eclipse/EclipsePlugin.java +++ b/src/main/java/org/apache/maven/plugin/eclipse/EclipsePlugin.java @@ -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 Fabrizio Giustina * @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.emptyList(), + Collections.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(); + } + } } } diff --git a/src/main/java/org/apache/maven/plugin/eclipse/writers/EclipseClasspathWriter.java b/src/main/java/org/apache/maven/plugin/eclipse/writers/EclipseClasspathWriter.java index 75503da5..dc17faf4 100644 --- a/src/main/java/org/apache/maven/plugin/eclipse/writers/EclipseClasspathWriter.java +++ b/src/main/java/org/apache/maven/plugin/eclipse/writers/EclipseClasspathWriter.java @@ -254,6 +254,28 @@ public void write() writer.addAttribute( ATTR_EXCLUDING, excludes ); } + boolean attributeElemOpen = false; + + // mark test source folders as "test" (required for eclipse 4.8 photon) + if ( dir.isTest() ) + { + if ( !attributeElemOpen ) + { + writer.startElement( ATTRIBUTES ); + attributeElemOpen = true; + } + + writer.startElement( ATTRIBUTE ); + writer.addAttribute( VALUE, "true" ); + writer.addAttribute( NAME, "test" ); + writer.endElement(); + } + + if ( attributeElemOpen ) + { + writer.endElement(); + } + writer.endElement(); } @@ -531,6 +553,21 @@ protected void addDependency( XMLWriter writer, IdeDependency dep ) boolean attributeElemOpen = false; + // mark test dependencies as "test" (required for eclipse 4.8 photon) + if ( dep.isTestDependency() ) + { + if ( !attributeElemOpen ) + { + writer.startElement( ATTRIBUTES ); + attributeElemOpen = true; + } + + writer.startElement( ATTRIBUTE ); + writer.addAttribute( VALUE, "true" ); + writer.addAttribute( NAME, "test" ); + writer.endElement(); + } + if ( javadocpath != null ) { if ( !attributeElemOpen )