Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plugin #219

Merged
merged 29 commits into from
Oct 22, 2019
Merged

Plugin #219

merged 29 commits into from
Oct 22, 2019

Conversation

jmfayard
Copy link
Collaborator

@jmfayard jmfayard commented Oct 18, 2019

Plugin documentation:
https://github.com/LouisCAD/Splitties/tree/plugin/plugin

Run ./gradlew :plugin:publishToMavenLocal

Run $ ./gradlew migrateToAndroidX in the project that needs to be migrated

Running :plugin:publishPlugins will publish a version to https://plugins.gradle.org/plugin/com.louiscad.splitties
This in turns will allow us to test it more easily in other projects.

What about the version? I considered three alternatives:

  • using an exact version number -- but it will never be "the right version" for all dependencies and I find it annyoing
  • using _ -- but that makes the Android Sync fails, so no
  • using + -- that works and only needs to be explained

I kept the version for Splitties, which is a special case, and for AndroidX (just for now)

Caveat: Android Studio does not seem to support auto-completion for build.gradle


The path to the CSV file is hardcoded. It should be possible to use the CSV from the resources folder but I couldn't find the right syntax for this. https://github.com/LouisCAD/Splitties/blob/plugin/plugin/src/main/kotlin/com/louiscad/splitties/MigrateAndroidxTask.kt#L14-L16

Jean-Michel Fayard and others added 16 commits September 6, 2019 17:59
…trategy

# Conflicts:
#	plugin/src/main/kotlin/com/louiscad/splitties/Splitties.kt
#	plugin/src/main/kotlin/com/louiscad/splitties/SplittiesPlugin.kt
```
$ ./gradlew migrateToAndroidX
> Configure project :
Hello World SplittiesPlugin

> Task :migrateToAndroidX
Let's migrate this Android project from support libraries to AndroidX.
moduleDirectories=[/Users/jmfayard/Downloads/SmallVictories/update-legacy-project/app]

There's 24 source files that may need migration
CSV file ok.
Starting batch migration
Migrating file named "MainActivityTest.kt" with full name: "/Users/jmfayard/Downloads/SmallVictories/update-legacy-project/app/src/androidTest/java/com/raywenderlich/android/smallvictories/MainActivityTest.kt"… Overwriting file… Done.✔🆗
Migrating file named "VictoryViewModelTest.kt" with full name: "/Users/jmfayard/Downloads/SmallVictories/update-legacy-project/app/src/androidTest/java/com/raywenderlich/android/smallvictories/VictoryViewModelTest.kt"… Overwriting file… Done.✔🆗
Migrating file named "content_main.xml" with full name: "/Users/jmfayard/Downloads/SmallVictories/update-legacy-project/app/src/main/res/layout/content_main.xml"… Overwriting file… Done.✔🆗
Migrating file named "activity_main.xml" with full name: "/Users/jmfayard/Downloads/SmallVictories/update-legacy-project/app/src/main/res/layout/activity_main.xml"… Overwriting file… Done.✔🆗
Migrating file named "MainActivity.kt" with full name: "/Users/jmfayard/Downloads/SmallVictories/update-legacy-project/app/src/main/java/com/raywenderlich/android/smallvictories/MainActivity.kt"… Overwriting file… Done.✔🆗
Migrating file named "VictoryViewModel.kt" with full name: "/Users/jmfayard/Downloads/SmallVictories/update-legacy-project/app/src/main/java/com/raywenderlich/android/smallvictories/VictoryViewModel.kt"… Overwriting file… Done.✔🆗
Migrating file named "SplashActivity.kt" with full name: "/Users/jmfayard/Downloads/SmallVictories/update-legacy-project/app/src/main/java/com/raywenderlich/android/smallvictories/SplashActivity.kt"… Overwriting file… Done.✔🆗
Migrating file named "build.gradle" with full name: "/Users/jmfayard/Downloads/SmallVictories/update-legacy-project/app/build.gradle"… Overwriting file… Done.✔🆗oid/smallvictories/VictoryUiModel.kt"…

7 source files (kt,java,xml) have been migrated (17 didn't need it).
1 gradle files have been migrated (0 didn't need it).
AndroidX migration complete!
You now just need to update the dependencies, if not already done.

BUILD SUCCESSFUL in 1s
1 actionable task: 1 executed

Publishing build scan...
https://gradle.com/s/ye2bgafkqdhfa
```
@jmfayard jmfayard requested a review from LouisCAD October 18, 2019 14:47
using an exact version will mislead people
using "_" makes Android Sync fails

We should keep an exact version for important things like splitties version and Kotlin version
Thanks to Paul from Gradle, the path to the CSV file is not hardcoded anymore
@jmfayard jmfayard requested a review from LouisCAD October 19, 2019 18:40
Except for versions that do not have yet a stable release.
Those may be filtered out by the filter refreshVersions.rejectVersionIf { ... }
Copy link
Owner

@LouisCAD LouisCAD left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks Good To Me.
Will publish the plugin on the Gradle Portal in the afternoon CEST, and merge into develop.

LouisCAD and others added 2 commits October 22, 2019 17:31
Gradle Build Scan:
https://gradle.com/s/dfriulkefvlvm

```
> Task :migrateToAndroidX
## Searching Android Support Dependencies

androidTestImplementation("android.arch.core:core-testing:1.1.1")
androidTestImplementation("com.android.support.test:runner:1.0.2")
androidTestImplementation("com.android.support.test:rules:1.0.2")
androidTestImplementation("com.android.support.test.espresso:espresso-core:3.0.2")
implementation("com.android.support:appcompat-v7:28.0.0-beta01")
implementation("com.android.support.constraint:constraint-layout:1.1.2")
implementation("com.android.support:design:28.0.0-beta01")
implementation("android.arch.lifecycle:runtime:1.1.1")
implementation("android.arch.lifecycle:extensions:1.1.1")
implementation("android.arch.lifecycle:compiler:1.1.1")

## Use instead those Androidx libraries

androidTestImplementation("androidx.arch.core:core-testing")
androidTestImplementation("androidx.test:runner")
androidTestImplementation("androidx.test:rules")
androidTestImplementation("androidx.test.espresso:espresso-core")
implementation("androidx.appcompat:appcompat")
implementation("androidx.constraintlayout:constraintlayout")
implementation("com.google.android.material:material")
implementation("androidx.lifecycle:lifecycle-runtime")
implementation("androidx.lifecycle:lifecycle-extensions")
implementation("androidx.lifecycle:lifecycle-compiler")
```
@LouisCAD LouisCAD merged commit 74ed81f into develop Oct 22, 2019
@LouisCAD LouisCAD deleted the plugin branch October 24, 2019 10:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants