Skip to content

Commit

Permalink
Much closer, should have been more commits
Browse files Browse the repository at this point in the history
Tests pass, but one shouldn't, looking into it.
  • Loading branch information
LightGuard committed Jan 25, 2013
1 parent c6237de commit 45d325d
Show file tree
Hide file tree
Showing 879 changed files with 73,615 additions and 25 deletions.
54 changes: 35 additions & 19 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>

<groupId>org.asciidoc</groupId>
<artifactId>maven-asciidoctor-plugin</artifactId>
<artifactId>asciidoctor-maven-plugin</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>maven-plugin</packaging>

Expand Down Expand Up @@ -75,21 +75,21 @@
</dependency>
<dependency>
<groupId>org.jruby</groupId>
<artifactId>jruby</artifactId>
<artifactId>jruby-complete</artifactId>
<version>${jruby.version}</version>
<scope>compile</scope>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.spockframework</groupId>
<artifactId>spock-core</artifactId>
<version>${spock.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<version>3.1</version>
</dependency>
<!--<dependency>-->
<!--<groupId>org.apache.maven.plugins</groupId>-->
<!--<artifactId>maven-site-plugin</artifactId>-->
<!--<version>3.1</version>-->
<!--</dependency>-->
</dependencies>

<build>
Expand All @@ -99,7 +99,7 @@
<artifactId>maven-plugin-plugin</artifactId>
<version>3.1</version>
<configuration>
<goalPrefix>maven-asciidoctor-plugin</goalPrefix>
<goalPrefix>asciidoctor</goalPrefix>
<skipErrorNoDescriptorsFound>true</skipErrorNoDescriptorsFound>
</configuration>
<executions>
Expand All @@ -109,25 +109,41 @@
<goal>descriptor</goal>
</goals>
</execution>
<execution>
<id>help-goal</id>
<goals>
<goal>helpmojo</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.spockframework</groupId>
<artifactId>spock-maven</artifactId>
<version>${spock.version}</version>
<groupId>org.codehaus.gmaven</groupId>
<artifactId>gmaven-plugin</artifactId>
<version>1.4</version>
<configuration>
<providerSelection>2.0</providerSelection>
</configuration>
<executions>
<execution>
<goals>
<goal>find-specs</goal>
<goal>compile</goal>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.codehaus.gmaven.runtime</groupId>
<artifactId>gmaven-runtime-2.0</artifactId>
<version>1.4</version>
<exclusions>
<exclusion>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
<version>2.0.5</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
Expand Down
34 changes: 28 additions & 6 deletions src/main/java/org/asciidoc/maven/AsciidoctorMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@
package org.asciidoc.maven;

import java.io.File;
import java.io.InputStream;
import java.io.InputStreamReader;

import javax.script.Bindings;
import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
import javax.script.ScriptException;
import javax.script.SimpleBindings;

import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
Expand All @@ -26,7 +34,7 @@
@Mojo(name = "process-asciidoc")
public class AsciidoctorMojo extends AbstractMojo {
@Parameter(property = "sourceDir", defaultValue = "${basedir}/src/asciidoc", required = true)
protected File siteDirectory;
protected File sourceDirectory;

@Parameter(property = "outputDir", defaultValue = "${project.build.directory}", required = true)
protected File outputDirectory;
Expand All @@ -36,15 +44,29 @@ public class AsciidoctorMojo extends AbstractMojo {

@Override
public void execute() throws MojoExecutionException, MojoFailureException {
//To change body of implemented methods use File | Settings | File Templates.
final ScriptEngineManager engineManager = new ScriptEngineManager();
final ScriptEngine rubyEngine = engineManager.getEngineByName("jruby");
final Bindings bindings = new SimpleBindings();

bindings.put("srcDir", sourceDirectory.getAbsolutePath());
bindings.put("outputDir", outputDirectory.getAbsolutePath());
bindings.put("backend", backend);

try {
final InputStream script = AbstractMojo.class.getClassLoader().getResourceAsStream("execute_asciidoctor.rb");
final InputStreamReader streamReader = new InputStreamReader(script);
rubyEngine.eval(streamReader, bindings);
} catch (ScriptException e) {
getLog().error("Error running ruby script", e);
}
}

public File getSiteDirectory() {
return siteDirectory;
public File getSourceDirectory() {
return sourceDirectory;
}

public void setSiteDirectory(File siteDirectory) {
this.siteDirectory = siteDirectory;
public void setSourceDirectory(File sourceDirectory) {
this.sourceDirectory = sourceDirectory;
}

public File getOutputDirectory() {
Expand Down
19 changes: 19 additions & 0 deletions src/main/resources/bin/asciidoctor
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/bin/env ruby_noexec_wrapper
#
# This file was generated by RubyGems.
#
# The application 'asciidoctor' is installed as part of a gem, and
# this file is here to facilitate running it.
#

require 'rubygems'

version = ">= 0"

if ARGV.first =~ /^_(.*)_$/ and Gem::Version.correct? $1 then
version = $1
ARGV.shift
end

gem 'asciidoctor', version
load Gem.bin_path('asciidoctor', 'asciidoctor', version)
19 changes: 19 additions & 0 deletions src/main/resources/bin/tilt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/bin/env ruby_noexec_wrapper
#
# This file was generated by RubyGems.
#
# The application 'tilt' is installed as part of a gem, and
# this file is here to facilitate running it.
#

require 'rubygems'

version = ">= 0"

if ARGV.first =~ /^_(.*)_$/ and Gem::Version.correct? $1 then
version = $1
ARGV.shift
end

gem 'tilt', version
load Gem.bin_path('tilt', 'tilt', version)
Binary file added src/main/resources/cache/asciidoctor-0.0.9.gem
Binary file not shown.
Binary file added src/main/resources/cache/tilt-1.3.3.gem
Binary file not shown.
Loading

0 comments on commit 45d325d

Please sign in to comment.