|
1 | | -Codecov Java Example |
2 | | -==================== |
| 1 | +[Codecov][1] Gradle Example |
| 2 | +=========================== |
3 | 3 |
|
4 | | -| [https://codecov.io][1] | [@codecov][2] | [hello@codecov.io][3] | |
5 | | -| ----------------------- | ------------- | --------------------- | |
| 4 | +1. Add Jacoco Plugin to your `build.gradle`. [See here](https://github.com/codecov/example-gradle/blob/master/build.gradle#L5 |
| 5 | +1. Set Jacoco to export xml. [See here](https://github.com/codecov/example-gradle/blob/master/build.gradle#L18-L23) |
| 6 | +1. Execute your tests as normal |
| 7 | +1. Call `if [ -e ./gradlew ]; then ./gradlew jacocoTestReport;else gradle jacocoTestReport;fi` to generate report. [See here](https://github.com/codecov/example-gradle/blob/65f88382659cf17c8693c3079941a12c8d004f03/circle.yml#L3) |
| 8 | +1. Call `bash <(curl -s https://codecov.io/bash)` to upload reports to Codecov. [See here](https://github.com/codecov/example-gradle/blob/65f88382659cf17c8693c3079941a12c8d004f03/circle.yml#L4) |
| 9 | + - Public project? Using TravisCI, CircleCI or AppVeyor? You're all set! No upload token required. |
| 10 | + - Otherwise please include your repository upload token. [See here](http://docs.codecov.io/v4.3.0/docs/about-the-codecov-bash-uploader#section-upload-token) |
6 | 11 |
|
7 | | -This repository serves as an **example** on how to use [Codecov Global][4] for Java with a [Gradle][5] build script. |
8 | 12 |
|
9 | | -## Usage |
| 13 | +## Frequently Asked Questions |
10 | 14 |
|
| 15 | +####❔ Do you support Multi-module projects? |
11 | 16 |
|
12 | | -### Add Jacoco plugin |
13 | | -Gradle ships with a [JaCoCo plugin][6]. Just add it to your `build.gradle`. |
14 | | -```groovy |
15 | | -apply plugin: 'jacoco' |
16 | | -``` |
17 | | - |
18 | | -And enable the `jacoco` XML report. |
19 | | -```groovy |
20 | | -jacocoTestReport { |
21 | | - reports { |
22 | | - xml.enabled true |
23 | | - } |
24 | | -} |
25 | | -``` |
26 | | - |
27 | | -# Circle CI |
28 | | - |
29 | | -Add to your `circle.yml` file. |
30 | | -```yml |
31 | | -test: |
32 | | - post: |
33 | | - - if [ -e ./gradlew ]; then ./gradlew jacocoTestReport;else gradle jacocoTestReport;fi |
34 | | - - bash <(curl -s https://codecov.io/bash) |
35 | | -``` |
36 | | -
|
37 | | -> Another option is our [Bash uploader][7] |
38 | | -
|
39 | | -## Private Repos |
40 | | -
|
41 | | -Add to your `.travis.yml` file. |
42 | | -```yml |
43 | | -test: |
44 | | - post: |
45 | | - - if [ -e ./gradlew ]; then ./gradlew jacocoTestReport;else gradle jacocoTestReport;fi |
46 | | - - bash <(curl -s https://codecov.io/bash) -t uuid-repo-token |
47 | | -``` |
48 | | - |
49 | | -View source and learn more about [Codecov Global Uploader][4] |
50 | | - |
51 | | -## Multi-module projects (exmple with Travis CI) |
52 | 17 | Update your parent (root) `build.gradle`: |
53 | 18 | ```groovy |
54 | 19 | allprojects { |
@@ -112,14 +77,7 @@ after_success: |
112 | 77 |
|
113 | 78 | No need to have anything else report-related in child modules |
114 | 79 |
|
115 | | -[Credits for multi-module][8] |
| 80 | +[Credits for multi-module](https://csiebler.github.io/blog/2014/02/09/multi-project-code-coverage-using-gradle-and-jacoco/) |
116 | 81 |
|
117 | 82 |
|
118 | 83 | [1]: https://codecov.io/ |
119 | | -[2]: https://twitter.com/codecov |
120 | | -[3]: mailto:hello@codecov.io |
121 | | -[4]: https://github.com/codecov/codecov-python |
122 | | -[5]: http://gradle.org/ |
123 | | -[6]: https://docs.gradle.org/current/userguide/jacoco_plugin.html |
124 | | -[7]: https://github.com/codecov/codecov-bash |
125 | | -[8]: https://csiebler.github.io/blog/2014/02/09/multi-project-code-coverage-using-gradle-and-jacoco/ |
0 commit comments