Skip to content

Commit

Permalink
Merge pull request #21238 from glefloch/fix/included-build-filter
Browse files Browse the repository at this point in the history
Do not filter gradle composite project in dependency resolution
  • Loading branch information
aloubyansky authored Nov 5, 2021
2 parents a14aa65 + 829d29c commit 2cd3bbe
Show file tree
Hide file tree
Showing 14 changed files with 253 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
18 changes: 18 additions & 0 deletions integration-tests/gradle/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@
<artifactId>quarkus-grpc</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-hibernate-orm</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-hibernate-orm-panache</artifactId>
Expand Down Expand Up @@ -176,6 +181,19 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-hibernate-orm-deployment</artifactId>
<version>${project.version}</version>
<type>pom</type>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-hibernate-orm-panache-deployment</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -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'
}
Original file line number Diff line number Diff line change
@@ -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'
Original file line number Diff line number Diff line change
@@ -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;
}



}
Original file line number Diff line number Diff line change
@@ -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<Product> getProducts() {
return em.createNamedQuery("Product.findAll", Product.class).getResultList();
}
}
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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'
}
Original file line number Diff line number Diff line change
@@ -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'
Original file line number Diff line number Diff line change
@@ -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<Product> list() {
return productService.getProducts();
}
}
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,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;
}
}

0 comments on commit 2cd3bbe

Please sign in to comment.