From 2f1a3fc4cd55faa6880558e74b254d31e0d42356 Mon Sep 17 00:00:00 2001 From: Johno Crawford Date: Fri, 27 Jul 2018 00:14:07 +0200 Subject: [PATCH 1/2] Support for Travis Pro. --- .../maven/plugin/CoverallsReportMojo.java | 2 + .../maven/plugin/service/TravisPro.java | 48 ++++++++++ .../maven/plugin/service/TravisProTest.java | 87 +++++++++++++++++++ 3 files changed, 137 insertions(+) create mode 100644 src/main/java/org/eluder/coveralls/maven/plugin/service/TravisPro.java create mode 100644 src/test/java/org/eluder/coveralls/maven/plugin/service/TravisProTest.java diff --git a/src/main/java/org/eluder/coveralls/maven/plugin/CoverallsReportMojo.java b/src/main/java/org/eluder/coveralls/maven/plugin/CoverallsReportMojo.java index f555f8a1..19f956fd 100644 --- a/src/main/java/org/eluder/coveralls/maven/plugin/CoverallsReportMojo.java +++ b/src/main/java/org/eluder/coveralls/maven/plugin/CoverallsReportMojo.java @@ -54,6 +54,7 @@ import org.eluder.coveralls.maven.plugin.service.ServiceSetup; import org.eluder.coveralls.maven.plugin.service.Shippable; import org.eluder.coveralls.maven.plugin.service.Travis; +import org.eluder.coveralls.maven.plugin.service.TravisPro; import org.eluder.coveralls.maven.plugin.service.Wercker; import org.eluder.coveralls.maven.plugin.source.SourceCallback; import org.eluder.coveralls.maven.plugin.source.SourceLoader; @@ -304,6 +305,7 @@ protected List getServices() { List services = new ArrayList<>(); services.add(new Shippable(env)); services.add(new Travis(env)); + services.add(new TravisPro(env)); services.add(new Circle(env)); services.add(new Jenkins(env)); services.add(new Bamboo(env)); diff --git a/src/main/java/org/eluder/coveralls/maven/plugin/service/TravisPro.java b/src/main/java/org/eluder/coveralls/maven/plugin/service/TravisPro.java new file mode 100644 index 00000000..5ee18fb1 --- /dev/null +++ b/src/main/java/org/eluder/coveralls/maven/plugin/service/TravisPro.java @@ -0,0 +1,48 @@ +package org.eluder.coveralls.maven.plugin.service; + +import java.util.Map; + +/* + * #[license] + * coveralls-maven-plugin + * %% + * Copyright (C) 2013 - 2016 Tapio Rautonen + * %% + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * %[license] + */ + +/** + * Service implementation for Travis CI Pro. + *

+ * https://travis-ci.org/ + */ +public class TravisPro extends Travis { + + public static final String TRAVIS_NAME = "travis-pro"; + + public TravisPro(final Map env) { + super(env); + } + + @Override + public String getName() { + return TRAVIS_NAME; + } +} diff --git a/src/test/java/org/eluder/coveralls/maven/plugin/service/TravisProTest.java b/src/test/java/org/eluder/coveralls/maven/plugin/service/TravisProTest.java new file mode 100644 index 00000000..3a6a93d6 --- /dev/null +++ b/src/test/java/org/eluder/coveralls/maven/plugin/service/TravisProTest.java @@ -0,0 +1,87 @@ +package org.eluder.coveralls.maven.plugin.service; + +/* + * #[license] + * coveralls-maven-plugin + * %% + * Copyright (C) 2013 - 2016 Tapio Rautonen + * %% + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * %[license] + */ + +import org.junit.Test; + +import java.util.HashMap; +import java.util.Map; +import java.util.Properties; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +public class TravisProTest { + + private Map env() { + Map env = new HashMap(); + env.put("TRAVIS", "true"); + env.put("TRAVIS_JOB_ID", "job123"); + env.put("TRAVIS_BRANCH", "master"); + env.put("TRAVIS_PULL_REQUEST", "pull10"); + return env; + } + + @Test + public void testIsSelectedForNothing() { + assertFalse(new TravisPro(new HashMap()).isSelected()); + } + + @Test + public void testIsSelectedForTravis() { + assertTrue(new TravisPro(env()).isSelected()); + } + + @Test + public void testGetName() { + assertEquals("travis-pro", new TravisPro(env()).getName()); + } + + @Test + public void testGetJobId() { + assertEquals("job123", new TravisPro(env()).getJobId()); + } + + @Test + public void testGetBranch() { + assertEquals("master", new TravisPro(env()).getBranch()); + } + + @Test + public void testGetPullRequest() { + assertEquals("pull10", new TravisPro(env()).getPullRequest()); + } + + @Test + public void testGetEnvironment() { + Properties properties = new TravisPro(env()).getEnvironment(); + assertEquals(2, properties.size()); + assertEquals("job123", properties.getProperty("travis_job_id")); + assertEquals("pull10", properties.getProperty("travis_pull_request")); + } +} From c1babbf443aee924afcfa7ca835fd1801ba4bffa Mon Sep 17 00:00:00 2001 From: Johno Crawford Date: Fri, 27 Jul 2018 00:27:38 +0200 Subject: [PATCH 2/2] Travis doesn't support oracle JDK anymore. See travis-ci/travis-ci#7884 --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index e0396a19..0a321ae8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,7 +3,7 @@ language: java sudo: false jdk: - - oraclejdk7 + - openjdk7 env: global: