Skip to content

Commit

Permalink
Gradle to 6.1
Browse files Browse the repository at this point in the history
  • Loading branch information
cortinico committed Jan 20, 2020
1 parent ed3eece commit b728a25
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 44 deletions.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.2-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.1-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
49 changes: 6 additions & 43 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import java.net.URL

pluginManagement {
repositories {
mavenLocal()
Expand All @@ -17,44 +15,9 @@ pluginManagement {
}
}

include(":plugin")

// Exclude the sample modules from the build if the Codegen plugin is not found in any Maven repository.
if (pluginIsInstalled()) {
include(":samples:junit-tests",
":samples:kotlin-android",
":samples:kotlin-coroutines",
":samples:groovy-android",
":samples:generated-code")
}

fun pluginIsInstalled(): Boolean {
// Building the path to check the in the Maven repository if the plugin is available.
var path = PublishingVersions.PLUGIN_GROUP.replace('.', '/')
path += "/${PublishingVersions.PLUGIN_ARTIFACT}"
path += "/${PublishingVersions.PLUGIN_VERSION}"
path += "/${PublishingVersions.PLUGIN_ARTIFACT}-${PublishingVersions.PLUGIN_VERSION}.jar"

return this
.pluginManagement
.repositories
.filterIsInstance<MavenArtifactRepository>()
.any {
try {
// Gradle portal is exposing a wrong URL:
// https://plugins.gradle.org/m2
// The trailing slash is missing and this is breaking
// URL composition and plugin discovery.
var baseUrlString = it.url.toString()
if (!baseUrlString.endsWith("/")) {
baseUrlString = baseUrlString.plus("/")
}
val baseUrl = URL(baseUrlString)
URL(baseUrl, path).openStream().use { stream ->
return@any stream.read() >= 0
}
} catch (ignored: java.io.IOException) {
return@any false
}
}
}
include(":plugin",
":samples:junit-tests",
":samples:kotlin-android",
":samples:kotlin-coroutines",
":samples:groovy-android",
":samples:generated-code")

0 comments on commit b728a25

Please sign in to comment.