This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $ java -jar build/libs/spring-cmdline-example.jar world | |
| Hello, world! | |
| $ java -jar build/libs/spring-cmdline-example.jar --bye world | |
| Goodbye, world! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $ java -jar build/libs/spring-cmdline-example.jar | |
| Error: Operand [name] is required | |
| Option Description | |
| ------ ----------- | |
| -b, --bye | |
| -h, --help Usage information | |
| Operands Description | |
| -------- ----------- |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| jar { | |
| dependsOn configurations.runtime | |
| from { configurations.runtime.collect { it.isDirectory() ? it : zipTree(it) } } | |
| manifest { | |
| attributes 'Main-Class': 'com.trigonic.utils.spring.cmdline.example.Example' | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $ gradle clean build | |
| :clean | |
| :compileJava | |
| :processResources UP-TO-DATE | |
| :classes | |
| :jar | |
| :assemble | |
| :compileTestJava UP-TO-DATE | |
| :processTestResources UP-TO-DATE | |
| :testClasses UP-TO-DATE |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.trigonic.utils.spring.cmdline.example; | |
| import com.trigonic.utils.spring.cmdline.*; | |
| import java.util.logging.*; | |
| public class Example implements Runnable { | |
| public static void main(String[] args) { | |
| LogManager.getLogManager().getLogger("").setLevel(Level.SEVERE); // (1) | |
| new CommandLineAppContext().run(Example.class, args); // (2) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| apply plugin: 'java' // (1) | |
| repositories { // (2) | |
| mavenCentral() | |
| } | |
| dependencies { // (3) | |
| compile 'com.trigonic:spring-cmdline:0.3' | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import static org.junit.Assert.* | |
| import groovy.mock.interceptor.MockFor | |
| import org.junit.Test | |
| class CollaboratingClassTest { | |
| @Test | |
| void test() { | |
| MockFor mockJavaClass = new MockFor(JavaClass) | |
| def javaClassInstance = mockJavaClass.proxyDelegateInstance() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class CollaboratingClass { | |
| JavaClass javaClass | |
| CollaboratingClass(JavaClass javaClass) { | |
| this.javaClass = javaClass | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class JavaClass { | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def existingStringEquals = String.metaClass.getMetaMethod('equals', String.class) | |
| String.metaClass.equals = { other -> | |
| if (other instanceof GString) { | |
| other = other.toString() | |
| } else { | |
| if (other == null) { | |
| Object[] args = new Object[1] | |
| args[0] = null | |
| existingStringEquals.invoke(delegate, args) | |
| } else { |
NewerOlder