From 5eb6a967e5af1fcb573485556bb35edc0bae56b7 Mon Sep 17 00:00:00 2001 From: Jackson Tian Date: Thu, 22 Nov 2018 19:42:30 +0800 Subject: [PATCH 01/25] Fix maven compile issue --- .travis.yml | 5 +++++ README.md | 6 +++--- pom.xml | 11 ++++++++--- .../org/jacoco/examples/maven/java/HelloWorld.java | 2 +- .../jacoco/examples/maven/java/HelloWorldTest.java | 4 ++-- 5 files changed, 19 insertions(+), 9 deletions(-) diff --git a/.travis.yml b/.travis.yml index 7d0efc5..e7a82ec 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,10 @@ language: java sudo: false # faster builds +jdk: + - oraclejdk8 + - oraclejdk9 + - oraclejdk11 + after_success: - bash <(curl -s https://codecov.io/bash) diff --git a/README.md b/README.md index 07f3dae..a8047ad 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ - - - # [Codecov][0] Java Example +[![Build Status](https://travis-ci.org/codecov/example-java.svg?branch=master)](https://travis-ci.org/codecov/example-java) +[![codecov](https://codecov.io/gh/codecov/example-java/branch/master/graph/badge.svg)](https://codecov.io/gh/codecov/example-java) + ## Guide ### Travis Setup diff --git a/pom.xml b/pom.xml index ff03228..20f0038 100644 --- a/pom.xml +++ b/pom.xml @@ -1,12 +1,12 @@ - @@ -22,6 +22,11 @@ JaCoCo Maven plug-in example for Java project http://www.eclemma.org/jacoco + + UTF-8 + 1.8 + 1.8 + @@ -38,7 +43,7 @@ org.jacoco jacoco-maven-plugin - 0.7.9 + 0.8.2 diff --git a/src/main/java/org/jacoco/examples/maven/java/HelloWorld.java b/src/main/java/org/jacoco/examples/maven/java/HelloWorld.java index a36abe7..15edac4 100644 --- a/src/main/java/org/jacoco/examples/maven/java/HelloWorld.java +++ b/src/main/java/org/jacoco/examples/maven/java/HelloWorld.java @@ -1,7 +1,7 @@ package org.jacoco.examples.maven.java; public class HelloWorld { - + public String getMessage(boolean bigger) { if (bigger) { return "Hello Universe!"; diff --git a/src/test/java/org/jacoco/examples/maven/java/HelloWorldTest.java b/src/test/java/org/jacoco/examples/maven/java/HelloWorldTest.java index 2d17e16..6b8451e 100644 --- a/src/test/java/org/jacoco/examples/maven/java/HelloWorldTest.java +++ b/src/test/java/org/jacoco/examples/maven/java/HelloWorldTest.java @@ -13,10 +13,10 @@ public class HelloWorldTest { public void setup() { subject = new HelloWorld(); } - + @Test public void testGetMessage() { assertEquals("Hello World!", subject.getMessage(false)); } - + } From 2128e522f24920331e638e44c9fc477f5d1df1d2 Mon Sep 17 00:00:00 2001 From: Mihir Joshi Date: Mon, 16 Dec 2019 11:21:18 +0530 Subject: [PATCH 02/25] Update pom.xml --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index e4411a2..945ce63 100644 --- a/pom.xml +++ b/pom.xml @@ -27,7 +27,7 @@ junit junit - 4.10 + 4.12 test @@ -38,7 +38,7 @@ org.jacoco jacoco-maven-plugin - 0.8.2 + 0.8.5 From 1787fd90df0737cdffdfb786ba32efe57a2faeda Mon Sep 17 00:00:00 2001 From: Mihir Joshi Date: Mon, 16 Dec 2019 12:49:17 +0530 Subject: [PATCH 03/25] Update pom.xml --- pom.xml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pom.xml b/pom.xml index 945ce63..12fe918 100644 --- a/pom.xml +++ b/pom.xml @@ -54,6 +54,11 @@ + + org.apache.maven.plugins + maven-compiler-plugin + 3.8.0 + From 7495836d84e0cf75cc353ceabe3475bbdee86ca0 Mon Sep 17 00:00:00 2001 From: Thomas Hu Date: Thu, 6 Aug 2020 19:56:16 -0400 Subject: [PATCH 04/25] Update .travis.yml --- .travis.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index e7a82ec..665c26e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,9 +2,8 @@ language: java sudo: false # faster builds jdk: - - oraclejdk8 - - oraclejdk9 - oraclejdk11 + - oraclejdk14 after_success: - bash <(curl -s https://codecov.io/bash) From 2d9c7aa8c87b514f328d6e010471804eb64f5180 Mon Sep 17 00:00:00 2001 From: fossabot Date: Wed, 26 Aug 2020 18:20:14 -0500 Subject: [PATCH 05/25] Add license scan report and status Signed off by: fossabot --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index a40f633..092bfc7 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,7 @@ [![Build Status](https://travis-ci.org/codecov/example-java.svg?branch=master)](https://travis-ci.org/codecov/example-java) [![codecov](https://codecov.io/gh/codecov/example-java/branch/master/graph/badge.svg)](https://codecov.io/gh/codecov/example-java) +[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Fcodecov%2Fexample-java.svg?type=shield)](https://app.fossa.com/projects/git%2Bgithub.com%2Fcodecov%2Fexample-java?ref=badge_shield) ## Guide @@ -63,3 +64,7 @@ We are happy to help if you have any questions. Please contact email our Support [3]: https://github.com/codecov/example-android [4]: https://github.com/codecov/example-java-maven [5]: https://docs.codecov.io/docs/about-the-codecov-bash-uploader#section-upload-token + + +## License +[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Fcodecov%2Fexample-java.svg?type=large)](https://app.fossa.com/projects/git%2Bgithub.com%2Fcodecov%2Fexample-java?ref=badge_large) \ No newline at end of file From ac96a1f4b78e643d6ba6a8cc3a836cc3a018f6f9 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Fri, 28 Aug 2020 03:26:22 +0000 Subject: [PATCH 06/25] Bump maven-compiler-plugin from 3.8.0 to 3.8.1 Bumps [maven-compiler-plugin](https://github.com/apache/maven-compiler-plugin) from 3.8.0 to 3.8.1. - [Release notes](https://github.com/apache/maven-compiler-plugin/releases) - [Commits](https://github.com/apache/maven-compiler-plugin/compare/maven-compiler-plugin-3.8.0...maven-compiler-plugin-3.8.1) Signed-off-by: dependabot-preview[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index b14e1c2..21cb707 100644 --- a/pom.xml +++ b/pom.xml @@ -62,7 +62,7 @@ org.apache.maven.plugins maven-compiler-plugin - 3.8.0 + 3.8.1 From 7143f15e0fb7a9b49dedf6a9dca99de9389f581e Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Fri, 28 Aug 2020 03:26:46 +0000 Subject: [PATCH 07/25] Bump junit from 4.12 to 4.13 Bumps [junit](https://github.com/junit-team/junit4) from 4.12 to 4.13. - [Release notes](https://github.com/junit-team/junit4/releases) - [Changelog](https://github.com/junit-team/junit4/blob/main/doc/ReleaseNotes4.12.md) - [Commits](https://github.com/junit-team/junit4/compare/r4.12...r4.13) Signed-off-by: dependabot-preview[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index b14e1c2..f320d06 100644 --- a/pom.xml +++ b/pom.xml @@ -32,7 +32,7 @@ junit junit - 4.12 + 4.13 test From 23a41465d59018eb84bc6fa7846b30d6783df011 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Wed, 16 Sep 2020 06:53:44 +0000 Subject: [PATCH 08/25] Bump jacoco-maven-plugin from 0.8.5 to 0.8.6 Bumps [jacoco-maven-plugin](https://github.com/jacoco/jacoco) from 0.8.5 to 0.8.6. - [Release notes](https://github.com/jacoco/jacoco/releases) - [Commits](https://github.com/jacoco/jacoco/compare/v0.8.5...v0.8.6) Signed-off-by: dependabot-preview[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 22a6189..07c644b 100644 --- a/pom.xml +++ b/pom.xml @@ -43,7 +43,7 @@ org.jacoco jacoco-maven-plugin - 0.8.5 + 0.8.6 From 605910d18bea47a91f5d2dd046a896d24f8acd5d Mon Sep 17 00:00:00 2001 From: xMaNaSx <72237817+xMaNaSx@users.noreply.github.com> Date: Fri, 2 Oct 2020 07:31:06 +0530 Subject: [PATCH 09/25] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 092bfc7..b5f89d8 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,7 @@ env: #### JaCoCo Reports -- Make sure you are on the most up-to-date JaCoCo version. There are issues with previous versions of JaCoCo. +- Make sure you are using the latest version of JaCoCo. There are issues with previous versions of JaCoCo. - JaCoCo reports can expire - Codecov will reject reports that are older than 12 hours. The logs contain details if a report expired. ## Support @@ -67,4 +67,4 @@ We are happy to help if you have any questions. Please contact email our Support ## License -[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Fcodecov%2Fexample-java.svg?type=large)](https://app.fossa.com/projects/git%2Bgithub.com%2Fcodecov%2Fexample-java?ref=badge_large) \ No newline at end of file +[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Fcodecov%2Fexample-java.svg?type=large)](https://app.fossa.com/projects/git%2Bgithub.com%2Fcodecov%2Fexample-java?ref=badge_large) From 97deec1b28f4f95c854b27deb7ba352eb4b5add5 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Mon, 12 Oct 2020 06:57:15 +0000 Subject: [PATCH 10/25] Bump junit from 4.13 to 4.13.1 Bumps [junit](https://github.com/junit-team/junit4) from 4.13 to 4.13.1. - [Release notes](https://github.com/junit-team/junit4/releases) - [Changelog](https://github.com/junit-team/junit4/blob/main/doc/ReleaseNotes4.13.1.md) - [Commits](https://github.com/junit-team/junit4/compare/r4.13...r4.13.1) Signed-off-by: dependabot-preview[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 07c644b..1a19f91 100644 --- a/pom.xml +++ b/pom.xml @@ -32,7 +32,7 @@ junit junit - 4.13 + 4.13.1 test From 7f9091cc418fcd291d04c06146c170ccc88f74b6 Mon Sep 17 00:00:00 2001 From: Bhathiya Jayasekara Date: Tue, 16 Feb 2021 16:36:57 +0530 Subject: [PATCH 11/25] Fix code range in the git link --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b5f89d8..f9764b7 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ after_success: ``` ### Produce Coverage Reports -1. Add JaCoCo Plugin to your pom.xml file, [see here](https://github.com/codecov/example-java/blob/master/pom.xml#L38-L56) +1. Add JaCoCo Plugin to your pom.xml file, [see here](https://github.com/codecov/example-java/blob/master/pom.xml#L43-L61) ## Caveats From eb292cf0c0645e0c97e43d1edaacf6d1c79e25d4 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Thu, 22 Apr 2021 06:41:27 +0000 Subject: [PATCH 12/25] Bump junit from 4.13.1 to 4.13.2 Bumps [junit](https://github.com/junit-team/junit4) from 4.13.1 to 4.13.2. - [Release notes](https://github.com/junit-team/junit4/releases) - [Changelog](https://github.com/junit-team/junit4/blob/main/doc/ReleaseNotes4.13.1.md) - [Commits](https://github.com/junit-team/junit4/compare/r4.13.1...r4.13.2) Signed-off-by: dependabot-preview[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 1a19f91..6367533 100644 --- a/pom.xml +++ b/pom.xml @@ -32,7 +32,7 @@ junit junit - 4.13.1 + 4.13.2 test From c7a541678bc7d3e6ea148d1c3809190c97e0e2b8 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Thu, 29 Apr 2021 22:04:28 +0000 Subject: [PATCH 13/25] Upgrade to GitHub-native Dependabot --- .github/dependabot.yml | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 .github/dependabot.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..a217b34 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,7 @@ +version: 2 +updates: +- package-ecosystem: maven + directory: "/" + schedule: + interval: daily + open-pull-requests-limit: 10 From 30be86670e2de78279015a6644be5b9a0d82e587 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Wed, 5 May 2021 06:16:48 +0000 Subject: [PATCH 14/25] Bump jacoco-maven-plugin from 0.8.6 to 0.8.7 Bumps [jacoco-maven-plugin](https://github.com/jacoco/jacoco) from 0.8.6 to 0.8.7. - [Release notes](https://github.com/jacoco/jacoco/releases) - [Commits](https://github.com/jacoco/jacoco/compare/v0.8.6...v0.8.7) Signed-off-by: dependabot-preview[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 1a19f91..e435177 100644 --- a/pom.xml +++ b/pom.xml @@ -43,7 +43,7 @@ org.jacoco jacoco-maven-plugin - 0.8.6 + 0.8.7 From 69598880bd5619e6597d38aa4ba24bdb7c7a7fdb Mon Sep 17 00:00:00 2001 From: Tom Hu Date: Sun, 14 Aug 2022 23:32:24 -0700 Subject: [PATCH 15/25] Move to caluclator --- .github/workflows/ci.yml | 18 +++++ .travis.yml | 9 --- pom.xml | 80 +++++++------------ src/Calculator.java | 7 ++ src/CalculatorTest.java | 12 +++ .../examples/maven/java/HelloWorld.java | 13 --- .../examples/maven/java/HelloWorldTest.java | 22 ----- 7 files changed, 66 insertions(+), 95 deletions(-) create mode 100644 .github/workflows/ci.yml delete mode 100644 .travis.yml create mode 100644 src/Calculator.java create mode 100644 src/CalculatorTest.java delete mode 100644 src/main/java/org/jacoco/examples/maven/java/HelloWorld.java delete mode 100644 src/test/java/org/jacoco/examples/maven/java/HelloWorldTest.java diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..20c7de6 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,18 @@ +name: Workflow for Codecov example-java +on: [push, pull_request] +jobs: + run: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Set up JDK 18 + uses: actions/setup-java@v1 + with: + java-version: 18 + - name: Test with Maven + run: mvn -B test --file pom.xml + - name: ls + run: ls + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v3 diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 665c26e..0000000 --- a/.travis.yml +++ /dev/null @@ -1,9 +0,0 @@ -language: java -sudo: false # faster builds - -jdk: - - oraclejdk11 - - oraclejdk14 - -after_success: - - bash <(curl -s https://codecov.io/bash) diff --git a/pom.xml b/pom.xml index 8923188..30a14e2 100644 --- a/pom.xml +++ b/pom.xml @@ -1,70 +1,48 @@ - - - + 4.0.0 + io.codecov + example-java + 1.0 - org.jacoco - org.jacoco.examples.maven.java - 1.0-SNAPSHOT - jar - - JaCoCo Maven plug-in example for Java project - http://www.eclemma.org/jacoco + Codecov example Java repository + http://github.com/codecov/example-java + 18 UTF-8 - 1.8 - 1.8 junit junit - 4.13.2 + 5.7.1 test - src/main/java - - - org.jacoco - jacoco-maven-plugin - 0.8.7 - - - - prepare-agent - - - - report - test - - report - - - - - - org.apache.maven.plugins - maven-compiler-plugin - 3.8.1 - - - + + org.jacoco + jacoco-maven-plugin + 0.8.8 + + + prepare-agent + + prepare-agent + + + + report + test + + report + + + + + diff --git a/src/Calculator.java b/src/Calculator.java new file mode 100644 index 0000000..efa95f0 --- /dev/null +++ b/src/Calculator.java @@ -0,0 +1,7 @@ +package io.codecov; + +public class Calculator { + public int add(int x, int y) { + return x + y + } +} diff --git a/src/CalculatorTest.java b/src/CalculatorTest.java new file mode 100644 index 0000000..c03a822 --- /dev/null +++ b/src/CalculatorTest.java @@ -0,0 +1,12 @@ +package io.codecov; + +import static org.junit.Assert.*; + +import org.junit.Test; + +public class CalculatorTest { + @Test + public void testAdd() { + assertEquals(new Calculator.add(1, 1), 2); + } +} diff --git a/src/main/java/org/jacoco/examples/maven/java/HelloWorld.java b/src/main/java/org/jacoco/examples/maven/java/HelloWorld.java deleted file mode 100644 index 15edac4..0000000 --- a/src/main/java/org/jacoco/examples/maven/java/HelloWorld.java +++ /dev/null @@ -1,13 +0,0 @@ -package org.jacoco.examples.maven.java; - -public class HelloWorld { - - public String getMessage(boolean bigger) { - if (bigger) { - return "Hello Universe!"; - } else { - return "Hello World!"; - } - } - -} diff --git a/src/test/java/org/jacoco/examples/maven/java/HelloWorldTest.java b/src/test/java/org/jacoco/examples/maven/java/HelloWorldTest.java deleted file mode 100644 index 6b8451e..0000000 --- a/src/test/java/org/jacoco/examples/maven/java/HelloWorldTest.java +++ /dev/null @@ -1,22 +0,0 @@ -package org.jacoco.examples.maven.java; - -import static org.junit.Assert.*; - -import org.junit.Before; -import org.junit.Test; - -public class HelloWorldTest { - - private HelloWorld subject; - - @Before - public void setup() { - subject = new HelloWorld(); - } - - @Test - public void testGetMessage() { - assertEquals("Hello World!", subject.getMessage(false)); - } - -} From 8a1bb0b57fc063a0562d6c0e316e3ef1d2b2a221 Mon Sep 17 00:00:00 2001 From: Tom Hu Date: Mon, 15 Aug 2022 12:07:19 -0700 Subject: [PATCH 16/25] maven --- .github/workflows/{ci.yml => ci-maven.yml} | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) rename .github/workflows/{ci.yml => ci-maven.yml} (72%) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci-maven.yml similarity index 72% rename from .github/workflows/ci.yml rename to .github/workflows/ci-maven.yml index 20c7de6..66987f6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci-maven.yml @@ -1,4 +1,4 @@ -name: Workflow for Codecov example-java +name: Workflow for Codecov example-java using Maven on: [push, pull_request] jobs: run: @@ -10,6 +10,8 @@ jobs: uses: actions/setup-java@v1 with: java-version: 18 + - name: Install dependencies + run: mvn install -DskipTests=true -Dmaven.javadoc.skip=true -B -V - name: Test with Maven run: mvn -B test --file pom.xml - name: ls From 9c93db971039de623d37af3437217b8acd5dd642 Mon Sep 17 00:00:00 2001 From: Tom Hu Date: Mon, 15 Aug 2022 12:10:00 -0700 Subject: [PATCH 17/25] plugins --- pom.xml | 42 ++++++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/pom.xml b/pom.xml index 30a14e2..8925cee 100644 --- a/pom.xml +++ b/pom.xml @@ -23,26 +23,28 @@ - - org.jacoco - jacoco-maven-plugin - 0.8.8 - - - prepare-agent - - prepare-agent - - - - report - test - - report - - - - + + + org.jacoco + jacoco-maven-plugin + 0.8.8 + + + prepare-agent + + prepare-agent + + + + report + test + + report + + + + + From 13ce5beca9e905f16b6e717231edd6f7a1c900a6 Mon Sep 17 00:00:00 2001 From: Tom Hu Date: Mon, 15 Aug 2022 12:11:27 -0700 Subject: [PATCH 18/25] version of junit to 4.13.2 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 8925cee..7e9935f 100644 --- a/pom.xml +++ b/pom.xml @@ -17,7 +17,7 @@ junit junit - 5.7.1 + 4.13.2 test From 8c39974e5899bca59004d1255d51abc60732de06 Mon Sep 17 00:00:00 2001 From: Tom Hu Date: Mon, 15 Aug 2022 12:45:28 -0700 Subject: [PATCH 19/25] Update dir structure --- .gitignore | 1 + pom.xml | 3 ++- src/Calculator.java | 7 ------- src/main/java/calculator/Calculator.java | 7 +++++++ src/{ => test/java/calculator}/CalculatorTest.java | 4 ++-- 5 files changed, 12 insertions(+), 10 deletions(-) create mode 100644 .gitignore delete mode 100644 src/Calculator.java create mode 100644 src/main/java/calculator/Calculator.java rename src/{ => test/java/calculator}/CalculatorTest.java (65%) diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..2f7896d --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +target/ diff --git a/pom.xml b/pom.xml index 7e9935f..8959d20 100644 --- a/pom.xml +++ b/pom.xml @@ -9,7 +9,8 @@ Codecov example Java repository http://github.com/codecov/example-java - 18 + 18 + 18 UTF-8 diff --git a/src/Calculator.java b/src/Calculator.java deleted file mode 100644 index efa95f0..0000000 --- a/src/Calculator.java +++ /dev/null @@ -1,7 +0,0 @@ -package io.codecov; - -public class Calculator { - public int add(int x, int y) { - return x + y - } -} diff --git a/src/main/java/calculator/Calculator.java b/src/main/java/calculator/Calculator.java new file mode 100644 index 0000000..86a68eb --- /dev/null +++ b/src/main/java/calculator/Calculator.java @@ -0,0 +1,7 @@ +package calculator; + +public class Calculator { + public static int add(int x, int y) { + return x + y; + } +} diff --git a/src/CalculatorTest.java b/src/test/java/calculator/CalculatorTest.java similarity index 65% rename from src/CalculatorTest.java rename to src/test/java/calculator/CalculatorTest.java index c03a822..fc08b21 100644 --- a/src/CalculatorTest.java +++ b/src/test/java/calculator/CalculatorTest.java @@ -1,4 +1,4 @@ -package io.codecov; +package calculator; import static org.junit.Assert.*; @@ -7,6 +7,6 @@ public class CalculatorTest { @Test public void testAdd() { - assertEquals(new Calculator.add(1, 1), 2); + assertEquals(new Calculator().add(1, 1), 2); } } From cf7246ca530a4d92439dccdfcbc4e4d158523fd3 Mon Sep 17 00:00:00 2001 From: Tom Hu Date: Mon, 15 Aug 2022 12:48:18 -0700 Subject: [PATCH 20/25] Update calculator --- src/main/java/calculator/Calculator.java | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/main/java/calculator/Calculator.java b/src/main/java/calculator/Calculator.java index 86a68eb..4ab41f8 100644 --- a/src/main/java/calculator/Calculator.java +++ b/src/main/java/calculator/Calculator.java @@ -1,7 +1,23 @@ package calculator; public class Calculator { - public static int add(int x, int y) { + public static double add(double x, double y) { return x + y; } + + public static double subtract(double x, double y) { + return x - y; + } + + public static double multiply(double x, double y) { + return x * y; + } + + public static double divide(double x, double y) { + if (y == 0) { + System.out.println("Cannot divide by 0"); + return 0; + } + return x / y; + } } From 7d5ff74696f1b92b4ac950284809fc8232497cce Mon Sep 17 00:00:00 2001 From: Tom Hu Date: Mon, 15 Aug 2022 12:52:46 -0700 Subject: [PATCH 21/25] Update tests --- .github/workflows/ci-maven.yml | 2 -- src/test/java/calculator/CalculatorTest.java | 4 +++- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci-maven.yml b/.github/workflows/ci-maven.yml index 66987f6..ee78883 100644 --- a/.github/workflows/ci-maven.yml +++ b/.github/workflows/ci-maven.yml @@ -14,7 +14,5 @@ jobs: run: mvn install -DskipTests=true -Dmaven.javadoc.skip=true -B -V - name: Test with Maven run: mvn -B test --file pom.xml - - name: ls - run: ls - name: Upload coverage to Codecov uses: codecov/codecov-action@v3 diff --git a/src/test/java/calculator/CalculatorTest.java b/src/test/java/calculator/CalculatorTest.java index fc08b21..4735e30 100644 --- a/src/test/java/calculator/CalculatorTest.java +++ b/src/test/java/calculator/CalculatorTest.java @@ -5,8 +5,10 @@ import org.junit.Test; public class CalculatorTest { + private static final double DELTA = 0.001; + @Test public void testAdd() { - assertEquals(new Calculator().add(1, 1), 2); + assertEquals(new Calculator().add(1, 1), 2, DELTA); } } From f34cf056e38cacb53fef76257cd53711593f041e Mon Sep 17 00:00:00 2001 From: Tom Hu Date: Mon, 15 Aug 2022 12:56:59 -0700 Subject: [PATCH 22/25] Add all tests --- src/test/java/calculator/CalculatorTest.java | 36 ++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/src/test/java/calculator/CalculatorTest.java b/src/test/java/calculator/CalculatorTest.java index 4735e30..0f860a3 100644 --- a/src/test/java/calculator/CalculatorTest.java +++ b/src/test/java/calculator/CalculatorTest.java @@ -1,6 +1,6 @@ package calculator; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; import org.junit.Test; @@ -9,6 +9,38 @@ public class CalculatorTest { @Test public void testAdd() { - assertEquals(new Calculator().add(1, 1), 2, DELTA); + assertEquals(Calculator.add(1, 2), 3.0, DELTA); + assertEquals(Calculator.add(1.0, 2.0), 3.0, DELTA); + assertEquals(Calculator.add(0, 2.0), 2.0, DELTA); + assertEquals(Calculator.add(2.0, 0), 2.0, DELTA); + assertEquals(Calculator.add(-4, 2.0), -2.0, DELTA); + } + + @Test + public void testSubtract() { + assertEquals(Calculator.subtract(1, 2), -1.0, DELTA); + assertEquals(Calculator.subtract(2, 1), 1.0, DELTA); + assertEquals(Calculator.subtract(1.0, 2.0), -1.0, DELTA); + assertEquals(Calculator.subtract(0, 2.0), -2.0, DELTA); + assertEquals(Calculator.subtract(2.0, 0), 2.0, DELTA); + assertEquals(Calculator.subtract(-4, 2.0), -6.0, DELTA); + } + + @Test + public void testMultiply() { + assertEquals(Calculator.multiply(1, 2), 2.0, DELTA); + assertEquals(Calculator.multiply(1.0, 2.0), 2.0, DELTA); + assertEquals(Calculator.multiply(0, 2.0), 0.0, DELTA); + assertEquals(Calculator.multiply(2.0, 0), 0.0, DELTA); + assertEquals(Calculator.multiply(-4, 2.0), -8.0, DELTA); + } + + @Test + public void testDivide() { + assertEquals(Calculator.divide(1, 2), 0.5, DELTA); + assertEquals(Calculator.divide(1.0, 2.0), 0.5, DELTA); + assertEquals(Calculator.divide(0, 2.0), 0, DELTA); + assertEquals(Calculator.divide(-4, 2.0), -2.0, DELTA); + // assertEquals(Calculator.divide(2.0, 0), 0.0, DELTA); } } From ea816710a3f143c9de818814342c450937b4fb0d Mon Sep 17 00:00:00 2001 From: Tom Hu Date: Wed, 24 Aug 2022 17:24:25 -0700 Subject: [PATCH 23/25] strip repository to be a placeholder --- .github/dependabot.yml | 7 -- .github/workflows/ci-maven.yml | 18 ----- .gitignore | 1 - README.md | 77 +++----------------- pom.xml | 51 ------------- src/main/java/calculator/Calculator.java | 23 ------ src/test/java/calculator/CalculatorTest.java | 46 ------------ 7 files changed, 12 insertions(+), 211 deletions(-) delete mode 100644 .github/dependabot.yml delete mode 100644 .github/workflows/ci-maven.yml delete mode 100644 .gitignore delete mode 100644 pom.xml delete mode 100644 src/main/java/calculator/Calculator.java delete mode 100644 src/test/java/calculator/CalculatorTest.java diff --git a/.github/dependabot.yml b/.github/dependabot.yml deleted file mode 100644 index a217b34..0000000 --- a/.github/dependabot.yml +++ /dev/null @@ -1,7 +0,0 @@ -version: 2 -updates: -- package-ecosystem: maven - directory: "/" - schedule: - interval: daily - open-pull-requests-limit: 10 diff --git a/.github/workflows/ci-maven.yml b/.github/workflows/ci-maven.yml deleted file mode 100644 index ee78883..0000000 --- a/.github/workflows/ci-maven.yml +++ /dev/null @@ -1,18 +0,0 @@ -name: Workflow for Codecov example-java using Maven -on: [push, pull_request] -jobs: - run: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v2 - - name: Set up JDK 18 - uses: actions/setup-java@v1 - with: - java-version: 18 - - name: Install dependencies - run: mvn install -DskipTests=true -Dmaven.javadoc.skip=true -B -V - - name: Test with Maven - run: mvn -B test --file pom.xml - - name: Upload coverage to Codecov - uses: codecov/codecov-action@v3 diff --git a/.gitignore b/.gitignore deleted file mode 100644 index 2f7896d..0000000 --- a/.gitignore +++ /dev/null @@ -1 +0,0 @@ -target/ diff --git a/README.md b/README.md index f9764b7..ad1db91 100644 --- a/README.md +++ b/README.md @@ -1,70 +1,17 @@ -# [Codecov][0] Java Example - -[![Build Status](https://travis-ci.org/codecov/example-java.svg?branch=master)](https://travis-ci.org/codecov/example-java) -[![codecov](https://codecov.io/gh/codecov/example-java/branch/master/graph/badge.svg)](https://codecov.io/gh/codecov/example-java) +# [Codecov](https://codecov.io) Java [![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Fcodecov%2Fexample-java.svg?type=shield)](https://app.fossa.com/projects/git%2Bgithub.com%2Fcodecov%2Fexample-java?ref=badge_shield) -## Guide - -### Travis Setup - -Add the following to your `.travis.yml`: -```yml -language: java -after_success: - - bash <(curl -s https://codecov.io/bash) -``` - -### Produce Coverage Reports -1. Add JaCoCo Plugin to your pom.xml file, [see here](https://github.com/codecov/example-java/blob/master/pom.xml#L43-L61) - -## Caveats - -#### Private Repo -You will need to add the following your `.travis.yml`: -```yml -env: - global: - - CODECOV_TOKEN=:uuid-repo-token -``` - -#### JaCoCo Reports - -- Make sure you are using the latest version of JaCoCo. There are issues with previous versions of JaCoCo. -- JaCoCo reports can expire - Codecov will reject reports that are older than 12 hours. The logs contain details if a report expired. - -## Support - -### FAQ -- Q: How do I enable multi-module projects?
A: In your `pom.xml` file please append a list of modules in your projects: -```xml - - - module_a/ - module_b/ - - -``` -- Q: Seeing `Skipping JaCoCo execution due to missing execution data file`?
A: Please see [http://stackoverflow.com/questions/18107375/...](http://stackoverflow.com/questions/18107375/getting-skipping-jacoco-execution-due-to-missing-execution-data-file-upon-exec). -- We should talk about using other CIs here. -- Q: Does Codecov accept `jacoco.exec` reports?
A: **No**, these files are not supported. Please produce a `xml` file as detailed in the pom.xml file at [codecov/example-java][1]. -- Q: Is there a Gradle example?
A: **Yes**, enter [codecov/example-gradle][2] -- Q: Is there a Android example?
A: **Yes**, enter [codecov/example-android][3] -- Q: Is there a Maven example?
A: **Yes**, enter [codecov/example-maven][4] - -1. More documentation at https://docs.codecov.io -2. Configure codecov through the `codecov.yml` https://docs.codecov.io/docs/codecov-yaml -3. View source and learn more about [Codecov Global Uploader](https://github.com/codecov/codecov-bash) - -We are happy to help if you have any questions. Please contact email our Support at [support@codecov.io](mailto:support@codecov.io) +This repository points to other example repositories on how Codecov can be integrated with a simple Java project. -[0]: https://codecov.io/ -[1]: https://github.com/codecov/example-java -[2]: https://github.com/codecov/example-gradle -[3]: https://github.com/codecov/example-android -[4]: https://github.com/codecov/example-java-maven -[5]: https://docs.codecov.io/docs/about-the-codecov-bash-uploader#section-upload-token +- [example-java-gradle](https://github.com/codecov/example-java-gradle) +- [example-java-maven](https://github.com/codecov/example-java-maven) +- [example-java-android](https://github.com/codecov/example-java-android) +For more information, please see the links below. -## License -[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Fcodecov%2Fexample-java.svg?type=large)](https://app.fossa.com/projects/git%2Bgithub.com%2Fcodecov%2Fexample-java?ref=badge_large) +## Links +- [Quick Start](https://docs.codecov.com/docs/quick-start) +- [GitHub Tutorial](https://docs.codecov.com/docs/github-tutorial) +- [Community Boards](https://community.codecov.io) +- [Support](https://codecov.io/support) +- [Documentation](https://docs.codecov.io) diff --git a/pom.xml b/pom.xml deleted file mode 100644 index 8959d20..0000000 --- a/pom.xml +++ /dev/null @@ -1,51 +0,0 @@ - - - - 4.0.0 - io.codecov - example-java - 1.0 - - Codecov example Java repository - http://github.com/codecov/example-java - - 18 - 18 - UTF-8 - - - - - junit - junit - 4.13.2 - test - - - - - - - org.jacoco - jacoco-maven-plugin - 0.8.8 - - - prepare-agent - - prepare-agent - - - - report - test - - report - - - - - - - - diff --git a/src/main/java/calculator/Calculator.java b/src/main/java/calculator/Calculator.java deleted file mode 100644 index 4ab41f8..0000000 --- a/src/main/java/calculator/Calculator.java +++ /dev/null @@ -1,23 +0,0 @@ -package calculator; - -public class Calculator { - public static double add(double x, double y) { - return x + y; - } - - public static double subtract(double x, double y) { - return x - y; - } - - public static double multiply(double x, double y) { - return x * y; - } - - public static double divide(double x, double y) { - if (y == 0) { - System.out.println("Cannot divide by 0"); - return 0; - } - return x / y; - } -} diff --git a/src/test/java/calculator/CalculatorTest.java b/src/test/java/calculator/CalculatorTest.java deleted file mode 100644 index 0f860a3..0000000 --- a/src/test/java/calculator/CalculatorTest.java +++ /dev/null @@ -1,46 +0,0 @@ -package calculator; - -import static org.junit.Assert.assertEquals; - -import org.junit.Test; - -public class CalculatorTest { - private static final double DELTA = 0.001; - - @Test - public void testAdd() { - assertEquals(Calculator.add(1, 2), 3.0, DELTA); - assertEquals(Calculator.add(1.0, 2.0), 3.0, DELTA); - assertEquals(Calculator.add(0, 2.0), 2.0, DELTA); - assertEquals(Calculator.add(2.0, 0), 2.0, DELTA); - assertEquals(Calculator.add(-4, 2.0), -2.0, DELTA); - } - - @Test - public void testSubtract() { - assertEquals(Calculator.subtract(1, 2), -1.0, DELTA); - assertEquals(Calculator.subtract(2, 1), 1.0, DELTA); - assertEquals(Calculator.subtract(1.0, 2.0), -1.0, DELTA); - assertEquals(Calculator.subtract(0, 2.0), -2.0, DELTA); - assertEquals(Calculator.subtract(2.0, 0), 2.0, DELTA); - assertEquals(Calculator.subtract(-4, 2.0), -6.0, DELTA); - } - - @Test - public void testMultiply() { - assertEquals(Calculator.multiply(1, 2), 2.0, DELTA); - assertEquals(Calculator.multiply(1.0, 2.0), 2.0, DELTA); - assertEquals(Calculator.multiply(0, 2.0), 0.0, DELTA); - assertEquals(Calculator.multiply(2.0, 0), 0.0, DELTA); - assertEquals(Calculator.multiply(-4, 2.0), -8.0, DELTA); - } - - @Test - public void testDivide() { - assertEquals(Calculator.divide(1, 2), 0.5, DELTA); - assertEquals(Calculator.divide(1.0, 2.0), 0.5, DELTA); - assertEquals(Calculator.divide(0, 2.0), 0, DELTA); - assertEquals(Calculator.divide(-4, 2.0), -2.0, DELTA); - // assertEquals(Calculator.divide(2.0, 0), 0.0, DELTA); - } -} From 40dc876e1dd249e1a2cb817a4852b057da904109 Mon Sep 17 00:00:00 2001 From: Tom Hu <88201630+thomasrockhu-codecov@users.noreply.github.com> Date: Mon, 31 Oct 2022 16:32:45 -0400 Subject: [PATCH 24/25] Create LICENSE.md --- LICENSE.md | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 LICENSE.md diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..c341b2a --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2022 Codecov + +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. From b8a1bc6cbfa6ba6e7238e17f0a908c7ee4b0133a Mon Sep 17 00:00:00 2001 From: Tom Hu Date: Mon, 22 Jan 2024 12:27:04 -0800 Subject: [PATCH 25/25] chore(ci): add fossa workflow --- .github/workflows/enforce-license-compliance.yml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 .github/workflows/enforce-license-compliance.yml diff --git a/.github/workflows/enforce-license-compliance.yml b/.github/workflows/enforce-license-compliance.yml new file mode 100644 index 0000000..86be741 --- /dev/null +++ b/.github/workflows/enforce-license-compliance.yml @@ -0,0 +1,14 @@ +name: Enforce License Compliance + +on: + pull_request: + branches: [main, master] + +jobs: + enforce-license-compliance: + runs-on: ubuntu-latest + steps: + - name: 'Enforce License Compliance' + uses: getsentry/action-enforce-license-compliance@57ba820387a1a9315a46115ee276b2968da51f3d # main + with: + fossa_api_key: ${{ secrets.FOSSA_API_KEY }}