Skip to content

Commit d226e0b

Browse files
committed
Fix Jacoco in Gradle multi module projects
1 parent fb5b21c commit d226e0b

File tree

11 files changed

+173
-1
lines changed

11 files changed

+173
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
plugins {
2+
id 'io.quarkus'
3+
}
4+
5+
dependencies {
6+
implementation project(":common")
7+
testImplementation('io.quarkus:quarkus-jacoco')
8+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package org.acme.quarkus.sample;
2+
3+
import jakarta.inject.Inject;
4+
import jakarta.ws.rs.GET;
5+
import jakarta.ws.rs.Path;
6+
import jakarta.ws.rs.Produces;
7+
import jakarta.ws.rs.core.MediaType;
8+
9+
import org.acme.common.CommonBean;
10+
11+
@Path("/hello")
12+
public class HelloResource {
13+
14+
@Inject
15+
CommonBean common;
16+
17+
@GET
18+
@Produces(MediaType.TEXT_PLAIN)
19+
public String hello() {
20+
return "hello " + common.getName();
21+
}
22+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package org.acme.quarkus.sample;
2+
3+
import io.quarkus.test.junit.QuarkusTest;
4+
import org.junit.jupiter.api.Test;
5+
6+
import static io.restassured.RestAssured.given;
7+
import static org.hamcrest.CoreMatchers.is;
8+
9+
@QuarkusTest
10+
public class HelloResourceTest {
11+
12+
@Test
13+
public void testHelloEndpoint() {
14+
given()
15+
.when().get("/hello")
16+
.then()
17+
.statusCode(200)
18+
.body(is("hello common"));
19+
}
20+
21+
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
buildscript {
2+
repositories {
3+
mavenLocal {
4+
content {
5+
includeGroupByRegex 'io.quarkus.*'
6+
includeGroup 'org.hibernate.orm'
7+
}
8+
}
9+
mavenCentral()
10+
gradlePluginPortal()
11+
}
12+
}
13+
14+
apply plugin: 'java'
15+
16+
group = 'com.quarkus.demo'
17+
version = '1.0'
18+
19+
20+
subprojects {
21+
22+
apply plugin: 'java'
23+
24+
test {
25+
dependsOn 'cleanTest'
26+
useJUnitPlatform()
27+
forkEvery 1
28+
systemProperty "java.util.logging.manager", "org.jboss.logmanager.LogManager"
29+
}
30+
31+
repositories {
32+
mavenLocal {
33+
content {
34+
includeGroupByRegex 'io.quarkus.*'
35+
includeGroup 'org.hibernate.orm'
36+
}
37+
}
38+
mavenCentral()
39+
}
40+
41+
dependencies {
42+
43+
implementation 'io.quarkus:quarkus-rest'
44+
45+
testImplementation 'io.quarkus:quarkus-junit5'
46+
testImplementation 'io.rest-assured:rest-assured'
47+
48+
implementation enforcedPlatform("${quarkusPlatformGroupId}:${quarkusPlatformArtifactId}:${quarkusPlatformVersion}")
49+
50+
}
51+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
plugins {
2+
id 'io.quarkus'
3+
id 'java-library'
4+
}
5+
6+
dependencies {
7+
8+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package org.acme.common;
2+
3+
import jakarta.enterprise.context.RequestScoped;
4+
5+
@RequestScoped
6+
public class CommonBean {
7+
8+
public String getName() {
9+
return "common";
10+
}
11+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<beans
3+
xmlns="http://xmlns.jcp.org/xml/ns/javaee"
4+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5+
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
6+
http://xmlns.jcp.org/xml/ns/javaee/beans_1_1.xsd">
7+
8+
</beans>
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
quarkusPlatformArtifactId=quarkus-bom
2+
quarkusPlatformGroupId=io.quarkus
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
pluginManagement {
2+
repositories {
3+
mavenLocal {
4+
content {
5+
includeGroupByRegex 'io.quarkus.*'
6+
includeGroup 'org.hibernate.orm'
7+
}
8+
}
9+
mavenCentral()
10+
gradlePluginPortal()
11+
}
12+
//noinspection GroovyAssignabilityCheck
13+
plugins {
14+
id 'io.quarkus' version "${quarkusPluginVersion}"
15+
}
16+
}
17+
18+
rootProject.name = 'quarkus-basic-multi-module-build'
19+
20+
include ':common'
21+
include ':application'
22+
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package io.quarkus.gradle;
2+
3+
import java.io.File;
4+
5+
import org.junit.jupiter.api.Test;
6+
7+
public class JacocoMultiModuleTest extends QuarkusGradleWrapperTestBase {
8+
9+
/**
10+
* This test should probably do more than simply verify a successful command execution.
11+
* It was originally added to make sure the process doesn't fail.
12+
*/
13+
@Test
14+
public void testJacoco() throws Exception {
15+
final File projectDir = getProjectDir("basic-multi-module-project-jacoco");
16+
runGradleWrapper(projectDir, "clean", "test");
17+
}
18+
}

0 commit comments

Comments
 (0)