diff --git a/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/dependency/DependencyUtils.java b/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/dependency/DependencyUtils.java index 8b39eb505865f..da7ee30afef4e 100644 --- a/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/dependency/DependencyUtils.java +++ b/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/dependency/DependencyUtils.java @@ -52,9 +52,6 @@ public static Configuration duplicateConfiguration(Project project, Configuratio configurationCopy.getDependencyConstraints().addAll(toDuplicate.getAllDependencyConstraints()); for (Dependency dependency : toDuplicate.getAllDependencies()) { - if (includedBuild(project, dependency.getName()) != null) { - continue; - } if (isTestFixtureDependency(dependency)) { continue; } diff --git a/integration-tests/gradle/pom.xml b/integration-tests/gradle/pom.xml index f20a11c0cc06f..979b9b73094bb 100644 --- a/integration-tests/gradle/pom.xml +++ b/integration-tests/gradle/pom.xml @@ -79,6 +79,11 @@ quarkus-grpc ${project.version} + + io.quarkus + quarkus-hibernate-orm + ${project.version} + io.quarkus quarkus-hibernate-orm-panache @@ -176,6 +181,19 @@ + + io.quarkus + quarkus-hibernate-orm-deployment + ${project.version} + pom + test + + + * + * + + + io.quarkus quarkus-hibernate-orm-panache-deployment diff --git a/integration-tests/gradle/src/main/resources/composite-project-with-dependencies/gradle-dao/build.gradle b/integration-tests/gradle/src/main/resources/composite-project-with-dependencies/gradle-dao/build.gradle new file mode 100644 index 0000000000000..3377a70ec455b --- /dev/null +++ b/integration-tests/gradle/src/main/resources/composite-project-with-dependencies/gradle-dao/build.gradle @@ -0,0 +1,31 @@ +plugins { + id 'java' + id 'io.quarkus' +} + +repositories { + mavenCentral() + mavenLocal() +} + +dependencies { + implementation enforcedPlatform("${quarkusPlatformGroupId}:${quarkusPlatformArtifactId}:${quarkusPlatformVersion}") + implementation 'io.quarkus:quarkus-hibernate-orm' + implementation 'io.quarkus:quarkus-jdbc-h2' + implementation 'io.quarkus:quarkus-arc' + implementation 'io.quarkus:quarkus-resteasy' + testImplementation 'io.quarkus:quarkus-junit5' + testImplementation 'io.rest-assured:rest-assured' +} + +group 'org.acme.gradle.multi' +version '1.0.0-SNAPSHOT' + +compileJava { + options.encoding = 'UTF-8' + options.compilerArgs << '-parameters' +} + +compileTestJava { + options.encoding = 'UTF-8' +} diff --git a/integration-tests/gradle/src/main/resources/composite-project-with-dependencies/gradle-dao/settings.gradle b/integration-tests/gradle/src/main/resources/composite-project-with-dependencies/gradle-dao/settings.gradle new file mode 100644 index 0000000000000..ea78f9be0b500 --- /dev/null +++ b/integration-tests/gradle/src/main/resources/composite-project-with-dependencies/gradle-dao/settings.gradle @@ -0,0 +1,18 @@ +pluginManagement { + repositories { + mavenCentral() + // in case a custom local repo is configured we are going to use that instead of the default mavenLocal() + if (System.properties.containsKey('maven.repo.local')) { + maven { + url System.properties.get('maven.repo.local') + } + } else { + mavenLocal() + } + gradlePluginPortal() + } + plugins { + id 'io.quarkus' version "${quarkusPluginVersion}" + } +} +rootProject.name='gradle-dao' diff --git a/integration-tests/gradle/src/main/resources/composite-project-with-dependencies/gradle-dao/src/main/java/org/acme/gradle/multi/dao/Product.java b/integration-tests/gradle/src/main/resources/composite-project-with-dependencies/gradle-dao/src/main/java/org/acme/gradle/multi/dao/Product.java new file mode 100644 index 0000000000000..55fdacfa21b9c --- /dev/null +++ b/integration-tests/gradle/src/main/resources/composite-project-with-dependencies/gradle-dao/src/main/java/org/acme/gradle/multi/dao/Product.java @@ -0,0 +1,35 @@ +package org.acme.gradle.multi.dao; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.NamedQuery; + +@Entity +@NamedQuery(name = "Product.findAll", query = "SELECT p FROM Product p ORDER BY p.name") +public class Product { + @Id + private Integer id; + + @Column + private String name; + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + + +} diff --git a/integration-tests/gradle/src/main/resources/composite-project-with-dependencies/gradle-dao/src/main/java/org/acme/gradle/multi/dao/ProductService.java b/integration-tests/gradle/src/main/resources/composite-project-with-dependencies/gradle-dao/src/main/java/org/acme/gradle/multi/dao/ProductService.java new file mode 100644 index 0000000000000..bdc27e414f890 --- /dev/null +++ b/integration-tests/gradle/src/main/resources/composite-project-with-dependencies/gradle-dao/src/main/java/org/acme/gradle/multi/dao/ProductService.java @@ -0,0 +1,18 @@ +package org.acme.gradle.multi.dao; + +import java.util.List; + +import javax.enterprise.context.ApplicationScoped; +import javax.inject.Inject; +import javax.persistence.EntityManager; + +@ApplicationScoped +public class ProductService { + + @Inject + EntityManager em; + + public List getProducts() { + return em.createNamedQuery("Product.findAll", Product.class).getResultList(); + } +} diff --git a/integration-tests/gradle/src/main/resources/composite-project-with-dependencies/gradle-dao/src/main/resources/META-INF/beans.xml b/integration-tests/gradle/src/main/resources/composite-project-with-dependencies/gradle-dao/src/main/resources/META-INF/beans.xml new file mode 100644 index 0000000000000..e69de29bb2d1d diff --git a/integration-tests/gradle/src/main/resources/composite-project-with-dependencies/gradle-dao/src/main/resources/application.properties b/integration-tests/gradle/src/main/resources/composite-project-with-dependencies/gradle-dao/src/main/resources/application.properties new file mode 100644 index 0000000000000..2baaa7afab00d --- /dev/null +++ b/integration-tests/gradle/src/main/resources/composite-project-with-dependencies/gradle-dao/src/main/resources/application.properties @@ -0,0 +1,5 @@ +quarkus.datasource.db-kind = h2 +quarkus.datasource.username = hibernate +quarkus.datasource.password = hibernate +quarkus.datasource.jdbc.url = jdbc:h2:mem:myDB +quarkus.hibernate-orm.database.generation=drop-and-create \ No newline at end of file diff --git a/integration-tests/gradle/src/main/resources/composite-project-with-dependencies/gradle-rest/build.gradle b/integration-tests/gradle/src/main/resources/composite-project-with-dependencies/gradle-rest/build.gradle new file mode 100644 index 0000000000000..835892d981591 --- /dev/null +++ b/integration-tests/gradle/src/main/resources/composite-project-with-dependencies/gradle-rest/build.gradle @@ -0,0 +1,38 @@ +plugins { + id 'java' + id 'io.quarkus' +} + +repositories { + mavenCentral() + // in case a custom local repo is configured we are going to use that instead of the default mavenLocal() + 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' + implementation 'io.quarkus:quarkus-resteasy-jackson' + implementation 'io.quarkus:quarkus-arc' + implementation 'org.acme.gradle.multi:gradle-dao:1.0.0-SNAPSHOT' + testImplementation 'io.quarkus:quarkus-junit5' + testImplementation 'io.rest-assured:rest-assured' +} + +group 'org.acme.gradle.multi' +version '1.0.0-SNAPSHOT' + +compileJava { + options.encoding = 'UTF-8' + options.compilerArgs << '-parameters' +} + +compileTestJava { + options.encoding = 'UTF-8' +} diff --git a/integration-tests/gradle/src/main/resources/composite-project-with-dependencies/gradle-rest/settings.gradle b/integration-tests/gradle/src/main/resources/composite-project-with-dependencies/gradle-rest/settings.gradle new file mode 100644 index 0000000000000..5d9af80a5f474 --- /dev/null +++ b/integration-tests/gradle/src/main/resources/composite-project-with-dependencies/gradle-rest/settings.gradle @@ -0,0 +1,20 @@ +pluginManagement { + repositories { + mavenCentral() + // in case a custom local repo is configured we are going to use that instead of the default mavenLocal() + if (System.properties.containsKey('maven.repo.local')) { + maven { + url System.properties.get('maven.repo.local') + } + } else { + mavenLocal() + } + gradlePluginPortal() + } + plugins { + id 'io.quarkus' version "${quarkusPluginVersion}" + } +} +rootProject.name='gradle-rest' + +includeBuild '../gradle-dao' diff --git a/integration-tests/gradle/src/main/resources/composite-project-with-dependencies/gradle-rest/src/main/java/org/acme/gradle/multi/rest/ProductResource.java b/integration-tests/gradle/src/main/resources/composite-project-with-dependencies/gradle-rest/src/main/java/org/acme/gradle/multi/rest/ProductResource.java new file mode 100644 index 0000000000000..46e6bfa31d142 --- /dev/null +++ b/integration-tests/gradle/src/main/resources/composite-project-with-dependencies/gradle-rest/src/main/java/org/acme/gradle/multi/rest/ProductResource.java @@ -0,0 +1,25 @@ +package org.acme.gradle.multi.rest; + +import java.util.List; + +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; + +import org.acme.gradle.multi.dao.Product; +import org.acme.gradle.multi.dao.ProductService; + +@Path("/product") +public class ProductResource { + + @Inject + ProductService productService; + + @GET + @Produces(MediaType.APPLICATION_JSON) + public List list() { + return productService.getProducts(); + } +} \ No newline at end of file diff --git a/integration-tests/gradle/src/main/resources/composite-project-with-dependencies/gradle-rest/src/main/resources/application.properties b/integration-tests/gradle/src/main/resources/composite-project-with-dependencies/gradle-rest/src/main/resources/application.properties new file mode 100644 index 0000000000000..e69de29bb2d1d diff --git a/integration-tests/gradle/src/main/resources/composite-project-with-dependencies/gradle.properties b/integration-tests/gradle/src/main/resources/composite-project-with-dependencies/gradle.properties new file mode 100644 index 0000000000000..ec2b6ef199c2c --- /dev/null +++ b/integration-tests/gradle/src/main/resources/composite-project-with-dependencies/gradle.properties @@ -0,0 +1,2 @@ +quarkusPlatformArtifactId=quarkus-bom +quarkusPlatformGroupId=io.quarkus diff --git a/integration-tests/gradle/src/test/java/io/quarkus/gradle/devmode/CompositeBuildWithDependenciesDevModeTest.java b/integration-tests/gradle/src/test/java/io/quarkus/gradle/devmode/CompositeBuildWithDependenciesDevModeTest.java new file mode 100644 index 0000000000000..78b11ea272dd7 --- /dev/null +++ b/integration-tests/gradle/src/test/java/io/quarkus/gradle/devmode/CompositeBuildWithDependenciesDevModeTest.java @@ -0,0 +1,43 @@ +package io.quarkus.gradle.devmode; + +import static org.assertj.core.api.Assertions.assertThat; + +import java.io.File; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; + +public class CompositeBuildWithDependenciesDevModeTest extends QuarkusDevGradleTestBase { + + @Override + protected String projectDirectoryName() { + return "composite-project-with-dependencies"; + } + + @Override + protected String[] buildArguments() { + return new String[] { "clean", "quarkusDev" }; + } + + @Override + protected void testDevMode() throws Exception { + assertThat(getHttpResponse("/product")).contains("[]"); + } + + @Override + protected File getProjectDir() { + File projectDir = super.getProjectDir(); + final File restAppProjectProperties = new File(projectDir, "gradle-rest/gradle.properties"); + final File daoAppProjectProperties = new File(projectDir, "gradle-dao/gradle.properties"); + final Path projectProperties = projectDir.toPath().resolve("gradle.properties"); + + try { + Files.copy(projectProperties, restAppProjectProperties.toPath()); + Files.copy(projectProperties, daoAppProjectProperties.toPath()); + } catch (IOException e) { + throw new IllegalStateException("Unable to copy gradle.properties file", e); + } + this.projectDir = restAppProjectProperties.getParentFile(); + return this.projectDir; + } +}