Skip to content

Conversation

jjohannes
Copy link
Contributor

@jjohannes jjohannes commented Apr 14, 2020

This commit improves the grouping of subprojects in the Gradle build by basically getting rid of two things:

  • A quite messy list of lists of projects for different purposes - ProjectGroups.kt
  • A ModuleType property each project had to set

Instead, each project now applies one uber plugin indicating it's purpose:

  • gradlebuild.distribution - part of the distribution. Subcategories determine if the project is in the core of the distribution or if it is a packaged plugin; if it is part of the api or only an implementation detail; if it is written in Java or Kotlin
    • gradlebuild.distribution.core-implementation-java
    • gradlebuild.distribution.core-implementation-kotlin
    • gradlebuild.distribution.core-api-java
    • gradlebuild.distribution.core-api-kotlin
    • gradlebuild.distribution.plugins-api-java
    • gradlebuild.distribution.plugins-implementation-java
    • gradlebuild.distribution.plugins-implementation-kotlin
  • gradlebuild.portalplugin - subproject is not part of distribution but separately published to the plugin portal.
    • gradlebuild.portalplugin.kotlin
  • gradlebuild.internal - internal project
    • gradlebuild.internal.java
    • gradlebuild.internal.kotlin
    • gradlebuild.internal.kotlin-js

Other concerns that cross-cut these categories are realized by additional plugins (e.g. subproject is also published separately) or as a configuration property of the UnitTestAndCompilePlugin extension (e.g. is used in workers). This can be further refined in the future.

This change also removes some configuration time ordering issues.

Following this improvement, I want to get rid of the "grouping" that is done by creating a bunch of configurations in the root build which is then used to assemble the distribution. This should all move into the "distribution" project and the "IntTestImage" plugin. Which both can be simplified now that we have the cleaner structuring that comes with this improvement.

@jjohannes jjohannes self-assigned this Apr 14, 2020
@jjohannes jjohannes added @jvm in:building-gradle gradle/gradle build labels Apr 14, 2020
import org.owasp.dependencycheck.gradle.extension.DependencyCheckExtension


open class DependencyVulnerabilitiesPlugin : Plugin<Project> {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we remove this completely? It is not used, out of date (selected plugin version of 'org.owasp.dependencycheck' does not work with current wrapper anymore) and not included in any CI pipeline.

@Suppress("unchecked_cast")
val Project.libraries
get() = rootProject.extra["libraries"] as Map<String, Map<String, String>>
get() = if (rootProject.extra.has("libraries")) rootProject.extra["libraries"] as Map<String, Map<String, String>> else mapOf()
Copy link
Contributor Author

@jjohannes jjohannes Apr 14, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need this has check for pre-compiled script plugin compilation. (In a next step we shall get rid of using extra altogether.)

gradleRuntimeSource(project(":apiMetadata"))
gradleDocumentation(project(":docs"))
gradleScripts(project(":launcher"))
gradleRuntimeSource.withDependencies {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This config code is now also executed as part of pre-compiled script compilation. There the projects we try to find here (e.g. project(":apiMetadata")) do not exist. We now only apply the dependencies once the configuration is resolved (withDependencies hook).



tasks {
validatePlugins {
Copy link
Contributor Author

@jjohannes jjohannes Apr 14, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was a duplication. This is configured for all "java/kotlin" projects already by UnitTestAndCompilePlugin.

}

private
fun Project.sharedDependencyAndQualityConfigs() {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I moved this here to make sure this is done as the first thing and is available for all other plugins/scripts afterwards. Then we do not have to be careful of order in the root build script (apart from applying the lifecycle plugin first).

A follow up should be to get rid of storing dependencies in "extra" altogether.

moduleType = ModuleType.INTERNAL
// so that all Gradle features are available
configurations.performanceTestRuntimeOnly.get().withDependencies {
addAll(rootProject.configurations.testRuntime.get().allDependencies)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made this change in some places to get rid of the "extra" properties set in the root build script.

In the next step I want to clean up the distribution building and improve this part further so that we do not need to reach into the root project anymore.

@jjohannes jjohannes requested a review from blindpirate April 14, 2020 12:45
@jjohannes jjohannes force-pushed the jjohannes/gradle-build/grouping branch from 319a0b9 to e6cfe48 Compare April 14, 2020 16:46
@jjohannes
Copy link
Contributor Author

jjohannes commented Apr 14, 2020

@jjohannes jjohannes force-pushed the jjohannes/gradle-build/grouping branch from e6cfe48 to 9f562dc Compare April 15, 2020 14:24
@jjohannes
Copy link
Contributor Author

@bot-gradle test this

@bot-gradle
Copy link
Collaborator

OK, I've already triggered ReadyForMerge build for you.

@gradle gradle deleted a comment from bot-gradle Apr 15, 2020
@jjohannes jjohannes force-pushed the jjohannes/gradle-build/grouping branch from c729b19 to 20cb240 Compare April 16, 2020 11:04
@jjohannes jjohannes force-pushed the jjohannes/gradle-build/grouping branch 4 times, most recently from 4350d3f to 89275e4 Compare April 17, 2020 11:10
@jjohannes jjohannes force-pushed the jjohannes/gradle-build/grouping branch from 89275e4 to 51857e4 Compare April 17, 2020 11:45
@jjohannes jjohannes force-pushed the jjohannes/gradle-build/grouping branch from 51857e4 to 1416e7b Compare April 17, 2020 13:38
Copy link
Member

@ljacomet ljacomet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice clean, thanks for taking the time! 👍

@jjohannes jjohannes force-pushed the jjohannes/gradle-build/grouping branch from 1416e7b to 32aa2d7 Compare April 17, 2020 15:06
@jjohannes jjohannes removed the request for review from blindpirate April 17, 2020 15:06
@jjohannes jjohannes merged commit a69b556 into master Apr 17, 2020
@jjohannes jjohannes deleted the jjohannes/gradle-build/grouping branch May 4, 2020 09:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

in:building-gradle gradle/gradle build

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants