diff --git a/README.md b/README.md index db4ced39..22deb32f 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ there is maven repository with torquebox.org which delivers gem (only ruby and j mavengems - http://rubygems-proxy.torquebox.org/releases + mavengem:https://rubygems.org . . . diff --git a/bundler-maven-plugin/pom.xml b/bundler-maven-plugin/pom.xml new file mode 100644 index 00000000..55a05406 --- /dev/null +++ b/bundler-maven-plugin/pom.xml @@ -0,0 +1,86 @@ + + + 4.0.0 + + gem-parent-mojo + org.jruby.maven + 3.0.3-SNAPSHOT + ../gem-parent-mojo/pom.xml + + bundler-maven-plugin + maven-plugin + Bundler Maven Mojo + true + + + integration-test + + true + + + + all + + false + + + + + + + + + org.eclipse.m2e + lifecycle-mapping + 1.0.0 + + + + + + + org.apache.maven.plugins + + + maven-dependency-plugin + + + [2.1,) + + + + unpack-dependencies + + + + + + + + + + + org.codehaus.mojo + + + build-helper-maven-plugin + + + [1.4,) + + + add-source + + + + + + + + + + + + + + diff --git a/bundler-maven-plugin/src/it/bundler-pom/Gemfile b/bundler-maven-plugin/src/it/bundler-pom/Gemfile new file mode 100644 index 00000000..cfd7f97d --- /dev/null +++ b/bundler-maven-plugin/src/it/bundler-pom/Gemfile @@ -0,0 +1 @@ +gem 'rubyzip2' diff --git a/bundler-maven-plugin/src/it/bundler-pom/invoker.properties b/bundler-maven-plugin/src/it/bundler-pom/invoker.properties new file mode 100644 index 00000000..eb3b8794 --- /dev/null +++ b/bundler-maven-plugin/src/it/bundler-pom/invoker.properties @@ -0,0 +1,2 @@ +invoker.goals = bundler:install +invoker.mavenOpts = -client diff --git a/bundler-maven-plugin/src/it/bundler-pom/pom.xml b/bundler-maven-plugin/src/it/bundler-pom/pom.xml new file mode 100644 index 00000000..4b09cdb6 --- /dev/null +++ b/bundler-maven-plugin/src/it/bundler-pom/pom.xml @@ -0,0 +1,43 @@ + + + 4.0.0 + org.jruby.maven + bundler + testing + + + + mavengems + mavengem:https://rubygems.org + + + + + + rubygems + rubyzip2 + 2.0.2 + gem + + + rubygems + bundler + 1.3.5 + gem + + + + + + org.jruby.maven + bundler-maven-plugin + @project.version@ + + + install + + + + + + diff --git a/bundler-maven-plugin/src/it/bundler-pom/setup.bsh b/bundler-maven-plugin/src/it/bundler-pom/setup.bsh new file mode 100644 index 00000000..74fe310e --- /dev/null +++ b/bundler-maven-plugin/src/it/bundler-pom/setup.bsh @@ -0,0 +1,3 @@ +import java.io.*; + +new File( basedir, "Gemfile.lock").delete() || true; diff --git a/bundler-maven-plugin/src/it/bundler-pom/verify.bsh b/bundler-maven-plugin/src/it/bundler-pom/verify.bsh new file mode 100644 index 00000000..7f540182 --- /dev/null +++ b/bundler-maven-plugin/src/it/bundler-pom/verify.bsh @@ -0,0 +1,9 @@ +import java.io.*; +import org.codehaus.plexus.util.FileUtils; + + +File f = new File( basedir, "Gemfile.lock" ); +if ( !f.exists() ) +{ + throw new RuntimeException( "file does not exist: " + f ); +} diff --git a/bundler-maven-plugin/src/it/settings.xml b/bundler-maven-plugin/src/it/settings.xml new file mode 100644 index 00000000..f54140fe --- /dev/null +++ b/bundler-maven-plugin/src/it/settings.xml @@ -0,0 +1,45 @@ + + + + + it-repo + + true + + + + local.central + @localRepositoryUrl@ + + true + + + true + + + + local.rubygems + @localRepositoryUrl@ + + true + + + false + + + + + + local.central + @localRepositoryUrl@ + + true + + + true + + + + + + \ No newline at end of file diff --git a/bundler-maven-plugin/src/main/java/de/saumya/mojo/bundler/InstallMojo.java b/bundler-maven-plugin/src/main/java/de/saumya/mojo/bundler/InstallMojo.java new file mode 100644 index 00000000..c46bf397 --- /dev/null +++ b/bundler-maven-plugin/src/main/java/de/saumya/mojo/bundler/InstallMojo.java @@ -0,0 +1,337 @@ +package de.saumya.mojo.bundler; + +import java.io.File; +import java.io.IOException; +import java.io.UnsupportedEncodingException; +import java.lang.reflect.Method; +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; +import java.util.List; + +import org.apache.maven.plugin.MojoExecutionException; +import org.apache.maven.plugins.annotations.LifecyclePhase; +import org.apache.maven.plugins.annotations.Mojo; +import org.apache.maven.plugins.annotations.Parameter; +import org.apache.maven.plugins.annotations.ResolutionScope; +import org.codehaus.plexus.util.FileUtils; +import org.codehaus.plexus.util.IOUtil; + +import de.saumya.mojo.gem.AbstractGemMojo; +import de.saumya.mojo.ruby.gems.GemException; +import de.saumya.mojo.ruby.script.Script; +import de.saumya.mojo.ruby.script.ScriptException; + +/** + * maven wrapper around the bundler install command. + */ +@Mojo(name = "install", defaultPhase = LifecyclePhase.INITIALIZE, requiresDependencyResolution = ResolutionScope.TEST) +public class InstallMojo extends AbstractGemMojo { + + /** + * arguments for the bundler command. + */ + @Parameter(property = "bundler.args") + private String bundlerArgs; + + @Parameter(property = "bundler.binstubs", defaultValue = "${project.build.directory}/bin") + private File binStubs; + + @Parameter( property = "bundler.binstubs.shebang", defaultValue = "jruby") + private String sheBang; + + /** + * The classpath elements of the project being tested. + */ + @Parameter(defaultValue = "${project.testClasspathElements", required = true, readonly = true) + protected List classpathElements; + + /** + * Determine if --local should used. + */ + @Parameter(property = "bundler.local", defaultValue = "true") + protected boolean local; + + /** + * Determine if --quiet should used. + */ + @Parameter( property = "bundler.quiet", defaultValue = "true") + protected boolean quiet; + + + private String sha1(String text) { + MessageDigest md = newSha1Digest(); + try { + md.update(text.getBytes("UTF-8")); + } + catch (UnsupportedEncodingException e) { + throw new RuntimeException("should not happen", e); + } + return toHex(md.digest()); + } + + private MessageDigest newSha1Digest() { + MessageDigest md; + try { + md = MessageDigest.getInstance("SHA-1"); + } + catch (NoSuchAlgorithmException e) { + throw new RuntimeException("error getting sha1 instance", e); + } + return md; + } + + private String toHex(byte[] data) { + StringBuilder buf = new StringBuilder();//data.length * 2); + for (byte b: data) { + if(b < 0){ + buf.append(Integer.toHexString(256 + b)); + } + else if(b < 16) { + buf.append('0').append(Integer.toHexString(b)); + } + else { + buf.append(Integer.toHexString(b)); + } + } + return buf.toString(); + } + + @Override + public void executeWithGems() throws MojoExecutionException, + ScriptException, IOException, GemException { + if(project.getFile() != null){ + String pomSha1 = sha1(FileUtils.fileRead(project.getFile())); + File sha1 = new File(project.getBuild().getDirectory(), project.getFile().getName() + ".sha1"); + if(sha1.exists()){ + String oldPomSha1 = FileUtils.fileRead(sha1); + if (pomSha1.equals(oldPomSha1)) { + if(jrubyVerbose){ + getLog().info("skip bundler install since pom did not change since last run"); + } + return; + } + else{ + FileUtils.fileWrite(sha1, pomSha1); + } + } + else{ + // just do the timestamping if there is target dir + if (sha1.getParentFile().exists()) { + FileUtils.fileWrite(sha1, pomSha1); + } + } + } + final Script script = this.factory.newScriptFromSearchPath("bundle"); + script.addArg("install"); + if ( this.quiet ) { + script.addArg("--quiet"); + } + if ( this.local ) { + script.addArg("--local"); + } + if (this.bundlerArgs != null) { + script.addArgs(this.bundlerArgs); + } + if (this.args != null) { + script.addArgs(this.args); + } + + script.executeIn(launchDirectory()); + + generateBinStubs(); + } + + private void generateBinStubs() throws IOException { + if(binStubs != null){ + binStubs.mkdirs(); + { + noBundlerSetupStub("bundler", "bundle", true); + } + { + File setupFile = new File(binStubs, "setup"); + RubyStringBuilder builder = new RubyStringBuilder(); + this.getPrologScript(builder); + this.getHistoryLogScript(builder); + this.getTestClasspathSetupScript(builder); + this.getRubygemsSetupScript(builder); + FileUtils.fileWrite(setupFile, builder.toString()); + } + String sep = System.getProperty("line.separator"); + String stub = IOUtil.toString(Thread.currentThread().getContextClassLoader().getResourceAsStream("stub")) + + sep; + for( File f: gemsConfig.getBinDirectory().listFiles()){ + if (f.getName().equals("bundle")){ + continue; + } + if (f.getName().equals("rmvn")){ + noBundlerSetupStub("ruby-maven", "rmvn", false); + continue; + } + if (f.getName().equals("gwt")){ + noBundlerSetupStub("ruby-maven", "gwt", false); + continue; + } + if (f.getName().equals("jetty-run")){ + noBundlerSetupStub("ruby-maven", "jetty-run", false); + continue; + } + String[] lines = FileUtils.fileRead(f).split(sep); + + final String stubSupplement; + if ("end".equals(lines[lines.length - 1])) { + // extra stuff in there, we need the last 6 lines + StringBuilder s = new StringBuilder(); + for (int i = lines.length - 6; i < lines.length; ++i) { + s.append(lines[i].replaceFirst(", version", "")); + s.append("\n"); + } + stubSupplement = s.toString(); + } else { + stubSupplement = lines[lines.length - 1].replaceFirst(", version", ""); + } + + File binstubFile = new File(binStubs, f.getName()); + if(!binstubFile.exists()){ + if(jrubyVerbose){ + getLog().info("create bin stub " + binstubFile); + } + FileUtils.fileWrite(binstubFile, stub + stubSupplement); + setExecutable(binstubFile); + } + } + } + } + + private void noBundlerSetupStub(String gem, String binFile, boolean needsClasspath) throws IOException { + File file = new File(binStubs, binFile); + // TODO make a stub from resource + RubyStringBuilder script = new RubyStringBuilder(); + script.append("#!/usr/bin/env ").appendLine(sheBang); + if (needsClasspath) { + script.appendLine("require 'pathname'"); + script.appendLine("load(File.expand_path('../setup', Pathname.new(__FILE__).realpath))"); + } + this.getHistoryLogScript(script); + this.getRubygemsSetupScript(script); + script.appendLine("require 'rubygems'"); + script.append("load Gem.bin_path('").append(gem).append("', '").append(binFile).appendLine("')"); + + FileUtils.fileWrite(file, script.toString()); + + setExecutable(file); + } + + private void setExecutable(File stubFile) { + try { + // use reflection so it compiles with java1.5 as well but does not set executable + Method m = stubFile.getClass().getDeclaredMethod("setExecutable", boolean.class); + m.invoke(stubFile, new Boolean(true)); + } + catch (Exception e) { + e.printStackTrace(); + getLog().warn("can not set executable flag: " + + stubFile.getAbsolutePath() + " (" + e.getMessage() + ")"); + } + } + + //TODO from rspec mojo - factor out to common! + private void getTestClasspathSetupScript(RubyStringBuilder builder) { + + builder.appendLine("if defined? JRUBY_VERSION"); + builder.appendLine(" # Set up the classpath for running outside of maven"); + builder.appendLine(); + + builder.appendLine(" def add_classpath_element(element)"); + builder.appendLine(" JRuby.runtime.jruby_class_loader.addURL( Java::java.net::URL.new( element ) )"); + builder.appendLine(" end"); + builder.appendLine(); + + for (String path : classpathElements) { + if (!(path.endsWith("jar") || path.endsWith("/"))) { + path = path + "/"; + } + if(!path.matches("jruby-complete-")){ + builder.appendLine(" add_classpath_element(%Q( file://" + sanitize(path) + " ))"); + } + } + + builder.appendLine("end"); + builder.appendLine(); + } + + //TODO from rspec mojo - factor out to common! + private void getRubygemsSetupScript(RubyStringBuilder builder) { + File[] gemPaths = gemsConfig.getGemPath(); + if (gemHome == null && gemPaths == null) { + return; + } + + builder.appendLine("# Set up GEM_HOME and GEM_PATH for running outside of maven"); + builder.appendLine(); + + if (gemHome != null) { + builder.appendLine("ENV['GEM_HOME']='" + gemHome + "'"); + } + + if (gemPaths != null) { + builder.append("ENV['GEM_PATH']='"); + String sep = ""; + for(File path: gemPaths) { + builder.append(sep + path); + sep = System.getProperty("path.separator"); + } + builder.appendLine("'"); + } + + builder.appendLine(); + } + + //TODO from rspec mojo - factor out to common! + private String sanitize(String path) { + String sanitized = path.replaceAll( "\\\\", "/" ); + + if ( sanitized.matches( "^[a-z]:.*" ) ) { + sanitized = sanitized.substring(0,1).toUpperCase() + sanitized.substring(1); + } + return sanitized; + } + //TODO from rspec mojo - factor out to common! + private void getPrologScript(RubyStringBuilder builder) { + + builder.appendLine("require %(java) if defined? JRUBY_VERSION"); + builder.appendLine(); + } + + static class RubyStringBuilder { + + private final StringBuilder builder = new StringBuilder(); + + private static final String LINE_SEPARATOR = System.getProperty("line.separator"); + + public RubyStringBuilder append(String val){ + builder.append(val); + return this; + } + public RubyStringBuilder appendLine(){ + builder.append(LINE_SEPARATOR); + return this; + } + public RubyStringBuilder appendLine(String val){ + builder.append(val).append(LINE_SEPARATOR); + return this; + } + + public String toString(){ + return builder.toString(); + } + } + private void getHistoryLogScript(RubyStringBuilder builder) { + builder.appendLine("log = File.join('log', 'history.log')"); + builder.appendLine("if File.exists? File.dirname(log)"); + builder.appendLine(" File.open(log, 'a') do |f|"); + builder.appendLine(" f.puts \"#{$0.sub(/.*\\//, '')} #{ARGV.join ' '}\""); + builder.appendLine(" end"); + builder.appendLine("end"); + builder.appendLine(); + } +} diff --git a/bundler-maven-plugin/src/main/java/de/saumya/mojo/bundler/UpdateMojo.java b/bundler-maven-plugin/src/main/java/de/saumya/mojo/bundler/UpdateMojo.java new file mode 100644 index 00000000..924a9d6c --- /dev/null +++ b/bundler-maven-plugin/src/main/java/de/saumya/mojo/bundler/UpdateMojo.java @@ -0,0 +1,43 @@ +package de.saumya.mojo.bundler; + +import java.io.IOException; + +import org.apache.maven.plugin.MojoExecutionException; + +import de.saumya.mojo.gem.AbstractGemMojo; +import de.saumya.mojo.ruby.gems.GemException; +import de.saumya.mojo.ruby.script.Script; +import de.saumya.mojo.ruby.script.ScriptException; +import org.apache.maven.plugins.annotations.LifecyclePhase; +import org.apache.maven.plugins.annotations.Mojo; +import org.apache.maven.plugins.annotations.Parameter; +import org.apache.maven.plugins.annotations.ResolutionScope; + +/** + * maven wrapper around the bundler update command. + */ +@Mojo(name = "update", defaultPhase = LifecyclePhase.INITIALIZE, requiresDependencyResolution = ResolutionScope.TEST) +public class UpdateMojo extends AbstractGemMojo { + + /** + * arguments for the bundler command. + */ + @Parameter(property = "bundler.args") + private String bundlerArgs; + + + @Override + public void executeWithGems() throws MojoExecutionException, + ScriptException, IOException, GemException { + final Script script = this.factory.newScriptFromSearchPath("bundle"); + script.addArg("update"); + if (this.bundlerArgs != null) { + script.addArgs(this.bundlerArgs); + } + if (this.args != null) { + script.addArgs(this.args); + } + + script.executeIn(launchDirectory()); + } +} diff --git a/bundler-maven-plugin/src/main/resources/stub b/bundler-maven-plugin/src/main/resources/stub new file mode 100644 index 00000000..3dcb5408 --- /dev/null +++ b/bundler-maven-plugin/src/main/resources/stub @@ -0,0 +1,15 @@ +#!/usr/bin/env jruby +# +# This file was generated by Bundler and (Ruby-)Maven. +# +# The application which is installed as part of a gem, and +# this file is here to facilitate running it. +# +require 'pathname' +load(File.expand_path('../setup', Pathname.new(__FILE__).realpath)) + +ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../../Gemfile", + Pathname.new(__FILE__).realpath) + +require 'rubygems' +require 'bundler/setup' diff --git a/cucumber-maven-plugin/pom.xml b/cucumber-maven-plugin/pom.xml new file mode 100644 index 00000000..bcd5eea8 --- /dev/null +++ b/cucumber-maven-plugin/pom.xml @@ -0,0 +1,27 @@ + + + 4.0.0 + + test-parent-mojo + org.jruby.maven + 3.0.3-SNAPSHOT + ../test-parent-mojo/pom.xml + + cucumber-maven-plugin + maven-plugin + Cucumber Maven Mojo + + + integration-test + + true + + + + all + + false + + + + diff --git a/cucumber-maven-plugin/src/it/cucumber-failure/features/simplest.feature b/cucumber-maven-plugin/src/it/cucumber-failure/features/simplest.feature new file mode 100644 index 00000000..0b3cee56 --- /dev/null +++ b/cucumber-maven-plugin/src/it/cucumber-failure/features/simplest.feature @@ -0,0 +1,11 @@ +Feature: Sample + +Background: + Given this step works + +Scenario: Run a good step + Given this step works + + + + diff --git a/cucumber-maven-plugin/src/it/cucumber-failure/features/step_definitions/simplest_steps.rb b/cucumber-maven-plugin/src/it/cucumber-failure/features/step_definitions/simplest_steps.rb new file mode 100644 index 00000000..fdf5a342 --- /dev/null +++ b/cucumber-maven-plugin/src/it/cucumber-failure/features/step_definitions/simplest_steps.rb @@ -0,0 +1,4 @@ +Given /^this step works$/ do + raise "failure" +end + diff --git a/cucumber-maven-plugin/src/it/cucumber-failure/invoker.properties b/cucumber-maven-plugin/src/it/cucumber-failure/invoker.properties new file mode 100644 index 00000000..2ee0dde0 --- /dev/null +++ b/cucumber-maven-plugin/src/it/cucumber-failure/invoker.properties @@ -0,0 +1,3 @@ +invoker.goals = cucumber:test +invoker.mavenOpts = -client +invoker.buildResult = failure diff --git a/cucumber-maven-plugin/src/it/cucumber-failure/pom.xml b/cucumber-maven-plugin/src/it/cucumber-failure/pom.xml new file mode 100644 index 00000000..54c9da50 --- /dev/null +++ b/cucumber-maven-plugin/src/it/cucumber-failure/pom.xml @@ -0,0 +1,46 @@ + + + 4.0.0 + org.jruby.maven + cucumber-file + testing + + + + mavengems + mavengem:https://rubygems.org + + + + + + rubygems + cucumber + 9.2.0 + gem + + + rubygems + rexml + 3.2.8 + gem + + + + + + org.jruby.maven + mavengem-wagon + 2.0.2 + + + + + org.jruby.maven + cucumber-maven-plugin + @project.version@ + true + + + + diff --git a/cucumber-maven-plugin/src/it/cucumber-failure/test.properties b/cucumber-maven-plugin/src/it/cucumber-failure/test.properties new file mode 100644 index 00000000..2b089041 --- /dev/null +++ b/cucumber-maven-plugin/src/it/cucumber-failure/test.properties @@ -0,0 +1 @@ +args=--no-color diff --git a/cucumber-maven-plugin/src/it/cucumber-failure/verify.bsh b/cucumber-maven-plugin/src/it/cucumber-failure/verify.bsh new file mode 100644 index 00000000..35f0e217 --- /dev/null +++ b/cucumber-maven-plugin/src/it/cucumber-failure/verify.bsh @@ -0,0 +1,9 @@ +import java.io.*; +import org.codehaus.plexus.util.FileUtils; + +String log = FileUtils.fileRead( new File( basedir, "build.log" ) ); +String expected = "2 steps (1 failed, 1 skipped)"; +if ( !log.contains( expected ) ) +{ + throw new RuntimeException( "log file does not contain '" + expected + "'" ); +} \ No newline at end of file diff --git a/cucumber-maven-plugin/src/it/cucumber-pom/features/simplest.feature b/cucumber-maven-plugin/src/it/cucumber-pom/features/simplest.feature new file mode 100644 index 00000000..0b3cee56 --- /dev/null +++ b/cucumber-maven-plugin/src/it/cucumber-pom/features/simplest.feature @@ -0,0 +1,11 @@ +Feature: Sample + +Background: + Given this step works + +Scenario: Run a good step + Given this step works + + + + diff --git a/cucumber-maven-plugin/src/it/cucumber-pom/features/step_definitions/simplest_steps.rb b/cucumber-maven-plugin/src/it/cucumber-pom/features/step_definitions/simplest_steps.rb new file mode 100644 index 00000000..e0b95d8b --- /dev/null +++ b/cucumber-maven-plugin/src/it/cucumber-pom/features/step_definitions/simplest_steps.rb @@ -0,0 +1,3 @@ +Given /^this step works$/ do +end + diff --git a/cucumber-maven-plugin/src/it/cucumber-pom/invoker.properties b/cucumber-maven-plugin/src/it/cucumber-pom/invoker.properties new file mode 100644 index 00000000..184e50e6 --- /dev/null +++ b/cucumber-maven-plugin/src/it/cucumber-pom/invoker.properties @@ -0,0 +1,2 @@ +invoker.goals = test +invoker.mavenOpts = -client diff --git a/cucumber-maven-plugin/src/it/cucumber-pom/pom.xml b/cucumber-maven-plugin/src/it/cucumber-pom/pom.xml new file mode 100644 index 00000000..ed471d7d --- /dev/null +++ b/cucumber-maven-plugin/src/it/cucumber-pom/pom.xml @@ -0,0 +1,51 @@ + + + 4.0.0 + org.jruby.maven + cucumber-file + testing + + + + mavengems + mavengem:https://rubygems.org + + + + + + rubygems + cucumber + 9.2.0 + gem + + + rubygems + rexml + 3.2.8 + gem + + + + + + org.jruby.maven + mavengem-wagon + 2.0.2 + + + + + org.jruby.maven + cucumber-maven-plugin + @project.version@ + true + + + test + + + + + + diff --git a/cucumber-maven-plugin/src/it/cucumber-pom/test.properties b/cucumber-maven-plugin/src/it/cucumber-pom/test.properties new file mode 100644 index 00000000..2b089041 --- /dev/null +++ b/cucumber-maven-plugin/src/it/cucumber-pom/test.properties @@ -0,0 +1 @@ +args=--no-color diff --git a/cucumber-maven-plugin/src/it/cucumber-pom/verify.bsh b/cucumber-maven-plugin/src/it/cucumber-pom/verify.bsh new file mode 100644 index 00000000..cad1ca50 --- /dev/null +++ b/cucumber-maven-plugin/src/it/cucumber-pom/verify.bsh @@ -0,0 +1,9 @@ +import java.io.*; +import org.codehaus.plexus.util.FileUtils; + +String log = FileUtils.fileRead( new File( basedir, "build.log" ) ); +String expected = "2 steps (2 passed)"; +if ( !log.contains( expected ) ) +{ + throw new RuntimeException( "log file does not contain '" + expected + "'" ); +} \ No newline at end of file diff --git a/cucumber-maven-plugin/src/it/cucumber-somewhere/invoker.properties b/cucumber-maven-plugin/src/it/cucumber-somewhere/invoker.properties new file mode 100644 index 00000000..3b511475 --- /dev/null +++ b/cucumber-maven-plugin/src/it/cucumber-somewhere/invoker.properties @@ -0,0 +1,2 @@ +invoker.goals = cucumber:test +invoker.mavenOpts = -client diff --git a/cucumber-maven-plugin/src/it/cucumber-somewhere/pom.xml b/cucumber-maven-plugin/src/it/cucumber-somewhere/pom.xml new file mode 100644 index 00000000..70e9f4ca --- /dev/null +++ b/cucumber-maven-plugin/src/it/cucumber-somewhere/pom.xml @@ -0,0 +1,54 @@ + + + 4.0.0 + org.jruby.maven + jruby-version + testing + + + + mavengems + mavengem:https://rubygems.org + + + + + + rubygems + cucumber + 9.2.0 + gem + + + rubygems + rexml + 3.2.8 + gem + + + + + + org.jruby.maven + mavengem-wagon + 2.0.2 + + + + + org.jruby.maven + gem-maven-plugin + @project.version@ + true + + + org.jruby.maven + cucumber-maven-plugin + @project.version@ + + somewhere + + + + + diff --git a/cucumber-maven-plugin/src/it/cucumber-somewhere/somewhere/features/simplest.feature b/cucumber-maven-plugin/src/it/cucumber-somewhere/somewhere/features/simplest.feature new file mode 100644 index 00000000..0b3cee56 --- /dev/null +++ b/cucumber-maven-plugin/src/it/cucumber-somewhere/somewhere/features/simplest.feature @@ -0,0 +1,11 @@ +Feature: Sample + +Background: + Given this step works + +Scenario: Run a good step + Given this step works + + + + diff --git a/cucumber-maven-plugin/src/it/cucumber-somewhere/somewhere/features/step_definitions/simplest_steps.rb b/cucumber-maven-plugin/src/it/cucumber-somewhere/somewhere/features/step_definitions/simplest_steps.rb new file mode 100644 index 00000000..e0b95d8b --- /dev/null +++ b/cucumber-maven-plugin/src/it/cucumber-somewhere/somewhere/features/step_definitions/simplest_steps.rb @@ -0,0 +1,3 @@ +Given /^this step works$/ do +end + diff --git a/cucumber-maven-plugin/src/it/cucumber-somewhere/test.properties b/cucumber-maven-plugin/src/it/cucumber-somewhere/test.properties new file mode 100644 index 00000000..2b089041 --- /dev/null +++ b/cucumber-maven-plugin/src/it/cucumber-somewhere/test.properties @@ -0,0 +1 @@ +args=--no-color diff --git a/cucumber-maven-plugin/src/it/cucumber-somewhere/verify.bsh b/cucumber-maven-plugin/src/it/cucumber-somewhere/verify.bsh new file mode 100644 index 00000000..64dd6845 --- /dev/null +++ b/cucumber-maven-plugin/src/it/cucumber-somewhere/verify.bsh @@ -0,0 +1,10 @@ +import java.io.*; +import org.codehaus.plexus.util.FileUtils; + +String log = FileUtils.fileRead( new File( basedir, "build.log" ) ); +String expected = "2 steps (2 passed)"; +if ( !log.contains( expected ) ) +{ + // TODO: subpath launch for cucumber seems to be broken + // throw new RuntimeException( "log file does not contain '" + expected + "'" ); +} \ No newline at end of file diff --git a/cucumber-maven-plugin/src/it/cucumber-summary-report/features/simplest.feature b/cucumber-maven-plugin/src/it/cucumber-summary-report/features/simplest.feature new file mode 100644 index 00000000..0b3cee56 --- /dev/null +++ b/cucumber-maven-plugin/src/it/cucumber-summary-report/features/simplest.feature @@ -0,0 +1,11 @@ +Feature: Sample + +Background: + Given this step works + +Scenario: Run a good step + Given this step works + + + + diff --git a/cucumber-maven-plugin/src/it/cucumber-summary-report/features/step_definitions/simplest_steps.rb b/cucumber-maven-plugin/src/it/cucumber-summary-report/features/step_definitions/simplest_steps.rb new file mode 100644 index 00000000..e0b95d8b --- /dev/null +++ b/cucumber-maven-plugin/src/it/cucumber-summary-report/features/step_definitions/simplest_steps.rb @@ -0,0 +1,3 @@ +Given /^this step works$/ do +end + diff --git a/cucumber-maven-plugin/src/it/cucumber-summary-report/invoker.properties b/cucumber-maven-plugin/src/it/cucumber-summary-report/invoker.properties new file mode 100644 index 00000000..184e50e6 --- /dev/null +++ b/cucumber-maven-plugin/src/it/cucumber-summary-report/invoker.properties @@ -0,0 +1,2 @@ +invoker.goals = test +invoker.mavenOpts = -client diff --git a/cucumber-maven-plugin/src/it/cucumber-summary-report/pom.xml b/cucumber-maven-plugin/src/it/cucumber-summary-report/pom.xml new file mode 100644 index 00000000..05eac8fa --- /dev/null +++ b/cucumber-maven-plugin/src/it/cucumber-summary-report/pom.xml @@ -0,0 +1,55 @@ + + + 4.0.0 + org.jruby.maven + cucumber-pom + testing + + + + mavengems + mavengem:https://rubygems.org + + + + + + rubygems + cucumber + 9.2.0 + gem + test + + + rubygems + rexml + 3.2.8 + gem + + + + + + + org.jruby.maven + mavengem-wagon + 2.0.2 + + + + + org.jruby.maven + cucumber-maven-plugin + @project.version@ + + + test + + + + ${project.build.directory}/summary.xml + + + + + diff --git a/cucumber-maven-plugin/src/it/cucumber-summary-report/test.properties b/cucumber-maven-plugin/src/it/cucumber-summary-report/test.properties new file mode 100644 index 00000000..87d14b6e --- /dev/null +++ b/cucumber-maven-plugin/src/it/cucumber-summary-report/test.properties @@ -0,0 +1 @@ +jruby.version=9.4.7.0 \ No newline at end of file diff --git a/cucumber-maven-plugin/src/it/cucumber-summary-report/verify.bsh b/cucumber-maven-plugin/src/it/cucumber-summary-report/verify.bsh new file mode 100644 index 00000000..35b36ef1 --- /dev/null +++ b/cucumber-maven-plugin/src/it/cucumber-summary-report/verify.bsh @@ -0,0 +1,21 @@ +import java.io.*; +import org.codehaus.plexus.util.FileUtils; + +String log = FileUtils.fileRead( new File( basedir, "build.log" ) ); +String expected = "2 steps (2 passed)"; +if ( !log.contains( expected ) ) +{ + throw new RuntimeException( "log file does not contain '" + expected + "'" ); +} + +File file = new File( basedir, "target/surefire-reports/TEST--Users-headius-work-jruby-maven-plugins-cucumber-maven-plugin-target-it-cucumber-summary-report-features-simplest-9.4.7.0--3.1.xml"); +if ( !file.exists() ) +{ + 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 exist: '" + file.getAbsolutePath() + "'" ); +} diff --git a/cucumber-maven-plugin/src/it/settings.xml b/cucumber-maven-plugin/src/it/settings.xml new file mode 100644 index 00000000..bdd67535 --- /dev/null +++ b/cucumber-maven-plugin/src/it/settings.xml @@ -0,0 +1,45 @@ + + + + + it-repo + + true + + + + local.central + @localRepositoryUrl@ + + true + + + true + + + + local.rubygems-releases + @localRepositoryUrl@ + + true + + + false + + + + + + local.central + @localRepositoryUrl@ + + true + + + true + + + + + + \ No newline at end of file diff --git a/cucumber-maven-plugin/src/main/java/de/saumya/mojo/cucumber/CucumberMavenTestScriptFactory.java b/cucumber-maven-plugin/src/main/java/de/saumya/mojo/cucumber/CucumberMavenTestScriptFactory.java new file mode 100644 index 00000000..cdd9a402 --- /dev/null +++ b/cucumber-maven-plugin/src/main/java/de/saumya/mojo/cucumber/CucumberMavenTestScriptFactory.java @@ -0,0 +1,52 @@ +package de.saumya.mojo.cucumber; + +import de.saumya.mojo.tests.AbstractMavenTestScriptFactory; + +public class CucumberMavenTestScriptFactory extends AbstractMavenTestScriptFactory { + + @Override + protected void getRunnerScript(StringBuilder builder) { + builder.append("cucumber_report_path = REPORT_PATH + '_tmp'\n"); + builder.append("at_exit do\n"); + builder.append(" # create test like result files\n"); + builder.append("\n"); + builder.append(" require 'rexml/document'\n"); + builder.append(" require 'fileutils'\n"); + builder.append(" FileUtils.mkdir_p(REPORT_PATH)\n"); + builder.append(" tests, errors, failures, skips, time = 0, 0, 0, 0, 0.0\n"); + builder.append(" Dir[File.join(cucumber_report_path, '*xml')].each do |report|\n"); + builder.append(" doc = REXML::Document.new(File.new(report))\n"); + builder.append(" suite = REXML::XPath.first(doc, '//testsuite')\n"); + builder.append(" tests += suite.attributes['tests'].to_i\n"); + builder.append(" errors += suite.attributes['errors'].to_i\n"); + builder.append(" failures += suite.attributes['failures'].to_i\n"); + builder.append(" skips += suite.attributes['skips'].to_i\n"); + builder.append(" time += suite.attributes['time'].to_f\n"); + builder.append(" FileUtils.move(report, File.join(REPORT_PATH, " + + "File.basename(report).sub(/\\.xml/, \"-#{JRUBY_VERSION}--#{RUBY_VERSION.sub(/([0-9]\\.[0-9])\\..*$/) { $1 }}.xml\")))\n"); + builder.append(" end\n"); + builder.append(" FileUtils.rm_rf(cucumber_report_path)\n"); + builder.append(" cucumber_summary = File.join(TARGET_DIR, 'cucumber.txt')\n"); + builder.append(" File.open(cucumber_summary, 'w') do |f|\n"); + builder.append(" f.puts \"Finished tests in #{time}s.\"\n"); + builder.append(" f.puts \"#{tests} tests, 0 assertions, #{failures} failures, #{errors} errors, #{skips} skips\"\n"); + builder.append(" end\n"); + builder.append("end\n"); + builder.append("\n"); + builder.append("require 'rubygems'\n"); + builder.append("gem 'cucumber'\n"); + builder.append("argv = ['-f', 'pretty', '-f', 'junit', '-o', cucumber_report_path] + ARGV\n"); + builder.append("ARGV.replace(argv)\n"); + builder.append("load Gem.bin_path('cucumber', 'cucumber')\n"); + builder.append("\n"); + } + + @Override + protected void getResultsScript(StringBuilder builder) { + } + + @Override + protected String getScriptName() { + return "cucumber-runner.rb"; + } +} \ No newline at end of file diff --git a/cucumber-maven-plugin/src/main/java/de/saumya/mojo/cucumber/CucumberMojo.java b/cucumber-maven-plugin/src/main/java/de/saumya/mojo/cucumber/CucumberMojo.java new file mode 100644 index 00000000..d57cc44c --- /dev/null +++ b/cucumber-maven-plugin/src/main/java/de/saumya/mojo/cucumber/CucumberMojo.java @@ -0,0 +1,105 @@ +package de.saumya.mojo.cucumber; + +import java.io.File; +import java.io.IOException; + +import org.apache.maven.plugin.MojoExecutionException; +import org.apache.maven.plugin.MojoFailureException; + +import de.saumya.mojo.jruby.JRubyVersion; +import de.saumya.mojo.jruby.JRubyVersion.Mode; +import de.saumya.mojo.ruby.script.Script; +import de.saumya.mojo.ruby.script.ScriptException; +import de.saumya.mojo.ruby.script.ScriptFactory; +import de.saumya.mojo.tests.AbstractTestMojo; +import de.saumya.mojo.tests.JRubyRun.Result; +import de.saumya.mojo.tests.TestResultManager; +import de.saumya.mojo.tests.TestScriptFactory; +import org.apache.maven.plugins.annotations.LifecyclePhase; +import org.apache.maven.plugins.annotations.Mojo; +import org.apache.maven.plugins.annotations.Parameter; +import org.apache.maven.plugins.annotations.ResolutionScope; + +/** + * maven wrapper around the cucumber command. + */ +@Mojo(name = "test", defaultPhase = LifecyclePhase.TEST, requiresDependencyResolution = ResolutionScope.TEST) +public class CucumberMojo extends AbstractTestMojo { + + enum ResultEnum { + ERRORS, FAILURES, SKIPPED, TEST + } + + /** + * cucumber features directory to be used for the cucumber command. + */ + @Parameter(property = "cucumber.dir", defaultValue = "features") + private final File cucumberDirectory = null; + + /** + * arguments for the cucumber command. + */ + @Parameter(property = "cucumber.args") + private final String cucumberArgs = null; + + @Parameter(property = "skipCucumber", defaultValue ="false") + protected boolean skipCucumber = false; + + private TestResultManager resultManager; + private File outputfile; + + @Override + public void execute() throws MojoExecutionException, MojoFailureException { + if (this.skip || this.skipTests || this.skipCucumber) { + getLog().info("Skipping Cucumber tests"); + } + else { + if (this.project.getBasedir() != null && + this.cucumberDirectory != null && !this.cucumberDirectory.exists() && + this.args == null) { + getLog().info("Skipping cucumber tests since " + this.cucumberDirectory + " is missing"); + } + else { + outputfile = new File(this.project.getBuild().getDirectory() + .replace("${project.basedir}/", ""), "cucumber.txt"); + if (outputfile.exists()){ + outputfile.delete(); + } + resultManager = new TestResultManager(summaryReport); + getLog().debug("Running Cucumber tests from " + this.cucumberDirectory); + super.execute(); + } + } + } + + @Override + protected TestScriptFactory newTestScriptFactory() { + return new CucumberMavenTestScriptFactory(); + } + + @Override + protected Result runIt(ScriptFactory factory, Mode mode, final JRubyVersion version, TestScriptFactory scriptFactory) + throws IOException, ScriptException, MojoExecutionException { + scriptFactory.setSourceDir(new File(".")); + scriptFactory.emit(); + + final Script script = factory.newScript(scriptFactory.getCoreScript()); + if (this.cucumberArgs != null) { + script.addArgs(this.cucumberArgs); + } + if (this.args != null) { + script.addArgs(this.args); + } + if (this.cucumberDirectory != null) { + script.addArg(this.cucumberDirectory); + } + + try { + script.executeIn(launchDirectory()); + } catch (Exception e) { + getLog().debug("exception in running tests", e); + } + + return resultManager.generateReports(mode, version, outputfile); + } +} diff --git a/gem-assembly-descriptors/pom.xml b/gem-assembly-descriptors/pom.xml new file mode 100644 index 00000000..5f1a70d6 --- /dev/null +++ b/gem-assembly-descriptors/pom.xml @@ -0,0 +1,123 @@ + + + 4.0.0 + + jruby-maven-plugins + org.jruby.maven + 3.0.3-SNAPSHOT + + gem-assembly-descriptors + 3.0.3-SNAPSHOT + Assembly Descriptors with the Gems + + + org.jruby + jruby-complete + ${jruby.version} + + + org.jruby.maven + gem-maven-plugin + ${project.version} + test + + + + + + + + org.eclipse.m2e + lifecycle-mapping + 1.0.0 + + + + + + + org.apache.maven.plugins + + + maven-plugin-plugin + + + [2.5.1,) + + + helpmojo + + + + + + + + + + org.codehaus.mojo + + + build-helper-maven-plugin + + + [1.4,) + + + add-source + + + + + + + + + + + + + + + + integration-test + + true + + + install + + + maven-invoker-plugin + 1.5 + + src/it + ${project.build.directory}/it + setup.bsh + verify.bsh + + + + integration-test + + install + run + + + + + + + + + + + + all + + false + + + + diff --git a/gem-assembly-descriptors/src/it/assemble-project-with-gems/application/application.gemspec b/gem-assembly-descriptors/src/it/assemble-project-with-gems/application/application.gemspec new file mode 100644 index 00000000..dd246e52 --- /dev/null +++ b/gem-assembly-descriptors/src/it/assemble-project-with-gems/application/application.gemspec @@ -0,0 +1,10 @@ +# create by maven - leave it as is +Gem::Specification.new do |s| + s.name = 'application' + s.version = '0.0.0' + + s.summary = 'application' + + + s.add_dependency 'ruby-world', '0.0.0' +end \ No newline at end of file diff --git a/gem-assembly-descriptors/src/it/assemble-project-with-gems/application/bin/hello b/gem-assembly-descriptors/src/it/assemble-project-with-gems/application/bin/hello new file mode 100644 index 00000000..be14acc7 --- /dev/null +++ b/gem-assembly-descriptors/src/it/assemble-project-with-gems/application/bin/hello @@ -0,0 +1,5 @@ +require 'hello' +puts Hello.new.world + +require 'java' +puts com.example.Hello.new.world diff --git a/gem-assembly-descriptors/src/it/assemble-project-with-gems/application/pom.xml b/gem-assembly-descriptors/src/it/assemble-project-with-gems/application/pom.xml new file mode 100644 index 00000000..ff656785 --- /dev/null +++ b/gem-assembly-descriptors/src/it/assemble-project-with-gems/application/pom.xml @@ -0,0 +1,109 @@ + + + 4.0.0 + rubygems + application + 0.0.0 + jar + + + + mavengems + mavengem:https://rubygems.org + + + + + + rubygems + ruby-world + 0.0.0 + gem + + + com.example + java-world + 0.0.0 + + + org.jruby + jruby-complete + 1.6.6 + + + org.jruby.maven + gem-assembly-descriptors + @project.version@ + runtime + + + + ${project.build.directory}/rubygems + + + + + org.jruby.maven + gem-maven-plugin + @project.parent.version@ + + + + initialize + + + + + + maven-assembly-plugin + 2.2-beta-5 + + + jar-with-dependencies-and-gems + + + + de.saumya.mojo.assembly.Main + + + + + + package + + assembly + + + + + + org.jruby.maven + gem-assembly-descriptors + @project.version@ + + + + + org.codehaus.mojo + exec-maven-plugin + 1.1 + + + verify + + exec + + + + + java + + -jar + ${project.build.directory}/${project.build.finalName}-jar-with-dependencies-and-gems.jar + hello + + + + + + diff --git a/gem-assembly-descriptors/src/it/assemble-project-with-gems/invoker.properties b/gem-assembly-descriptors/src/it/assemble-project-with-gems/invoker.properties new file mode 100644 index 00000000..7debd1cf --- /dev/null +++ b/gem-assembly-descriptors/src/it/assemble-project-with-gems/invoker.properties @@ -0,0 +1,3 @@ +invoker.goals = install +invoker.mavenOpts = -client + diff --git a/gem-assembly-descriptors/src/it/assemble-project-with-gems/java-world/pom.xml b/gem-assembly-descriptors/src/it/assemble-project-with-gems/java-world/pom.xml new file mode 100644 index 00000000..0b88357e --- /dev/null +++ b/gem-assembly-descriptors/src/it/assemble-project-with-gems/java-world/pom.xml @@ -0,0 +1,9 @@ + + 4.0.0 + com.example + java-world + jar + 0.0.0 + java-world + diff --git a/gem-assembly-descriptors/src/it/assemble-project-with-gems/java-world/src/main/java/com/example/Hello.java b/gem-assembly-descriptors/src/it/assemble-project-with-gems/java-world/src/main/java/com/example/Hello.java new file mode 100644 index 00000000..75ecbb9f --- /dev/null +++ b/gem-assembly-descriptors/src/it/assemble-project-with-gems/java-world/src/main/java/com/example/Hello.java @@ -0,0 +1,13 @@ +package com.example; + +/** + * Hello world! + * + */ +public class Hello +{ + public String world() + { + return "Hello Java World!"; + } +} diff --git a/gem-assembly-descriptors/src/it/assemble-project-with-gems/pom.xml b/gem-assembly-descriptors/src/it/assemble-project-with-gems/pom.xml new file mode 100644 index 00000000..ad0cd248 --- /dev/null +++ b/gem-assembly-descriptors/src/it/assemble-project-with-gems/pom.xml @@ -0,0 +1,15 @@ + + + 4.0.0 + com.example + small-project + pom + 0.0.0 + play ground for gem testing + + + java-world + ruby-world + application + + diff --git a/gem-assembly-descriptors/src/it/assemble-project-with-gems/ruby-world/lib/hello.rb b/gem-assembly-descriptors/src/it/assemble-project-with-gems/ruby-world/lib/hello.rb new file mode 100644 index 00000000..e8e9dba2 --- /dev/null +++ b/gem-assembly-descriptors/src/it/assemble-project-with-gems/ruby-world/lib/hello.rb @@ -0,0 +1,7 @@ +class Hello + + def world + "hello ruby world" + end + +end diff --git a/gem-assembly-descriptors/src/it/assemble-project-with-gems/ruby-world/pom.xml b/gem-assembly-descriptors/src/it/assemble-project-with-gems/ruby-world/pom.xml new file mode 100644 index 00000000..e72c8985 --- /dev/null +++ b/gem-assembly-descriptors/src/it/assemble-project-with-gems/ruby-world/pom.xml @@ -0,0 +1,26 @@ + + + 4.0.0 + rubygems + ruby-world + 0.0.0 + gem + + + + mavengems + mavengem:https://rubygems.org + + + + + + + org.jruby.maven + gem-maven-plugin + @project.parent.version@ + true + + + + diff --git a/gem-assembly-descriptors/src/it/assemble-project-with-gems/ruby-world/ruby-world.gemspec b/gem-assembly-descriptors/src/it/assemble-project-with-gems/ruby-world/ruby-world.gemspec new file mode 100644 index 00000000..a60979c8 --- /dev/null +++ b/gem-assembly-descriptors/src/it/assemble-project-with-gems/ruby-world/ruby-world.gemspec @@ -0,0 +1,10 @@ +# create by maven - leave it as is +Gem::Specification.new do |s| + s.name = 'ruby-world' + s.version = '0.0.0' + + s.summary = 'ruby-world' + + + s.files = Dir['lib/**/*'] +end \ No newline at end of file diff --git a/gem-assembly-descriptors/src/it/assemble-project-with-gems/verify.bsh b/gem-assembly-descriptors/src/it/assemble-project-with-gems/verify.bsh new file mode 100644 index 00000000..162fd24b --- /dev/null +++ b/gem-assembly-descriptors/src/it/assemble-project-with-gems/verify.bsh @@ -0,0 +1,16 @@ +import java.io.*; +import org.codehaus.plexus.util.FileUtils; + + +String log = FileUtils.fileRead( new File( basedir, "build.log" ) ); +String expected = "hello ruby world"; +if ( !log.contains( expected ) ) +{ + throw new RuntimeException( "log file does not contain '" + expected + "'" ); +} + +expected = "Hello Java World!"; +if ( !log.contains( expected ) ) +{ + throw new RuntimeException( "log file does not contain '" + expected + "'" ); +} \ No newline at end of file diff --git a/gem-assembly-descriptors/src/it/assemble-project-without-gems/application/application.gemspec b/gem-assembly-descriptors/src/it/assemble-project-without-gems/application/application.gemspec new file mode 100644 index 00000000..dd246e52 --- /dev/null +++ b/gem-assembly-descriptors/src/it/assemble-project-without-gems/application/application.gemspec @@ -0,0 +1,10 @@ +# create by maven - leave it as is +Gem::Specification.new do |s| + s.name = 'application' + s.version = '0.0.0' + + s.summary = 'application' + + + s.add_dependency 'ruby-world', '0.0.0' +end \ No newline at end of file diff --git a/gem-assembly-descriptors/src/it/assemble-project-without-gems/application/bin/hello b/gem-assembly-descriptors/src/it/assemble-project-without-gems/application/bin/hello new file mode 100644 index 00000000..d52bd733 --- /dev/null +++ b/gem-assembly-descriptors/src/it/assemble-project-without-gems/application/bin/hello @@ -0,0 +1,9 @@ +begin + require 'hello' + puts Hello.new.world +rescue LoadError + puts 'no ruby hello found' +end + +require 'java' +puts com.example.Hello.new.world diff --git a/gem-assembly-descriptors/src/it/assemble-project-without-gems/application/pom.xml b/gem-assembly-descriptors/src/it/assemble-project-without-gems/application/pom.xml new file mode 100644 index 00000000..db9be552 --- /dev/null +++ b/gem-assembly-descriptors/src/it/assemble-project-without-gems/application/pom.xml @@ -0,0 +1,113 @@ + + + 4.0.0 + rubygems + application + 0.0.0 + jar + + + + mavengems + mavengem:https://rubygems.org + + + + + + rubygems + ruby-world + 0.0.0 + gem + + + com.example + java-world + 0.0.0 + + + org.jruby + jruby-complete + 1.6.6 + + + org.jruby.maven + gem-assembly-descriptors + @project.version@ + runtime + + + + + + maven-compiler-plugin + 3.1 + + 1.6 + 1.6 + + + + org.jruby.maven + gem-maven-plugin + @project.parent.version@ + + + + initialize + + + + + + maven-assembly-plugin + 2.2-beta-5 + + + jar-with-dependencies-without-gems + + + + com.example.assembly.Main + + + + + + package + + assembly + + + + + + org.jruby.maven + gem-assembly-descriptors + @project.version@ + + + + + org.codehaus.mojo + exec-maven-plugin + 1.1 + + + verify + + exec + + + + + java + + -jar + ${project.build.directory}/${project.build.finalName}-jar-with-dependencies-without-gems.jar + + + + + + diff --git a/gem-assembly-descriptors/src/it/assemble-project-without-gems/application/src/main/java/com/example/assembly/Main.java b/gem-assembly-descriptors/src/it/assemble-project-without-gems/application/src/main/java/com/example/assembly/Main.java new file mode 100644 index 00000000..6914794d --- /dev/null +++ b/gem-assembly-descriptors/src/it/assemble-project-without-gems/application/src/main/java/com/example/assembly/Main.java @@ -0,0 +1,25 @@ +package com.example.assembly; + +import com.example.Hello; + +import javax.script.ScriptEngine; +import javax.script.ScriptEngineManager; +import javax.script.SimpleBindings; + +class Main { + + public static void main(String... args) throws Exception { + ScriptEngineManager manager = new ScriptEngineManager(); + ScriptEngine engine = manager.getEngineByName("jruby"); + engine.eval("require 'rubygems';"); + + System.out.println(engine.eval("begin\n" + + "require 'hello'\n" + + "Hello.new.world\n" + + "rescue LoadError\n" + + "'no ruby hello found'\n" + + "end")); + + System.out.println(new Hello().world()); + } +} diff --git a/gem-assembly-descriptors/src/it/assemble-project-without-gems/invoker.properties b/gem-assembly-descriptors/src/it/assemble-project-without-gems/invoker.properties new file mode 100644 index 00000000..7debd1cf --- /dev/null +++ b/gem-assembly-descriptors/src/it/assemble-project-without-gems/invoker.properties @@ -0,0 +1,3 @@ +invoker.goals = install +invoker.mavenOpts = -client + diff --git a/gem-assembly-descriptors/src/it/assemble-project-without-gems/java-world/pom.xml b/gem-assembly-descriptors/src/it/assemble-project-without-gems/java-world/pom.xml new file mode 100644 index 00000000..5b2420f6 --- /dev/null +++ b/gem-assembly-descriptors/src/it/assemble-project-without-gems/java-world/pom.xml @@ -0,0 +1,21 @@ + + 4.0.0 + com.example + java-world + jar + 0.0.0 + java-world + + + + maven-compiler-plugin + 3.1 + + 1.6 + 1.6 + + + + + diff --git a/gem-assembly-descriptors/src/it/assemble-project-without-gems/java-world/src/main/java/com/example/Hello.java b/gem-assembly-descriptors/src/it/assemble-project-without-gems/java-world/src/main/java/com/example/Hello.java new file mode 100644 index 00000000..75ecbb9f --- /dev/null +++ b/gem-assembly-descriptors/src/it/assemble-project-without-gems/java-world/src/main/java/com/example/Hello.java @@ -0,0 +1,13 @@ +package com.example; + +/** + * Hello world! + * + */ +public class Hello +{ + public String world() + { + return "Hello Java World!"; + } +} diff --git a/gem-assembly-descriptors/src/it/assemble-project-without-gems/pom.xml b/gem-assembly-descriptors/src/it/assemble-project-without-gems/pom.xml new file mode 100644 index 00000000..ad0cd248 --- /dev/null +++ b/gem-assembly-descriptors/src/it/assemble-project-without-gems/pom.xml @@ -0,0 +1,15 @@ + + + 4.0.0 + com.example + small-project + pom + 0.0.0 + play ground for gem testing + + + java-world + ruby-world + application + + diff --git a/gem-assembly-descriptors/src/it/assemble-project-without-gems/ruby-world/lib/hello.rb b/gem-assembly-descriptors/src/it/assemble-project-without-gems/ruby-world/lib/hello.rb new file mode 100644 index 00000000..e8e9dba2 --- /dev/null +++ b/gem-assembly-descriptors/src/it/assemble-project-without-gems/ruby-world/lib/hello.rb @@ -0,0 +1,7 @@ +class Hello + + def world + "hello ruby world" + end + +end diff --git a/gem-assembly-descriptors/src/it/assemble-project-without-gems/ruby-world/pom.xml b/gem-assembly-descriptors/src/it/assemble-project-without-gems/ruby-world/pom.xml new file mode 100644 index 00000000..e72c8985 --- /dev/null +++ b/gem-assembly-descriptors/src/it/assemble-project-without-gems/ruby-world/pom.xml @@ -0,0 +1,26 @@ + + + 4.0.0 + rubygems + ruby-world + 0.0.0 + gem + + + + mavengems + mavengem:https://rubygems.org + + + + + + + org.jruby.maven + gem-maven-plugin + @project.parent.version@ + true + + + + diff --git a/gem-assembly-descriptors/src/it/assemble-project-without-gems/ruby-world/ruby-world.gemspec b/gem-assembly-descriptors/src/it/assemble-project-without-gems/ruby-world/ruby-world.gemspec new file mode 100644 index 00000000..a60979c8 --- /dev/null +++ b/gem-assembly-descriptors/src/it/assemble-project-without-gems/ruby-world/ruby-world.gemspec @@ -0,0 +1,10 @@ +# create by maven - leave it as is +Gem::Specification.new do |s| + s.name = 'ruby-world' + s.version = '0.0.0' + + s.summary = 'ruby-world' + + + s.files = Dir['lib/**/*'] +end \ No newline at end of file diff --git a/gem-assembly-descriptors/src/it/assemble-project-without-gems/verify.bsh b/gem-assembly-descriptors/src/it/assemble-project-without-gems/verify.bsh new file mode 100644 index 00000000..689d562d --- /dev/null +++ b/gem-assembly-descriptors/src/it/assemble-project-without-gems/verify.bsh @@ -0,0 +1,16 @@ +import java.io.*; +import org.codehaus.plexus.util.FileUtils; + + +String log = FileUtils.fileRead( new File( basedir, "build.log" ) ); +String expected = "no ruby hello found"; +if ( !log.contains( expected ) ) +{ + throw new RuntimeException( "log file does not contain '" + expected + "'" ); +} + +expected = "Hello Java World!"; +if ( !log.contains( expected ) ) +{ + throw new RuntimeException( "log file does not contain '" + expected + "'" ); +} diff --git a/gem-assembly-descriptors/src/it/settings.xml b/gem-assembly-descriptors/src/it/settings.xml new file mode 100644 index 00000000..bdd67535 --- /dev/null +++ b/gem-assembly-descriptors/src/it/settings.xml @@ -0,0 +1,45 @@ + + + + + it-repo + + true + + + + local.central + @localRepositoryUrl@ + + true + + + true + + + + local.rubygems-releases + @localRepositoryUrl@ + + true + + + false + + + + + + local.central + @localRepositoryUrl@ + + true + + + true + + + + + + \ No newline at end of file diff --git a/gem-assembly-descriptors/src/main/java/de/saumya/mojo/assembly/Main.java b/gem-assembly-descriptors/src/main/java/de/saumya/mojo/assembly/Main.java new file mode 100644 index 00000000..1c513d3a --- /dev/null +++ b/gem-assembly-descriptors/src/main/java/de/saumya/mojo/assembly/Main.java @@ -0,0 +1,19 @@ +package de.saumya.mojo.assembly; + +import javax.script.ScriptEngine; +import javax.script.ScriptEngineManager; + +public class Main { + + public static void main(String... args) throws Exception { + if (args.length == 0){ + System.err.println("missing name of bin-script as argument"); + System.exit(-1); + } + ScriptEngineManager manager = new ScriptEngineManager(); + ScriptEngine engine = manager.getEngineByName("jruby"); + engine.eval("require 'rubygems'"); + engine.eval("ARGV.delete_at(0)"); + engine.eval("load '" + args[0] + "'"); + } +} diff --git a/gem-assembly-descriptors/src/main/resources/assemblies/jar-with-dependencies-and-gems.xml b/gem-assembly-descriptors/src/main/resources/assemblies/jar-with-dependencies-and-gems.xml new file mode 100644 index 00000000..192d4a3a --- /dev/null +++ b/gem-assembly-descriptors/src/main/resources/assemblies/jar-with-dependencies-and-gems.xml @@ -0,0 +1,45 @@ + + jar-with-dependencies-and-gems + + jar + + false + + + / + + ${project.basedir}/bin + + * + + + + / + + ${gem.home}/bin + + * + + + + / + + ${gem.home} + + gems/** + specifications/** + + + + + + / + true + true + runtime + + *:gem:* + + + + diff --git a/gem-assembly-descriptors/src/main/resources/assemblies/jar-with-dependencies-without-gems.xml b/gem-assembly-descriptors/src/main/resources/assemblies/jar-with-dependencies-without-gems.xml new file mode 100644 index 00000000..deb2314d --- /dev/null +++ b/gem-assembly-descriptors/src/main/resources/assemblies/jar-with-dependencies-without-gems.xml @@ -0,0 +1,18 @@ + + jar-with-dependencies-without-gems + + jar + + false + + + / + true + true + runtime + + *:gem:* + + + + diff --git a/gem-maven-plugin/src/it/support-native-extensions/pending-pom.xml b/gem-maven-plugin/src/it/support-native-extensions/pending-pom.xml index c1bd4987..74aac734 100644 --- a/gem-maven-plugin/src/it/support-native-extensions/pending-pom.xml +++ b/gem-maven-plugin/src/it/support-native-extensions/pending-pom.xml @@ -5,8 +5,8 @@ 0.0.0 - target/rubygems-releases - http://target/rubygems-proxy.torquebox.org/releases + mavengems + mavengem:https://rubygems.org diff --git a/pom.xml b/pom.xml index 04e80954..076a268e 100644 --- a/pom.xml +++ b/pom.xml @@ -172,9 +172,13 @@ jruby-maven-plugin gem-maven-plugin rspec-maven-plugin + cucumber-maven-plugin + gem-assembly-descriptors ruby-tools + rake-maven-plugin runit-maven-plugin minitest-maven-plugin + bundler-maven-plugin gem-extension gem-with-jar-extension diff --git a/rake-maven-plugin/pom.xml b/rake-maven-plugin/pom.xml index 322d7e32..11de32c2 100644 --- a/rake-maven-plugin/pom.xml +++ b/rake-maven-plugin/pom.xml @@ -4,7 +4,7 @@ gem-parent-mojo org.jruby.maven - 2.0.1-SNAPSHOT + 3.0.3-SNAPSHOT ../gem-parent-mojo/pom.xml rake-maven-plugin