-
-
Save ysb33r/3fd93c4253e8775d5571 to your computer and use it in GitHub Desktop.
// This is a first stab at trying to convert the asciidoctorj pom.xml to build.gradle | |
// Note the WORKAROUND. These are to work around problems with erubis. Gradle is much stricter | |
// about broken POMs that Maven. | |
// | |
// This had been done using some code which is is based on the current version of jruby-gradle-plugin, | |
// but with updates to fix shortcomings in the release 2.2.0 | |
// | |
// This requires Gradle 2.0 or better. | |
// | |
buildscript { | |
repositories { | |
mavenLocal() | |
jcenter() | |
} | |
dependencies { | |
classpath 'com.github.jrubygradle:jruby-gradle-plugin:0.1.0-SNAPSHOT' | |
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:0.5' | |
} | |
} | |
// We temporarily set buildDir to somewhere else fo rhte sake of this experiment | |
buildDir = new File(projectDir,'buildGradle') | |
apply plugin: 'java' | |
apply plugin: 'maven' | |
apply plugin: 'com.lookout.jruby' | |
apply plugin: 'com.jfrog.bintray' | |
repositories { | |
maven { | |
url 'http://rubygems-proxy.torquebox.org/prereleases' | |
name 'rubygems-prerelease' | |
} | |
// WORKAROUND: for broken some POMs on Rubygems | |
// We also make this the last repository that will be checked. | |
ivy { | |
url 'http://rubygems-proxy.torquebox.org/releases' | |
name 'brokenRubyGems' | |
layout('pattern') { | |
artifact 'rubygems/[module]/[revision]/[artifact]-[revision].[ext]' | |
m2compatible = true | |
} | |
} | |
} | |
group = 'org.asciidoctor' | |
// module = asciidoctorj | |
version = '1.5.1-SNAPSHOT' | |
ext { | |
jruby_version = '1.7.9' | |
junit_version = '4.11' | |
jsoup_version = '1.7.3' | |
xmlmatchers_version = '1.0-RC1' | |
hamcrest_version = '1.3' | |
guava_version = '15.0' | |
haml_version = '4.0.4' | |
tilt_version = '2.0.0' | |
coderay_version = '1.1.0' | |
cacheUri_version = '0.0.5' | |
threadsafe_version = '0.3.4' | |
asciidoctor_epub3_version = '1.0.0.alpha.3' | |
asciidoctor_version = '1.5.0' | |
erubis_version = '2.7.0' | |
slim_version = '2.0.2' | |
jcommander_version = '1.32' | |
slf4_version = '1.7.5' | |
} | |
dependencies { | |
compile "org.slf4j:slf4j-api:${slf4_version}" | |
compile "org.jruby:jruby-complete:${jruby_version}" | |
testCompile "junit:junit:${junit_version}" | |
testCompile ("org.xmlmatchers:xml-matchers:${xmlmatchers_version}") { | |
exclude module : 'Saxon-HE' | |
} | |
testCompile "net.sf.saxon:Saxon-HE:9.5.1-6" | |
testCompile "org.hamcrest:hamcrest-library:${hamcrest_version}" | |
testCompile "com.google.guava:guava:${guava_version}" | |
testCompile "org.jsoup:jsoup:${jsoup_version}" | |
gems "rubygems:thread_safe:${threadsafe_version}" | |
gems "rubygems:haml:${haml_version}" | |
gems "rubygems:open-uri-cached:${cacheUri_version}" | |
gems "rubygems:asciidoctor:${asciidoctor_version}" | |
gems "rubygems:coderay:${coderay_version}" | |
gems "rubygems:asciidoctor-epub3:${asciidoctor_epub3_version}-SNAPSHOT" | |
gems "rubygems:tilt:${tilt_version}" | |
// WORKAROUND: for broken some POMs on Rubygems | |
gems "brokenGem:erubis:${erubis_version}@gem" | |
gems "rubygems:slim:${slim_version}" | |
compile "com.beust:jcommander:${jcommander_version}" | |
testRuntime "org.slf4j:slf4j-simple:${slf4_version}" | |
} | |
if( !hasProperty( 'bintrayUser' ) ) | |
ext.bintrayUser = '' | |
if( !hasProperty( 'bintrayKey' ) ) | |
ext.bintrayKey = '' | |
//jrubyJar { | |
// dependsOn jrubyPrepareGems | |
//} | |
// Might need to do some more work in the jruby-gradle-plugin | |
// to automatially add the 'gems'. Otherwise maybe we should | |
// update the plugn to to do this for jrubyJar and let asciidoctor | |
// use that instead | |
jar { | |
from (jruby.gemInstallDir) { | |
include 'gems/**' | |
} | |
manifest { | |
attributes 'Implementation-Version' : project.version | |
atributes 'Main-Class': 'org.asciidoctor.cli.AsciidoctorInvoker' | |
} | |
} | |
task sourcesJar(type: Jar, dependsOn: classes) { | |
classifier = 'sources' | |
from sourceSets.main.allSource | |
} | |
artifacts { | |
archives sourcesJar | |
} | |
// Some additional attributes might be needed to bintray. | |
bintray { | |
user = project.bintrayUser | |
key = project.bintrayKey | |
publish = true | |
dryRun = false | |
configurations = ['archives'] | |
pkg { | |
repo = 'bintray-lordofthejars-maven-asciidoctorj' | |
name = 'lordofthejars-maven-asciidoctorj' | |
labels = ['asciidoctor','asciidoc','asciidoctorj'] | |
version { | |
name = project.version | |
vcsTag = "v${project.version}" | |
desc = 'AsciidoctorJ provides Java bindings for the Asciidoctor RubyGem using JRuby' | |
} | |
} | |
// dependsOn 'jrubyJar' | |
} | |
Shouldn't the jruby-gradle-plugin coordinates be:
com.lookout:jruby-gradle-plugin:2.2.0-SNAPSHOT
Also, I'm getting an error with the attributes()
clause in the jar plugin.
Could not find method attributes() for arguments [build_2nbmvdcq2mt9icea588vvf5nms$_run_closure4_closure13@1e692555] on root project 'asciidoctorj'
In order to get the WhenEnvironmentVariablesAreSet test to work, you need to add the following to the Gradle build:
sourceSets.test.runtimeClasspath = sourceSets.test.runtimeClasspath + files(jruby.gemInstallDir)
That's because AsciidoctorJ assumes that the Asciidoctor gem (as well as a handful of others) are extracted and on the classpath always. The test is verifying that we can set a custom GEM_PATH / GEM_HOME and wipe out any external GEM_PATH / GEM_HOME that's being inherited by JRuby from the external environment. If the test fails when the extracted gems are not on the classpath, that means that AsciidoctorJ is doing what it's supposed to do, isolate the gem environment.
Btw, I wouldn't necessarily add this behavior to the JRuby Gradle plugin because this may be sort of a unique situation.
Another way to verify that the test works is to set the GEM_PATH using the GEM_PATH environment variable. Then, it should only use the gems in the location set by the plugin and not the ones that it is bundling.
I still think this is an area of AsciidoctorJ that needs some cleanup.
Btw, would you consider submitting this as a pull request? I imagine you have modifications that allow the tests to work as well since currently they hard code values to Maven output directories.
@mojavelinux the plugin has moved to jruby-gradle repository and is being split into smaller plugins. jrubyWar & jrubyJar is being moved out into separate plugins. It will come with a version reset. So my current code in the gist is pointing to a local snapshot. As soon as we get the next version out I'll submit the PR.
erubis POM is broken. If you pull the pom.xml you'll find it is invalid. Gradle is very strict about this. The root cause is being addressed - jruby/rubygems-servlets#4
Thanks for the sourceSets tip it works.
I did not realise that there were hard-coded values inside the tests. I'll have a look.
Nice work!
What's broken about the erubis gem? We should get that fixed.