Permalink
Browse files

resolves #194 migrate project to multi-module Gradle build

- add multi-module Gradle build
- remove Maven build script (pom.xml)
- setup Gradle wrapper
- relocate core to asciidoctorj-core subproject
- setup asciidoctorj-epub3, asciidoctorj-pdf and asciidoctorj-distribution subprojects
- move bundling of asciidoctorj-epub3 into separate jar
- define version and properName properties for each artifact in gradle.properties
- use JRuby Gradle plugin to manage gems
- bundle only essential sources from gems; copy to output folder of main source set
- configure Gradle to generate Eclipse and IDEA project files
- create distribution zip for AsciidoctorJ (bundles core, epub3 and pdf)
- use Gradle to generate start scripts for distribution
- optimize JVM flags for start scripts in distribution
- add additional information to manifest of artifacts
- configure install to local Maven repository
- configure signing (GPG) plugin
- configure upload to Bintray (creates package & version; includes distribution zip)
- update script to test against Asciidoctor upstream (using Maven to install gem)
- activate and fix broken iconfont test
- autoload asciidoctor-pdf gem when backend is set to pdf
  • Loading branch information...
1 parent b25ff5e commit a56733ac9a67e4f09a49a662dd915a674316b6d8 @mojavelinux mojavelinux committed Nov 29, 2014
Showing with 988 additions and 605 deletions.
  1. +8 −8 .gitignore
  2. +7 −12 .travis.yml
  3. +38 −0 asciidoctorj-core/build.gradle
  4. +2 −0 asciidoctorj-core/gradle.properties
  5. 0 { → asciidoctorj-core}/src/main/java/org/asciidoctor/AbstractDirectoryWalker.java
  6. 0 { → asciidoctorj-core}/src/main/java/org/asciidoctor/AsciiDocDirectoryWalker.java
  7. 0 { → asciidoctorj-core}/src/main/java/org/asciidoctor/Asciidoctor.java
  8. 0 { → asciidoctorj-core}/src/main/java/org/asciidoctor/Attributes.java
  9. 0 { → asciidoctorj-core}/src/main/java/org/asciidoctor/AttributesBuilder.java
  10. 0 { → asciidoctorj-core}/src/main/java/org/asciidoctor/CompatMode.java
  11. 0 { → asciidoctorj-core}/src/main/java/org/asciidoctor/DirectoryWalker.java
  12. 0 { → asciidoctorj-core}/src/main/java/org/asciidoctor/GlobDirectoryWalker.java
  13. 0 { → asciidoctorj-core}/src/main/java/org/asciidoctor/Options.java
  14. 0 { → asciidoctorj-core}/src/main/java/org/asciidoctor/OptionsBuilder.java
  15. 0 { → asciidoctorj-core}/src/main/java/org/asciidoctor/Placement.java
  16. 0 { → asciidoctorj-core}/src/main/java/org/asciidoctor/SafeMode.java
  17. 0 { → asciidoctorj-core}/src/main/java/org/asciidoctor/ast/AbstractBlock.java
  18. 0 { → asciidoctorj-core}/src/main/java/org/asciidoctor/ast/AbstractBlockImpl.java
  19. 0 { → asciidoctorj-core}/src/main/java/org/asciidoctor/ast/Author.java
  20. 0 { → asciidoctorj-core}/src/main/java/org/asciidoctor/ast/Block.java
  21. 0 { → asciidoctorj-core}/src/main/java/org/asciidoctor/ast/BlockImpl.java
  22. 0 { → asciidoctorj-core}/src/main/java/org/asciidoctor/ast/ContentPart.java
  23. 0 { → asciidoctorj-core}/src/main/java/org/asciidoctor/ast/Document.java
  24. 0 { → asciidoctorj-core}/src/main/java/org/asciidoctor/ast/DocumentHeader.java
  25. 0 { → asciidoctorj-core}/src/main/java/org/asciidoctor/ast/DocumentRuby.java
  26. 0 { → asciidoctorj-core}/src/main/java/org/asciidoctor/ast/Inline.java
  27. 0 { → asciidoctorj-core}/src/main/java/org/asciidoctor/ast/RevisionInfo.java
  28. 0 { → asciidoctorj-core}/src/main/java/org/asciidoctor/ast/Section.java
  29. 0 { → asciidoctorj-core}/src/main/java/org/asciidoctor/ast/SectionImpl.java
  30. 0 { → asciidoctorj-core}/src/main/java/org/asciidoctor/ast/StructuredDocument.java
  31. 0 { → asciidoctorj-core}/src/main/java/org/asciidoctor/ast/Title.java
  32. 0 { → asciidoctorj-core}/src/main/java/org/asciidoctor/cli/AsciidoctorCliOptions.java
  33. 0 { → asciidoctorj-core}/src/main/java/org/asciidoctor/cli/AsciidoctorInvoker.java
  34. 0 { → asciidoctorj-core}/src/main/java/org/asciidoctor/cli/DocTypeEnum.java
  35. 0 { → asciidoctorj-core}/src/main/java/org/asciidoctor/cli/SafeModeConverter.java
  36. 0 { → asciidoctorj-core}/src/main/java/org/asciidoctor/extension/BlockMacroProcessor.java
  37. 0 { → asciidoctorj-core}/src/main/java/org/asciidoctor/extension/BlockProcessor.java
  38. 0 { → asciidoctorj-core}/src/main/java/org/asciidoctor/extension/IncludeProcessor.java
  39. 0 { → asciidoctorj-core}/src/main/java/org/asciidoctor/extension/InlineMacroProcessor.java
  40. 0 { → asciidoctorj-core}/src/main/java/org/asciidoctor/extension/JavaExtensionRegistry.java
  41. 0 { → asciidoctorj-core}/src/main/java/org/asciidoctor/extension/MacroProcessor.java
  42. 0 { → asciidoctorj-core}/src/main/java/org/asciidoctor/extension/Postprocessor.java
  43. 0 { → asciidoctorj-core}/src/main/java/org/asciidoctor/extension/Preprocessor.java
  44. 0 { → asciidoctorj-core}/src/main/java/org/asciidoctor/extension/PreprocessorReader.java
  45. 0 { → asciidoctorj-core}/src/main/java/org/asciidoctor/extension/Processor.java
  46. 0 { → asciidoctorj-core}/src/main/java/org/asciidoctor/extension/Reader.java
  47. 0 { → asciidoctorj-core}/src/main/java/org/asciidoctor/extension/RubyExtensionRegistry.java
  48. 0 { → asciidoctorj-core}/src/main/java/org/asciidoctor/extension/Treeprocessor.java
  49. 0 ...sciidoctorj-core}/src/main/java/org/asciidoctor/extension/internal/ExtensionRegistryExecutor.java
  50. 0 { → asciidoctorj-core}/src/main/java/org/asciidoctor/extension/spi/ExtensionRegistry.java
  51. 0 { → asciidoctorj-core}/src/main/java/org/asciidoctor/internal/AsciidoctorModule.java
  52. 0 { → asciidoctorj-core}/src/main/java/org/asciidoctor/internal/AsciidoctorUtils.java
  53. 0 { → asciidoctorj-core}/src/main/java/org/asciidoctor/internal/CaseInsensitiveMap.java
  54. 0 { → asciidoctorj-core}/src/main/java/org/asciidoctor/internal/DefaultCssResolver.java
  55. 0 { → asciidoctorj-core}/src/main/java/org/asciidoctor/internal/EnvironmentInjector.java
  56. 0 { → asciidoctorj-core}/src/main/java/org/asciidoctor/internal/IOUtils.java
  57. 0 { → asciidoctorj-core}/src/main/java/org/asciidoctor/internal/JRubyAsciidoctor.java
  58. 0 { → asciidoctorj-core}/src/main/java/org/asciidoctor/internal/JRubyAsciidoctorModuleFactory.java
  59. 0 { → asciidoctorj-core}/src/main/java/org/asciidoctor/internal/JRubyRuntimeContext.java
  60. +5 −0 { → asciidoctorj-core}/src/main/java/org/asciidoctor/internal/RubyGemsPreloader.java
  61. 0 { → asciidoctorj-core}/src/main/java/org/asciidoctor/internal/RubyHashUtil.java
  62. 0 { → asciidoctorj-core}/src/main/java/org/asciidoctor/internal/RubyUtils.java
  63. 0 { → asciidoctorj-core}/src/main/resources/org/asciidoctor/internal/asciidoctorclass.rb
  64. 0 { → asciidoctorj-core}/src/test/java/org/asciidoctor/WhenAnAsciidoctorClassIsInstantiated.java
  65. 0 { → asciidoctorj-core}/src/test/java/org/asciidoctor/WhenAsciiDocIsRenderedToDocument.java
  66. +2 −6 { → asciidoctorj-core}/src/test/java/org/asciidoctor/WhenAttributesAreUsedInAsciidoctor.java
  67. 0 { → asciidoctorj-core}/src/test/java/org/asciidoctor/WhenCustomTemplatesAreUsed.java
  68. 0 { → asciidoctorj-core}/src/test/java/org/asciidoctor/WhenDirectoriesWithAsciidocFilesAreScanned.java
  69. 0 { → asciidoctorj-core}/src/test/java/org/asciidoctor/WhenDocumentHeaderIsRequired.java
  70. 0 { → asciidoctorj-core}/src/test/java/org/asciidoctor/WhenGlobExpressionIsUsedForScanning.java
  71. 0 { → asciidoctorj-core}/src/test/java/org/asciidoctor/WhenStructuredDocumentIsRequired.java
  72. 0 ...sciidoctorj-core}/src/test/java/org/asciidoctor/WhenUserRequiresTheAsciidoctorRuntimeVersion.java
  73. 0 { → asciidoctorj-core}/src/test/java/org/asciidoctor/cli/WhenAsciidoctorAPICallIsCalled.java
  74. 0 { → asciidoctorj-core}/src/test/java/org/asciidoctor/cli/WhenAsciidoctorIsCalledUsingCli.java
  75. 0 { → asciidoctorj-core}/src/test/java/org/asciidoctor/extension/ArrowsAndBoxesBlock.java
  76. 0 { → asciidoctorj-core}/src/test/java/org/asciidoctor/extension/ArrowsAndBoxesExtension.java
  77. 0 ...ciidoctorj-core}/src/test/java/org/asciidoctor/extension/ArrowsAndBoxesIncludesPostProcessor.java
  78. 0 { → asciidoctorj-core}/src/test/java/org/asciidoctor/extension/ChangeAttributeValuePreprocessor.java
  79. 0 { → asciidoctorj-core}/src/test/java/org/asciidoctor/extension/CustomFooterPostProcessor.java
  80. 0 { → asciidoctorj-core}/src/test/java/org/asciidoctor/extension/GistMacro.java
  81. 0 { → asciidoctorj-core}/src/test/java/org/asciidoctor/extension/HasMoreLinesPreprocessor.java
  82. 0 { → asciidoctorj-core}/src/test/java/org/asciidoctor/extension/ManpageMacro.java
  83. 0 { → asciidoctorj-core}/src/test/java/org/asciidoctor/extension/NextLineEmptyPreprocessor.java
  84. 0 { → asciidoctorj-core}/src/test/java/org/asciidoctor/extension/NumberLinesPreprocessor.java
  85. 0 { → asciidoctorj-core}/src/test/java/org/asciidoctor/extension/TerminalCommandTreeprocessor.java
  86. 0 { → asciidoctorj-core}/src/test/java/org/asciidoctor/extension/UriIncludeProcessor.java
  87. 0 ...sciidoctorj-core}/src/test/java/org/asciidoctor/extension/WhenExtensionIsRegisteredAsService.java
  88. 0 { → asciidoctorj-core}/src/test/java/org/asciidoctor/extension/WhenJavaExtensionIsRegistered.java
  89. 0 ...sciidoctorj-core}/src/test/java/org/asciidoctor/extension/WhenReaderIsManipulatedInExtension.java
  90. 0 { → asciidoctorj-core}/src/test/java/org/asciidoctor/extension/WhenRubyExtensionIsRegistered.java
  91. 0 { → asciidoctorj-core}/src/test/java/org/asciidoctor/extension/YellBlock.java
  92. 0 { → asciidoctorj-core}/src/test/java/org/asciidoctor/extension/YellStaticBlock.java
  93. 0 { → asciidoctorj-core}/src/test/java/org/asciidoctor/internal/WhenClassloaderIsRequired.java
  94. +1 −13 ...ciidoctorj-core}/src/test/java/org/asciidoctor/internal/WhenDocumentIsRenderedWithPreloading.java
  95. 0 { → asciidoctorj-core}/src/test/java/org/asciidoctor/internal/WhenEnvironmentVariablesAreSet.java
  96. 0 { → asciidoctorj-core}/src/test/java/org/asciidoctor/util/ClasspathHelper.java
  97. 0 { → asciidoctorj-core}/src/test/java/org/asciidoctor/util/ClasspathResources.java
  98. 0 { → asciidoctorj-core}/src/test/resources/YellRubyBlock.rb
  99. 0 { → asciidoctorj-core}/src/test/resources/appendix.asciidoc
  100. 0 { → asciidoctorj-core}/src/test/resources/arrows-and-boxes-example.ad
  101. 0 { → asciidoctorj-core}/src/test/resources/brokeninclude.asciidoc
  102. 0 { → asciidoctorj-core}/src/test/resources/changeattribute.adoc
  103. 0 { → asciidoctorj-core}/src/test/resources/contentstructure.asciidoc
  104. 0 { → asciidoctorj-core}/src/test/resources/document-with-arrays.adoc
  105. 0 { → asciidoctorj-core}/src/test/resources/documentblocks.asciidoc
  106. 0 { → asciidoctorj-core}/src/test/resources/documentheaders.asciidoc
  107. 0 { → asciidoctorj-core}/src/test/resources/documenttitle.adoc
  108. 0 { → asciidoctorj-core}/src/test/resources/documentwithdate.asciidoc
  109. 0 { → asciidoctorj-core}/src/test/resources/documentwithnote.asciidoc
  110. 0 { → asciidoctorj-core}/src/test/resources/documentwithtime.asciidoc
  111. 0 { → asciidoctorj-core}/src/test/resources/documentwithundefinedattribute.asciidoc
  112. 0 { → asciidoctorj-core}/src/test/resources/math.asciidoc
  113. 0 { → asciidoctorj-core}/src/test/resources/multiple_levels.asciidoc
  114. 0 { → asciidoctorj-core}/src/test/resources/rendersample.asciidoc
  115. 0 { → asciidoctorj-core}/src/test/resources/renderwithfrontmatter.adoc
  116. 0 { → asciidoctorj-core}/src/test/resources/sample-with-gist-macro.ad
  117. 0 { → asciidoctorj-core}/src/test/resources/sample-with-man-link.ad
  118. 0 { → asciidoctorj-core}/src/test/resources/sample-with-ruby-yell-block.ad
  119. 0 { → asciidoctorj-core}/src/test/resources/sample-with-terminal-command.ad
  120. 0 { → asciidoctorj-core}/src/test/resources/sample-with-uri-include.ad
  121. 0 { → asciidoctorj-core}/src/test/resources/sample-with-yell-block.ad
  122. 0 ...idoctorj-core}/src/test/resources/src/custom-backends/haml/html5-tweaks/block_paragraph.html.haml
  123. 0 { → asciidoctorj-core}/src/test/resources/src/documents/_sample.adoc
  124. 0 { → asciidoctorj-core}/src/test/resources/src/documents/sample.ad
  125. 0 { → asciidoctorj-core}/src/test/resources/src/documents/sample.adoc
  126. 0 { → asciidoctorj-core}/src/test/resources/src/documents/sample.asc
  127. 0 { → asciidoctorj-core}/src/test/resources/src/documents/sample.asciidoc
  128. 0 { → asciidoctorj-core}/src/test/resources/src/documents/sample.d
  129. 0 { → asciidoctorj-core}/src/test/resources/src/documents/sample.doc
  130. 0 { → asciidoctorj-core}/src/test/resources/src/documents/sample.txt
  131. 0 { → asciidoctorj-core}/src/test/resources/toc2sample.asciidoc
  132. 0 { → asciidoctorj-core}/src/test/resources/tocsample.asciidoc
  133. +29 −0 asciidoctorj-distribution/build.gradle
  134. +2 −0 asciidoctorj-distribution/gradle.properties
  135. +24 −0 asciidoctorj-epub3/build.gradle
  136. +3 −0 asciidoctorj-epub3/gradle.properties
  137. +2 −1 ...dBackendIsSet.java → asciidoctorj-epub3/src/test/java/org/asciidoctor/WhenEpub3BackendIsUsed.java
  138. +50 −0 asciidoctorj-epub3/src/test/java/org/asciidoctor/util/ClasspathHelper.java
  139. +28 −0 asciidoctorj-epub3/src/test/java/org/asciidoctor/util/ClasspathResources.java
  140. 0 { → asciidoctorj-epub3}/src/test/resources/content-document.adoc
  141. 0 { → asciidoctorj-epub3}/src/test/resources/epub-index.adoc
  142. +34 −0 asciidoctorj-pdf/build.gradle
  143. +3 −0 asciidoctorj-pdf/gradle.properties
  144. +33 −0 asciidoctorj-pdf/src/test/java/org/asciidoctor/WhenBackendIsPdf.java
  145. +50 −0 asciidoctorj-pdf/src/test/java/org/asciidoctor/util/ClasspathHelper.java
  146. +28 −0 asciidoctorj-pdf/src/test/java/org/asciidoctor/util/ClasspathResources.java
  147. +9 −0 asciidoctorj-pdf/src/test/resources/sample.adoc
  148. +150 −0 build.gradle
  149. +1 −0 gradle.properties
  150. +66 −0 gradle/deploy.gradle
  151. +18 −0 gradle/eclipse.gradle
  152. +3 −0 gradle/idea.gradle
  153. +101 −0 gradle/publish.gradle
  154. +11 −0 gradle/sign.gradle
  155. BIN gradle/wrapper/gradle-wrapper.jar
  156. +6 −0 gradle/wrapper/gradle-wrapper.properties
  157. +164 −0 gradlew
  158. +90 −0 gradlew.bat
  159. +0 −390 pom.xml
  160. +9 −0 settings.gradle
  161. +0 −42 src/main/assembly/default.xml
  162. +0 −39 src/main/scripts/asciidoctor
  163. +0 −23 src/main/scripts/asciidoctor.bat
  164. +0 −39 src/main/scripts/asciidoctorj
  165. +0 −23 src/main/scripts/asciidoctorj.bat
  166. +11 −9 test-asciidoctor-upstream.sh
View
@@ -1,10 +1,10 @@
+build/
target/
-/.settings
-/bin
-/build
-/.project
-/.classpath
-/.gradle
-.idea/
-.idea_modules/
+.classpath
+.project
+.settings/
+/.gradle/
*.iml
+*.ipr
+*.iws
+.idea/
View
@@ -1,21 +1,16 @@
language: java
-before_script:
- - unset GEM_PATH GEM_HOME JRUBY_OPTS
jdk:
- oraclejdk8
- oraclejdk7
- openjdk7
- - openjdk6
-#env:
-# global:
-# - JAVA_OPTS="-Xms128m -Xmx512m --XX:MaxPermSize=256m -XX:-UseGCOverheadLimit"
+ # the JRuby Gradle plugin doesn't support Java 6, so we can't run the build on openjdk6
+ # technically, AsciidoctorJ should work against Java 6, but there's no CI warranty in place ;)
+ #- openjdk6
+before_script: unset GEM_PATH GEM_HOME JRUBY_OPTS
+install: ./gradlew assemble
+script: ./gradlew -S check && bash test-asciidoctor-upstream.sh
notifications:
+ email: false
irc:
channels:
- "irc.freenode.org#asciidoctor"
-script:
- - mvn clean test -DforkCount=1 -DreuseForks=false
- - bash test-asciidoctor-upstream.sh
-#matrix:
-# allow_failures:
-# - script: mvn test #current release could fail because of backward incompatibility
@@ -0,0 +1,38 @@
+dependencies {
+ compile "org.jruby:jruby-complete:$jrubyVersion"
+ compile "org.slf4j:slf4j-api:$slf4Version"
+ compile "com.beust:jcommander:$jcommanderVersion"
+ gems "rubygems:asciidoctor:$asciidoctorGemVersion"
+ gems "rubygems:coderay:$coderayGemVersion"
+ gems "rubygems:erubis:$erubisGemVersion"
+ gems "rubygems:haml:$hamlGemVersion"
+ gems "rubygems:open-uri-cached:$openUriCachedGemVersion"
+ gems "rubygems:slim:$slimGemVersion"
+ gems "rubygems:thread_safe:$threadSafeGemVersion"
+ gems "rubygems:tilt:$tiltGemVersion"
+ testCompile("org.xmlmatchers:xml-matchers:$xmlmatchersVersion") { exclude module: 'Saxon-HE' }
+ testCompile "net.sf.saxon:Saxon-HE:$saxonVersion"
+ testCompile "com.google.guava:guava:$guavaVersion"
+ testCompile "org.jsoup:jsoup:$jsoupVersion"
+}
+
+def gemFiles = fileTree(jruby.gemInstallDir) {
+ include 'specifications/*.gemspec'
+ include 'gems/*/lib/**'
+ include "gems/asciidoctor-${asciidoctorGemVersion}/data/**"
+}
+
+jrubyPrepareGems << {
+ copy { // bundles the gems inside this artifact
+ from gemFiles
+ into sourceSets.main.output.resourcesDir
+ }
+}
+
+// explicitly package if we aren't copying gem sources
+//jar.from gemFiles
+
+// NOTE sources & javadoc jars only needed for AsciidoctorJ core since it's the only module that has sources
+artifacts {
+ archives sourcesJar, javadocJar
+}
@@ -0,0 +1,2 @@
+properName=AsciidoctorJ
+description=AsciidoctorJ provides Java bindings for the Asciidoctor RubyGem (asciidoctor) using JRuby.
@@ -12,6 +12,7 @@
private static final String CODERAY = "coderay";
private static final String ERUBIS = "erubis";
private static final String EPUB3 = "epub3";
+ private static final String PDF = "pdf";
private static final Map<String, String> optionToRequiredGem = new HashMap<String, String>() {
{
@@ -21,6 +22,7 @@
put(Attributes.DATA_URI, "require 'base64'");
put(Attributes.CACHE_URI, "require 'open-uri/cached'");
put(EPUB3, "require 'asciidoctor-epub3'");
+ put(PDF, "require 'asciidoctor-pdf'");
}
};
@@ -61,6 +63,9 @@ public void preloadRequiredLibraries(Map<String, Object> options) {
preloadLibrary(EPUB3);
}
+ if(isOptionSet(options, Options.BACKEND) && "pdf".equalsIgnoreCase((String) options.get(Options.BACKEND))) {
+ preloadLibrary(PDF);
+ }
}
private void preloadLibrary(String option) {
@@ -35,7 +35,6 @@
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
-import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
@@ -703,15 +702,12 @@ public void experimental_flag_should_enable_experimental_features_like_keyboard_
assertThat(image.text(), is("F11"));
}
- @Ignore
- // Ignore because of fail only in Travis and cannot inspect the report.
@Test
public void iconfont_attributes_should_be_used_for_using_custom_font_css_icons()
throws URISyntaxException, IOException {
Attributes attributes = attributes().icons(Attributes.FONT_ICONS)
- .iconFontRemote(true).iconFontCdn(new URI("http://mycdn"))
- .iconFontName("myfont").get();
+ .iconFontRemote(true).iconFontCdn(new URI("http://mycdn/css/font-awesome.min.css")).get();
Options options = options().inPlace(true).attributes(attributes).get();
File inputFile = classpath.getResource("documentwithnote.asciidoc");
@@ -721,7 +717,7 @@ public void iconfont_attributes_should_be_used_for_using_custom_font_css_icons()
Document doc = Jsoup.parse(expectedFile, "UTF-8");
Elements stylesheetLinks = doc
- .select("link[href$=http://mycdn/myfont.min.css]");
+ .select("link[href=http://mycdn/css/font-awesome.min.css]");
assertThat(stylesheetLinks.size(), is(1));
expectedFile.delete();
@@ -10,6 +10,7 @@
import org.asciidoctor.OptionsBuilder;
import org.jruby.RubyBoolean;
import org.junit.Test;
+import org.junit.Ignore;
public class WhenDocumentIsRenderedWithPreloading {
@@ -53,19 +54,6 @@ public void erubis_gem_should_be_preloaded() {
assertThat(evalScriptlet.isFalse(), is(true));
}
-
- @Test
- public void epub3_gem_should_be_preloaded() {
-
- Map<String, Object> options = OptionsBuilder.options().backend("epub3").asMap();
-
- JRubyAsciidoctor asciidoctor = (JRubyAsciidoctor) JRubyAsciidoctor.create();
-
- asciidoctor.rubyGemsPreloader.preloadRequiredLibraries(options);
- RubyBoolean evalScriptlet = (RubyBoolean) asciidoctor.rubyRuntime.evalScriptlet("require 'asciidoctor-epub3'");
- assertThat(evalScriptlet.isFalse(), is(true));
-
- }
@Test
public void not_erubis_gem_should_be_preloaded() {
@@ -0,0 +1,29 @@
+dependencies {
+ compile project(':asciidoctorj')
+ compile project(':asciidoctorj-epub3')
+ compile project(':asciidoctorj-pdf')
+ runtime "org.slf4j:slf4j-simple:$slf4Version"
+}
+
+apply plugin: 'application'
+
+tasks.withType(AbstractArchiveTask) {
+ baseName 'asciidoctorj'
+ classifier 'bin' // use classifier for identification in repository list
+ eachFile { it.path = it.path.replaceFirst('-bin(?=/)', '') }
+ //destinationDir = ...
+}
+
+startScripts {
+ applicationName = 'asciidoctorj'
+ mainClassName = 'org.asciidoctor.cli.AsciidoctorInvoker'
+ defaultJvmOpts = [
+ '-client', '-Xmn128m', '-Xms256m', '-Xmx256m',
+ '-Xverify:none', '-XX:+UseFastAccessorMethods', '-XX:+TieredCompilation', '-XX:TieredStopAtLevel=1', '-XX:+DisableExplicitGC',
+ '-Djruby.compile.mode=OFF', '-Djruby.compat.version=RUBY2_0'
+ ]
+}
+
+artifacts {
+ dists distZip
+}
@@ -0,0 +1,2 @@
+properName=AsciidoctorJ Distribution
+description=Installable distribution of AsciidoctorJ components, providing the asciidoctorj command line interface.
@@ -0,0 +1,24 @@
+dependencies {
+ compile project(':asciidoctorj')
+ gems("rubygems:asciidoctor-epub3:$asciidoctorEpub3GemVersion") {
+ // Exclude gems provided by AsciidoctorJ core
+ exclude module: 'asciidoctor'
+ exclude module: 'thread_safe'
+ }
+}
+
+def gemFiles = fileTree(jruby.gemInstallDir) {
+ include 'specifications/*'
+ include 'gems/*/lib/**'
+ include 'gems/*/data/**'
+}
+
+jrubyPrepareGems << {
+ copy { // bundles the gems inside this artifact
+ from gemFiles
+ into sourceSets.main.output.resourcesDir
+ }
+}
+
+// explicitly package if we aren't copying gem sources
+//jar.from gemFiles
@@ -0,0 +1,3 @@
+properName=AsciidoctorJ EPUB3
+description=AsciidoctorJ EPUB3 bundles the Asciidoctor EPUB3 RubyGem (asciidoctor-epub3) so it can be loaded into the JVM using JRuby.
+version=1.5.0-alpha.4
@@ -10,8 +10,9 @@
import org.asciidoctor.util.ClasspathResources;
import org.junit.Rule;
import org.junit.Test;
+import org.junit.Ignore;
-public class WhenANoneStandardBackendIsSet {
+public class WhenEpub3BackendIsUsed {
private Asciidoctor asciidoctor = JRubyAsciidoctor.create();
@@ -0,0 +1,50 @@
+package org.asciidoctor.util;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.net.URISyntaxException;
+import java.net.URL;
+
+/**
+ * Hels getting files from the classpath.
+ */
+public class ClasspathHelper {
+
+ private ClassLoader classloader;
+
+ /**
+ * Gets a resourse in a similar way as {@link File#File(String)}
+ */
+ public File getResource(String pathname) {
+ try {
+ URL resource = classloader.getResource(pathname);
+ if (resource != null) {
+ return new File(classloader.getResource(pathname).toURI());
+ }
+ else {
+ throw new RuntimeException(new FileNotFoundException(pathname));
+ }
+ } catch (URISyntaxException e) {
+ throw new RuntimeException(e.getMessage(), e);
+ }
+ }
+
+ /**
+ * Gets a resourse in a similar way as {@link File#File(String, String)}
+ */
+ public File getResource(String parent, String child) {
+ return new File(getResource(parent), child);
+ }
+
+ public ClassLoader getClassloader() {
+ return classloader;
+ }
+
+ public void setClassloader(ClassLoader classloader) {
+ this.classloader = classloader;
+ }
+
+ public void setClassloader(Class<?> clazz) {
+ this.classloader = clazz.getClassLoader();
+ }
+}
@@ -0,0 +1,28 @@
+package org.asciidoctor.util;
+
+import org.junit.rules.TestRule;
+import org.junit.runner.Description;
+import org.junit.runners.model.Statement;
+
+/**
+ * JUnit TestRule to handle classpath files.
+ *
+ * Delegates to {@link ClasspathHelper}
+ */
+public class ClasspathResources extends ClasspathHelper implements TestRule {
+
+ protected void before(Class<?> clazz) throws Throwable {
+ super.setClassloader(clazz);
+ }
+
+ @Override
+ public Statement apply(final Statement base, final Description description) {
+ return new Statement() {
+ @Override
+ public void evaluate() throws Throwable {
+ before(description.getTestClass());
+ base.evaluate();
+ }
+ };
+ }
+}
@@ -0,0 +1,34 @@
+dependencies {
+ compile project(':asciidoctorj')
+ gems("rubygems:asciidoctor-pdf:$asciidoctorPdfGemVersion") {
+ // Exclude gems provided by AsciidoctorJ core
+ exclude module: 'asciidoctor'
+ exclude module: 'thread_safe'
+ // FIXME The prawn and ttfunk gems are not resolving correctly, so we have to do it manually for now
+ exclude module: 'prawn'
+ exclude module: 'ttfunk'
+ }
+ gems "rubygems:prawn:$prawnGemVersion"
+ gems "rubygems:ttfunk:$ttfunkGemVersion"
+}
+
+def gemFiles = fileTree(jruby.gemInstallDir) {
+ include 'specifications/*.gemspec'
+ include 'gems/*/lib/**'
+ include "gems/*/data/fonts/*"
+ include "gems/asciidoctor-pdf-${asciidoctorPdfGemVersion}/data/**"
+ // Accomodate Prawn's non-conforming packaging
+ include "gems/prawn-$prawnGemVersion/VERSION"
+ include "gems/prawn-$prawnGemVersion/data/*.txt"
+ include "gems/prawn-$prawnGemVersion/data/encodings/*"
+}
+
+jrubyPrepareGems << {
+ copy { // bundles the gems inside this artifact
+ from gemFiles
+ into sourceSets.main.output.resourcesDir
+ }
+}
+
+// explicitly package if we aren't copying gem sources
+//jar.from gemFiles
@@ -0,0 +1,3 @@
+properName=AsciidoctorJ PDF
+description=AsciidoctorJ PDF bundles the Asciidoctor PDF RubyGem (asciidoctor-pdf) so it can be loaded into the JVM using JRuby.
+version=1.5.0-alpha.6
Oops, something went wrong.

0 comments on commit a56733a

Please sign in to comment.