Skip to content

Commit

Permalink
Focus on refreshVersions (#115)
Browse files Browse the repository at this point in the history
Focus on refreshVersions
  • Loading branch information
Jean-Michel Fayard authored Nov 6, 2019
2 parents 7feb88a + 988bb69 commit d02577f
Show file tree
Hide file tree
Showing 140 changed files with 2,114 additions and 2,875 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/gradle5-build.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# .github/workflows/gradle-build-pr.yml
# https://github.com/marketplace/actions/gradle-command
name: Run gradle checkAll
on: [push, pull_request]
name: Gradle 5.6.3
on: [pull_request]
jobs:
gradle:
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v1
Expand Down
10 changes: 6 additions & 4 deletions .github/workflows/gradlerc-cron.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
# .github/workflows/gradle-build-pr.yml
# https://github.com/marketplace/actions/gradle-command
name: Run gradle checkAll
on: [push, pull_request]
name: Gradle RC
on:
schedule:
- cron: 0 0 * * * # daily
jobs:
gradle:
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v1
Expand All @@ -15,6 +17,6 @@ jobs:
java-version: 11
- uses: eskatos/gradle-command-action@v1
with:
gradle-version: 5.6.3
gradle-version: rc
arguments: checkAll
build-root-directory: composite
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
# .github/workflows/gradle-build-pr.yml
# https://github.com/marketplace/actions/gradle-command
name: Run gradle checkAll
on: [push, pull_request]
name: sample-android
on: [pull_request]
jobs:
gradle:
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v1
- uses: actions/setup-java@v1
with:
java-version: 11
java-version: 8
- uses: eskatos/gradle-command-action@v1
with:
gradle-version: 4.8
arguments: checkAll
build-root-directory: composite
arguments: refreshVersions
gradle-version: 5.6.3
build-root-directory: sample-android
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,7 @@ build/
.idea/
!gradle-wrapper.jar
_DS_Store
*.iml
local.properties
.gradle

6 changes: 0 additions & 6 deletions .travis.yml

This file was deleted.

26 changes: 2 additions & 24 deletions composite/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@ defaultTasks("run")
val PLUGIN: IncludedBuild = gradle.includedBuild("plugin")
val SAMPLE_KOTLIN: IncludedBuild = gradle.includedBuild("sample-kotlin")
val SAMPLE_GROOVY: IncludedBuild = gradle.includedBuild("sample-groovy")
val SAMPLE_VERSIONS_ONLY: IncludedBuild = gradle.includedBuild("sample-versionsOnlyMode")
// val SAMPLE_ANDROID: IncludedBuild = gradle.includedBuild("sample-android")
val REFRESH_VERSIONS = ":refreshVersions"
val BUILD_SRC_VERSIONS = ":buildSrcVersions"
val CUSTOM = "custom"

tasks.register("publishLocally") {
Expand Down Expand Up @@ -44,32 +43,11 @@ tasks.register("pluginTests") {
tasks.register("checkAll") {
group = CUSTOM
description = "Run all checks"
dependsOn(SAMPLE_VERSIONS_ONLY.task(REFRESH_VERSIONS))
//dependsOn(SAMPLE_ANDROID.task(REFRESH_VERSIONS))
dependsOn(SAMPLE_KOTLIN.task(REFRESH_VERSIONS))
dependsOn(SAMPLE_GROOVY.task(REFRESH_VERSIONS))
dependsOn(SAMPLE_KOTLIN.task(BUILD_SRC_VERSIONS))
dependsOn(SAMPLE_GROOVY.task(BUILD_SRC_VERSIONS))
dependsOn(PLUGIN.task(":validateTaskProperties"))
dependsOn(PLUGIN.task(":check"))
dependsOn(SAMPLE_VERSIONS_ONLY.task(":checkAll"))
}


tasks.register("updateGradle") {
group = CUSTOM
description = "Update Gradle in all modules"
dependsOn(":wrapper")
dependsOn(PLUGIN.task(":wrapper"))
dependsOn(SAMPLE_KOTLIN.task(":wrapper"))
dependsOn(SAMPLE_GROOVY.task(":wrapper"))
dependsOn(SAMPLE_VERSIONS_ONLY.task(":wrapper"))
}

tasks.withType<Wrapper> {
group = CUSTOM
description = "Update Gradle with ./gradlew wrapper"
gradleVersion = System.getenv("GRADLE_VERSION") ?: "5.6.1"
distributionType = Wrapper.DistributionType.ALL
}

buildScan {
Expand Down
7 changes: 6 additions & 1 deletion composite/settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,9 @@ rootProject.name = "buildSrcVersions-composite"
includeBuild("../plugin")
includeBuild("../sample-kotlin")
includeBuild("../sample-groovy")
includeBuild("../sample-versionsOnlyMode")

// ../sample-android should be opened in Android Studio
//Adding
// includeBuild("../sample-android")
// would fail with the error:
// New Gradle Sync is not supported due to containing Kotlin modules
20 changes: 3 additions & 17 deletions plugin/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
id("de.fayard.buildSrcVersions") version ("0.6.5") // plugin.de.fayard.buildSrcVersions

id("de.fayard.refreshVersions")
id("com.gradle.plugin-publish")
`java-gradle-plugin`
`maven-publish`
Expand All @@ -11,23 +10,17 @@ plugins {
}


version = "0.7.1" // plugin.de.fayard.refreshversions
version = "0.8.2" // plugin.de.fayard.refreshversions
group = "de.fayard"


gradlePlugin {
plugins {
create("buildSrcVersions") {
id = "de.fayard.buildSrcVersions"
displayName = "./gradlew buildSrcVersions"
description = "Painless dependencies management"
implementationClass = "de.fayard.BuildSrcVersionsPlugin"
}
create("refreshVersions") {
id = "de.fayard.refreshVersions"
displayName = "./gradlew refreshVersions"
description = "Painless dependencies management"
implementationClass = "de.fayard.BuildSrcVersionsPlugin"
implementationClass = "de.fayard.RefreshVersionsPlugin"
}
}
}
Expand Down Expand Up @@ -63,8 +56,6 @@ dependencies {

implementation("com.squareup.okio:okio:2.1.0")
implementation( "com.squareup.moshi:moshi:1.7.0")
implementation("com.squareup:kotlinpoet:1.3.0")

}


Expand All @@ -76,11 +67,6 @@ tasks.withType<Test> {
useJUnitPlatform()
}

tasks.withType<Wrapper> {
gradleVersion = System.getenv("GRADLE_VERSION") ?: "5.6.1"
distributionType = Wrapper.DistributionType.ALL
}

java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
Expand Down
21 changes: 1 addition & 20 deletions plugin/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,20 +1 @@
# Dependencies and Plugin versions with their available updates
# Generated by $ ./gradlew refreshVersions
# See https://github.com/jmfayard/buildSrcVersions/issues/77
plugin.org.gradle.kotlin.kotlin.dsl=1.2.9
# available=1.3.1
plugin.de.fayard.refreshVersions=0.7.0
plugin.com.gradle.plugin-publish=0.10.0
# available=0.10.1
plugin.com.gradle.build-scan=2.4.1
# available=2.4.2
version.kotlintest.runner.junit5=3.1.9
# available=3.4.1
version.gradle.versions.plugin=0.25.0
version.org.jetbrains.kotlin=1.3.41
# available=1.3.50
version.kotlinpoet=1.3.0
version.moshi=1.7.0
# available=1.8.0
version.okio=2.1.0
# You can edit the rest of the file, it will be kept intact
resolutionStrategyConfig=verbose
84 changes: 84 additions & 0 deletions plugin/gradle/plugins.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
/**
* File generated by $ ./gradlew refreshVersions
*
* Gradle has replaced the buildscript { ... } block by a better alternative that looks like this
*
```
plugins {
id("com.android.application")
id("com.louiscad.splitties")
id("org.jetbrains.kotlin.android")
id("org.jetbrains.kotlin.kapt")
id("kotlin-android-extensions")
}
```
* This boilerplate does two things:
*
* 1. it configures the plugin versions using the file `versions.properties` generated by
* $ ./gradlew refreshVersions
*
* 2. it fixes the bug of the Android Gradle Plugin that doesn't publish the required metadata
* Please see and upvote the issue:
* https://issuetracker.google.com/issues/64551265
*
* Include this file like this:
*
```kotlin
// settings.gradle.kts
pluginManagement {
repositories {
google()
gradlePluginPortal()
}
}
apply(from = "plugins.gradle.kts")
// rootProject.name = xxx
// include(":app")
```
***/
@Suppress("CAST_NEVER_SUCCEEDS")
(this as Settings).pluginManagement {

/**
* This `resolutionStrategy` allows plugin versions to be configured from
* `versions.properties
* The convention is simply
* plugin.$PLUGINID=$PLUGIN_VERSION
* To check what happen, you can set the property
* resolutionStrategyConfig=verbose
**/
val resolutionStrategyConfig = extra["resolutionStrategyConfig"]
val versionProperties = file("../versions.properties")
if (resolutionStrategyConfig == "false" || versionProperties.canRead().not()) return@pluginManagement
val androidPluginIds = listOf("com.android.application", "com.android.library")
val kotlinPluginIds = listOf("org.jetbrains.kotlin.android", "org.jetbrains.kotlin.kapt", "kotlin-android-extensions")
@Suppress("UNCHECKED_CAST")
val properties: Map<String, String> = java.util.Properties().apply {
load(versionProperties.reader())
} as Map<String, String>
require("module.kotlin" in properties) { "version.properties MUST contain module.kotlin=.... and/or module.android=...." }
resolutionStrategy.eachPlugin {
val pluginId = requested.id.id
val version = properties["plugin.$pluginId"]
val message = when {
pluginId in kotlinPluginIds -> {
val module = "org.jetbrains.kotlin:kotlin-gradle-plugin:${properties["module.kotlin"]}"
useModule(module)
"ResolutionStrategy used module=$module for plugin=$pluginId"
}
pluginId in androidPluginIds -> {
val module = "com.android.tools.build:gradle:${properties["module.android"]}"
useModule(module)
"ResolutionStrategy used module=$module for plugin=$pluginId"
}
version != null -> {
useVersion(version)
"ResolutionStrategy used version=$version for plugin=$pluginId"
}
else -> "ResolutionStrategy did not find a version for $pluginId"
}
if (resolutionStrategyConfig == "verbose") println(message)
}
}
12 changes: 4 additions & 8 deletions plugin/settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
pluginManagement {
val resolutionStrategyConfig: String? by extra
resolutionStrategy.eachPlugin {
val property = "plugin.${requested.id.id}"
if (extra.has(property) && resolutionStrategyConfig != "false") {
val version = extra.get(property) as String
useVersion(version)
if (resolutionStrategyConfig == "verbose") println("ResolutionStrategy selected version=$version from property=$property")
}
repositories {
mavenLocal()
gradlePluginPortal()
}
}
apply(from = "gradle/plugins.gradle.kts")
rootProject.name = "plugin"
Loading

0 comments on commit d02577f

Please sign in to comment.