-
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.
Externalize Gradle model builder in a module
- Loading branch information
Showing
11 changed files
with
176 additions
and
19 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
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
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
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
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,4 @@ | ||
dependencies { | ||
implementation "io.quarkus:quarkus-core-deployment:${version}" | ||
testImplementation "io.quarkus:quarkus-devtools-testing:${version}" | ||
} |
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,93 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<parent> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>io.quarkus.gradle.plugin.parent</artifactId> | ||
<version>999-SNAPSHOT</version> | ||
<relativePath>../pom.xml</relativePath> | ||
</parent> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-gradle-tooling</artifactId> | ||
<packaging>pom</packaging> | ||
<name>Quarkus - Gradle Tooling</name> | ||
<description>Quarkus - Gradle Tooling</description> | ||
|
||
<dependencies> | ||
<!-- Compile --> | ||
<dependency> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-bootstrap-core</artifactId> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.codehaus.mojo</groupId> | ||
<artifactId>exec-maven-plugin</artifactId> | ||
<executions> | ||
<execution> | ||
<id>gradle</id> | ||
<phase>prepare-package</phase> | ||
<configuration> | ||
<executable>${gradle.executable}</executable> | ||
<arguments> | ||
<argument>clean</argument> | ||
<argument>${gradle.task}</argument> | ||
<argument>-Pdescription=${project.description}</argument> | ||
<argument>-Dmaven.repo.local=${settings.localRepository}</argument> | ||
<argument>-S</argument> | ||
<argument>--stacktrace</argument> | ||
<argument>--no-daemon</argument> | ||
</arguments> | ||
<environmentVariables> | ||
<MAVEN_REPO_LOCAL>${settings.localRepository}</MAVEN_REPO_LOCAL> | ||
<GRADLE_OPTS>${env.MAVEN_OPTS}</GRADLE_OPTS> | ||
</environmentVariables> | ||
<skip>${skip.gradle.build}</skip> | ||
</configuration> | ||
<goals> | ||
<goal>exec</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.codehaus.mojo</groupId> | ||
<artifactId>build-helper-maven-plugin</artifactId> | ||
<executions> | ||
<execution> | ||
<id>attach-artifacts</id> | ||
<phase>package</phase> | ||
<goals> | ||
<goal>attach-artifact</goal> | ||
</goals> | ||
<configuration> | ||
<artifacts> | ||
<artifact> | ||
<file>build/libs/gradle-tooling-${project.version}.jar</file> | ||
<type>jar</type> | ||
</artifact> | ||
<artifact> | ||
<file>build/libs/gradle-tooling-${project.version}-javadoc.jar</file> | ||
<type>jar</type> | ||
<classifier>javadoc</classifier> | ||
</artifact> | ||
<artifact> | ||
<file>build/libs/gradle-tooling-${project.version}-sources.jar</file> | ||
<type>jar</type> | ||
<classifier>sources</classifier> | ||
</artifact> | ||
</artifacts> | ||
<skipAttach>${skip.gradle.build}</skipAttach> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
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
55 changes: 55 additions & 0 deletions
55
devtools/gradle/gradle-tooling/src/main/java/io/quarkus/gradle/tooling/ToolingUtils.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,55 @@ | ||
package io.quarkus.gradle.tooling; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import org.gradle.api.Project; | ||
import org.gradle.api.UnknownDomainObjectException; | ||
import org.gradle.api.artifacts.Configuration; | ||
import org.gradle.api.artifacts.Dependency; | ||
import org.gradle.api.artifacts.ModuleDependency; | ||
import org.gradle.api.attributes.Category; | ||
import org.gradle.api.initialization.IncludedBuild; | ||
import org.gradle.api.plugins.JavaPlugin; | ||
|
||
public class ToolingUtils { | ||
|
||
private static final String DEPLOYMENT_CONFIGURATION_SUFFIX = "Deployment"; | ||
public static final String DEV_MODE_CONFIGURATION_NAME = "quarkusDev"; | ||
|
||
public static String toDeploymentConfigurationName(String baseConfigurationName) { | ||
return baseConfigurationName + DEPLOYMENT_CONFIGURATION_SUFFIX; | ||
} | ||
|
||
public static List<Dependency> getEnforcedPlatforms(Project project) { | ||
final List<org.gradle.api.artifacts.Dependency> directExtension = new ArrayList<>(); | ||
final Configuration impl = project.getConfigurations() | ||
.getByName(JavaPlugin.IMPLEMENTATION_CONFIGURATION_NAME); | ||
|
||
for (Dependency d : impl.getAllDependencies()) { | ||
if (!(d instanceof ModuleDependency)) { | ||
continue; | ||
} | ||
final ModuleDependency module = (ModuleDependency) d; | ||
if (isEnforcedPlatform(module)) { | ||
directExtension.add(d); | ||
} | ||
} | ||
return directExtension; | ||
} | ||
|
||
public static boolean isEnforcedPlatform(ModuleDependency module) { | ||
final Category category = module.getAttributes().getAttribute(Category.CATEGORY_ATTRIBUTE); | ||
return category != null && (Category.ENFORCED_PLATFORM.equals(category.getName()) | ||
|| Category.REGULAR_PLATFORM.equals(category.getName())); | ||
} | ||
|
||
public static IncludedBuild includedBuild(final Project project, final String projectName) { | ||
try { | ||
return project.getGradle().includedBuild(projectName); | ||
} catch (UnknownDomainObjectException ignore) { | ||
return null; | ||
} | ||
} | ||
|
||
} |
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
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
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