Skip to content

Commit

Permalink
Use more concise Kotlin DSL constructs across Gradle config
Browse files Browse the repository at this point in the history
  • Loading branch information
PawelLipski committed Aug 1, 2022
1 parent 51a8671 commit 44d4eef
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 42 deletions.
7 changes: 7 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Note that the rules in CODEOWNERS are NOT additive -
# for any given file, only the LAST matching rule (and not all matching rules) applies.

* @PawelLipski

/buildSrc/ @MaciejG604 @PawelLipski
*gradle* @MaciejG604 @PawelLipski
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ fun Project.configureCheckerFramework() {
)

dependencies {
add("compileOnly", lib("checker.qual"))
add("checkerFramework", lib("checker"))
"compileOnly"(lib("checker.qual"))
"checkerFramework"(lib("checker"))
}
}
}
Expand Down Expand Up @@ -82,14 +82,18 @@ fun Project.applyI18nFormatterAndTaintingCheckers() {

// Apparently, I18nFormatterChecker doesn't see resource bundles in its classpath unless they're
// defined in a separate module.
dependencies { add("checkerFramework", project(":frontend:resourcebundles")) }
dependencies {
"checkerFramework"(project(":frontend:resourcebundles"))
}
}

fun Project.applySubtypingChecker() {
val shouldRunAllCheckers: Boolean by rootProject.extra

if (shouldRunAllCheckers) {
dependencies { add("checkerFramework", project(":qual")) }
dependencies {
"checkerFramework"(project(":qual"))
}
configure<CheckerFrameworkExtension> {
checkers.add("org.checkerframework.common.subtyping.SubtypingChecker")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ fun Project.lib(id: String): Provider<MinimalExternalModuleDependency> {

fun Project.commonsIO() {
dependencies {
add("implementation", lib("commonsIO"))
"implementation"(lib("commonsIO"))
}
}

Expand All @@ -103,62 +103,62 @@ fun Project.ideProbe() {
}

dependencies {
add("uiTestImplementation", testFixtures(project(":testCommon")))
add("uiTestImplementation", bundle("ideProbe"))
"uiTestImplementation"(testFixtures(project(":testCommon")))
"uiTestImplementation"(bundle("ideProbe"))

// This is technically redundant (both since ide-probe pulls in scala-library anyway,
// and since ide-probe is meant to use in src/uiTest code, not src/test code),
// but apparently needed for IntelliJ to detect Scala SDK version in the project (it's
// probably https://youtrack.jetbrains.com/issue/SCL-14310).
add("testImplementation", lib("scala.library"))
"testImplementation"(lib("scala.library"))
}
}

fun Project.jcabiAspects() {
apply<AspectJPlugin>()

dependencies { add("aspect", lib("jcabi.aspects")) }
dependencies { "aspect"(lib("jcabi.aspects")) }
}

fun Project.jetbrainsAnnotations() {
dependencies {
val annotations = lib("jetbrains.annotations")
add("compileOnly", annotations)
add("testCompileOnly", annotations)
"compileOnly"(annotations)
"testCompileOnly"(annotations)
}
}

fun Project.jgit() {
dependencies {
add("implementation", lib("jgit"))
"implementation"(lib("jgit"))
}
}

fun Project.junit() {
dependencies {
add("testImplementation", lib("junit"))
"testImplementation"(lib("junit"))
}
}

fun Project.lombok() {
dependencies {
val lombok = lib("lombok")
add("compileOnly", lombok)
add("annotationProcessor", lombok)
add("testCompileOnly", lombok)
add("testAnnotationProcessor", lombok)
"compileOnly"(lombok)
"annotationProcessor"(lombok)
"testCompileOnly"(lombok)
"testAnnotationProcessor"(lombok)
}
}

fun Project.powerMock() {
dependencies {
add("testImplementation", bundle("powerMock"))
"testImplementation"(bundle("powerMock"))
}
}

fun Project.reflections() {
dependencies {
add("implementation", lib("reflections"))
"implementation"(lib("reflections"))
}
}

Expand All @@ -168,7 +168,7 @@ fun Project.slf4jLambdaApi() {
// also in debug messages, but this plugin allows us to use lambdas that generate log messages
// (mainly using string interpolation plugin) and these lambdas are evaluated only when needed
// (i.e. when the given log level is active)
add("implementation", lib("slf4j-lambda"))
"implementation"(lib("slf4j-lambda"))
}
}

Expand All @@ -185,7 +185,7 @@ fun Project.slf4jTestImpl() {
// Global exclusion on slf4j-api does NOT apply to tests since it's only limited to
// `runtimeClasspath` configuration.
dependencies {
add("testRuntimeOnly", lib("slf4j-simple"))
"testRuntimeOnly"(lib("slf4j-simple"))
}
}

Expand All @@ -194,6 +194,6 @@ fun Project.vavr() {
// Unlike any other current dependency, Vavr classes are very likely to end up in binary
// interface of the depending subproject,
// hence it's better to just treat Vavr as an `api` and not `implementation` dependency by default.
add("api", lib("vavr"))
"api"(lib("vavr"))
}
}
2 changes: 1 addition & 1 deletion scripts/enforce-settings-gradle-match-directories
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ source "$self_dir"/utils.sh

diff -u \
<(git ls-files '**/build.gradle.kts' ':!:buildSrc' | tr / : | sed 's/:build.gradle.kts//') \
<(grep -Po "(?<=include\(\").*(?=\")" settings.gradle.kts | sort) || {
<(grep -Po '(?<=^ ").*(?=",)' settings.gradle.kts | sort) || {
die 'Gradle subprojects listed in settings.gradle.kts do not match the directories of the project (`+` => Gradle subproject non-existent or listed twice; `-` => superfluous directory)'
}
2 changes: 1 addition & 1 deletion scripts/verify-artifact-contents
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ function fail() {

jars_in_plugin_zip=$(zipinfo -1 "$plugin_zip" | grep -Po '(?<=git-machete-intellij-plugin/lib/).*\.jar' | sort)

gradle_projects=$(cat settings.gradle.kts | grep -Po '(?<=^include\(").*(?="\))' | sort)
gradle_projects=$(grep -Po '(?<=^ ").*(?=",)' settings.gradle.kts | sort)
for project in $gradle_projects; do
project_path=${project//:/\/}
project_jar_name=${project//:/-}
Expand Down
38 changes: 20 additions & 18 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,23 @@ pluginManagement {

rootProject.name = "git-machete-intellij-plugin"
// Note: please keep the projects in a topological order
include("binding")
include("qual")
include("testCommon")
include("gitCore:api")
include("gitCore:jGit")
include("branchLayout:api")
include("branchLayout:impl")
include("backend:api")
include("backend:impl")
include("frontend:icons")
include("frontend:base")
include("frontend:actions")
include("frontend:file")
include("frontend:resourcebundles")
include("frontend:graph:api")
include("frontend:graph:impl")
include("frontend:ui:api")
include("frontend:ui:impl")
include(
"binding",
"qual",
"testCommon",
"gitCore:api",
"gitCore:jGit",
"branchLayout:api",
"branchLayout:impl",
"backend:api",
"backend:impl",
"frontend:icons",
"frontend:base",
"frontend:actions",
"frontend:file",
"frontend:resourcebundles",
"frontend:graph:api",
"frontend:graph:impl",
"frontend:ui:api",
"frontend:ui:impl",
)

0 comments on commit 44d4eef

Please sign in to comment.