From 4d970a744d404c9242d1935511ab78f7e34dfcda Mon Sep 17 00:00:00 2001 From: "l.vygovsky" <l.vygovsky@argus> Date: Wed, 11 Mar 2015 17:18:53 +0300 Subject: [PATCH 1/2] Add m2e plugins ignore. --- jruby-maven-plugin/pom.xml | 14 ++++++++++++++ parent-mojo/pom.xml | 36 ++++++++++++++++++++++++++++++++++++ rails3-maven-plugin/pom.xml | 14 ++++++++++++++ ruby-tools/pom.xml | 31 +++++++++++++++++++++++++++++++ 4 files changed, 95 insertions(+) diff --git a/jruby-maven-plugin/pom.xml b/jruby-maven-plugin/pom.xml index f0fb5b96..3acdf2f2 100644 --- a/jruby-maven-plugin/pom.xml +++ b/jruby-maven-plugin/pom.xml @@ -78,6 +78,20 @@ <ignore /> </action> </pluginExecution> + <pluginExecution> + <pluginExecutionFilter> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-plugin-plugin</artifactId> + <versionRange>[2.5.1,)</versionRange> + <goals> + <goal>helpmojo</goal> + <goal>descriptor</goal> + </goals> + </pluginExecutionFilter> + <action> + <ignore></ignore> + </action> + </pluginExecution> </pluginExecutions> </lifecycleMappingMetadata> </configuration> diff --git a/parent-mojo/pom.xml b/parent-mojo/pom.xml index 3a5d1133..578f1e37 100644 --- a/parent-mojo/pom.xml +++ b/parent-mojo/pom.xml @@ -75,6 +75,42 @@ </executions> </plugin> </plugins> + <pluginManagement> + <plugins> + <!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself.--> + <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> + [2.5.1,) + </versionRange> + <goals> + <goal>helpmojo</goal> + <goal>descriptor</goal> + </goals> + </pluginExecutionFilter> + <action> + <ignore></ignore> + </action> + </pluginExecution> + </pluginExecutions> + </lifecycleMappingMetadata> + </configuration> + </plugin> + </plugins> + </pluginManagement> </build> <profiles> <profile> diff --git a/rails3-maven-plugin/pom.xml b/rails3-maven-plugin/pom.xml index 7c32c895..c1227d5b 100644 --- a/rails3-maven-plugin/pom.xml +++ b/rails3-maven-plugin/pom.xml @@ -75,6 +75,20 @@ <ignore /> </action> </pluginExecution> + <pluginExecution> + <pluginExecutionFilter> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-plugin-plugin</artifactId> + <versionRange>[2.5.1,)</versionRange> + <goals> + <goal>helpmojo</goal> + <goal>descriptor</goal> + </goals> + </pluginExecutionFilter> + <action> + <ignore></ignore> + </action> + </pluginExecution> </pluginExecutions> </lifecycleMappingMetadata> </configuration> diff --git a/ruby-tools/pom.xml b/ruby-tools/pom.xml index 3298a588..803ab33a 100644 --- a/ruby-tools/pom.xml +++ b/ruby-tools/pom.xml @@ -140,6 +140,37 @@ </executions> </plugin> </plugins> + <pluginManagement> + <plugins> + <!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself.--> + <plugin> + <groupId>org.eclipse.m2e</groupId> + <artifactId>lifecycle-mapping</artifactId> + <version>1.0.0</version> + <configuration> + <lifecycleMappingMetadata> + <pluginExecutions> + <pluginExecution> + <pluginExecutionFilter> + <groupId>org.codehaus.mojo</groupId> + <artifactId> + exec-maven-plugin + </artifactId> + <versionRange>[1.2,)</versionRange> + <goals> + <goal>exec</goal> + </goals> + </pluginExecutionFilter> + <action> + <ignore></ignore> + </action> + </pluginExecution> + </pluginExecutions> + </lifecycleMappingMetadata> + </configuration> + </plugin> + </plugins> + </pluginManagement> </build> <profiles> <profile> -- GitLab From b06022c286ac31b5de76002fb877f1346504e29b Mon Sep 17 00:00:00 2001 From: "l.vygovsky" <l.vygovsky@argus> Date: Wed, 11 Mar 2015 19:50:11 +0300 Subject: [PATCH 2/2] Adds options to exclude maven test class path from jruby execution. --- .../de/saumya/mojo/gem/AbstractGemMojo.java | 6 ++--- .../saumya/mojo/jruby/AbstractJRubyMojo.java | 24 +++++++++++++++---- 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/gem-maven-plugin/src/main/java/de/saumya/mojo/gem/AbstractGemMojo.java b/gem-maven-plugin/src/main/java/de/saumya/mojo/gem/AbstractGemMojo.java index 655dd3d1..c214c27b 100644 --- a/gem-maven-plugin/src/main/java/de/saumya/mojo/gem/AbstractGemMojo.java +++ b/gem-maven-plugin/src/main/java/de/saumya/mojo/gem/AbstractGemMojo.java @@ -232,7 +232,7 @@ public abstract class AbstractGemMojo extends AbstractJRubyMojo { new GemScriptFactory(this.logger, this.classRealm, null, - this.project.getTestClasspathElements(), + getProjectClasspath(), this.jrubyFork, this.gemsConfig): (JRUBY_CORE.equals(artifact.getArtifactId()) ? @@ -240,13 +240,13 @@ public abstract class AbstractGemMojo extends AbstractJRubyMojo { this.classRealm, artifact.getFile(), resolveJRubyStdlibArtifact(artifact).getFile(), - this.project.getTestClasspathElements(), + getProjectClasspath(), this.jrubyFork, this.gemsConfig) : new GemScriptFactory(this.logger, this.classRealm, artifact.getFile(), - this.project.getTestClasspathElements(), + getProjectClasspath(), this.jrubyFork, this.gemsConfig)); diff --git a/jruby-maven-plugin/src/main/java/de/saumya/mojo/jruby/AbstractJRubyMojo.java b/jruby-maven-plugin/src/main/java/de/saumya/mojo/jruby/AbstractJRubyMojo.java index 715a7651..5f9be016 100644 --- a/jruby-maven-plugin/src/main/java/de/saumya/mojo/jruby/AbstractJRubyMojo.java +++ b/jruby-maven-plugin/src/main/java/de/saumya/mojo/jruby/AbstractJRubyMojo.java @@ -2,6 +2,8 @@ package de.saumya.mojo.jruby; import java.io.File; import java.io.IOException; +import java.util.ArrayList; +import java.util.List; import java.util.Map; import java.util.Set; @@ -141,6 +143,12 @@ public abstract class AbstractJRubyMojo extends AbstractMojo { */ protected MavenProject project; + /** + * add project test class path to JVM classpath. + * @parameter default-value=true expression="${gem.addProjectClasspath}" + */ + protected boolean addProjectClasspath; + /** * local repository for internal use. * @@ -197,7 +205,7 @@ public abstract class AbstractJRubyMojo extends AbstractMojo { } try { ClassRealm realm = classRealm.getWorld().newRealm("jruby-all"); - for (String path : this.project.getTestClasspathElements()) { + for (String path : getProjectClasspath()) { realm.addConstituent(new File(path).toURI().toURL()); } if (this.jrubyVersion != null) { @@ -231,19 +239,19 @@ public abstract class AbstractJRubyMojo extends AbstractMojo { new ScriptFactory(this.logger, this.classRealm, null, - this.project.getTestClasspathElements(), + getProjectClasspath(), this.jrubyFork): (JRUBY_CORE.equals(artifact.getArtifactId()) ? new ScriptFactory(this.logger, this.classRealm, artifact.getFile(), resolveJRubyStdlibArtifact(artifact).getFile(), - this.project.getTestClasspathElements(), + getProjectClasspath(), this.jrubyFork) : new ScriptFactory(this.logger, this.classRealm, artifact.getFile(), - this.project.getTestClasspathElements(), + getProjectClasspath(), this.jrubyFork) ); if(libDirectory != null && libDirectory.exists()){ @@ -395,4 +403,12 @@ public abstract class AbstractJRubyMojo extends AbstractMojo { } throw new MojoExecutionException("failed to resolve jruby stdlib artifact"); } + + protected List<String> getProjectClasspath() throws DependencyResolutionRequiredException { + if (addProjectClasspath) { + return project.getTestClasspathElements(); + } else { + return new ArrayList<String>(); + } + } } -- GitLab