Ahmed Riyadh
05/16/2024, 11:01 AM// Example configurations
gettext {
translations {
srcDir = 'src'
include = 'main/java/com/example/**/*.java'
commentFormat = ' #. '
outputFilename = 'translations.pot'
}
}
Any idea how to use the exact same configurations in Gradle Kotlin DSL? it doesn't have GetTextExtension
class and I tried with different ways but this is the only way that make the sync process work with no issues:
tasks.withType(org.mini2Dx.gettext.plugin.task.GeneratePotTask::class) {
srcDir = "src"
include = "main/java/com/example/**/*.java"
commentFormat = " #. "
outputFile = layout.buildDirectory.file("gettext/translations.pot").get().asFile
}
But this code doesn't seems to have any affect at all, running the task ./gradlew generatePots
from GetText Gradle plugin won't work and generate the files for example, any idea how to use a Groovy plugin like this on Gradle Kotlin DSL?
Thank you.Vampire
05/16/2024, 11:31 AMapply
to apply the plugin, or did you properly apply the plugin through the plugins { ... }
block?Ahmed Riyadh
05/16/2024, 11:32 AMplugins {}
block but it didn't work (maybe I has something wrong so I used the legacy apply(plugin = "...")
I tried:
plugins {
id("org.mini2Dx.gettext") version "1.11.0"
}
But got:
Plugin [id: 'org.mini2Dx.gettext', version: '1.11.0'] was not found in any of the following sources:
Vampire
05/16/2024, 11:33 AMplugins { ... ]
block and only for things those add without condition.Ahmed Riyadh
05/16/2024, 11:34 AMwithGroovyBuilder
or something similar? but I still don't know how to use it and I tried but I always get type declaration errorVampire
05/16/2024, 11:35 AMAhmed Riyadh
05/16/2024, 11:35 AMVampire
05/16/2024, 11:36 AMplugins { ... }
block work instead.Vampire
05/16/2024, 11:36 AMVampire
05/16/2024, 11:36 AMVampire
05/16/2024, 11:37 AMAhmed Riyadh
05/16/2024, 11:37 AMbuildscript {
repositories {
mavenLocal()
mavenCentral()
}
dependencies {
classpath 'org.mini2Dx:gettext-gradle-plugin:1.7.1'
}
}
...
project(":your-project") {
apply plugin: "org.mini2Dx.gettext"
...
should be:
plugins {
id("org.mini2Dx.gettext") version "1.11.0"
}
But it didn't work for some reason, any idea?Vampire
05/16/2024, 11:38 AMAhmed Riyadh
05/16/2024, 11:38 AMVampire
05/16/2024, 11:39 AMVampire
05/16/2024, 11:39 AMtasks.withType
is not working is, because there is no such task. The gettext { translations { ... } }
is not configuring a task, but it is adding the translations
element to the gettext
named domain object container that would probably then add a task for that element.Vampire
05/16/2024, 11:40 AMtasks.withType(...) { ... }
but always tasks.withType(...).confiugreEach { ... }
or you break task-configuration avoidance.Vampire
05/16/2024, 11:43 AMpluginManagement {
resolutionStrategy {
eachPlugin {
when (requested.id.id) {
"org.mini2Dx.gettext" ->
useModule("org.mini2Dx:gettext-gradle-plugin:1.11.0")
}
}
}
}
And in your build script then
plugins {
id("org.mini2Dx.gettext")
}
and
val translations by gettext.registering {
srcDir = "src"
// ...
}
Vampire
05/16/2024, 11:45 AMAhmed Riyadh
05/16/2024, 11:46 AMVampire
05/16/2024, 11:46 AMAhmed Riyadh
05/16/2024, 12:00 PM./gradlew generatePots
task cause failure that wasn't in the groovy code and might be not related to the plugin itself) but at least I'm getting a different error:
For more information, please refer to <https://docs.gradle.org/8.7/userguide/validation_problems.html#ignored_annotations_on_field> in the Gradle documentation.
- Type 'org.mini2Dx.gettext.plugin.task.GeneratePotTask' field 'exclude' without corresponding getter has been annotated with @Input, @Optional.
Reason: Annotations on fields are only used if there's a corresponding getter for the field.
Possible solutions:
1. Add a getter for field 'exclude'.
2. Remove the annotations on 'exclude'.
For more information, please refer to <https://docs.gradle.org/8.7/userguide/validation_problems.html#ignored_annotations_on_field> in the Gradle documentation.
- Type 'org.mini2Dx.gettext.plugin.task.GeneratePotTask' field 'excludes' without corresponding getter has been annotated with @Input, @Optional.
Reason: Annotations on fields are only used if there's a corresponding getter for the field.
Possible solutions:
1. Add a getter for field 'excludes'.
2. Remove the annotations on 'excludes'.
Vampire
05/16/2024, 12:01 PMAhmed Riyadh
05/16/2024, 12:02 PMVampire
05/16/2024, 12:03 PMVampire
05/16/2024, 12:03 PMAhmed Riyadh
05/16/2024, 12:08 PMbuildscript {
repositories {
mavenCentral()
maven {
url '<https://jitpack.io>'
content {
includeGroup "com.github.RyanTheAllmighty.gettext"
}
}
}
dependencies {
classpath 'com.github.RyanTheAllmighty.gettext:gettext-gradle-plugin:aab5c30bf8'
}
}
apply(plugin = 'org.mini2Dx.gettext')
Any idea to apply the plugin from this repository/buildscript in Gradle Kotlin DSL so instead of
"org.mini2Dx.gettext" ->
useModule("org.mini2Dx:gettext-gradle-plugin:1.11.0")
Will use the forked one, so I can test it.Vampire
05/16/2024, 12:18 PMAhmed Riyadh
05/16/2024, 12:18 PMVampire
05/16/2024, 12:22 PMVampire
05/16/2024, 12:22 PMAhmed Riyadh
05/16/2024, 12:23 PMpluginManagement {
resolutionStrategy {
eachPlugin {
when (requested.id.id) {
"org.mini2Dx.gettext" ->
useModule("org.mini2Dx:gettext-gradle-plugin:1.11.0")
}
}
}
}
To use the fork one instead of the original gradle plugin, but I'm still not sure about this, I tried updating the code to:
pluginManagement {
resolutionStrategy {
eachPlugin {
repositories {
mavenCentral()
maven {
setUrl("<https://jitpack.io>")
content {
includeGroup("com.github.RyanTheAllmighty.gettext")
includeGroup("com.github.ATLauncher.gradle-macappbundle")
}
}
}
when (requested.id.id) {
"org.mini2Dx.gettext" ->
useModule("com.github.RyanTheAllmighty.gettext:gettext-gradle-plugin:aab5c30bf8")
}
}
}
}
and I'm getting this error: Plugin [id: 'org.mini2Dx.gettext', artifact: 'com.github.RyanTheAllmighty.gettext:gettext-gradle-plugin:aab5c30bf8'] was not found in any of the following sources:
Vampire
05/16/2024, 12:25 PMAhmed Riyadh
05/16/2024, 12:26 PMbuildscript {
repositories {
mavenCentral()
maven {
url '<https://jitpack.io>'
content {
includeGroup "com.github.RyanTheAllmighty.gettext"
}
}
}
dependencies {
classpath 'com.github.RyanTheAllmighty.gettext:gettext-gradle-plugin:aab5c30bf8'
}
}
apply plugin: 'org.mini2Dx.gettext'
Vampire
05/16/2024, 12:26 PMrepositories
in the eachPlugin
, that is just visual clutter.
It belongs directly inside pluginManagement
Vampire
05/16/2024, 12:29 PMmaven("<https://jitpack.io>") {
content {
includeGroup("com.github.RyanTheAllmighty.gettext")
}
}
as plugin repository and switching to useModule("com.github.RyanTheAllmighty.gettext:gettext-gradle-plugin:aab5c30bf8")
works fine hereAhmed Riyadh
05/16/2024, 12:48 PMrepositories {
mavenCentral()
maven("<https://jitpack.io>") {
content {
includeGroup("com.github.RyanTheAllmighty.gettext")
}
}
}
In the resolutionStrategy
will cause all the other plugins to not be found:
Plugin [id: 'org.example.plugin', version: '0.6.1'] was not found in any of the following sources:
Vampire
05/16/2024, 12:56 PMgradlePluginPortal()
which serves most pluginsAhmed Riyadh
05/16/2024, 1:00 PM