Skip to content

Commit

Permalink
Merge pull request #67 from icerockdev/#50-gradle-6
Browse files Browse the repository at this point in the history
update to gradle 6.3
  • Loading branch information
Alex009 committed May 4, 2020
2 parents fb82c8a + 55318ce commit 8708df2
Show file tree
Hide file tree
Showing 10 changed files with 115 additions and 66 deletions.
29 changes: 26 additions & 3 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,32 @@
* Copyright 2019 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.
*/

buildscript {
repositories {
mavenLocal()

jcenter()
google()

maven { url = uri("https://dl.bintray.com/kotlin/kotlin") }
maven { url = uri("https://kotlin.bintray.com/kotlinx") }
maven { url = uri("https://plugins.gradle.org/m2/") }
maven { url = uri("https://dl.bintray.com/icerockdev/plugins") }
}
dependencies {
with(Deps.Plugins) {
listOf(
androidApplication,
androidLibrary,
kotlinMultiplatform,
kotlinKapt,
kotlinAndroid,
mokoResources
)
}.let { plugins(it) }
}
}

allprojects {
repositories {
mavenLocal()
Expand All @@ -13,9 +39,6 @@ allprojects {
maven { url = uri("https://kotlin.bintray.com/kotlinx") }
maven { url = uri("https://dl.bintray.com/icerockdev/moko") }
}

// workaround for https://youtrack.jetbrains.com/issue/KT-27170
configurations.create("compileClasspath")
}

tasks.register("clean", Delete::class).configure {
Expand Down
50 changes: 37 additions & 13 deletions buildSrc/src/main/kotlin/Deps.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,45 @@

object Deps {
object Plugins {
const val android =
private const val androidPluginModule =
"com.android.tools.build:gradle:${Versions.Plugins.android}"
const val kotlin =
val androidApplication = PluginDesc(
id = "com.android.application",
module = androidPluginModule
)
val androidLibrary = PluginDesc(
id = "com.android.library",
module = androidPluginModule
)

private const val kotlinPluginModule =
"org.jetbrains.kotlin:kotlin-gradle-plugin:${Versions.Plugins.kotlin}"
const val mokoResources =
"dev.icerock.moko:resources-generator:${Versions.Plugins.mokoResources}"
val kotlinMultiplatform = PluginDesc(
id = "org.jetbrains.kotlin.multiplatform",
module = kotlinPluginModule
)
val kotlinKapt = PluginDesc(
id = "kotlin-kapt",
module = kotlinPluginModule
)
val kotlinAndroid = PluginDesc(
id = "kotlin-android",
module = kotlinPluginModule
)
val kotlinAndroidExtensions = PluginDesc(
id = "kotlin-android-extensions",
module = kotlinPluginModule
)

val mobileMultiplatform = PluginDesc(
id = "dev.icerock.mobile.multiplatform",
module = "dev.icerock:mobile-multiplatform:0.6.1"
)

val mokoResources = PluginDesc(
id = "dev.icerock.mobile.multiplatform-resources",
module = "dev.icerock.moko:resources-generator:${Versions.Plugins.mokoResources}"
)
}

object Libs {
Expand Down Expand Up @@ -55,13 +88,4 @@ object Deps {
const val detektFormatting = "io.gitlab.arturbosch.detekt:detekt-formatting:${Versions.Plugins.detekt}"
}
}

val plugins: Map<String, String> = mapOf(
"com.android.application" to Plugins.android,
"com.android.library" to Plugins.android,
"org.jetbrains.kotlin.multiplatform" to Plugins.kotlin,
"kotlin-kapt" to Plugins.kotlin,
"kotlin-android" to Plugins.kotlin,
"dev.icerock.mobile.multiplatform-resources" to Plugins.mokoResources
)
}
25 changes: 25 additions & 0 deletions buildSrc/src/main/kotlin/PluginDesc.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* Copyright 2020 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.
*/

import org.gradle.kotlin.dsl.DependencyHandlerScope
import org.gradle.plugin.use.PluginDependenciesSpec

data class PluginDesc(
val id: String,
val module: String
)

fun DependencyHandlerScope.plugin(pluginDesc: PluginDesc) {
"classpath"(pluginDesc.module)
}

fun DependencyHandlerScope.plugins(pluginDescList: List<PluginDesc>) {
pluginDescList
.distinctBy { it.module }
.forEach { plugin(it) }
}

fun PluginDependenciesSpec.plugin(pluginDesc: PluginDesc) {
id(pluginDesc.id)
}
6 changes: 3 additions & 3 deletions gradle-plugin/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*/

plugins {
id("org.gradle.kotlin.kotlin-dsl") version "1.3.6"
`kotlin-dsl`
id("org.gradle.maven-publish")
id("io.gitlab.arturbosch.detekt") version(Versions.Plugins.detekt)
}
Expand All @@ -17,8 +17,8 @@ repositories {

dependencies {
implementation(Deps.Libs.Jvm.kotlinPoet)
compileOnly(Deps.Plugins.kotlin)
compileOnly(Deps.Plugins.android)
compileOnly(Deps.Plugins.kotlinMultiplatform.module)
compileOnly(Deps.Plugins.androidLibrary.module)
implementation(Deps.Libs.Jvm.apacheCommonsText)
detektPlugins(Deps.Libs.Jvm.detektFormatting)
}
Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
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.4-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.3-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
33 changes: 14 additions & 19 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,8 @@ if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi

# For Cygwin, switch paths to Windows format before running java
if $cygwin ; then
# For Cygwin or MSYS, switch paths to Windows format before running java
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
Expand Down Expand Up @@ -154,19 +154,19 @@ if $cygwin ; then
else
eval `echo args$i`="\"$arg\""
fi
i=$((i+1))
i=`expr $i + 1`
done
case $i in
(0) set -- ;;
(1) set -- "$args0" ;;
(2) set -- "$args0" "$args1" ;;
(3) set -- "$args0" "$args1" "$args2" ;;
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
0) set -- ;;
1) set -- "$args0" ;;
2) set -- "$args0" "$args1" ;;
3) set -- "$args0" "$args1" "$args2" ;;
4) set -- "$args0" "$args1" "$args2" "$args3" ;;
5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi

Expand All @@ -175,14 +175,9 @@ save () {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}
APP_ARGS=$(save "$@")
APP_ARGS=`save "$@"`

# Collect all arguments for the java command, following the shell quoting and substitution rules
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"

# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
cd "$(dirname "$0")"
fi

exec "$JAVACMD" "$@"
3 changes: 3 additions & 0 deletions gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%

@rem Resolve any "." and ".." in APP_HOME to make it shorter.
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi

@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"

Expand Down
8 changes: 4 additions & 4 deletions resources/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
*/

plugins {
id("com.android.library")
id("org.jetbrains.kotlin.multiplatform")
id("kotlin-android-extensions")
id("dev.icerock.mobile.multiplatform")
plugin(Deps.Plugins.androidLibrary)
plugin(Deps.Plugins.kotlinMultiplatform)
plugin(Deps.Plugins.kotlinAndroidExtensions)
plugin(Deps.Plugins.mobileMultiplatform)
id("maven-publish")
}

Expand Down
25 changes: 2 additions & 23 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,14 @@
* Copyright 2019 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.
*/

pluginManagement {
repositories {
mavenLocal()

jcenter()
google()

maven { url = uri("https://dl.bintray.com/kotlin/kotlin") }
maven { url = uri("https://kotlin.bintray.com/kotlinx") }
maven { url = uri("https://plugins.gradle.org/m2/") }
maven { url = uri("https://dl.bintray.com/icerockdev/plugins") }
}
resolutionStrategy.eachPlugin {
val module = Deps.plugins[requested.id.id] ?: return@eachPlugin

useModule(module)
}
}

enableFeaturePreview("GRADLE_METADATA")

val properties = startParameter.projectProperties

// ./gradlew -PlibraryPublish :gradle-plugin:publishPluginPublicationToMavenLocal :resources:publishToMavenLocal
val properties: Map<String, String> = startParameter.projectProperties
val libraryPublish: Boolean = properties.containsKey("libraryPublish")

include(":resources")
include(":gradle-plugin")
if(!libraryPublish) {
if (!libraryPublish) {
include(":sample:android-app")
include(":sample:mpp-library", ":sample:mpp-library:nested-module")
include(":sample:mpp-conditional")
Expand Down

0 comments on commit 8708df2

Please sign in to comment.