-
I want to migrate from the official plugin and apart from replacing I tried the following approaches:
I am always getting the following error: I am using Gradle v7.5 The issue can be related to #13 |
Beta Was this translation helpful? Give feedback.
Replies: 11 comments
-
Could you explain your case a bit more than ending results? What is the goal you want to a achieve? The only reason I can suppose is you want to process resources (copy, download, unzip, etc) before passing them to the generator, is my guess correct or you have a bit more complicated scenario I haven't thought about? PS: if it's a simple resource processing, plugin is dependent on the |
Beta Was this translation helpful? Give feedback.
-
We have a custom task that preprocesses JSON files before they are fed to the I checked it now and our task is indeed executed since Thanks a lot. |
Beta Was this translation helpful? Give feedback.
-
Thank you too! |
Beta Was this translation helpful? Give feedback.
-
I was too quick to close the issue. I missed it previously, but there is the following warning from Gradle:
Adding |
Beta Was this translation helpful? Give feedback.
-
Correct, you can't hook on the generator task itself. Currently, all tasks are created on Generator task depends on Thus you may hook either before To pack schemas and sources I use following scripts for a project where many models built at once: // part of jsongen.groovy
task copySchemas(type: Copy) {
from jsonDirBase // original schema placement
into targetJSONBaseDir // some random directory under build folder
}
project.tasks.build.dependsOn(copySchemas) // it's safe to copy independently // part of publishing.groovy
task sourceJar(type: Jar, dependsOn: build) {
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
from sourceSets.main.allJava
archieveClassifier.set "sources"
}
task schemasJar(type: Jar, dependsOn: build) {
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
from targetJSONBaseDir
archieveClassifier.set "schemas"
}
publishing {
publications {
modulePublish(MavenPublications) {
artifact jar
artifact sourcesJar
artifact schemasJar
artifactId = project.artifactId
}
}
} |
Beta Was this translation helpful? Give feedback.
-
Did this a trick for you? |
Beta Was this translation helpful? Give feedback.
-
I meanwhile gave up on creating source jars. I will try your solution if I'll see that I have to create them. |
Beta Was this translation helpful? Give feedback.
-
I've converted to a discussion, as it's not an issue |
Beta Was this translation helpful? Give feedback.
-
Any update on the topic? |
Beta Was this translation helpful? Give feedback.
-
@sergeykad For java, groovy or kotlin (not-android) projects you can actually use UPD: this is enabled for all tasks, released in 5.0 |
Beta Was this translation helpful? Give feedback.
-
@sergeykad Added an example how to efficinlty pack sources and schemas to jars and publish them. |
Beta Was this translation helpful? Give feedback.
Correct, you can't hook on the generator task itself. Currently, all tasks are created on
afterEvaluate
stage. This could be changed later on if more precision is required.Generator task depends on
ProcessingResources
and lombok and compile tasks (java and kotlin) depend on generator task.Thus you may hook either before
ProcessingResources
or afterbuild
.To pack schemas and sources I use following scripts for a project where many models built at once: