Skip to content

Commit

Permalink
Merge pull request quarkusio#19151 from asodja/spring-dependency-plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
glefloch authored Aug 7, 2021
2 parents 2341ae6 + b42be66 commit a31bde8
Show file tree
Hide file tree
Showing 9 changed files with 134 additions and 51 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -132,15 +132,9 @@ private void resolveConditionalDependencies(List<ExtensionDependency> conditiona

private Configuration createConditionalDependenciesConfiguration(Configuration existingDeps,
List<ExtensionDependency> extensions) {
List<Dependency> toResolve = new ArrayList<>();
for (Dependency dependency : existingDeps.getDependencies()) {
toResolve.add(dependency);
}
for (Dependency dependency : collectConditionalDependencies(extensions)) {
toResolve.add(dependency);
}
return project.getConfigurations()
.detachedConfiguration(toResolve.toArray(new Dependency[0]));
Configuration newConfiguration = existingDeps.copy();
newConfiguration.getDependencies().addAll(collectConditionalDependencies(extensions));
return newConfiguration;
}

private Set<Dependency> collectConditionalDependencies(List<ExtensionDependency> extensionDependencies) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ public static Configuration duplicateConfiguration(Project project, Configuratio
if (configurationCopy != null) {
project.getConfigurations().remove(configurationCopy);
}

configurationCopy = project.getConfigurations().create(COPY_CONFIGURATION_NAME);

// We add boms for dependency resolution
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@ public static QuarkusModel create(File projectDir, String mode, List<String> jvm
try (ProjectConnection connection = GradleConnector.newConnector()
.forProjectDirectory(projectDir)
.connect()) {
connection.newBuild().forTasks(tasks).addJvmArguments(jvmArgs).run();

return connection.action(new QuarkusModelBuildAction(mode)).run();
return connection.action(new QuarkusModelBuildAction(mode)).forTasks(tasks).addJvmArguments(jvmArgs).run();
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
plugins {
id 'java'
id 'io.quarkus'
id 'io.spring.dependency-management'
}

repositories {
mavenCentral()
if (System.properties.containsKey('maven.repo.local')) {
maven {
url System.properties.get('maven.repo.local')
}
} else {
mavenLocal()
}
}

dependencyManagement {
dependencies {
dependency "io.quarkus:quarkus-resteasy:${quarkusPlatformVersion}"
}
}

dependencies {
implementation enforcedPlatform("${quarkusPlatformGroupId}:${quarkusPlatformArtifactId}:${quarkusPlatformVersion}") {
// We exclude resteasy so Spring dependency management handles it
exclude group: 'io.quarkus', module: 'quarkus-resteasy'
}
implementation "io.quarkus:quarkus-resteasy"
}

compileJava {
options.compilerArgs << '-parameters'
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
quarkusPlatformArtifactId=quarkus-bom
quarkusPlatformGroupId=io.quarkus
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
pluginManagement {
repositories {
if (System.properties.containsKey('maven.repo.local')) {
maven {
url System.properties.get('maven.repo.local')
}
} else {
mavenLocal()
}
mavenCentral()
gradlePluginPortal()
}
plugins {
id 'io.quarkus' version "${quarkusPluginVersion}"
id 'io.spring.dependency-management' version '1.0.11.RELEASE'
}
}
rootProject.name='code-with-quarkus'
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package org.acme;

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 ExampleResource {

@GET
@Produces(MediaType.TEXT_PLAIN)
public String hello() {
return "";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,44 +23,44 @@ public class ConditionalDependenciesTest extends QuarkusGradleWrapperTestBase {
public void publishTestExtensions() throws IOException, InterruptedException, URISyntaxException {
File dependencyProject = getProjectDir("conditional-dependencies");
runGradleWrapper(dependencyProject, ":ext-a:runtime:publishToMavenLocal",
":ext-a:deployment:publishToMavenLocal");
runGradleWrapper(dependencyProject, ":ext-b:runtime:publishToMavenLocal",
":ext-b:deployment:publishToMavenLocal");
runGradleWrapper(dependencyProject, ":ext-c:runtime:publishToMavenLocal",
":ext-c:deployment:publishToMavenLocal");
runGradleWrapper(dependencyProject, ":ext-d:runtime:publishToMavenLocal",
":ext-d:deployment:publishToMavenLocal");
runGradleWrapper(dependencyProject, ":ext-e:runtime:publishToMavenLocal",
":ext-e:deployment:publishToMavenLocal");
runGradleWrapper(dependencyProject, ":ext-f:runtime:publishToMavenLocal",
":ext-f:deployment:publishToMavenLocal");
runGradleWrapper(dependencyProject, ":ext-g:runtime:publishToMavenLocal",
":ext-g:deployment:publishToMavenLocal");
runGradleWrapper(dependencyProject, ":ext-h:runtime:publishToMavenLocal",
":ext-h:deployment:publishToMavenLocal");
runGradleWrapper(dependencyProject, ":ext-i:runtime:publishToMavenLocal",
":ext-i:deployment:publishToMavenLocal");
runGradleWrapper(dependencyProject, ":ext-j:runtime:publishToMavenLocal",
":ext-j:deployment:publishToMavenLocal");
runGradleWrapper(dependencyProject, ":ext-k:runtime:publishToMavenLocal",
":ext-k:deployment:publishToMavenLocal");
runGradleWrapper(dependencyProject, ":ext-l:runtime:publishToMavenLocal",
":ext-l:deployment:publishToMavenLocal");
runGradleWrapper(dependencyProject, ":ext-m:runtime:publishToMavenLocal",
":ext-m:deployment:publishToMavenLocal");
runGradleWrapper(dependencyProject, ":ext-n:runtime:publishToMavenLocal",
":ext-n:deployment:publishToMavenLocal");
runGradleWrapper(dependencyProject, ":ext-o:runtime:publishToMavenLocal",
":ext-o:deployment:publishToMavenLocal");
runGradleWrapper(dependencyProject, ":ext-p:runtime:publishToMavenLocal",
":ext-p:deployment:publishToMavenLocal");
runGradleWrapper(dependencyProject, ":ext-r:runtime:publishToMavenLocal",
":ext-r:deployment:publishToMavenLocal");
runGradleWrapper(dependencyProject, ":ext-s:runtime:publishToMavenLocal",
":ext-s:deployment:publishToMavenLocal");
runGradleWrapper(dependencyProject, ":ext-t:runtime:publishToMavenLocal",
":ext-t:deployment:publishToMavenLocal");
runGradleWrapper(dependencyProject, ":ext-u:runtime:publishToMavenLocal",
":ext-a:deployment:publishToMavenLocal",
":ext-b:runtime:publishToMavenLocal",
":ext-b:deployment:publishToMavenLocal",
":ext-c:runtime:publishToMavenLocal",
":ext-c:deployment:publishToMavenLocal",
":ext-d:runtime:publishToMavenLocal",
":ext-d:deployment:publishToMavenLocal",
":ext-e:runtime:publishToMavenLocal",
":ext-e:deployment:publishToMavenLocal",
":ext-f:runtime:publishToMavenLocal",
":ext-f:deployment:publishToMavenLocal",
":ext-g:runtime:publishToMavenLocal",
":ext-g:deployment:publishToMavenLocal",
":ext-h:runtime:publishToMavenLocal",
":ext-h:deployment:publishToMavenLocal",
":ext-i:runtime:publishToMavenLocal",
":ext-i:deployment:publishToMavenLocal",
":ext-j:runtime:publishToMavenLocal",
":ext-j:deployment:publishToMavenLocal",
":ext-k:runtime:publishToMavenLocal",
":ext-k:deployment:publishToMavenLocal",
":ext-l:runtime:publishToMavenLocal",
":ext-l:deployment:publishToMavenLocal",
":ext-m:runtime:publishToMavenLocal",
":ext-m:deployment:publishToMavenLocal",
":ext-n:runtime:publishToMavenLocal",
":ext-n:deployment:publishToMavenLocal",
":ext-o:runtime:publishToMavenLocal",
":ext-o:deployment:publishToMavenLocal",
":ext-p:runtime:publishToMavenLocal",
":ext-p:deployment:publishToMavenLocal",
":ext-r:runtime:publishToMavenLocal",
":ext-r:deployment:publishToMavenLocal",
":ext-s:runtime:publishToMavenLocal",
":ext-s:deployment:publishToMavenLocal",
":ext-t:runtime:publishToMavenLocal",
":ext-t:deployment:publishToMavenLocal",
":ext-u:runtime:publishToMavenLocal",
":ext-u:deployment:publishToMavenLocal");
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package io.quarkus.gradle;

import static org.assertj.core.api.Assertions.assertThat;

import java.io.File;
import java.io.IOException;
import java.net.URISyntaxException;

import org.junit.jupiter.api.Test;

public class SpringDependencyManagementTest extends QuarkusGradleWrapperTestBase {

@Test
public void testQuarkusBuildShouldWorkWithSpringDependencyManagement()
throws IOException, URISyntaxException, InterruptedException {
final File projectDir = getProjectDir("spring-dependency-plugin-project");

final BuildResult result = runGradleWrapper(projectDir, "clean", "quarkusBuild");

assertThat(result.getTasks().get(":quarkusBuild")).isEqualTo(BuildResult.SUCCESS_OUTCOME);
}
}

0 comments on commit a31bde8

Please sign in to comment.