Skip to content

Commit

Permalink
Extract CLI Java components into new submodule
Browse files Browse the repository at this point in the history
* Create new sub-module asciidoctorj-cli: migrated 'org.asciidoctor.jruby.cli'
classes and related tests to it.
* Created CliOptions in AsciidoctorUtils from values in AsciidoctorCliOptions
to avoid circular dependency.
* Updated README with new sub-module information.
* Fix jar names in command in README.
* Minor refactors and fixes.

Fixes asciidoctor#246
  • Loading branch information
abelsromero committed Mar 21, 2023
1 parent c8daaab commit e9d53a6
Show file tree
Hide file tree
Showing 26 changed files with 198 additions and 148 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ Improvement::
* Expose `sectnum` property in Section interface (#1121)
* Replace use of deprecated 'numbered' attribute by 'sectnums' (#1123) (@abelsromero)
* Expose `source` and `source_lines` use of deprecated 'numbered' in Document interface (#1145) (@abelsromero)
* Create `asciidoctorj-cli` module to prevent unnecessary dependencies to asciidoctorj jar consumers (#1149)

Bug Fixes::

Expand Down
9 changes: 8 additions & 1 deletion README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -284,8 +284,13 @@ asciidoctorj::
Also bundles optional RubyGems needed at runtime, such as coderay, tilt, haml and slim.
Produces the asciidoctorj jar.

asciidoctorj-cli::
`asciidoctorj` command Java components.
Produces the asciidoctorj-cli.

asciidoctorj-distribution::
Produces the distribution zip that provides the standalone `asciidoctorj` command.
Produces the distribution zip that provides the standalone `asciidoctorj` command including Java components,
launch scripts and required libraries.

asciidoctorj-arquillian-extension::
Bundles an Arquillian extension that allows to inject an Asciidoctor instance or other instances commonly used by Asciidoctor tests into a test case.
Expand All @@ -310,6 +315,8 @@ asciidoctorj-arquillian-extension/
build.gradle
asciidoctorj-api/
build.gradle
asciidoctorj-cli/
build.gradle
asciidoctorj-core/
build.gradle
asciidoctorj-distribution/
Expand Down
25 changes: 25 additions & 0 deletions asciidoctorj-cli/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
apply plugin: 'java-library'
apply plugin: 'biz.aQute.bnd.builder'

dependencies {
api project(':asciidoctorj-api')
api project(':asciidoctorj')
implementation "com.beust:jcommander:$jcommanderVersion"

testImplementation project(':asciidoctorj-arquillian-extension')
testImplementation "org.jsoup:jsoup:$jsoupVersion"
}

project.ext.publicationName = "mavenAsciidoctorJ"

apply from: rootProject.file('gradle/publish.gradle')
apply from: rootProject.file('gradle/signing.gradle')

jar {
bnd(
('Bundle-Name'): 'asciidoctorj-cli',
('Bundle-SymbolicName'): 'org.asciidoctor.asciidoctorj-cli',
('Import-Package'): 'com.beust.jcommander;resolution:=optional, *'
)
metaInf { from "$buildDir/version-info/" }
}
2 changes: 2 additions & 0 deletions asciidoctorj-cli/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
properName=AsciidoctorJ CLI
description=AsciidoctorJ Command Line Interface
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,9 @@ public boolean isQuiet() {
return quiet;
}

public Severity getFailureLevel() { return failureLevel; }
public Severity getFailureLevel() {
return failureLevel;
}

public boolean isRequire() {
return this.require != null && this.require.size() > 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

public enum DocTypeEnum {

article, book, inline;
article, book, inline

}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import org.asciidoctor.log.Severity;

public class MaxSeverityLogHandler implements LogHandler {

private Severity maxSeverity = Severity.DEBUG;

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
package org.asciidoctor.jruby.cli;

import org.asciidoctor.SafeMode;

import com.beust.jcommander.IStringConverter;
import org.asciidoctor.SafeMode;

public class SafeModeConverter implements IStringConverter<SafeMode> {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package org.asciidoctor.jruby.cli;

import com.beust.jcommander.JCommander;
import org.asciidoctor.*;
import org.asciidoctor.Attributes;
import org.asciidoctor.Options;
import org.asciidoctor.OptionsBuilder;
import org.asciidoctor.SafeMode;
import org.asciidoctor.jruby.internal.AsciidoctorUtils;
import org.junit.Test;

Expand Down Expand Up @@ -50,7 +53,6 @@ public void api_parameters_should_be_transformed_to_cli_command() {
assertThat(asciidoctorCliOptions.getAttributes(), hasEntry("myAtribute", "myValue"));
assertThat(asciidoctorCliOptions.getAttributes(), hasKey("sectnums"));
assertThat(asciidoctorCliOptions.getAttributes(), hasKey("copycss!"));

}

}
Loading

0 comments on commit e9d53a6

Please sign in to comment.