Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
version: 2.1
orbs:
codecov: codecov/codecov@3

jobs:
build:
docker:
- image: cimg/openjdk:18.0.2
steps:
- checkout
- run:
name: Install dependencies, run tests, and collect coverage
command: gradle build
- codecov/upload

workflow:
version: 2.1
build-test:
jobs:
- build
7 changes: 7 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
version: 2
updates:
- package-ecosystem: maven
directory: "/"
schedule:
interval: daily
open-pull-requests-limit: 10
16 changes: 16 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Workflow for Codecov example-java-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 tests, and collect coverage
run: gradle build
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
34 changes: 1 addition & 33 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,34 +1,2 @@
# Created by .ignore support plugin (hsz.mobi)
### Java template
*.class

# Package Files #
*.jar

### Maven template
target/
pom.xml.tag
pom.xml.releaseBackup
pom.xml.versionsBackup
pom.xml.next
release.properties
dependency-reduced-pom.xml
buildNumber.properties
.mvn/timing.properties

### JetBrains template
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio

*.iml

## Directory-based project format:
.idea/


### Gradle template
.gradle
.gradle/
build/

# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored)
!gradle-wrapper.jar

4 changes: 0 additions & 4 deletions .travis.yml

This file was deleted.

85 changes: 8 additions & 77 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,87 +1,18 @@
# [Codecov](https://codecov.io) Gradle Example
[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Fcodecov%2Fexample-gradle.svg?type=shield)](https://app.fossa.com/projects/git%2Bgithub.com%2Fcodecov%2Fexample-gradle?ref=badge_shield)
# [Codecov](https://codecov.io) Java Gradle Example
[![codecov](https://codecov.io/github/codecov/example-java-gradle/branch/main/graph/badge.svg?token=jotejZaRVK)](https://app.codecov.io/github/codecov/example-java-gradle)
[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Fcodecov%2Fexample-java-gradle.svg?type=shield)](https://app.fossa.com/projects/git%2Bgithub.com%2Fcodecov%2Fexample-java-gradle?ref=badge_shield)

This example repository shows how Codecov can be integrated with a simple java-gradle project. It uses **GitHub Actions** and **CircleCI** as CI/CD providers and **Jacoco** as the coverage provider.

## Guide
### Travis Setup

Add to your `.travis.yml` file.
```yml
language: java
jdk:
- oraclejdk8
before_script:
- chmod +x gradlew
script:
- ./gradlew check
- ./gradlew codeCoverageReport
after_success:
- bash <(curl -s https://codecov.io/bash)
```

### Produce Coverage Reports
1. Add Jacoco Plugin to your `build.gradle`. [See here](https://github.com/codecov/example-gradle/blob/master/build.gradle#L5)
2. Set Jacoco to export xml. [See here](https://github.com/codecov/example-gradle/blob/master/build.gradle#L18-L23)
3. Execute your tests as normal
4. Call `gradle jacocoTestReport` to generate report. [See here](https://github.com/codecov/example-gradle/blob/65f88382659cf17c8693c3079941a12c8d004f03/circle.yml#L3)

### FAQ
- Q: Do you support Multi-module projects?<br/>A:Update your parent (root) `build.gradle`:
```groovy
allprojects {
apply plugin: 'java'
apply plugin: 'maven'
apply plugin: 'jacoco'

sourceCompatibility = 1.8
targetCompatibility = 1.8

repositories {
mavenLocal()
mavenCentral()
jcenter()

maven { url "http://repo1.maven.org/maven2/" }
}
}

subprojects {
dependencies {
...
}

test.useTestNG()
}

task codeCoverageReport(type: JacocoReport) {
executionData fileTree(project.rootDir.absolutePath).include("**/build/jacoco/*.exec")

subprojects.each {
sourceSets it.sourceSets.main
}

reports {
xml.enabled true
xml.destination file("${buildDir}/reports/jacoco/report.xml")
html.enabled false
csv.enabled false
}
}

codeCoverageReport.dependsOn {
subprojects*.test
}
```

## Caveats
### Private Repo
Repository tokens are required for (a) all private repos, (b) public repos not using Travis-CI, CircleCI or AppVeyor. Find your repository token at Codecov and provide via appending `-t <your upload token>` to you where you upload reports.
For more information, please see the links below.

## 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)


## License
[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Fcodecov%2Fexample-gradle.svg?type=large)](https://app.fossa.com/projects/git%2Bgithub.com%2Fcodecov%2Fexample-gradle?ref=badge_large)
[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Fcodecov%2Fexample-java-gradle.svg?type=large)](https://app.fossa.com/projects/git%2Bgithub.com%2Fcodecov%2Fexample-java-gradle?ref=badge_large)
10 changes: 5 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
group 'org.jacoco'
version '1.0-SNAPSHOT'
group 'io.codecov'
version '1.0'

apply plugin: 'java'
apply plugin: 'jacoco'

sourceCompatibility = 1.7
targetCompatibility = 1.7
sourceCompatibility = 18
targetCompatibility = 18

repositories {
mavenCentral()
}

dependencies {
testCompile group: 'junit', name: 'junit', version: '4.11'
testImplementation "junit:junit:4.13"
}

jacocoTestReport {
Expand Down
4 changes: 0 additions & 4 deletions circle.yml

This file was deleted.

Binary file removed gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
5 changes: 0 additions & 5 deletions gradle/wrapper/gradle-wrapper.properties

This file was deleted.

164 changes: 0 additions & 164 deletions gradlew

This file was deleted.

Loading