diff --git a/build.gradle b/build.gradle index 6f8891b0..a6077624 100644 --- a/build.gradle +++ b/build.gradle @@ -46,5 +46,10 @@ dependencies { task wrapper(type: Wrapper) { } +jar { + manifest { + attributes("version": "$version") + } +} defaultTasks 'build' diff --git a/samples/helloworld/build.gradle b/samples/helloworld/build.gradle index 174cc686..9ecfa2c5 100644 --- a/samples/helloworld/build.gradle +++ b/samples/helloworld/build.gradle @@ -1,39 +1,38 @@ -description = 'Hello World - Spring Shell' -version = "$helloworldVersion" - +description = 'Spring Shell Example' apply plugin: 'base' apply plugin: 'java' -apply plugin: 'idea' apply plugin: 'eclipse' repositories { - mavenLocal() - mavenCentral() - // Public Spring artifacts - mavenRepo name: "spring-release", urls: "http://repo.springsource.org/release" - mavenRepo name: "spring-milestone", urls: "http://repo.springsource.org/milestone" - mavenRepo name: "spring-snapshot", urls: "http://repo.springsource.org/snapshot" + mavenCentral() + maven { url "http://repo.springsource.org/snapshot" } + maven { url "http://repo.springsource.org/release" } + maven { url "http://repo.springsource.org/milestone" } + maven { url "http://spring-roo-repository.springsource.org/release" } } dependencies { - compile "org.springframework.shell:spring-shell:$springShellVersion" - compile "org.springframework:spring-core:$springVersion" - compile "org.springframework:spring-context-support:$springVersion" + compile "org.springframework.shell:spring-shell:$springShellVersion" + testCompile "junit:junit:$junitVersion" } +task copyDependency(type: Copy) { + into "$buildDir/libs/dependency" + from configurations.runtime +} + +project.ext.springShellJar = configurations.runtime.find { file -> file.name.contains("spring-shell")} +//println("spring shell name is:" + project.ext.springShellJar.name) + +project.ext.manifestClasspath = "dependency/" + springShellJar.name + " " +project.ext.manifestClasspath = project.ext.manifestClasspath + configurations.runtime.collect{ File file -> "dependency/"+file.name}.join(' ') jar { - dependsOn configurations.runtime - from { - configurations.runtime.collect { - it.isDirectory() ? it : zipTree(it) - } - } - - manifest { - attributes("Main-Class": "org.springframework.shell.Bootstrap") - } - + baseName "helloworld" + manifest { + attributes 'Main-Class' : 'org.springframework.shell.Bootstrap', "Class-Path" : project.ext.manifestClasspath + } } -defaultTasks 'build' \ No newline at end of file + +defaultTasks 'clean', 'build', 'copyDependency' diff --git a/samples/helloworld/gradle.properties b/samples/helloworld/gradle.properties index 752d62e0..9a953ff1 100644 --- a/samples/helloworld/gradle.properties +++ b/samples/helloworld/gradle.properties @@ -1,4 +1,6 @@ -springVersion = 3.1.1.RELEASE -springShellVersion=1.0.0.BUILD-SNAPSHOT +springShellVersion = 1.0.0.BUILD-SNAPSHOT +junitVersion = 4.8.1 +version = 1.0.0.BUILD-SNAPSHOT + + -helloworldVersion=1.0.0.BUILD-SNAPSHOT \ No newline at end of file diff --git a/samples/helloworld/src/main/java/org/springframework/shell/samples/helloworld/commands/HelloWorldCommands.java b/samples/helloworld/src/main/java/org/springframework/shell/samples/helloworld/commands/HelloWorldCommands.java index 4d696223..2cacab97 100644 --- a/samples/helloworld/src/main/java/org/springframework/shell/samples/helloworld/commands/HelloWorldCommands.java +++ b/samples/helloworld/src/main/java/org/springframework/shell/samples/helloworld/commands/HelloWorldCommands.java @@ -10,13 +10,13 @@ import org.springframework.stereotype.Component; public class HelloWorldCommands implements CommandMarker { - @CliAvailabilityIndicator({"hw help"}) + @CliAvailabilityIndicator({"hw echo"}) public boolean isCommandAvailable() { return true; } - @CliCommand(value = "hw-echo", help = "Print a hello world message") - public void config( + @CliCommand(value = "hw echo", help = "Print a hello world message") + public void hello( @CliOption(key = { "message" }, mandatory = true, help = "The hello world message") final String message, @CliOption(key = { "name1"}, mandatory = true, help = "The hello world name1 ") final String name1, @CliOption(key = { "name2","name22" }, mandatory = true, help = "The hello world name2 ") final String name2, @@ -25,4 +25,26 @@ public class HelloWorldCommands implements CommandMarker { System.out.println("Hello world " + message + ", name1: " + name1 + ", name2:" + name2 + ". time:" + time + ".location: " + location); } + + @CliCommand(value = "hw auto", help = "Print a hello world message") + public void autao( + @CliOption(key = { "message" }, mandatory = true, help = "The hello world message") final MessageType message){ + System.out.println("Hello world " + message); + } + + enum MessageType { + Type1("type1"), + Type2("type2"), + Type3("type3"); + + private String type; + + private MessageType(String type){ + this.type = type; + } + + public String getType(){ + return type; + } + } }