diff --git a/.travis.yml b/.travis.yml index 7da2ac59..251c2db2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,45 @@ language: java +# the following will skip the installation of dependencies. +install: true -script: ./gradlew build +# the following forces the use of JDK 8 +# matrix: +# include: +# - jdk: oraclejdk8 + +script: + - gradle clean build + - gradle dist --rerun-tasks +# - gradle distSetup --rerun-tasks +# - gradle zipDist --rerun-tasks +# - gradle zipTest --rerun-tasks + +before_deploy: + - git config --global user.email "builds@travis-ci.com" + - git config --global user.name "Travis CI" + - export GIT_TAG=$TRAVIS_BRANCH.$TRAVIS_BUILD_NUMBER + - git tag $GIT_TAG -a -m "Generated tag from TravisCI for build $TRAVIS_BUILD_NUMBER" + - git push -q https://$GITPERM@github.com/drlehr/java-hello-world-with-gradle --tags + - ls -R + +deploy: + skip_cleanup: true + provider: releases + api_key: + secure: $GITPERM + + file: + - "README.md" + - "build.gradle" + - ".travis.yml" + + on: + tags: false + all_branches: true +Collapse + +script: ./gradlew build deploy: provider: releases api_key: diff --git a/build.gradle b/build.gradle index efbf378d..42785215 100644 --- a/build.gradle +++ b/build.gradle @@ -7,6 +7,7 @@ * user guide available at https://docs.gradle.org/2.8/userguide/tutorial_java_projects.html */ + /* // Apply the java plugin to add support for Java apply plugin: 'java' @@ -28,37 +29,73 @@ dependencies { } */ + apply plugin: 'java' apply plugin: 'eclipse' apply plugin: 'application' - mainClassName = 'hello.HelloWorld' - // tag::repositories[] repositories { mavenCentral() } // end::repositories[] - // tag::jar[] jar { baseName = 'jb-hello-world' version = '0.1.0' } // end::jar[] - // tag::dependencies[] -sourceCompatibility = 1.7 -targetCompatibility = 1.7 - +sourceCompatibility = 1.8 +targetCompatibility = 1.8 dependencies { compile "joda-time:joda-time:2.2" - testCompile "junit:junit:4.12" + testCompile "org.junit.jupiter:junit-jupiter-api:5.0.1" +// the following is a work around to fix the warning: +// warning: unknown enum constant Status.STABLE + testCompileOnly "org.apiguardian:apiguardian-api:1.0.0" } // end::dependencies[] - +task dist { + description "Generate the dist(s) into the dist folder." +} +task distSetup { + description "Generate the dist folder." + delete "${projectDir}/dist" + copy { + from "${buildDir}/libs" + into "${projectDir}/dist/main" + } + copy { + from "${projectDir}/build/classes/test/Output" + into "${projectDir}/dist/test" + } +} +task zipDist(type: Zip, dependsOn: distSetup) { + from "${projectDir}/dist/main" + from "${projectDir}/Readme.md" + destinationDir = file("${projectDir}/dist") + version = "${version}" + appendix = "Main" + doLast { + println "Created ${zipDist.archiveName}" + } +} +task zipTest(type: Zip, dependsOn: distSetup) { + from "${projectDir}/dist/test" + from "${projectDir}/Readme.md" + destinationDir = file("${projectDir}/dist") + version = "${version}" + appendix = "Test Output" + doLast{ + println "Created ${zipTest.archiveName}" + } +} +distSetup.dependsOn(build) +dist.dependsOn(zipDist) +dist.dependsOn(zipTest) // tag::wrapper[] task wrapper(type: Wrapper) { - gradleVersion = '3.5' + gradleVersion = '4.9' } // end::wrapper[] diff --git a/src/test/java/hello/TestGreeter.java b/src/test/java/hello/TestGreeter.java index 16ff7e94..6aac8df5 100644 --- a/src/test/java/hello/TestGreeter.java +++ b/src/test/java/hello/TestGreeter.java @@ -4,43 +4,58 @@ import org.junit.Before; import org.junit.Test; + public class TestGreeter { private Greeter g; @Before - public void setUp() throws Exception - { + public void setUp() throws Exception { g = new Greeter(); } @Test - public void testGreeterEmpty() - { + public void testGreeterEmpty() { assertEquals(g.getName(),""); assertEquals(g.sayHello(),"Hello!"); } @Test - public void testGreeter() - { + public void testGreeter() { g.setName("World"); assertEquals(g.getName(),"World"); assertEquals(g.sayHello(),"Hello World!"); } - - @Test + + @Test + public void newtestHBWGreeterPass() { + + g.setName("Hollie, YOU ARE AMAZING"); + + assertEquals(g.getName(),"Hollie, YOU ARE AMAZING"); + + assertEquals(g.sayHello(),"Hello Hollie, YOU ARE AMAZING!"); + + } + + @Test + public void newtestHBWGreeterPass2(){ + + g.setName("Hollie"); + + assertEquals(g.getName(),"Hollie"); + + assertEquals(g.sayHello(),"Hello Hollie!"); + + } + + @Test public void newtestWMGreeterPass() { g.setName("Boris"); assertEquals(g.getName(),"Boris"); assertEquals(g.sayHello(),"Hello Boris!"); } - /* - @Test - public void newtestWMGreeterFail() { - g.setName("Sandvich"); - assertEquals(g.getName(),"Boris"); - assertEquals(g.sayHello(),"Hello Boris!"); - } - */ - } + + + +