-
Notifications
You must be signed in to change notification settings - Fork 28
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
Add Kotlin DSL template #23
base: main
Are you sure you want to change the base?
Conversation
scripts/src/lib/template/templates/gradle/kotlin/settings.gradle.kts
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like a great start, a few small changes, we should make sure that this is as close as possible to the groovy build script. Please let me know if you disagree with anything, if needed we can always change the groovy build script to match.
scripts/src/lib/template/templates/gradle/kotlin/build.gradle.kts.eta
Outdated
Show resolved
Hide resolved
scripts/src/lib/template/templates/gradle/kotlin/build.gradle.kts.eta
Outdated
Show resolved
Hide resolved
scripts/src/lib/template/templates/gradle/kotlin/build.gradle.kts.eta
Outdated
Show resolved
Hide resolved
scripts/src/lib/template/templates/gradle/kotlin/build.gradle.kts.eta
Outdated
Show resolved
Hide resolved
scripts/src/lib/template/templates/gradle/kotlin/build.gradle.kts.eta
Outdated
Show resolved
Hide resolved
@@ -0,0 +1,113 @@ | |||
plugins { | |||
id("fabric-loom") version "1.0-SNAPSHOT" | |||
id("maven-publish")<% if (it.kotlin) { %> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True, but I personally like id("maven-publish")
more. There are no ` characters and more consistent.
Maybe vote?
scripts/src/lib/template/templates/gradle/kotlin/build.gradle.kts.eta
Outdated
Show resolved
Hide resolved
scripts/src/lib/template/templates/gradle/kotlin/build.gradle.kts.eta
Outdated
Show resolved
Hide resolved
options.release.set(java.targetCompatibility.majorVersion.toInt()) | ||
} | ||
<% if (it.kotlin) { %> | ||
withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An import is better than the fqn imo
scripts/src/lib/template/templates/gradle/kotlin/build.gradle.kts.eta
Outdated
Show resolved
Hide resolved
scripts/src/lib/template/templates/gradle/kotlin/build.gradle.kts.eta
Outdated
Show resolved
Hide resolved
} | ||
|
||
withType<JavaCompile> { | ||
options.release.set(java.targetCompatibility.majorVersion.toInt()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this be <%= it.java.release %>
like in the groovy template?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wouldn't create more constants, This PR is about Kotlin DSL, but I think, it should be changed in groovy to reuse the targetCompatibility
constant
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO the best solution would be to use top-level constants in both Kotlin and Groovy buildscripts (val
/def
respectively) for these constants.
Since "this PR is about Kotlin DSL", shouldn't it follow the existing pattern?
} | ||
<% if (it.kotlin) { %> | ||
withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> { | ||
kotlinOptions.jvmTarget = java.targetCompatibility.toString() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
...and shouldn't this be <%= it.java.kotlinRelease %>
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
again... no magic constants if possible.
|
||
jar { | ||
from("LICENSE") { | ||
rename { "${it}_${base.archivesName}" } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rename { "${it}_${base.archivesName}" } | |
rename { "${it}_${base.archivesName.get()}" } |
archivesName
is a Property<String>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done. but it worked without get()
Use property(...) instead of properties[...]
} | ||
|
||
withType<JavaCompile> { | ||
options.release.set(java.targetCompatibility.majorVersion.toInt()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO the best solution would be to use top-level constants in both Kotlin and Groovy buildscripts (val
/def
respectively) for these constants.
Since "this PR is about Kotlin DSL", shouldn't it follow the existing pattern?
withType<JavaCompile> { | ||
options.release.set(java.targetCompatibility.majorVersion.toInt()) | ||
} | ||
java { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
java { | |
java { |
Co-authored-by: Juuz <[email protected]>
No description provided.