Skip to content

Commit

Permalink
Merge branch 'release/3.1.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanseifert committed Jul 11, 2018
2 parents 369cde8 + 587f3eb commit 9027837
Show file tree
Hide file tree
Showing 7 changed files with 202 additions and 17 deletions.
7 changes: 4 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
# 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
pom.xml.versionsBackup
pom.xml.next
release.properties
maven-eclipse.xml
infinitest.filters

node_modules/
npm-debug.log
Expand All @@ -20,6 +18,7 @@ npm-debug.log
.pmd
.checkstyle
.idea
.vagrant
*.iml
.DS_Store
.rubygems
Expand All @@ -28,3 +27,5 @@ npm-debug.log
*.sublime-*
*nbactions*.xml
.temp/

pom-test.xml
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
13 changes: 9 additions & 4 deletions README.md
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>
```

Expand Down
76 changes: 69 additions & 7 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ under the License.

<groupId>io.wcm.devops.maven.plugins</groupId>
<artifactId>eclipse-maven-plugin</artifactId>
<version>3.0.0</version>
<version>3.1.0</version>
<packaging>maven-plugin</packaging>

<name>wcm.io DevOps Maven Eclipse Plugin</name>
<name>wcm.io DevOps Eclipse Maven Plugin</name>
<description>
The Eclipse Plugin is used to generate Eclipse IDE files (.project, .classpath and the .settings folder) from a POM.
</description>
Expand Down Expand Up @@ -139,6 +139,16 @@ under the License.
<artifactId>wagon-provider-api</artifactId>
<version>2.1</version>
</dependency>
<dependency>
<groupId>org.apache.maven.shared</groupId>
<artifactId>maven-filtering</artifactId>
<version>3.1.1</version>
</dependency>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-interpolation</artifactId>
<version>1.25</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
Expand Down Expand Up @@ -320,6 +330,7 @@ under the License.
<excludes combine.children="append">
<exclude>README-testing.txt</exclude>
<exclude>README.md</exclude>
<exclude>infinitest.filters</exclude>

<!--
These files contain several files for eclipse
Expand All @@ -341,22 +352,20 @@ under the License.
<version>2.5.3</version>
<configuration>
<autoVersionSubmodules>true</autoVersionSubmodules>
<useReleaseProfile>false</useReleaseProfile>
<releaseProfiles>release</releaseProfiles>
<goals>deploy</goals>
</configuration>
<dependencies>
<dependency>
<groupId>org.apache.maven.scm</groupId>
<artifactId>maven-scm-provider-gitexe</artifactId>
<version>1.9.4</version>
<version>1.10.0</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<version>1.6.6</version>
<version>1.6.8</version>
</plugin>
<plugin>
<groupId>external.atlassian.jgitflow</groupId>
Expand Down Expand Up @@ -564,7 +573,7 @@ under the License.
</profile>
<!-- configuration to deploy into maven central -->
<profile>
<id>release</id>
<id>release-profile</id>
<activation>
<property>
<name>performRelease</name>
Expand Down Expand Up @@ -612,6 +621,59 @@ under the License.
</plugins>
</build>
</profile>
<!-- This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself. -->
<profile>
<id>only-eclipse</id>
<activation>
<property>
<name>m2e.version</name>
</property>
</activation>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-plugin-plugin</artifactId>
<versionRange>[3.4,)</versionRange>
<goals>
<goal>descriptor</goal>
<goal>helpmojo</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore />
</action>
</pluginExecution>
<pluginExecution>
<pluginExecutionFilter>
<groupId>org.apache.rat</groupId>
<artifactId>apache-rat-plugin</artifactId>
<versionRange>[0.11,)</versionRange>
<goals>
<goal>check</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore />
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
</profile>
</profiles>

<reporting>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ public class EclipseConfigFile
* @since 2.5
*/
private URL url;

private boolean filtering;

/**
* Getter for <code>content</code>.
Expand Down Expand Up @@ -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;
}

}
57 changes: 56 additions & 1 deletion src/main/java/org/apache/maven/plugin/eclipse/EclipsePlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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();
}

}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();

}
Expand Down Expand Up @@ -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 )
Expand Down

0 comments on commit 9027837

Please sign in to comment.