Make custom Gradle task, that generates code, run on IDE importhow do i make Intellij Idea recognize the generated resources from a custom gradle task?Gradle - Groovy and Java class dependency - CompileGradle task with XSL XML template generationbuild.gradle for eclipse project with multiple source foldersIntellij Idea: Importing Gradle project - getting JAVA_HOME not defined yetGradle wsdl generatingHow to make javaCompile share classpath from groovyCompile in GradleHow to exclude all but one specific jar from Gradle distZip task?Gradle: How to make Jar during build
Super Duper Vdd stiffening required on 555 timer, what is the best way?
Is there a command to install basic applications on Ubuntu 16.04?
TEMPO: play a sound in animated GIF/PDF/SVG
Heat equation: Squiggly lines
Why are Gatwick's runways too close together?
Understanding the point of a kölsche Witz
On math looking obvious in retrospect
Plotting octahedron inside the sphere and sphere inside the cube
Redis Cache Shared Session Configuration
Is it legal for a company to enter an agreement not to hire employees from another company?
How are you supposed to know the strumming pattern for a song from the "chord sheet music"?
The cat ate your input again!
How much maintenance time did it take to make an F4U Corsair ready for another flight?
PhD advisor lost funding, need advice
How to remove ambiguity: "... lives in the city of H, the capital of the province of NS, WHERE the unemployment rate is ..."?
What gave Harry Potter the idea of writing in Tom Riddle's diary?
Why did I get only 5 points even though I won?
How to create events observer that only call when REST api dispatch events?
How does "Te vas a cansar" mean "You're going to get tired"?
What is this "Table of astronomy" about?
Submitting a new paper just after another was accepted by the same journal
How to assign many blockers at the same time?
Does fossil fuels use since 1990 account for half of all the fossil fuels used in history?
Can "être sur" mean "to be about" ?
Make custom Gradle task, that generates code, run on IDE import
how do i make Intellij Idea recognize the generated resources from a custom gradle task?Gradle - Groovy and Java class dependency - CompileGradle task with XSL XML template generationbuild.gradle for eclipse project with multiple source foldersIntellij Idea: Importing Gradle project - getting JAVA_HOME not defined yetGradle wsdl generatingHow to make javaCompile share classpath from groovyCompile in GradleHow to exclude all but one specific jar from Gradle distZip task?Gradle: How to make Jar during build
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
Since there is no Gradle plugin for axis2 (a wsdl code generator), I called an Ant task in a custom Gradle task.
As of now ./gradlew build
generates the code, and ./gradlew clean
deletes it. Also, the code is only generated if changes in the input file(s) or in the output directory are detected.
The only problem I'm having is that the code is not generated automatically when the project is imported into an IDE.
How do I need to change the build.gradle.kts
below in order to have the IDEs (currently IntelliJ, but I would also like support for Eclipse) generate the code on import?
plugins
id("base") // needed for delete
val axis2 by configurations.creating
dependencies
axis2("org.apache.axis2:axis2-ant-plugin:$axis2Version")
axis2("org.apache.axis2:axis2-xmlbeans:$axis2Version")
val wsdl2Java by tasks.registering
group = "build"
description = "Creates Java classes and resources from WSDL schema."
inputs.files(fileTree("$projectDir/src/main/resources/wsdl"))
outputs.dir("$projectDir/generated/")
doLast
ant.withGroovyBuilder
"echo"("message" to "Generating Classes from WSDL!")
"taskdef"("name" to "codegen", "classname" to "org.apache.axis2.tool.ant.AntCodegenTask", "classpath" to axis2.asPath)
"codegen"(
"wsdlfilename" to "$projectDir/src/main/resources/wsdl/MP12N-H-HOST-WEB-SOAP.wsdl",
"output" to "$projectDir/generated/",
"targetSourceFolderLocation" to "src/main/java",
"targetResourcesFolderLocation" to "src/main/resources",
"packageName" to "de.hanel.com.jws.main",
"databindingName" to "xmlbeans")
val deleteGenerated by tasks.registering(Delete::class)
delete("$projectDir/generated/")
tasks
compileJava
dependsOn(wsdl2Java)
clean
dependsOn(deleteGenerated)
java
sourceSets["main"].java
srcDir("generated/src/main/java")
sourceSets["main"].resources
srcDir("generated/src/main/resources")
java gradle intellij-idea code-generation gradle-kotlin-dsl
add a comment |
Since there is no Gradle plugin for axis2 (a wsdl code generator), I called an Ant task in a custom Gradle task.
As of now ./gradlew build
generates the code, and ./gradlew clean
deletes it. Also, the code is only generated if changes in the input file(s) or in the output directory are detected.
The only problem I'm having is that the code is not generated automatically when the project is imported into an IDE.
How do I need to change the build.gradle.kts
below in order to have the IDEs (currently IntelliJ, but I would also like support for Eclipse) generate the code on import?
plugins
id("base") // needed for delete
val axis2 by configurations.creating
dependencies
axis2("org.apache.axis2:axis2-ant-plugin:$axis2Version")
axis2("org.apache.axis2:axis2-xmlbeans:$axis2Version")
val wsdl2Java by tasks.registering
group = "build"
description = "Creates Java classes and resources from WSDL schema."
inputs.files(fileTree("$projectDir/src/main/resources/wsdl"))
outputs.dir("$projectDir/generated/")
doLast
ant.withGroovyBuilder
"echo"("message" to "Generating Classes from WSDL!")
"taskdef"("name" to "codegen", "classname" to "org.apache.axis2.tool.ant.AntCodegenTask", "classpath" to axis2.asPath)
"codegen"(
"wsdlfilename" to "$projectDir/src/main/resources/wsdl/MP12N-H-HOST-WEB-SOAP.wsdl",
"output" to "$projectDir/generated/",
"targetSourceFolderLocation" to "src/main/java",
"targetResourcesFolderLocation" to "src/main/resources",
"packageName" to "de.hanel.com.jws.main",
"databindingName" to "xmlbeans")
val deleteGenerated by tasks.registering(Delete::class)
delete("$projectDir/generated/")
tasks
compileJava
dependsOn(wsdl2Java)
clean
dependsOn(deleteGenerated)
java
sourceSets["main"].java
srcDir("generated/src/main/java")
sourceSets["main"].resources
srcDir("generated/src/main/resources")
java gradle intellij-idea code-generation gradle-kotlin-dsl
add a comment |
Since there is no Gradle plugin for axis2 (a wsdl code generator), I called an Ant task in a custom Gradle task.
As of now ./gradlew build
generates the code, and ./gradlew clean
deletes it. Also, the code is only generated if changes in the input file(s) or in the output directory are detected.
The only problem I'm having is that the code is not generated automatically when the project is imported into an IDE.
How do I need to change the build.gradle.kts
below in order to have the IDEs (currently IntelliJ, but I would also like support for Eclipse) generate the code on import?
plugins
id("base") // needed for delete
val axis2 by configurations.creating
dependencies
axis2("org.apache.axis2:axis2-ant-plugin:$axis2Version")
axis2("org.apache.axis2:axis2-xmlbeans:$axis2Version")
val wsdl2Java by tasks.registering
group = "build"
description = "Creates Java classes and resources from WSDL schema."
inputs.files(fileTree("$projectDir/src/main/resources/wsdl"))
outputs.dir("$projectDir/generated/")
doLast
ant.withGroovyBuilder
"echo"("message" to "Generating Classes from WSDL!")
"taskdef"("name" to "codegen", "classname" to "org.apache.axis2.tool.ant.AntCodegenTask", "classpath" to axis2.asPath)
"codegen"(
"wsdlfilename" to "$projectDir/src/main/resources/wsdl/MP12N-H-HOST-WEB-SOAP.wsdl",
"output" to "$projectDir/generated/",
"targetSourceFolderLocation" to "src/main/java",
"targetResourcesFolderLocation" to "src/main/resources",
"packageName" to "de.hanel.com.jws.main",
"databindingName" to "xmlbeans")
val deleteGenerated by tasks.registering(Delete::class)
delete("$projectDir/generated/")
tasks
compileJava
dependsOn(wsdl2Java)
clean
dependsOn(deleteGenerated)
java
sourceSets["main"].java
srcDir("generated/src/main/java")
sourceSets["main"].resources
srcDir("generated/src/main/resources")
java gradle intellij-idea code-generation gradle-kotlin-dsl
Since there is no Gradle plugin for axis2 (a wsdl code generator), I called an Ant task in a custom Gradle task.
As of now ./gradlew build
generates the code, and ./gradlew clean
deletes it. Also, the code is only generated if changes in the input file(s) or in the output directory are detected.
The only problem I'm having is that the code is not generated automatically when the project is imported into an IDE.
How do I need to change the build.gradle.kts
below in order to have the IDEs (currently IntelliJ, but I would also like support for Eclipse) generate the code on import?
plugins
id("base") // needed for delete
val axis2 by configurations.creating
dependencies
axis2("org.apache.axis2:axis2-ant-plugin:$axis2Version")
axis2("org.apache.axis2:axis2-xmlbeans:$axis2Version")
val wsdl2Java by tasks.registering
group = "build"
description = "Creates Java classes and resources from WSDL schema."
inputs.files(fileTree("$projectDir/src/main/resources/wsdl"))
outputs.dir("$projectDir/generated/")
doLast
ant.withGroovyBuilder
"echo"("message" to "Generating Classes from WSDL!")
"taskdef"("name" to "codegen", "classname" to "org.apache.axis2.tool.ant.AntCodegenTask", "classpath" to axis2.asPath)
"codegen"(
"wsdlfilename" to "$projectDir/src/main/resources/wsdl/MP12N-H-HOST-WEB-SOAP.wsdl",
"output" to "$projectDir/generated/",
"targetSourceFolderLocation" to "src/main/java",
"targetResourcesFolderLocation" to "src/main/resources",
"packageName" to "de.hanel.com.jws.main",
"databindingName" to "xmlbeans")
val deleteGenerated by tasks.registering(Delete::class)
delete("$projectDir/generated/")
tasks
compileJava
dependsOn(wsdl2Java)
clean
dependsOn(deleteGenerated)
java
sourceSets["main"].java
srcDir("generated/src/main/java")
sourceSets["main"].resources
srcDir("generated/src/main/resources")
java gradle intellij-idea code-generation gradle-kotlin-dsl
java gradle intellij-idea code-generation gradle-kotlin-dsl
edited Mar 28 at 10:16
mike
asked Mar 27 at 8:54
mikemike
3,4073 gold badges28 silver badges58 bronze badges
3,4073 gold badges28 silver badges58 bronze badges
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
You can mark any task or run configuration to be activated before/after Gradle import or IDE make:
Thanks, but that's not exactly what I asked :-) I want to configure the build system. It should tell the IDE what to do. This way it's easier for other users (and for me if I combe back to the project some later time).
– mike
Mar 27 at 9:55
Looks like the youtrack.jetbrains.com/issue/IDEA-160605 is what you need then. I'll update the answer.
– Andrey
Mar 27 at 10:12
add a comment |
I have a working solution now. Both Eclipse and IntelliJ generate the source code on import.
First we add the IDE-specific plugins.
apply
plugin("idea")
plugin("eclipse")
Then we get the corresponding IDE tasks and add our own task, that was defined in val wsdl2Java
, as dependency
// find by name (in tasks container), since a module is also called 'idea'
project.tasks.findByName("idea")?.dependsOn(wsdl2Java)
project.tasks.findByName("eclipse")?.dependsOn(wsdl2Java)
The only problem is that apparently Eclipse can't handle
java
sourceSets["main"].java
srcDir("generated/src/main/java")
sourceSets["main"].resources
srcDir("generated/src/main/resources")
But that's a different question.
UPDATE
The code block below tells Eclipse to include the generated sources
eclipse
classpath
plusConfigurations.add(configurations.findByName("compile"))
and this tells IntelliJ to mark the generated, and already included, sources as generated
idea
module
generatedSourceDirs.add(file("generated/src/main/java"))
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55373141%2fmake-custom-gradle-task-that-generates-code-run-on-ide-import%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
You can mark any task or run configuration to be activated before/after Gradle import or IDE make:
Thanks, but that's not exactly what I asked :-) I want to configure the build system. It should tell the IDE what to do. This way it's easier for other users (and for me if I combe back to the project some later time).
– mike
Mar 27 at 9:55
Looks like the youtrack.jetbrains.com/issue/IDEA-160605 is what you need then. I'll update the answer.
– Andrey
Mar 27 at 10:12
add a comment |
You can mark any task or run configuration to be activated before/after Gradle import or IDE make:
Thanks, but that's not exactly what I asked :-) I want to configure the build system. It should tell the IDE what to do. This way it's easier for other users (and for me if I combe back to the project some later time).
– mike
Mar 27 at 9:55
Looks like the youtrack.jetbrains.com/issue/IDEA-160605 is what you need then. I'll update the answer.
– Andrey
Mar 27 at 10:12
add a comment |
You can mark any task or run configuration to be activated before/after Gradle import or IDE make:
You can mark any task or run configuration to be activated before/after Gradle import or IDE make:
answered Mar 27 at 9:51
AndreyAndrey
4,43620 silver badges82 bronze badges
4,43620 silver badges82 bronze badges
Thanks, but that's not exactly what I asked :-) I want to configure the build system. It should tell the IDE what to do. This way it's easier for other users (and for me if I combe back to the project some later time).
– mike
Mar 27 at 9:55
Looks like the youtrack.jetbrains.com/issue/IDEA-160605 is what you need then. I'll update the answer.
– Andrey
Mar 27 at 10:12
add a comment |
Thanks, but that's not exactly what I asked :-) I want to configure the build system. It should tell the IDE what to do. This way it's easier for other users (and for me if I combe back to the project some later time).
– mike
Mar 27 at 9:55
Looks like the youtrack.jetbrains.com/issue/IDEA-160605 is what you need then. I'll update the answer.
– Andrey
Mar 27 at 10:12
Thanks, but that's not exactly what I asked :-) I want to configure the build system. It should tell the IDE what to do. This way it's easier for other users (and for me if I combe back to the project some later time).
– mike
Mar 27 at 9:55
Thanks, but that's not exactly what I asked :-) I want to configure the build system. It should tell the IDE what to do. This way it's easier for other users (and for me if I combe back to the project some later time).
– mike
Mar 27 at 9:55
Looks like the youtrack.jetbrains.com/issue/IDEA-160605 is what you need then. I'll update the answer.
– Andrey
Mar 27 at 10:12
Looks like the youtrack.jetbrains.com/issue/IDEA-160605 is what you need then. I'll update the answer.
– Andrey
Mar 27 at 10:12
add a comment |
I have a working solution now. Both Eclipse and IntelliJ generate the source code on import.
First we add the IDE-specific plugins.
apply
plugin("idea")
plugin("eclipse")
Then we get the corresponding IDE tasks and add our own task, that was defined in val wsdl2Java
, as dependency
// find by name (in tasks container), since a module is also called 'idea'
project.tasks.findByName("idea")?.dependsOn(wsdl2Java)
project.tasks.findByName("eclipse")?.dependsOn(wsdl2Java)
The only problem is that apparently Eclipse can't handle
java
sourceSets["main"].java
srcDir("generated/src/main/java")
sourceSets["main"].resources
srcDir("generated/src/main/resources")
But that's a different question.
UPDATE
The code block below tells Eclipse to include the generated sources
eclipse
classpath
plusConfigurations.add(configurations.findByName("compile"))
and this tells IntelliJ to mark the generated, and already included, sources as generated
idea
module
generatedSourceDirs.add(file("generated/src/main/java"))
add a comment |
I have a working solution now. Both Eclipse and IntelliJ generate the source code on import.
First we add the IDE-specific plugins.
apply
plugin("idea")
plugin("eclipse")
Then we get the corresponding IDE tasks and add our own task, that was defined in val wsdl2Java
, as dependency
// find by name (in tasks container), since a module is also called 'idea'
project.tasks.findByName("idea")?.dependsOn(wsdl2Java)
project.tasks.findByName("eclipse")?.dependsOn(wsdl2Java)
The only problem is that apparently Eclipse can't handle
java
sourceSets["main"].java
srcDir("generated/src/main/java")
sourceSets["main"].resources
srcDir("generated/src/main/resources")
But that's a different question.
UPDATE
The code block below tells Eclipse to include the generated sources
eclipse
classpath
plusConfigurations.add(configurations.findByName("compile"))
and this tells IntelliJ to mark the generated, and already included, sources as generated
idea
module
generatedSourceDirs.add(file("generated/src/main/java"))
add a comment |
I have a working solution now. Both Eclipse and IntelliJ generate the source code on import.
First we add the IDE-specific plugins.
apply
plugin("idea")
plugin("eclipse")
Then we get the corresponding IDE tasks and add our own task, that was defined in val wsdl2Java
, as dependency
// find by name (in tasks container), since a module is also called 'idea'
project.tasks.findByName("idea")?.dependsOn(wsdl2Java)
project.tasks.findByName("eclipse")?.dependsOn(wsdl2Java)
The only problem is that apparently Eclipse can't handle
java
sourceSets["main"].java
srcDir("generated/src/main/java")
sourceSets["main"].resources
srcDir("generated/src/main/resources")
But that's a different question.
UPDATE
The code block below tells Eclipse to include the generated sources
eclipse
classpath
plusConfigurations.add(configurations.findByName("compile"))
and this tells IntelliJ to mark the generated, and already included, sources as generated
idea
module
generatedSourceDirs.add(file("generated/src/main/java"))
I have a working solution now. Both Eclipse and IntelliJ generate the source code on import.
First we add the IDE-specific plugins.
apply
plugin("idea")
plugin("eclipse")
Then we get the corresponding IDE tasks and add our own task, that was defined in val wsdl2Java
, as dependency
// find by name (in tasks container), since a module is also called 'idea'
project.tasks.findByName("idea")?.dependsOn(wsdl2Java)
project.tasks.findByName("eclipse")?.dependsOn(wsdl2Java)
The only problem is that apparently Eclipse can't handle
java
sourceSets["main"].java
srcDir("generated/src/main/java")
sourceSets["main"].resources
srcDir("generated/src/main/resources")
But that's a different question.
UPDATE
The code block below tells Eclipse to include the generated sources
eclipse
classpath
plusConfigurations.add(configurations.findByName("compile"))
and this tells IntelliJ to mark the generated, and already included, sources as generated
idea
module
generatedSourceDirs.add(file("generated/src/main/java"))
edited Mar 28 at 10:31
answered Mar 27 at 10:53
mikemike
3,4073 gold badges28 silver badges58 bronze badges
3,4073 gold badges28 silver badges58 bronze badges
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55373141%2fmake-custom-gradle-task-that-generates-code-run-on-ide-import%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown