Trying to get a BASIC test that Gradle works properly in my environment. Some lines in directory list removed for clarity purposes. However, I have been through the documentation and Gradle produces a jar file, I cannot run the jar file. What am I missing?
C:\Code\gradletest>dir
Directory of C:\Code\gradletest
09/09/2014 09:21 AM
438 build.gradle 09/09/2014 09:41 AM
847 gradle-app.setting 09/09/2014 08:22 AM
126 HelloWorld.java 09/09/2014 09:19 AM
META-INF
Contents of build.gradle file is:
apply plugin: ‘java’ //apply plugin: ‘eclipse’
// tag::repositories[] repositories {
mavenCentral() } // end::repositories[]
// tag::jar[] jar {
baseName = ‘helloworld’
version = ‘0.1’ } // end::jar[]
// tag::dependencies[] dependencies {
compile “joda-time:joda-time:2.2” } // end::dependencies[]
// tag::wrapper[] task wrapper(type: Wrapper) {
gradleVersion = ‘2.1’ } // end::wrapper[]
Contents of META-INF\MANIFEST.MF
Manifest-Version: 1.0 Created-By: 1.8.0-b132 (Oracle Corporation) Main-Class: Code.gradletest.HelloWorld
Contents of HelloWorld.java
public class HelloWorld {
public static void main(String[] args) {
System.out.println(“Hello, world!”);
} }
First I used:
C:\Code\gradletest>gradle clean :clean
BUILD SUCCESSFUL
Total time: 4.824 secs
Then I used:
C:\Code\gradletest>gradle build :compileJava UP-TO-DATE :processResources UP-TO-DATE :classes UP-TO-DATE :jar :assemble :compileTestJava UP-TO-DATE :processTestResources UP-TO-DATE :testClasses UP-TO-DATE :test UP-TO-DATE :check UP-TO-DATE :build
BUILD SUCCESSFUL
Total time: 3.607 secs
C:\Code\gradletest>cd build\libs
C:\Code\gradletest\build\libs>dir
Directory of C:\Code\gradletest\build\libs
09/09/2014 09:23 AM
. 09/09/2014 09:23 AM
… 09/09/2014 09:23 AM
261 helloworld-0.1.jar
1 File(s)
261 bytes
2 Dir(s) 113,000,513,536 bytes free
Then I tried to run the jar and I consistently get the “error message”.
C:\Code\gradletest\build\libs>java -jar helloworld-0.1.jar no main manifest attribute, in helloworld-0.1.jar