-
-
Notifications
You must be signed in to change notification settings - Fork 108
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
sample-bleeding-edge: initial import
- Loading branch information
Showing
13 changed files
with
557 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Project exclude paths | ||
/.gradle/ | ||
.idea/ | ||
build/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
|
||
## Links | ||
|
||
- https://github.com/jmfayard/buildSrcVersions/issues/104 | ||
- https://discuss.kotlinlang.org/t/kotlin-1-3-60-early-access-preview/14579 | ||
- https://blog.jetbrains.com/idea/2019/10/introducing-package-search-eap/ | ||
- https://docs.gradle.org/6.0-rc-3/release-notes.html | ||
- https://youtrack.jetbrains.com/issues/PKGS | ||
- https://youtrack.jetbrains.com/issues?q=by:%20me | ||
- https://youtrack.jetbrains.com/issues?q=tag:%20Star | ||
- https://github.com/msfjarvis/viscerion | ||
- https://github.com/vierbergenlars/plugin-updates-gradle-plugin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
Sample project to demo how to manage Gradle dependencies with | ||
|
||
- [IntelliJ EAP - Package Search](https://blog.jetbrains.com/idea/2019/10/introducing-package-search-eap/) to add packages | ||
- The Gradle plugin [`de.fayard.refreshVersions`](https://plugins.gradle.org/plugin/de.fayard.refreshVersions) | ||
- The Gradle plugin [`com.louiscad.splitties`](https://plugins.gradle.org/plugin/com.louiscad.splitties) | ||
|
||
## Installation | ||
|
||
```bash | ||
$ git clone https://github.com/jmfayard/gradle-refreshVersions-example | ||
``` | ||
|
||
To get the Package Window and visual interface, you need to install the Package Search plugin that is available on the marketplace. | ||
|
||
If you’re using IntelliJ IDEA 2019.2 or later, you’re already using this functionality when it comes to code completion for packages. | ||
|
||
|
||
## Package Search | ||
|
||
Package Search provides a nice UX to add a dependency | ||
|
||
![](https://d3nmt5vlzunoa1.cloudfront.net/idea/files/2019/10/Screenshot-2019-10-21-at-10.28.33-1.png) | ||
|
||
## gradle refreshVerisons | ||
|
||
`./gradlew refreshVersions` extract dependencies versions to a file [versions.properties](versions.properties) | ||
|
||
[Read the friendly documentation](https://github.com/jmfayard/buildSrcVersions/issues/77) | ||
|
||
![image](https://user-images.githubusercontent.com/459464/68318855-b1cc5a00-00bd-11ea-827b-cee110839337.png) | ||
|
||
|
||
## splitties | ||
|
||
Splitties contains [typesafe accessor for common dependencies like retrofit, androidx, unit testing, ...](https://github.com/LouisCAD/Splitties/tree/develop/plugin/src/main/kotlin/com/louiscad/splitties) | ||
|
||
![Screen Shot 2019-11-06 at 5 31 38 PM](https://user-images.githubusercontent.com/459464/68317452-6e70ec00-00bb-11ea-84c4-94d3ef0fb86f.png) | ||
|
||
|
||
## Should I use it? | ||
|
||
No, we are not ready yet. | ||
|
||
But please do subscribe to the issue [Long term plan: focus on refreshVersions #104](https://github.com/jmfayard/buildSrcVersions/issues/104) | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import com.louiscad.splitties.AndroidX | ||
import com.louiscad.splitties.KotlinX | ||
import com.louiscad.splitties.Testing | ||
import de.fayard.versions.StabilityLevel | ||
import de.fayard.versions.candidateStabilityLevel | ||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile | ||
|
||
plugins { | ||
id("de.fayard.refreshVersions") .version("0.8.2") | ||
id("com.louiscad.splitties") .version("0.1.3") | ||
kotlin("jvm") .version("1.3.50") | ||
application | ||
} | ||
group = "de.fayard.experimental" | ||
version = "1.0-SNAPSHOT" | ||
|
||
refreshVersions { | ||
rejectVersionIf { | ||
//candidateStabilityLevel() isLessStableThan StabilityLevel.Stable | ||
false | ||
} | ||
} | ||
|
||
dependencies { | ||
implementation(KotlinX.coroutines.core) | ||
testImplementation(Testing.kotestKtor) | ||
testImplementation(Testing.kotestKoin) | ||
|
||
} | ||
|
||
repositories { | ||
mavenCentral() | ||
maven("https://dl.bintray.com/kotlin/kotlin-eap") | ||
} | ||
|
||
|
||
tasks.named<JavaExec>("run") { | ||
main = "de.fayard.experimental.HelloKt.main" | ||
} | ||
|
||
tasks.register("hello") { | ||
group = "custom" | ||
description = "Empty Hello World task, useful to debug build problems" | ||
} | ||
|
||
tasks.named<Delete>("clean") { | ||
group = "custom" | ||
description = "Delete build files" | ||
delete = setOf(".gradle", ".idea", "**.iml", "build", "app/build") | ||
} | ||
|
||
dependencies { | ||
implementation(kotlin("stdlib-jdk8")) | ||
} | ||
|
||
val compileKotlin: KotlinCompile by tasks | ||
compileKotlin.kotlinOptions { | ||
jvmTarget = "1.8" | ||
} | ||
val compileTestKotlin: KotlinCompile by tasks | ||
compileTestKotlin.kotlinOptions { | ||
jvmTarget = "1.8" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# See https://dev.to/jmfayard/configuring-gradle-with-gradle-properties-211k | ||
|
||
refreshVersions.useExperimentalUpdater=false | ||
|
||
# set to 'verbose' to better understand how the file "versions.proeprties" is used | ||
resolutionStrategyConfig=true | ||
|
||
org.gradle.jvmargs=-Xmx1536m | ||
org.gradle.caching=true | ||
org.gradle.parallel=true | ||
kotlin.code.style=official |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
/** | ||
* 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 versionProperties = file("../versions.properties") | ||
val resolutionStrategyConfig = extra["resolutionStrategyConfig"] | ||
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> | ||
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) | ||
} | ||
} |
Binary file not shown.
5 changes: 5 additions & 0 deletions
5
sample-bleeding-edge/gradle/wrapper/gradle-wrapper.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-bin.zip | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists |
Oops, something went wrong.