Skip to content

Commit

Permalink
feat: Created AnnotationProcessor for PicoCli
Browse files Browse the repository at this point in the history
This processor reads the PicoCli model created in the traditional
way using the annotations and introspection and generates code
that uses the PicoCli API to recreate the same model.
  • Loading branch information
quintesse committed Jul 6, 2021
1 parent c697ce1 commit 15e7e85
Show file tree
Hide file tree
Showing 7 changed files with 654 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
target
.idea
*.iml
/build
build
.gradle
.factorypath
bin
Expand Down
28 changes: 28 additions & 0 deletions annotation/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
plugins {
id 'java'
}

group 'dev.jbang'
version '0.71.1.1'

repositories {
mavenCentral()
}

dependencies {
implementation 'info.picocli:picocli-codegen:4.6.1'
implementation 'com.squareup:javapoet:1.13.0'
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.7.0'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.7.0'
}

tasks.withType( JavaCompile ).configureEach {
options.compilerArgs.addAll( [
'--add-exports', 'jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED',
'--add-exports', 'jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED'
] )
}

test {
useJUnitPlatform()
}
612 changes: 612 additions & 0 deletions annotation/src/main/java/MyProcessor.java

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
MyProcessor
16 changes: 9 additions & 7 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ repositories {
}

dependencies {
annotationProcessor project(':annotation')

implementation 'com.offbytwo:docopt:0.6.0.20150202'

implementation 'org.apache.commons:commons-text:1.9'
Expand All @@ -45,7 +47,7 @@ dependencies {
//implementation 'com.google.guava:guava:28.2-jre'


testCompile "com.github.tomakehurst:wiremock-jre8:2.27.2"
testImplementation "com.github.tomakehurst:wiremock-jre8:2.27.2"

testImplementation "org.junit.jupiter:junit-jupiter:5.7.1"
testRuntimeOnly('org.junit.jupiter:junit-jupiter-engine:5.7.1')
Expand All @@ -67,11 +69,11 @@ tasks.withType(AbstractArchiveTask) {


sonarqube {
properties {
property "sonar.projectKey", "jbangdev_jbang"
property "sonar.organization", "jbangdev"
property "sonar.host.url", "https://sonarcloud.io"
}
properties {
property "sonar.projectKey", "jbangdev_jbang"
property "sonar.organization", "jbangdev"
property "sonar.host.url", "https://sonarcloud.io"
}
}

spotless {
Expand Down Expand Up @@ -146,7 +148,7 @@ jar {
'Main-Class': 'dev.jbang.Main',
)
}
}
}


compileJava {
Expand Down
1 change: 1 addition & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@ gradleEnterprise {
//publishAlways()
}
}
include 'annotation'
3 changes: 2 additions & 1 deletion src/main/java/dev/jbang/cli/Jbang.java
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,8 @@ protected List<Object> handle(CommandLine.ParseResult parseResult) throws Comman
};

public static CommandLine getCommandLine(PrintWriter localout, PrintWriter localerr) {
CommandLine cl = new CommandLine(new Jbang());
// CommandLine cl = new CommandLine(new Jbang());
CommandLine cl = new CommandLine(Jbang_CliCfg.createCmdSpec());

cl.getHelpSectionMap().remove(SECTION_KEY_COMMAND_LIST_HEADING);
cl.getHelpSectionMap().put(SECTION_KEY_COMMAND_LIST, getCommandRenderer());
Expand Down

0 comments on commit 15e7e85

Please sign in to comment.