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

Refactor some build logic to the buildSrc & gradle kotlin-dsl #218

Closed
wants to merge 5 commits into from
Closed

Refactor some build logic to the buildSrc & gradle kotlin-dsl #218

wants to merge 5 commits into from

Conversation

jmfayard
Copy link

@jmfayard jmfayard commented Oct 8, 2018

Refactor some build logic to the buildSrc & gradle kotlin-dsl

Files buildSrc/src/main/java/{Versions.kt,Libs.kt} generated by kotlinpoet and the task
$ ./gradlew syncLibs

See https://blog.kotlin-academy.com/gradle-kotlin-the-missing-piece-of-the-puzzle-7528a85f0d2c

@googlebot
Copy link

We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for all the commit author(s) or Co-authors. If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google.
In order to pass this check, please resolve this problem and have the pull request author add another comment and the bot will run again. If the bot doesn't comment, it means it doesn't think anything has changed.

Files buildSrc/src/main/java/{Versions.kt,Libs.kt} are generated with the task
   $ ./gradlew syncLibs

Signed-off-by: Jean-Michel Fayard <jmfayard@gmail.com>
@googlebot
Copy link

CLAs look good, thanks!

@jmfayard
Copy link
Author

jmfayard commented Oct 8, 2018

Mmh, test PlantTest#test_shouldBeWatered is working on my computer but is failing on CircleCI.
I don't find the artifacts on CircleCi to find out why.
Any help?

@tiembo
Copy link
Contributor

tiembo commented Oct 9, 2018

That test is a bit flaky, and #212 should fix it. I manually kicked off a CI re-run.

@XinyueZ
Copy link
Contributor

XinyueZ commented Oct 9, 2018

Wow, pretty same what I want to introduce, thx @jmfayard, however, it is real kotlin special, I like it.

@jmfayard
Copy link
Author

@tiembo anyway I have a good grasp now on Gradle's Kotlin DSL.
If that's a topic you are interested in, I can update and improve this pull request.

If not, that's also fine. I used a few projects like yours to make sure that my plugin https://github.com/jmfayard/gradle-kotlin-dsl-libs works correctly, which seems to be the case :)

@XinyueZ
Copy link
Contributor

XinyueZ commented Oct 12, 2018

@jmfayard could you please resolve conflicts, I am personally as one of fans of dsl.

…lin-dsl

Signed-off-by: Jean-Michel Fayard <jmfayard@gmail.com>

# Conflicts:
#	build.gradle
Got feedback from the gradle team that it's better to sue
   buildSrc/src/main/kotlin

Signed-off-by: Jean-Michel Fayard <jmfayard@gmail.com>
@jmfayard
Copy link
Author

jmfayard commented Oct 15, 2018

@XinyueZ done

Signed-off-by: Jean-Michel Fayard <jmfayard@gmail.com>
@XinyueZ
Copy link
Contributor

XinyueZ commented Oct 16, 2018

@jmfayard I think you need format code 🌦

@jmfayard
Copy link
Author

@XinyueZ done.
Nice thing, I will use it to my projects too

@tiembo
Copy link
Contributor

tiembo commented Oct 23, 2018

Hi @jmfayard , apologies for the delay in replying.

I like the Kotlin DSL but feel that it's beyond the scope of this Jetpack-focused sample. Happy to note this PR in the README or Wiki as an sample of implementing gradle-kotlin-dsl-libs. Would that work?

@jmfayard
Copy link
Author

@tiembo no big problem for me, I needed repositories to test my plugin with anyway, so that part is mission accomplished.

Just for completion, I realize that putting kotlin dsl in the name of my plugin a bit of a misnommer.

I think that writing Gradle builds in Kotlin instead of Groovy is the future, but writing them in Groovy is the present, and I wouldn't actually recommend rewriting any existing build just for the sake of the rewrite. In the end, it's just the same Gradle build.

What I'm instead doing for my own projects (and it's a Gradle best practice by the way)

  • Keep the existing build.gradle files, especially the parts in it that are nice and declarative.
  • Find the parts from the build files that look like Groovy code, and extract that build logic to that special buildSrc Gradle module. And there I use Kotlin.

@tiembo
Copy link
Contributor

tiembo commented Oct 24, 2018

Referenced this PR in the wiki.

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.

None yet

4 participants