diff --git a/.gitignore b/.gitignore
index 2088ce53..aaf23d24 100644
--- a/.gitignore
+++ b/.gitignore
@@ -7,3 +7,5 @@ target
tmp
*Backup
release.properties
+.idea/
+*.iml
\ No newline at end of file
diff --git a/bundler-maven-plugin/src/it/bundler-pom/verify.bsh b/bundler-maven-plugin/src/it/bundler-pom/verify.bsh
index e389778e..7f540182 100644
--- a/bundler-maven-plugin/src/it/bundler-pom/verify.bsh
+++ b/bundler-maven-plugin/src/it/bundler-pom/verify.bsh
@@ -5,5 +5,5 @@ import org.codehaus.plexus.util.FileUtils;
File f = new File( basedir, "Gemfile.lock" );
if ( !f.exists() )
{
- throw new RuntimeException( "file does not exists: " + f );
+ throw new RuntimeException( "file does not exist: " + f );
}
diff --git a/cucumber-maven-plugin/src/it/cucumber-summary-report/verify.bsh b/cucumber-maven-plugin/src/it/cucumber-summary-report/verify.bsh
index 7a329619..4f2d0685 100644
--- a/cucumber-maven-plugin/src/it/cucumber-summary-report/verify.bsh
+++ b/cucumber-maven-plugin/src/it/cucumber-summary-report/verify.bsh
@@ -11,11 +11,11 @@ if ( !log.contains( expected ) )
File file = new File( basedir, "target/surefire-reports/TEST-simplest-1.6.5--1.8.xml");
if ( !file.exists() )
{
- throw new RuntimeException( "file does not exists: '" + file.getAbsolutePath() + "'" );
+ throw new RuntimeException( "file does not exist: '" + file.getAbsolutePath() + "'" );
}
file = new File( basedir, "target/summary.xml");
if ( !file.exists() )
{
- throw new RuntimeException( "file does not exists: '" + file.getAbsolutePath() + "'" );
+ throw new RuntimeException( "file does not exist: '" + file.getAbsolutePath() + "'" );
}
diff --git a/gem-maven-plugin/src/it/execute-compass-with-gems-from-plugin/verify.bsh b/gem-maven-plugin/src/it/execute-compass-with-gems-from-plugin/verify.bsh
index fe7eeb98..6469bd18 100644
--- a/gem-maven-plugin/src/it/execute-compass-with-gems-from-plugin/verify.bsh
+++ b/gem-maven-plugin/src/it/execute-compass-with-gems-from-plugin/verify.bsh
@@ -1,20 +1,18 @@
import java.io.*;
+import java.util.*;
import org.codehaus.plexus.util.FileUtils;
String log = FileUtils.fileRead( new File( basedir, "build.log" ) );
-String expected = "Successfully installed compass-";
-if ( !log.contains( expected ) )
-{
- throw new RuntimeException( "log file does not contain '" + expected + "'" );
-}
-expected = "Successfully installed sass-";
-if ( !log.contains( expected ) )
-{
- throw new RuntimeException( "log file does not contain '" + expected + "'" );
-}
-expected = "Individual stylesheets must be in the sass directory.";
-if ( !log.contains( expected ) )
+
+String installMessage = "Successfully installed ";
+String[] expectedGems = new String[] { "compass-", "sass-", "rb-inotify-" };
+
+for ( String expectedGem: expectedGems )
{
- throw new RuntimeException( "log file does not contain '" + expected + "'" );
+ String expected = installMessage + expectedGem;
+ if ( !log.contains( expected ) )
+ {
+ throw new RuntimeException( "log file does not contain '" + expected + "'" );
+ }
}
diff --git a/gem-maven-plugin/src/it/gemfile-to-pom-forced/verify.bsh b/gem-maven-plugin/src/it/gemfile-to-pom-forced/verify.bsh
index b99697bc..4823c00d 100644
--- a/gem-maven-plugin/src/it/gemfile-to-pom-forced/verify.bsh
+++ b/gem-maven-plugin/src/it/gemfile-to-pom-forced/verify.bsh
@@ -5,7 +5,7 @@ import org.codehaus.plexus.util.FileUtils;
File f = new File( basedir, "pom.xml" );
if ( !f.exists() )
{
- throw new RuntimeException( "file does not exists: " + f );
+ throw new RuntimeException( "file does not exist: " + f );
}
if ( f.lastModified() < new File( basedir, "timestamp" ).lastModified())
{
diff --git a/gem-maven-plugin/src/it/gemfile-to-pom/verify.bsh b/gem-maven-plugin/src/it/gemfile-to-pom/verify.bsh
index a3bb9d99..e1a28f8e 100644
--- a/gem-maven-plugin/src/it/gemfile-to-pom/verify.bsh
+++ b/gem-maven-plugin/src/it/gemfile-to-pom/verify.bsh
@@ -5,5 +5,5 @@ import org.codehaus.plexus.util.FileUtils;
File f = new File( basedir, "pom.xml" );
if ( !f.exists() )
{
- throw new RuntimeException( "file does not exists: " + f );
+ throw new RuntimeException( "file does not exist: " + f );
}
\ No newline at end of file
diff --git a/gem-maven-plugin/src/it/gemspec-to-pom-forced/verify.bsh b/gem-maven-plugin/src/it/gemspec-to-pom-forced/verify.bsh
index b99697bc..4823c00d 100644
--- a/gem-maven-plugin/src/it/gemspec-to-pom-forced/verify.bsh
+++ b/gem-maven-plugin/src/it/gemspec-to-pom-forced/verify.bsh
@@ -5,7 +5,7 @@ import org.codehaus.plexus.util.FileUtils;
File f = new File( basedir, "pom.xml" );
if ( !f.exists() )
{
- throw new RuntimeException( "file does not exists: " + f );
+ throw new RuntimeException( "file does not exist: " + f );
}
if ( f.lastModified() < new File( basedir, "timestamp" ).lastModified())
{
diff --git a/gem-maven-plugin/src/it/gemspec-to-pom/verify.bsh b/gem-maven-plugin/src/it/gemspec-to-pom/verify.bsh
index a3bb9d99..e1a28f8e 100644
--- a/gem-maven-plugin/src/it/gemspec-to-pom/verify.bsh
+++ b/gem-maven-plugin/src/it/gemspec-to-pom/verify.bsh
@@ -5,5 +5,5 @@ import org.codehaus.plexus.util.FileUtils;
File f = new File( basedir, "pom.xml" );
if ( !f.exists() )
{
- throw new RuntimeException( "file does not exists: " + f );
+ throw new RuntimeException( "file does not exist: " + f );
}
\ No newline at end of file
diff --git a/gem-maven-plugin/src/it/include-rubygems-in-test-resources-failure/pom.xml b/gem-maven-plugin/src/it/include-rubygems-in-test-resources-failure/pom.xml
index ba313582..f2010392 100644
--- a/gem-maven-plugin/src/it/include-rubygems-in-test-resources-failure/pom.xml
+++ b/gem-maven-plugin/src/it/include-rubygems-in-test-resources-failure/pom.xml
@@ -3,7 +3,7 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
com.example
- target/rubygems-in-test-resources
+ rubygems-in-test-resources-failure
testing
diff --git a/gem-maven-plugin/src/it/include-rubygems-in-test-resources/pom.xml b/gem-maven-plugin/src/it/include-rubygems-in-test-resources/pom.xml
index 1b46367c..2fac30fe 100644
--- a/gem-maven-plugin/src/it/include-rubygems-in-test-resources/pom.xml
+++ b/gem-maven-plugin/src/it/include-rubygems-in-test-resources/pom.xml
@@ -14,8 +14,8 @@
rubygems
- yard
- 0.8.0
+ sass
+ 3.2.7
gem
diff --git a/gem-maven-plugin/src/it/install-gem-pom/verify.bsh b/gem-maven-plugin/src/it/install-gem-pom/verify.bsh
index dca52044..07d937c8 100644
--- a/gem-maven-plugin/src/it/install-gem-pom/verify.bsh
+++ b/gem-maven-plugin/src/it/install-gem-pom/verify.bsh
@@ -5,5 +5,5 @@ import org.codehaus.plexus.util.FileUtils;
File f = new File( basedir, "target/pom_first-0.0.0.gem" );
if ( !f.exists() )
{
- throw new RuntimeException( "file does not exists: " + f );
+ throw new RuntimeException( "file does not exist: " + f );
}
\ No newline at end of file
diff --git a/gem-maven-plugin/src/it/install-gem-ruby-9.2.10-compatibility/pom.xml b/gem-maven-plugin/src/it/install-gem-ruby-9.2.10-compatibility/pom.xml
new file mode 100644
index 00000000..bbf18345
--- /dev/null
+++ b/gem-maven-plugin/src/it/install-gem-ruby-9.2.10-compatibility/pom.xml
@@ -0,0 +1,53 @@
+
+
+ 4.0.0
+ rubygems
+ pom_first
+ 0.0.0
+ Installs a gem from http://rubygems.org with Ruby 2.7 compatibility
+
+ 9.2.10.0
+
+
+
+ rubygems
+ yard
+ 0.9.25
+ gem
+
+
+
+
+
+ org.torquebox.mojo
+ mavengem-wagon
+ 1.0.3
+
+
+
+
+ de.saumya.mojo
+ gem-maven-plugin
+ @project.version@
+
+ ${jruby.version}
+
+
+
+ install-gems
+
+ initialize
+
+ initialize
+
+
+
+
+
+
+
+ mavengems
+ mavengem:http://rubygems.org
+
+
+
diff --git a/gem-maven-plugin/src/it/install-gem-ruby-9.2.10-compatibility/verify.bsh b/gem-maven-plugin/src/it/install-gem-ruby-9.2.10-compatibility/verify.bsh
new file mode 100644
index 00000000..81001ef8
--- /dev/null
+++ b/gem-maven-plugin/src/it/install-gem-ruby-9.2.10-compatibility/verify.bsh
@@ -0,0 +1,8 @@
+import java.io.*;
+import org.codehaus.plexus.util.FileUtils;
+
+File f = new File( basedir, "target/rubygems/gems/yard-0.9.25" );
+if ( !f.exists() )
+{
+ throw new RuntimeException( "file does not exist: " + f );
+}
\ No newline at end of file
diff --git a/gem-maven-plugin/src/it/install-java-gem-pom/verify.bsh b/gem-maven-plugin/src/it/install-java-gem-pom/verify.bsh
index bba0a380..9f070a5c 100644
--- a/gem-maven-plugin/src/it/install-java-gem-pom/verify.bsh
+++ b/gem-maven-plugin/src/it/install-java-gem-pom/verify.bsh
@@ -5,5 +5,5 @@ import org.codehaus.plexus.util.FileUtils;
File f = new File( basedir, "target/com.example.package-java-gem-0.0.0-java.gem" );
if ( !f.exists() )
{
- throw new RuntimeException( "file does not exists: " + f );
+ throw new RuntimeException( "file does not exist: " + f );
}
diff --git a/gem-maven-plugin/src/it/install-pom-with-gemspec/verify.bsh b/gem-maven-plugin/src/it/install-pom-with-gemspec/verify.bsh
index 3994195f..71ce441a 100644
--- a/gem-maven-plugin/src/it/install-pom-with-gemspec/verify.bsh
+++ b/gem-maven-plugin/src/it/install-pom-with-gemspec/verify.bsh
@@ -5,10 +5,10 @@ import org.codehaus.plexus.util.FileUtils;
File f = new File( basedir, "target/first.gem" );
if ( !f.exists() )
{
- throw new RuntimeException( "file does not exists: " + f );
+ throw new RuntimeException( "file does not exist: " + f );
}
f = new File( basedir, "pom.pom_first.gemspec.xml" );
if ( !f.exists() )
{
- throw new RuntimeException( "file does not exists: " + f );
+ throw new RuntimeException( "file does not exist: " + f );
}
diff --git a/gem-maven-plugin/src/it/jars-lock/verify.bsh b/gem-maven-plugin/src/it/jars-lock/verify.bsh
index bf3e1365..06b96d10 100644
--- a/gem-maven-plugin/src/it/jars-lock/verify.bsh
+++ b/gem-maven-plugin/src/it/jars-lock/verify.bsh
@@ -48,17 +48,17 @@ if ( !log.contains( expected ) )
File file = new File( basedir, "target/jars/org/slf4j/log4j-over-slf4j/1.7.10/log4j-over-slf4j-1.7.10.jar" );
if ( !file.exists() )
{
- throw new RuntimeException( "expected file does not exists '" + file + "'" );
+ throw new RuntimeException( "expected file does not exist '" + file + "'" );
}
file = new File( basedir, "target/jars/org/apache/kafka/kafka_2.10/0.8.1.1/kafka_2.10-0.8.1.1.jar" );
if ( !file.exists() )
{
- throw new RuntimeException( "expected file does not exists '" + file + "'" );
+ throw new RuntimeException( "expected file does not exist '" + file + "'" );
}
file = new File( basedir, "target/jars/org/bouncycastle/bcprov-jdk15on/1.49/bcprov-jdk15on-1.49.jar" );
if ( !file.exists() )
{
- throw new RuntimeException( "expected file does not exists '" + file + "'" );
+ throw new RuntimeException( "expected file does not exist '" + file + "'" );
}
diff --git a/gem-maven-plugin/src/it/package-gem-artifact-from-gemspec-no-pom/verify.bsh b/gem-maven-plugin/src/it/package-gem-artifact-from-gemspec-no-pom/verify.bsh
index 7cdcf77f..0a36045b 100644
--- a/gem-maven-plugin/src/it/package-gem-artifact-from-gemspec-no-pom/verify.bsh
+++ b/gem-maven-plugin/src/it/package-gem-artifact-from-gemspec-no-pom/verify.bsh
@@ -5,5 +5,5 @@ import org.codehaus.plexus.util.FileUtils;
File f = new File( basedir, "gem_first-0.0.0.gem" );
if ( !f.exists() )
{
- throw new RuntimeException( "file does not exists: " + f );
+ throw new RuntimeException( "file does not exist: " + f );
}
\ No newline at end of file
diff --git a/gem-maven-plugin/src/it/package-gem-artifact-from-gemspec-pom/verify.bsh b/gem-maven-plugin/src/it/package-gem-artifact-from-gemspec-pom/verify.bsh
index 74131b52..f2177ac1 100644
--- a/gem-maven-plugin/src/it/package-gem-artifact-from-gemspec-pom/verify.bsh
+++ b/gem-maven-plugin/src/it/package-gem-artifact-from-gemspec-pom/verify.bsh
@@ -5,5 +5,5 @@ import org.codehaus.plexus.util.FileUtils;
File f = new File( basedir, "target/gem_first-0.0.0.gem" );
if ( !f.exists() )
{
- throw new RuntimeException( "file does not exists: " + f );
+ throw new RuntimeException( "file does not exist: " + f );
}
\ No newline at end of file
diff --git a/jruby-maven-plugin/src/it/compile-dir-156/verify.bsh b/jruby-maven-plugin/src/it/compile-dir-156/verify.bsh
index 07faa8a5..3a90e91a 100644
--- a/jruby-maven-plugin/src/it/compile-dir-156/verify.bsh
+++ b/jruby-maven-plugin/src/it/compile-dir-156/verify.bsh
@@ -3,6 +3,6 @@ import java.io.*;
File target = new File(basedir, "target/classes");
for(String f: new String[] { "file.class", "more/hello.class" }){
if( !new File(target, f).exists() ){
- throw new RuntimeException("file does not exists: target/classes" + f);
+ throw new RuntimeException("file does not exist: target/classes" + f);
}
}
\ No newline at end of file
diff --git a/jruby-maven-plugin/src/it/compile-dir/verify.bsh b/jruby-maven-plugin/src/it/compile-dir/verify.bsh
index 07faa8a5..3a90e91a 100644
--- a/jruby-maven-plugin/src/it/compile-dir/verify.bsh
+++ b/jruby-maven-plugin/src/it/compile-dir/verify.bsh
@@ -3,6 +3,6 @@ import java.io.*;
File target = new File(basedir, "target/classes");
for(String f: new String[] { "file.class", "more/hello.class" }){
if( !new File(target, f).exists() ){
- throw new RuntimeException("file does not exists: target/classes" + f);
+ throw new RuntimeException("file does not exist: target/classes" + f);
}
}
\ No newline at end of file
diff --git a/jruby-maven-plugin/src/it/generate-java-and-compile-156/verify.bsh b/jruby-maven-plugin/src/it/generate-java-and-compile-156/verify.bsh
index f5647ec0..8368a159 100644
--- a/jruby-maven-plugin/src/it/generate-java-and-compile-156/verify.bsh
+++ b/jruby-maven-plugin/src/it/generate-java-and-compile-156/verify.bsh
@@ -3,6 +3,6 @@ import java.io.*;
File target = new File(basedir, "target/classes");
for(String f: new String[] { "com/example/Reply.class", "com/otherexample/MyReply.class" }){
if( !new File(target, f).exists() ){
- throw new RuntimeException("file does not exists: target/classes/" + f);
+ throw new RuntimeException("file does not exist: target/classes/" + f);
}
}
\ No newline at end of file
diff --git a/jruby-maven-plugin/src/it/generate-java-and-compile/verify.bsh b/jruby-maven-plugin/src/it/generate-java-and-compile/verify.bsh
index f5647ec0..8368a159 100644
--- a/jruby-maven-plugin/src/it/generate-java-and-compile/verify.bsh
+++ b/jruby-maven-plugin/src/it/generate-java-and-compile/verify.bsh
@@ -3,6 +3,6 @@ import java.io.*;
File target = new File(basedir, "target/classes");
for(String f: new String[] { "com/example/Reply.class", "com/otherexample/MyReply.class" }){
if( !new File(target, f).exists() ){
- throw new RuntimeException("file does not exists: target/classes/" + f);
+ throw new RuntimeException("file does not exist: target/classes/" + f);
}
}
\ No newline at end of file
diff --git a/minitest-maven-plugin/src/it/minispec-with-jar-dependencies/verify.bsh b/minitest-maven-plugin/src/it/minispec-with-jar-dependencies/verify.bsh
index 5750d8ec..119c84f6 100644
--- a/minitest-maven-plugin/src/it/minispec-with-jar-dependencies/verify.bsh
+++ b/minitest-maven-plugin/src/it/minispec-with-jar-dependencies/verify.bsh
@@ -12,11 +12,11 @@ if ( !log.contains( expected ) )
File f = new File( new File( new File( basedir, "target" ), "surefire-reports" ), "TEST-minispec-9.0.1.0.xml" );
if ( !f.exists() )
{
- throw new RuntimeException( "file does not exists: " + f );
+ throw new RuntimeException( "file does not exist: " + f );
}
f = new File( new File( new File( basedir, "target" ), "surefire-reports" ), "TEST-minispec-1.7.22--1.9.xml" );
if ( !f.exists() )
{
- throw new RuntimeException( "file does not exists: " + f );
+ throw new RuntimeException( "file does not exist: " + f );
}
diff --git a/minitest-maven-plugin/src/it/minitest-failure-19/verify.bsh b/minitest-maven-plugin/src/it/minitest-failure-19/verify.bsh
index c3832d63..279f3996 100644
--- a/minitest-maven-plugin/src/it/minitest-failure-19/verify.bsh
+++ b/minitest-maven-plugin/src/it/minitest-failure-19/verify.bsh
@@ -11,5 +11,5 @@ if ( !log.contains( expected ) )
File file = new File( basedir, "target/surefire-reports/TEST-minitest.xml");
if ( !file.exists() )
{
- throw new RuntimeException( "file does not exists: '" + file.getAbsolutePath() + "'" );
+ throw new RuntimeException( "file does not exist: '" + file.getAbsolutePath() + "'" );
}
diff --git a/minitest-maven-plugin/src/it/minitest-failure/verify.bsh b/minitest-maven-plugin/src/it/minitest-failure/verify.bsh
index c3832d63..279f3996 100644
--- a/minitest-maven-plugin/src/it/minitest-failure/verify.bsh
+++ b/minitest-maven-plugin/src/it/minitest-failure/verify.bsh
@@ -11,5 +11,5 @@ if ( !log.contains( expected ) )
File file = new File( basedir, "target/surefire-reports/TEST-minitest.xml");
if ( !file.exists() )
{
- throw new RuntimeException( "file does not exists: '" + file.getAbsolutePath() + "'" );
+ throw new RuntimeException( "file does not exist: '" + file.getAbsolutePath() + "'" );
}
diff --git a/minitest-maven-plugin/src/it/minitest-from-jruby/verify.bsh b/minitest-maven-plugin/src/it/minitest-from-jruby/verify.bsh
index 64b45abd..9ff78638 100644
--- a/minitest-maven-plugin/src/it/minitest-from-jruby/verify.bsh
+++ b/minitest-maven-plugin/src/it/minitest-from-jruby/verify.bsh
@@ -11,5 +11,5 @@ if ( !log.contains( expected ) )
File file = new File( basedir, "target/surefire-reports/TEST-minitest.xml");
if ( !file.exists() )
{
- throw new RuntimeException( "file does not exists: '" + file.getAbsolutePath() + "'" );
+ throw new RuntimeException( "file does not exist: '" + file.getAbsolutePath() + "'" );
}
diff --git a/minitest-maven-plugin/src/it/minitest-pom-210/verify.bsh b/minitest-maven-plugin/src/it/minitest-pom-210/verify.bsh
index 64b45abd..9ff78638 100644
--- a/minitest-maven-plugin/src/it/minitest-pom-210/verify.bsh
+++ b/minitest-maven-plugin/src/it/minitest-pom-210/verify.bsh
@@ -11,5 +11,5 @@ if ( !log.contains( expected ) )
File file = new File( basedir, "target/surefire-reports/TEST-minitest.xml");
if ( !file.exists() )
{
- throw new RuntimeException( "file does not exists: '" + file.getAbsolutePath() + "'" );
+ throw new RuntimeException( "file does not exist: '" + file.getAbsolutePath() + "'" );
}
diff --git a/minitest-maven-plugin/src/it/minitest-pom-508/verify.bsh b/minitest-maven-plugin/src/it/minitest-pom-508/verify.bsh
index 64b45abd..9ff78638 100644
--- a/minitest-maven-plugin/src/it/minitest-pom-508/verify.bsh
+++ b/minitest-maven-plugin/src/it/minitest-pom-508/verify.bsh
@@ -11,5 +11,5 @@ if ( !log.contains( expected ) )
File file = new File( basedir, "target/surefire-reports/TEST-minitest.xml");
if ( !file.exists() )
{
- throw new RuntimeException( "file does not exists: '" + file.getAbsolutePath() + "'" );
+ throw new RuntimeException( "file does not exist: '" + file.getAbsolutePath() + "'" );
}
diff --git a/minitest-maven-plugin/src/it/minitest-somewhere/verify.bsh b/minitest-maven-plugin/src/it/minitest-somewhere/verify.bsh
index 64b45abd..9ff78638 100644
--- a/minitest-maven-plugin/src/it/minitest-somewhere/verify.bsh
+++ b/minitest-maven-plugin/src/it/minitest-somewhere/verify.bsh
@@ -11,5 +11,5 @@ if ( !log.contains( expected ) )
File file = new File( basedir, "target/surefire-reports/TEST-minitest.xml");
if ( !file.exists() )
{
- throw new RuntimeException( "file does not exists: '" + file.getAbsolutePath() + "'" );
+ throw new RuntimeException( "file does not exist: '" + file.getAbsolutePath() + "'" );
}
diff --git a/minitest-maven-plugin/src/it/minitest-summary-report/verify.bsh b/minitest-maven-plugin/src/it/minitest-summary-report/verify.bsh
index 06710949..f3d75f12 100644
--- a/minitest-maven-plugin/src/it/minitest-summary-report/verify.bsh
+++ b/minitest-maven-plugin/src/it/minitest-summary-report/verify.bsh
@@ -11,11 +11,11 @@ if ( !log.contains( expected ) )
File file = new File( basedir, "target/surefire-reports/TEST-minitest.xml");
if ( !file.exists() )
{
- throw new RuntimeException( "file does not exists: '" + file.getAbsolutePath() + "'" );
+ throw new RuntimeException( "file does not exist: '" + file.getAbsolutePath() + "'" );
}
file = new File( basedir, "target/summary.xml");
if ( !file.exists() )
{
- throw new RuntimeException( "file does not exists: '" + file.getAbsolutePath() + "'" );
+ throw new RuntimeException( "file does not exist: '" + file.getAbsolutePath() + "'" );
}
diff --git a/parent-mojo/pom.xml b/parent-mojo/pom.xml
index 9657eeb7..b683afa1 100644
--- a/parent-mojo/pom.xml
+++ b/parent-mojo/pom.xml
@@ -118,7 +118,7 @@
maven-invoker-plugin
- 1.5
+ 3.0.1
src/it
${project.build.directory}/it
diff --git a/pom.xml b/pom.xml
index 6d5287c8..45b8cfab 100644
--- a/pom.xml
+++ b/pom.xml
@@ -41,6 +41,12 @@
4.8.2
test
+
+ org.assertj
+ assertj-core
+ 3.16.1
+ test
+
diff --git a/rspec-maven-plugin/src/it/rspec-3.x/verify.bsh b/rspec-maven-plugin/src/it/rspec-3.x/verify.bsh
index cd4a7521..f9b0a812 100644
--- a/rspec-maven-plugin/src/it/rspec-3.x/verify.bsh
+++ b/rspec-maven-plugin/src/it/rspec-3.x/verify.bsh
@@ -12,5 +12,5 @@ if ( !log.contains( expected ) )
File f = new File( new File( new File( basedir, "target" ), "surefire-reports" ), "TEST-rspec.xml" );
if ( !f.exists() )
{
- throw new RuntimeException( "file does not exists: " + f );
+ throw new RuntimeException( "file does not exist: " + f );
}
diff --git a/rspec-maven-plugin/src/it/rspec-failure-19/verify.bsh b/rspec-maven-plugin/src/it/rspec-failure-19/verify.bsh
index f9ab24c3..a9701560 100644
--- a/rspec-maven-plugin/src/it/rspec-failure-19/verify.bsh
+++ b/rspec-maven-plugin/src/it/rspec-failure-19/verify.bsh
@@ -11,5 +11,5 @@ if ( !log.contains( expected ) )
File f = new File( new File( new File( basedir, "target" ), "surefire-reports" ), "TEST-rspec.xml" );
if ( !f.exists() )
{
- throw new RuntimeException( "file does not exists: " + f );
+ throw new RuntimeException( "file does not exist: " + f );
}
diff --git a/rspec-maven-plugin/src/it/rspec-failure/verify.bsh b/rspec-maven-plugin/src/it/rspec-failure/verify.bsh
index f9ab24c3..a9701560 100644
--- a/rspec-maven-plugin/src/it/rspec-failure/verify.bsh
+++ b/rspec-maven-plugin/src/it/rspec-failure/verify.bsh
@@ -11,5 +11,5 @@ if ( !log.contains( expected ) )
File f = new File( new File( new File( basedir, "target" ), "surefire-reports" ), "TEST-rspec.xml" );
if ( !f.exists() )
{
- throw new RuntimeException( "file does not exists: " + f );
+ throw new RuntimeException( "file does not exist: " + f );
}
diff --git a/rspec-maven-plugin/src/it/rspec-pom/verify.bsh b/rspec-maven-plugin/src/it/rspec-pom/verify.bsh
index df226834..db5c7e28 100644
--- a/rspec-maven-plugin/src/it/rspec-pom/verify.bsh
+++ b/rspec-maven-plugin/src/it/rspec-pom/verify.bsh
@@ -12,5 +12,5 @@ if ( !log.contains( expected ) )
File f = new File( new File( new File( basedir, "target" ), "surefire-reports" ), "TEST-rspec.xml" );
if ( !f.exists() )
{
- throw new RuntimeException( "file does not exists: " + f );
+ throw new RuntimeException( "file does not exist: " + f );
}
diff --git a/rspec-maven-plugin/src/it/rspec-summary-report/verify.bsh b/rspec-maven-plugin/src/it/rspec-summary-report/verify.bsh
index cbe319ab..57d5bc3a 100644
--- a/rspec-maven-plugin/src/it/rspec-summary-report/verify.bsh
+++ b/rspec-maven-plugin/src/it/rspec-summary-report/verify.bsh
@@ -12,10 +12,10 @@ if ( !log.contains( expected ) )
File f = new File( new File( new File( basedir, "target" ), "surefire-reports" ), "TEST-rspec.xml" );
if ( !f.exists() )
{
- throw new RuntimeException( "file does not exists: " + f );
+ throw new RuntimeException( "file does not exist: " + f );
}
f = new File( new File( basedir, "target" ), "TEST-Ruby.xml" );
if ( !f.exists() )
{
- throw new RuntimeException( "file does not exists: " + f );
+ throw new RuntimeException( "file does not exist: " + f );
}
diff --git a/rspec-maven-plugin/src/it/rspec-with-jar-dependencies/verify.bsh b/rspec-maven-plugin/src/it/rspec-with-jar-dependencies/verify.bsh
index 0dda1b71..22e1ca7d 100644
--- a/rspec-maven-plugin/src/it/rspec-with-jar-dependencies/verify.bsh
+++ b/rspec-maven-plugin/src/it/rspec-with-jar-dependencies/verify.bsh
@@ -12,11 +12,11 @@ if ( !log.contains( expected ) )
File f = new File( new File( new File( basedir, "target" ), "surefire-reports" ), "TEST-rspec-9.0.1.0.xml" );
if ( !f.exists() )
{
- throw new RuntimeException( "file does not exists: " + f );
+ throw new RuntimeException( "file does not exist: " + f );
}
f = new File( new File( new File( basedir, "target" ), "surefire-reports" ), "TEST-rspec-1.7.22--1.9.xml" );
if ( !f.exists() )
{
- throw new RuntimeException( "file does not exists: " + f );
+ throw new RuntimeException( "file does not exist: " + f );
}
diff --git a/rspec-maven-plugin/src/main/java/de/saumya/mojo/rspec/RSpecMojo.java b/rspec-maven-plugin/src/main/java/de/saumya/mojo/rspec/RSpecMojo.java
index b475dc3f..a15e9f63 100644
--- a/rspec-maven-plugin/src/main/java/de/saumya/mojo/rspec/RSpecMojo.java
+++ b/rspec-maven-plugin/src/main/java/de/saumya/mojo/rspec/RSpecMojo.java
@@ -70,7 +70,7 @@ public void execute() throws MojoExecutionException, MojoFailureException {
new File( launchDirectory(), specSourceDirectory );
if ( !this.specsDir.isDirectory() )
{
- getLog().info("given " + specSourceDirectory + " does not exists - skipping RSpec test'" );
+ getLog().info("given " + specSourceDirectory + " does not exist - skipping RSpec test'" );
return;
}
outputfile = new File( this.project.getBuild().getDirectory().replace( "${project.basedir}/", ""),
diff --git a/ruby-tools/src/main/java/de/saumya/mojo/ruby/gems/GemsInstaller.java b/ruby-tools/src/main/java/de/saumya/mojo/ruby/gems/GemsInstaller.java
index 4ead6121..29864287 100644
--- a/ruby-tools/src/main/java/de/saumya/mojo/ruby/gems/GemsInstaller.java
+++ b/ruby-tools/src/main/java/de/saumya/mojo/ruby/gems/GemsInstaller.java
@@ -1,36 +1,37 @@
/**
- *
+ *
*/
package de.saumya.mojo.ruby.gems;
-import java.io.File;
-import java.io.FileFilter;
-import java.io.IOException;
-import java.util.Collection;
-import java.util.List;
-
+import de.saumya.mojo.ruby.script.JRubyVersion;
+import de.saumya.mojo.ruby.script.Script;
+import de.saumya.mojo.ruby.script.ScriptException;
+import de.saumya.mojo.ruby.script.ScriptFactory;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.plugin.descriptor.PluginDescriptor;
import org.apache.maven.project.MavenProject;
import org.codehaus.plexus.util.FileUtils;
-import de.saumya.mojo.ruby.script.Script;
-import de.saumya.mojo.ruby.script.ScriptException;
-import de.saumya.mojo.ruby.script.ScriptFactory;
+import java.io.File;
+import java.io.FileFilter;
+import java.io.IOException;
+import java.util.Collection;
+import java.util.List;
+
public class GemsInstaller {
private static final String OPENSSL_VERSION = "0.8.2";
private static final String OPENSSL = "jruby-openssl";
-
+
private static final FileFilter FILTER = new FileFilter() {
-
+
public boolean accept(File f) {
return f.getName().endsWith(".gemspec");
}
};
-
+
public final GemsConfig config;
public final ScriptFactory factory;
@@ -54,19 +55,19 @@ public void installPom(final MavenProject pom,
ScriptException, GemException {
installPom(pom, localRepository, null);
}
-
+
public void installPom(final MavenProject pom,
final ArtifactRepository localRepository, String scope) throws IOException,
ScriptException, GemException {
installGems(pom, localRepository, scope);
}
-
+
public MavenProject installOpenSSLGem(final Object repositorySystemSession,
final ArtifactRepository localRepository, List remotes) throws GemException,
IOException, ScriptException {
return installGem(OPENSSL, OPENSSL_VERSION, repositorySystemSession, localRepository, remotes);
}
-
+
public MavenProject installGem(final String name, final String version,
final Object repositorySystemSession,
final ArtifactRepository localRepository, List remoteRepositories) throws GemException,
@@ -87,21 +88,21 @@ public MavenProject installGem(final String name, final String version,
installPom(pom);
return pom;
}
-
+
public void installGems(final MavenProject pom,
- final ArtifactRepository localRepository)
+ final ArtifactRepository localRepository)
throws IOException, ScriptException, GemException
{
installGems(pom, localRepository, null);
-
+
}
-
+
public void installGems(final MavenProject pom,
- final ArtifactRepository localRepository, String scope )
+ final ArtifactRepository localRepository, String scope )
throws IOException, ScriptException, GemException {
installGems(pom, (Collection)null, localRepository, scope);
}
-
+
public void installGems(final MavenProject pom, PluginDescriptor plugin,
final ArtifactRepository localRepository) throws IOException,
ScriptException, GemException {
@@ -118,7 +119,7 @@ public void installGems(final MavenProject pom, final Collection artif
throws IOException, ScriptException, GemException {
installGems( pom, artifacts, localRepository, remoteRepos, null );
}
-
+
public void installGems(final MavenProject pom, final Collection artifacts,
final ArtifactRepository localRepository, List remoteRepos,
String scope ) throws IOException,
@@ -130,9 +131,9 @@ public void installGems(final MavenProject pom, final Collection artif
boolean hasAlreadyOpenSSL = false;
for (final Artifact artifact : pom.getArtifacts()) {
// assume pom.getBasedir() != null indicates the project pom
- if ( ( "compile".equals(artifact.getScope()) ||
+ if ( ( "compile".equals(artifact.getScope()) ||
"runtime".equals(artifact.getScope()) ||
- pom.getBasedir() != null ) &&
+ pom.getBasedir() != null ) &&
( scope == null || scope.equals(artifact.getScope()) ) ) {
if (!artifact.getFile().exists()) {
this.manager.resolve(artifact,
@@ -160,7 +161,7 @@ public void installGems(final MavenProject pom, final Collection artif
}
if ( pom.getArtifact().getFile() != null
// to filter out target/classes
- && pom.getArtifact().getFile().isFile()
+ && pom.getArtifact().getFile().isFile()
// have only gem files
&& pom.getArtifact().getFile().getName().endsWith(".gem") ) {
script = maybeAddArtifact(script, pom.getArtifact());
@@ -194,7 +195,7 @@ public void installGems(final MavenProject pom, final Collection artif
this.config.getBinDirectory().mkdirs();
}
script.execute();
-
+
if (this.config.getGemHome() != null){
// workaround for unpatched: https://github.com/rubygems/rubygems/commit/21cccd55b823848c5e941093a615b0fdd6cd8bc7
for(File spec : new File(this.config.getGemHome(), "specifications").listFiles(FILTER)){
@@ -227,21 +228,26 @@ private boolean exists(Artifact artifact) {
}
return false;
}
-
+
private Script maybeAddArtifact(Script script, final Artifact artifact)
throws IOException, GemException {
if (artifact.getType().contains("gem")) {
if (!exists(artifact)) {
if (script == null) {
+
script = this.factory.newScriptFromJRubyJar("gem")
.addArg("install")
.addArg("--ignore-dependencies")
- .addArg(booleanArg(this.config.isAddRdoc(), "rdoc"))
- .addArg(booleanArg(this.config.isAddRI(), "ri"))
- .addArg(booleanArg(this.config.isUserInstall(),
- "user-install"))
- .addArg(booleanArg(this.config.isVerbose(),
- "verbose"));
+ .addArg(booleanArg(this.config.isUserInstall(), "user-install"))
+ .addArg(booleanArg(this.config.isVerbose(), "verbose"));
+
+ final JRubyVersion version = this.factory.getVersion();
+ if (version == null || version.isVersionLowerThan(9, 2, 10)) {
+ script.addArg(booleanArg(this.config.isAddRdoc(), "rdoc"))
+ .addArg(booleanArg(this.config.isAddRI(), "ri"));
+ } else {
+ script.addArg(booleanArg(this.config.isAddRdoc(), "document"));
+ }
}
if (artifact.getFile() != null)
{
diff --git a/ruby-tools/src/main/java/de/saumya/mojo/ruby/rails/RailsService.java b/ruby-tools/src/main/java/de/saumya/mojo/ruby/rails/RailsService.java
index 64bec81c..0674180f 100644
--- a/ruby-tools/src/main/java/de/saumya/mojo/ruby/rails/RailsService.java
+++ b/ruby-tools/src/main/java/de/saumya/mojo/ruby/rails/RailsService.java
@@ -16,7 +16,7 @@ public class RailsService {
private final GemsInstaller installer;
private final RailsManager manager;
private final RailsState state;
- private final Object session;
+ private Object session;
public RailsService(final RailsState state,
final Object repositorySystemSession,
diff --git a/ruby-tools/src/main/java/de/saumya/mojo/ruby/script/AbstractLauncher.java b/ruby-tools/src/main/java/de/saumya/mojo/ruby/script/AbstractLauncher.java
index ce7c814c..4475bbef 100644
--- a/ruby-tools/src/main/java/de/saumya/mojo/ruby/script/AbstractLauncher.java
+++ b/ruby-tools/src/main/java/de/saumya/mojo/ruby/script/AbstractLauncher.java
@@ -2,17 +2,22 @@
import java.io.File;
import java.io.IOException;
+import java.io.OutputStream;
import java.util.List;
abstract class AbstractLauncher implements Launcher {
protected abstract void doExecute(final File launchDirectory,
- final List args, final File outputFile)
+ final List args, final File outputFile)
+ throws ScriptException, IOException;
+
+ protected abstract void doExecute(final File launchDirectory,
+ final List args, final OutputStream outputStream)
throws ScriptException, IOException;
public void execute(final List args) throws ScriptException,
IOException {
- doExecute(null, args, null);
+ doExecute(null, args, (File) null);
}
public void execute(final List args, final File outputFile)
@@ -20,28 +25,44 @@ public void execute(final List args, final File outputFile)
doExecute(null, args, outputFile);
}
+ public void execute(final List args, final OutputStream outputStream)
+ throws ScriptException, IOException {
+ doExecute(null, args, outputStream);
+ }
+
public void executeIn(final File launchDirectory, final List args)
throws ScriptException, IOException {
- doExecute(launchDirectory, args, null);
+ doExecute(launchDirectory, args, (File) null);
}
public void executeIn(final File launchDirectory, final List args,
- final File outputFile) throws ScriptException, IOException {
+ final File outputFile) throws ScriptException, IOException {
doExecute(launchDirectory, args, outputFile);
}
+ public void executeIn(final File launchDirectory, final List args,
+ final OutputStream outputStream) throws ScriptException, IOException {
+ doExecute(launchDirectory, args, outputStream);
+ }
+
public void executeScript(final String script, final List args)
throws ScriptException, IOException {
- executeScript(script, args, null);
+ executeScript(script, args, (File) null);
}
public void executeScript(final String script, final List args,
- final File outputFile) throws ScriptException, IOException {
+ final File outputFile) throws ScriptException, IOException {
executeScript(null, script, args, outputFile);
}
+ public void executeScript(final String script, final List args,
+ final OutputStream outputStream) throws ScriptException, IOException {
+ executeScript(null, script, args, outputStream);
+ }
+
public void executeScript(final File launchDirectory, final String script,
- final List args) throws ScriptException, IOException {
- executeScript(launchDirectory, script, args, null);
+ final List args) throws ScriptException, IOException {
+ executeScript(launchDirectory, script, args, (File) null);
}
+
}
diff --git a/ruby-tools/src/main/java/de/saumya/mojo/ruby/script/AntLauncher.java b/ruby-tools/src/main/java/de/saumya/mojo/ruby/script/AntLauncher.java
index 8b6b0ae3..39a67eb1 100644
--- a/ruby-tools/src/main/java/de/saumya/mojo/ruby/script/AntLauncher.java
+++ b/ruby-tools/src/main/java/de/saumya/mojo/ruby/script/AntLauncher.java
@@ -3,18 +3,16 @@
*/
package de.saumya.mojo.ruby.script;
-import java.io.File;
-import java.io.IOException;
-import java.nio.file.Files;
-import java.util.List;
-import java.util.Map;
-
+import de.saumya.mojo.ruby.Logger;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.taskdefs.Java;
-import org.apache.tools.ant.types.Path;
import org.apache.tools.ant.types.Environment.Variable;
+import org.apache.tools.ant.types.Path;
-import de.saumya.mojo.ruby.Logger;
+import java.io.*;
+import java.nio.file.Files;
+import java.util.List;
+import java.util.Map;
class AntLauncher extends AbstractLauncher {
@@ -22,11 +20,13 @@ class AntLauncher extends AbstractLauncher {
private static final String DEFAULT_XMX = "-Xmx384m";
- private final Logger logger;
+ private static final String TEMP_FILE_PREFIX = "jruby-ant-launcher-";
+
+ private final Logger logger;
private final ScriptFactory factory;
- private final Project project;
+ private final Project project;
AntLauncher(final Logger logger, final ScriptFactory factory) {
this.logger = logger;
@@ -35,8 +35,14 @@ class AntLauncher extends AbstractLauncher {
}
@Override
- protected void doExecute(final File launchDirectory,
- final List args, final File outputFile) {
+ protected void doExecute(final File launchDirectory,
+ final List args, File outputFile) throws ScriptException, IOException {
+ doExecute(launchDirectory, args,new FileOutputStream(outputFile));
+ }
+
+ @Override
+ protected void doExecute(final File launchDirectory, final List args,
+ final OutputStream outputStream) throws ScriptException, IOException {
final Java java = new Java();
java.setProject(this.project);
java.setClassname("org.jruby.Main");
@@ -79,7 +85,7 @@ protected void doExecute(final File launchDirectory,
// Does not work on all JVMs
// if (!factory.jvmArgs.matches("(-client|-server)")) {
-// java.createJvmarg().setValue("-client");
+// java.createJvmarg().setValue("-client");
// }
for (String arg : factory.jvmArgs.list) {
@@ -102,38 +108,50 @@ protected void doExecute(final File launchDirectory,
java.createJvmarg().setValue("-Xbootclasspath/a:"
+ jrubyJar.getAbsolutePath());
}
-
- if (outputFile != null) {
- java.setOutput(outputFile);
+
+ File outputTempFile = null;
+ if (outputStream != null) {
+ outputTempFile = File.createTempFile(TEMP_FILE_PREFIX, ".output");
+ java.setOutput(outputTempFile);
}
+
java.setLogError(true);
- File tempFile = null;
+ File errorTempFile = null;
try {
- tempFile = File.createTempFile("jruby-ant-launcher-", ".log");
- tempFile.deleteOnExit();
- java.setError(tempFile);
+ errorTempFile = File.createTempFile(TEMP_FILE_PREFIX, ".log");
+ errorTempFile.deleteOnExit();
+ java.setError(errorTempFile);
java.execute();
- }
- catch(IOException e) {
+
+ if (outputStream != null) {
+ writeInto(outputTempFile, outputStream);
+ outputTempFile.delete();
+ }
+ } catch (IOException e) {
logger.warn("can not create tempfile for stderr");
java.execute();
- }
- finally {
- if (tempFile != null) {
+ } finally {
+ if (errorTempFile != null && errorTempFile.length() > 0) {
try {
- byte[] encoded = Files.readAllBytes(tempFile.toPath());
- if (encoded.length > 0) {
+ byte[] encoded = Files.readAllBytes(errorTempFile.toPath());
logger.warn(new String(encoded));
- }
- }
- catch(IOException e) {
+ } catch (IOException e) {
logger.warn("can not read error file");
}
- tempFile.delete();
+ errorTempFile.delete();
}
}
}
+ private void writeInto(File file, OutputStream outputStream) throws IOException {
+ byte[] buffer = new byte[1024 * 4];
+ final InputStream fileIS = new FileInputStream(file);
+
+ while (fileIS.read(buffer) > 0) {
+ outputStream.write(buffer);
+ }
+ }
+
private Project createAntProject() {
final Project project = new Project();
@@ -153,7 +171,7 @@ private Project createAntProject() {
@Override
public void execute(final List args) throws ScriptException,
IOException {
- doExecute(null, args, null);
+ doExecute(null, args, (OutputStream) null);
}
@Override
@@ -165,7 +183,7 @@ public void execute(final List args, final File outputFile)
@Override
public void executeIn(final File launchDirectory, final List args)
throws ScriptException, IOException {
- doExecute(launchDirectory, args, null);
+ doExecute(launchDirectory, args, (OutputStream) null);
}
@Override
@@ -177,7 +195,7 @@ public void executeIn(final File launchDirectory, final List args,
@Override
public void executeScript(final String script, final List args)
throws ScriptException, IOException {
- executeScript(script, args, null);
+ executeScript(script, args, (OutputStream) null);
}
@Override
@@ -189,15 +207,29 @@ public void executeScript(final String script, final List args,
@Override
public void executeScript(final File launchDirectory, final String script,
final List args) throws ScriptException, IOException {
- executeScript(launchDirectory, script, args, null);
+ executeScript(launchDirectory, script, args, (OutputStream) null);
}
+ @Override
public void executeScript(final File launchDirectory, final String script,
final List args, final File outputFile)
throws ScriptException, IOException {
+ addScriptArguments(script, args);
+ doExecute(launchDirectory, args, outputFile);
+ }
+
+ @Override
+ public void executeScript(final File launchDirectory, final String script,
+ final List args, final OutputStream outputStream)
+ throws ScriptException, IOException {
+ addScriptArguments(script, args);
+ doExecute(launchDirectory, args, outputStream);
+ }
+
+ private void addScriptArguments(String script, List args) {
args.add(0, "-e");
args.add(1, script);
args.add(2, "--");
- doExecute(launchDirectory, args, outputFile);
}
+
}
diff --git a/ruby-tools/src/main/java/de/saumya/mojo/ruby/script/EmbeddedLauncher.java b/ruby-tools/src/main/java/de/saumya/mojo/ruby/script/EmbeddedLauncher.java
index 32f9be52..ea9007be 100644
--- a/ruby-tools/src/main/java/de/saumya/mojo/ruby/script/EmbeddedLauncher.java
+++ b/ruby-tools/src/main/java/de/saumya/mojo/ruby/script/EmbeddedLauncher.java
@@ -3,15 +3,15 @@
*/
package de.saumya.mojo.ruby.script;
-import java.io.File;
-import java.io.IOException;
-import java.io.PrintStream;
+import java.io.*;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.net.MalformedURLException;
+import java.nio.file.Files;
import java.util.List;
import java.util.Map;
+import org.apache.commons.io.FileUtils;
import org.codehaus.classworlds.ClassRealm;
import org.codehaus.classworlds.DuplicateRealmException;
import org.codehaus.classworlds.NoSuchRealmException;
@@ -20,6 +20,8 @@
class EmbeddedLauncher extends AbstractLauncher {
+ private static final String TEMP_FILE_PREFIX = "jruby-embedded-launcher-";
+
private static final Class>[] No_ARG_TYPES = new Class[0];
private static final Object[] NO_ARGS = new Object[0];
@@ -93,6 +95,16 @@ protected void doExecute(final File launchDirectory,
doExecute(launchDirectory, outputFile, args, true);
}
+ @Override
+ protected void doExecute(final File launchDirectory,
+ final List args, OutputStream outputStream)
+ throws ScriptException, IOException {
+ final File outputFile = Files.createTempFile(TEMP_FILE_PREFIX, ".output").toFile();
+ doExecute(launchDirectory, outputFile, args, true);
+ byte[] outputBytes = FileUtils.readFileToByteArray(outputFile);
+ outputStream.write(outputBytes);
+ }
+
private void doExecute(final File launchDirectory, final File outputFile,
final List args, final boolean warn)
throws ScriptException, IOException {
@@ -201,6 +213,16 @@ private void doExecute(final File launchDirectory, final File outputFile,
}
}
+ @Override
+ public void executeScript(final File launchDirectory,
+ final String script, final List args,
+ final OutputStream outputStream) throws ScriptException, IOException {
+ final File outputFile = Files.createTempFile(TEMP_FILE_PREFIX, ".output").toFile();
+ executeScript(launchDirectory, script, args, outputFile);
+ byte[] outputBytes = FileUtils.readFileToByteArray(outputFile);
+ outputStream.write(outputBytes);
+ }
+
public void executeScript(final File launchDirectory, final String script,
final List args, final File outputFile)
throws ScriptException, IOException {
diff --git a/ruby-tools/src/main/java/de/saumya/mojo/ruby/script/JRubyVersion.java b/ruby-tools/src/main/java/de/saumya/mojo/ruby/script/JRubyVersion.java
new file mode 100644
index 00000000..f09efe6f
--- /dev/null
+++ b/ruby-tools/src/main/java/de/saumya/mojo/ruby/script/JRubyVersion.java
@@ -0,0 +1,61 @@
+package de.saumya.mojo.ruby.script;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class JRubyVersion {
+
+ private final String version;
+ private final String language;
+
+ public JRubyVersion(String version, String language) {
+ this.version = version;
+ this.language = language;
+ }
+
+ public String getVersion() {
+ return version;
+ }
+
+ public String getLanguage() {
+ return language;
+ }
+
+ public boolean isVersionLowerThan(Integer... version) {
+ final List parts = extractVersionComponents(this.version);
+
+ for (int i = 0; i < version.length && i < parts.size(); i++) {
+ if (parts.get(i) == version[i])
+ continue;
+ return parts.get(i) < version[i];
+ }
+ return false;
+ }
+
+ private List extractVersionComponents(String versionString) {
+ if (versionString == null)
+ throw new NumberFormatException();
+
+ final String[] parts = versionString.split("\\.");
+
+ final List versionComponents = new ArrayList();
+ for (String part : parts) {
+ versionComponents.add(Integer.parseInt(part));
+ }
+ return versionComponents;
+ }
+
+ public boolean isLanguageLowerThan(int major, int minor) {
+ final List parts = extractVersionComponents(language);
+
+ int majorLanguageVersion = parts.get(0);
+ int minorLanguageVersion = parts.get(1);
+
+ if (major == majorLanguageVersion) {
+ return minorLanguageVersion < minor;
+ } else {
+ return majorLanguageVersion < major;
+ }
+ }
+
+}
diff --git a/ruby-tools/src/main/java/de/saumya/mojo/ruby/script/Launcher.java b/ruby-tools/src/main/java/de/saumya/mojo/ruby/script/Launcher.java
index 779ddbb8..8343155e 100644
--- a/ruby-tools/src/main/java/de/saumya/mojo/ruby/script/Launcher.java
+++ b/ruby-tools/src/main/java/de/saumya/mojo/ruby/script/Launcher.java
@@ -5,6 +5,7 @@
import java.io.File;
import java.io.IOException;
+import java.io.OutputStream;
import java.util.List;
interface Launcher {
@@ -15,6 +16,9 @@ public abstract void execute(final List args)
public abstract void execute(final List args, final File outputFile)
throws ScriptException, IOException;
+ public abstract void execute(final List args, final OutputStream outputStream)
+ throws ScriptException, IOException;
+
public abstract void executeIn(final File launchDirectory,
final List args) throws ScriptException, IOException;
@@ -22,6 +26,9 @@ public abstract void executeIn(final File launchDirectory,
final List args, final File outputFile)
throws ScriptException, IOException;
+ public abstract void executeIn(final File launchDirectory, final List args,
+ final OutputStream outputStream) throws ScriptException, IOException;
+
public abstract void executeScript(final String script,
final List args) throws ScriptException, IOException;
@@ -29,6 +36,10 @@ public abstract void executeScript(final String script,
final List args, final File outputFile)
throws ScriptException, IOException;
+ public abstract void executeScript(final String script,
+ final List args, final OutputStream outputStream)
+ throws ScriptException, IOException;
+
public abstract void executeScript(final File launchDirectory,
final String script, final List args)
throws ScriptException, IOException;
@@ -37,4 +48,7 @@ public abstract void executeScript(final File launchDirectory,
final String script, final List args,
final File outputFile) throws ScriptException, IOException;
+ public abstract void executeScript(final File launchDirectory,
+ final String script, final List args,
+ final OutputStream outputStream) throws ScriptException, IOException;
}
\ No newline at end of file
diff --git a/ruby-tools/src/main/java/de/saumya/mojo/ruby/script/Script.java b/ruby-tools/src/main/java/de/saumya/mojo/ruby/script/Script.java
index 7b40e409..871c506f 100644
--- a/ruby-tools/src/main/java/de/saumya/mojo/ruby/script/Script.java
+++ b/ruby-tools/src/main/java/de/saumya/mojo/ruby/script/Script.java
@@ -5,6 +5,7 @@
import java.io.File;
import java.io.IOException;
+import java.io.OutputStream;
import java.net.URL;
public class Script extends Arguments {
@@ -97,6 +98,18 @@ public void execute(final File output) throws ScriptException,
}
}
+ public void execute(final OutputStream output) throws ScriptException,
+ IOException {
+ if (this.script != null) {
+ this.scriptFactory.launcher.executeScript(this.script,
+ this.list,
+ output);
+ }
+ else {
+ this.scriptFactory.launcher.execute(this.list, output);
+ }
+ }
+
public void executeIn(final File launchDirectory)
throws ScriptException, IOException {
if (this.script != null) {
diff --git a/ruby-tools/src/main/java/de/saumya/mojo/ruby/script/ScriptFactory.java b/ruby-tools/src/main/java/de/saumya/mojo/ruby/script/ScriptFactory.java
index b0513625..c79bc314 100644
--- a/ruby-tools/src/main/java/de/saumya/mojo/ruby/script/ScriptFactory.java
+++ b/ruby-tools/src/main/java/de/saumya/mojo/ruby/script/ScriptFactory.java
@@ -1,98 +1,95 @@
/**
- *
+ *
*/
package de.saumya.mojo.ruby.script;
+import de.saumya.mojo.ruby.Logger;
+import de.saumya.mojo.ruby.ScriptUtils;
+import org.codehaus.classworlds.ClassRealm;
+import org.codehaus.classworlds.DuplicateRealmException;
+import org.codehaus.classworlds.NoSuchRealmException;
+
+import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
+import java.nio.charset.StandardCharsets;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import org.codehaus.classworlds.ClassRealm;
-import org.codehaus.classworlds.DuplicateRealmException;
-import org.codehaus.classworlds.NoSuchRealmException;
-
-import de.saumya.mojo.ruby.Logger;
-import de.saumya.mojo.ruby.ScriptUtils;
-
public class ScriptFactory {
public static List NO_CLASSPATH = Collections.emptyList();
- final Arguments switches = new Arguments();
- final Arguments jvmArgs = new Arguments();
+ final Arguments switches = new Arguments();
+ final Arguments jvmArgs = new Arguments();
- private final Map env = new HashMap();
- final File jrubyStdlibJar;
+ private final Map env = new HashMap();
+ final File jrubyStdlibJar;
- final Logger logger;
- final ClassRealm classRealm;
- final File jrubyJar;
- final List classpathElements;
- final boolean fork;
+ final Logger logger;
+ final ClassRealm classRealm;
+ final File jrubyJar;
+ final List classpathElements;
+ final boolean fork;
- final Launcher launcher;
+ final Launcher launcher;
public ScriptFactory(final Logger logger, final ClassRealm classRealm,
- final File jrubyJar,
- final List classpathElements, final boolean fork) throws ScriptException, IOException {
+ final File jrubyJar,
+ final List classpathElements, final boolean fork) throws ScriptException, IOException {
this(logger, classRealm, jrubyJar, jrubyJar, classpathElements, fork);
}
-
+
public ScriptFactory(final Logger logger, final ClassRealm classRealm,
- final File jrubyJar, File stdlibJar,
- final List classpathElements, final boolean fork) throws ScriptException, IOException {
+ final File jrubyJar, File stdlibJar,
+ final List classpathElements, final boolean fork) throws ScriptException, IOException {
this.logger = logger;
this.jrubyStdlibJar = stdlibJar;
this.jrubyJar = jrubyJar;
- if(this.jrubyJar != null){
+ if (this.jrubyJar != null) {
this.logger.debug("script uses jruby jar:" + this.jrubyJar.getAbsolutePath());
}
-
+
this.classpathElements = classpathElements == null
? NO_CLASSPATH
: Collections.unmodifiableList(classpathElements);
this.fork = fork;
if (classRealm != null && jrubyJar != null) {
this.classRealm = getOrCreateClassRealm(classRealm, jrubyJar);
- }
- else {
+ } else {
this.classRealm = classRealm;
}
if (fork) {
this.launcher = new AntLauncher(logger, this);
- }
- else {
+ } else {
this.launcher = new EmbeddedLauncher(logger, this);
}
}
- private static synchronized ClassRealm getOrCreateClassRealm(final ClassRealm classRealm, final File jrubyJar) throws MalformedURLException, ScriptException {
- ClassRealm jruby;
- try {
- jruby = classRealm.getWorld().getRealm("jruby");
- }
- catch (final NoSuchRealmException e) {
- try {
- jruby = classRealm.getWorld().newRealm("jruby");
- if(jrubyJar != null){
- jruby.addConstituent(jrubyJar.toURI().toURL());
- }
- }
- catch (final DuplicateRealmException ee) {
- throw new ScriptException("could not setup classrealm for jruby",
- ee);
- }
- }
- return jruby;
- }
+ private static synchronized ClassRealm getOrCreateClassRealm(final ClassRealm classRealm, final File jrubyJar) throws MalformedURLException, ScriptException {
+ ClassRealm jruby;
+ try {
+ jruby = classRealm.getWorld().getRealm("jruby");
+ } catch (final NoSuchRealmException e) {
+ try {
+ jruby = classRealm.getWorld().newRealm("jruby");
+ if (jrubyJar != null) {
+ jruby.addConstituent(jrubyJar.toURI().toURL());
+ }
+ } catch (final DuplicateRealmException ee) {
+ throw new ScriptException("could not setup classrealm for jruby",
+ ee);
+ }
+ }
+ return jruby;
+ }
public Script newScriptFromSearchPath(final String scriptName)
throws IOException {
@@ -104,38 +101,33 @@ public Script newScriptFromJRubyJar(final String scriptName)
try {
// the first part only works on jruby-complete.jar
URL url = new URL("jar:file:"
- + this.jrubyStdlibJar.getAbsolutePath()
- + "!/META-INF/jruby.home/bin/" + scriptName);
+ + this.jrubyStdlibJar.getAbsolutePath()
+ + "!/META-INF/jruby.home/bin/" + scriptName);
url.openConnection().getContent();
return new Script(this, url);
- }
- catch (Exception e) {
+ } catch (Exception e) {
try {
// fallback on classloader
return newScriptFromResource("META-INF/jruby.home/bin/" + scriptName);
- }
- catch (FileNotFoundException ee) {
+ } catch (FileNotFoundException ee) {
// find jruby-home
String base = ".";
- if ( this.env.containsKey( "JRUBY_HOME" ) ) {
- base = this.env.get( "JRUBY_HOME" );
- }
- else if ( System.getProperty( "jruby.home" ) != null ) {
- base = System.getProperty( "jruby.home" );
- }
- else {
- for( String arg : this.jvmArgs.list ){
- if (arg.startsWith("-Djruby.home=")){
+ if (this.env.containsKey("JRUBY_HOME")) {
+ base = this.env.get("JRUBY_HOME");
+ } else if (System.getProperty("jruby.home") != null) {
+ base = System.getProperty("jruby.home");
+ } else {
+ for (String arg : this.jvmArgs.list) {
+ if (arg.startsWith("-Djruby.home=")) {
base = arg.substring("-Djruby.home=".length());
break;
}
}
}
- File f = new File( base, new File( "bin", scriptName ).getPath() );
- if ( f.exists() ){
+ File f = new File(base, new File("bin", scriptName).getPath());
+ if (f.exists()) {
return new Script(this, f);
- }
- else {
+ } else {
throw ee;
}
}
@@ -151,8 +143,7 @@ public Script newScriptFromResource(final String scriptName)
}
if (url.getProtocol().equals("file")) {
return new Script(this, url.getPath(), false);
- }
- else {
+ } else {
return new Script(this, url);
}
}
@@ -172,7 +163,7 @@ public Script newScript(final File file) {
public void addJvmArgs(final String args) {
this.jvmArgs.parseAndAdd(args);
}
-
+
public void addSwitch(final String name) {
this.switches.add(name);
}
@@ -188,13 +179,12 @@ public void addSwitches(final String switches) {
public void addEnv(final String name, final File value) {
if (value != null) {
this.env.put(name, value.getAbsolutePath());
- }
- else {
+ } else {
this.env.put(name, null);
}
}
-
- public Map environment(){
+
+ public Map environment() {
return env;
}
@@ -211,6 +201,29 @@ public void addEnvs(final String environmentVars) {
}
}
+ /**
+ * Returns JRuby version representation found.
+ * {@code null} if version format could not be processed.
+ */
+ public JRubyVersion getVersion() {
+ try {
+ final ByteArrayOutputStream os = new ByteArrayOutputStream();
+ this.newArguments().addArg("-v").execute(os);
+ final String[] versionParts = os.toString(StandardCharsets.UTF_8.toString()).split(" ");
+ final String jrubyVersion = versionParts[1];
+ final String languageVersion = extractLanguageVersion(versionParts[2]);
+ return new JRubyVersion(jrubyVersion, languageVersion);
+ } catch (Exception e) {
+ logger.warn("Could not identify version: " + e.getMessage());
+ return null;
+ }
+ }
+
+ private String extractLanguageVersion(String versionPart) {
+ return versionPart
+ .replaceAll("\\(|\\)|ruby-", "");
+ }
+
@Override
public String toString() {
// TODO
diff --git a/ruby-tools/src/test/java/de/saumya/mojo/ruby/EmbeddedLauncherTest.java b/ruby-tools/src/test/java/de/saumya/mojo/ruby/EmbeddedLauncherTest.java
index f85ffddf..b83443d9 100644
--- a/ruby-tools/src/test/java/de/saumya/mojo/ruby/EmbeddedLauncherTest.java
+++ b/ruby-tools/src/test/java/de/saumya/mojo/ruby/EmbeddedLauncherTest.java
@@ -15,8 +15,8 @@
import de.saumya.mojo.ruby.script.ScriptFactory;
public class EmbeddedLauncherTest extends TestCase {
-
- private static final String SEP = System.getProperty("line.separator");
+
+ private static final String SEP = System.getProperty("line.separator");
public EmbeddedLauncherTest(final String testName) {
super(testName);
@@ -42,7 +42,7 @@ public void setUp() throws Exception {
GemsConfig config = new GemsConfig();
config.setGemHome(home);
config.addGemPath(path);
-
+
this.path.mkdirs();
this.expected = "onetwothree" + SEP + this.home.getAbsolutePath() + SEP
+ this.path.getAbsolutePath() + SEP;
@@ -135,7 +135,7 @@ public void testScript() throws Exception {
.addArg("three")
.execute();
assertEquals(this.expected,
- FileUtils.fileRead("target/test-classes/test.rb-gem.txt"));
+ FileUtils.fileRead("target/test-classes/test.rb-gem.txt"));
}
public void testScriptInTarget() throws Exception {
@@ -145,7 +145,7 @@ public void testScriptInTarget() throws Exception {
.addArg("three")
.executeIn(new File("target"));
assertEquals(this.expected,
- FileUtils.fileRead("target/test-classes/test.rb-gem.txt") );
+ FileUtils.fileRead("target/test-classes/test.rb-gem.txt") );
}
public void testScriptWithOutput() throws Exception {
diff --git a/ruby-tools/src/test/java/de/saumya/mojo/ruby/script/AbstractLauncherTest.java b/ruby-tools/src/test/java/de/saumya/mojo/ruby/script/AbstractLauncherTest.java
new file mode 100644
index 00000000..733a69e5
--- /dev/null
+++ b/ruby-tools/src/test/java/de/saumya/mojo/ruby/script/AbstractLauncherTest.java
@@ -0,0 +1,85 @@
+package de.saumya.mojo.ruby.script;
+
+import de.saumya.mojo.ruby.NoopLogger;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+
+import static de.saumya.mojo.ruby.script.TestDataFactories.gemScriptFactory;
+import static org.assertj.core.api.Assertions.assertThat;
+
+@RunWith(Parameterized.class)
+public class AbstractLauncherTest {
+
+ @Parameterized.Parameters
+ public static Collection