-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #20435 from glefloch/fix/20419
Handle dependency constraint in gradle conditional dependency resolution
- Loading branch information
Showing
7 changed files
with
113 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
integration-tests/gradle/src/main/resources/dependency-constraints-project/build.gradle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
plugins { | ||
id 'java' | ||
id 'io.quarkus' | ||
} | ||
|
||
group = 'com.quarkus.demo' | ||
version = '1.0' | ||
|
||
repositories { | ||
mavenCentral() | ||
if (System.properties.containsKey('maven.repo.local')) { | ||
maven { | ||
url System.properties.get('maven.repo.local') | ||
} | ||
} else { | ||
mavenLocal() | ||
} | ||
} | ||
|
||
dependencies { | ||
implementation enforcedPlatform("${quarkusPlatformGroupId}:${quarkusPlatformArtifactId}:${quarkusPlatformVersion}") | ||
implementation 'io.quarkus:quarkus-resteasy' | ||
|
||
constraints { | ||
implementation 'javax.json.bind:javax.json.bind-api:1.0' | ||
} | ||
|
||
implementation 'javax.json.bind:javax.json.bind-api' | ||
} | ||
|
2 changes: 2 additions & 0 deletions
2
integration-tests/gradle/src/main/resources/dependency-constraints-project/gradle.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
quarkusPlatformArtifactId=quarkus-bom | ||
quarkusPlatformGroupId=io.quarkus |
21 changes: 21 additions & 0 deletions
21
integration-tests/gradle/src/main/resources/dependency-constraints-project/settings.gradle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
pluginManagement { | ||
repositories { | ||
if (System.properties.containsKey('maven.repo.local')) { | ||
maven { | ||
url System.properties.get('maven.repo.local') | ||
} | ||
} else { | ||
mavenLocal() | ||
} | ||
mavenCentral() | ||
gradlePluginPortal() | ||
} | ||
//noinspection GroovyAssignabilityCheck | ||
plugins { | ||
id 'io.quarkus' version "${quarkusPluginVersion}" | ||
} | ||
} | ||
|
||
rootProject.name = 'quarkus-dependency-constraint' | ||
|
||
|
17 changes: 17 additions & 0 deletions
17
...s/dependency-constraints-project/src/main/java/org/acme/quarkus/sample/HelloResource.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package org.acme.quarkus.sample; | ||
|
||
import javax.inject.Inject; | ||
import javax.ws.rs.GET; | ||
import javax.ws.rs.Path; | ||
import javax.ws.rs.Produces; | ||
import javax.ws.rs.core.MediaType; | ||
|
||
@Path("/hello") | ||
public class HelloResource { | ||
|
||
@GET | ||
@Produces(MediaType.TEXT_PLAIN) | ||
public String hello() { | ||
return "hello"; | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
integration-tests/gradle/src/test/java/io/quarkus/gradle/DependencyConstraintsTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package io.quarkus.gradle; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
import java.io.File; | ||
import java.nio.file.Path; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
public class DependencyConstraintsTest extends QuarkusGradleWrapperTestBase { | ||
|
||
@Test | ||
public void shoudBuildProjectWithDependencyConstraint() throws Exception { | ||
File projectDir = getProjectDir("dependency-constraints-project"); | ||
|
||
BuildResult buildResult = runGradleWrapper(projectDir, "clean", "quarkusBuild", "-Dquarkus.package.type=mutable-jar"); | ||
|
||
assertThat(buildResult.getTasks().get(":quarkusBuild")).isEqualTo(BuildResult.SUCCESS_OUTCOME); | ||
|
||
final File buildDir = new File(projectDir, "build"); | ||
final Path mainLib = buildDir.toPath().resolve("quarkus-app").resolve("lib").resolve("main"); | ||
|
||
assertThat(mainLib.resolve("javax.json.bind.javax.json.bind-api-1.0.jar")).exists(); | ||
} | ||
|
||
} |
16 changes: 16 additions & 0 deletions
16
...ests/gradle/src/test/java/io/quarkus/gradle/devmode/DependencyConstraintsDevModeTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package io.quarkus.gradle.devmode; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
public class DependencyConstraintsDevModeTest extends QuarkusDevGradleTestBase { | ||
|
||
@Override | ||
protected String projectDirectoryName() { | ||
return "dependency-constraints-project"; | ||
} | ||
|
||
@Override | ||
protected void testDevMode() throws Exception { | ||
assertThat(getHttpResponse("/hello")).contains("hello"); | ||
} | ||
} |