Gradle task not running as demanded (before compiling)How can I import one Gradle script into another?gradle doLast philosophyHow can I force gradle to redownload dependencies?What is Gradle in Android Studio?How to pass parameters or arguments into a gradle taskCould not find method compile() for arguments GradleUse compiled class in a gradle build scriptGradle plugin task orderingGradle custom task action orderWhat's the difference between implementation and compile in Gradle?
Can I say: "When was your train leaving?" if the train leaves in the future?
Is this possible when it comes to the relations of P, NP, NP-Hard and NP-Complete?
Motorola 6845 and bitwise graphics
The meaning of the Middle English word “king”
What information exactly does an instruction cache store?
Why weren't the bells paid heed to in S8E5?
Is it safe to use two single-pole breakers for a 240 V circuit?
Find the unknown area, x
How does this Martian habitat 3D printer built for NASA work?
Use of さ as a filler
White foam around tubeless tires
How to make a not so good looking person more appealing?
Are there any sonatas with only two sections?
Is this a group? If so, what group is it?
Would life always name the light from their sun "white"
Extract the characters before last colon
Filter a data-frame and add a new column according to the given condition
Why are solar panels kept tilted?
Smooth function that vanishes only on unit cube
Substring join or additional table, which is faster?
Help understanding this line - usage of くれる
Promotion comes with unexpected 24/7/365 on-call
Do we have C++20 ranges library in GCC 9?
Is 12 minutes connection in Bristol Temple Meads long enough?
Gradle task not running as demanded (before compiling)
How can I import one Gradle script into another?gradle doLast philosophyHow can I force gradle to redownload dependencies?What is Gradle in Android Studio?How to pass parameters or arguments into a gradle taskCould not find method compile() for arguments GradleUse compiled class in a gradle build scriptGradle plugin task orderingGradle custom task action orderWhat's the difference between implementation and compile in Gradle?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
INTRODUCTION
The project is in Kotlin and builds using Gradle. I'm trying to generate a basic data class with some build info, let's say for now that I need it [re]generated every time before running.
Here's the Gradle task I have now:
def generatedDir = "$buildDir/generated"
// noinspection GroovyAssignabilityCheck
task generateBuildInfo
inputs.property "version", rootProject.version.toString()
inputs.property "name", rootProject.name.toString()
outputs.dir generatedDir
outputs.upToDateWhen false
doFirst
def buildInfoFile = file("$generatedDir/BuildInfo.kt")
buildInfoFile.parentFile.mkdirs()
buildInfoFile.text = """
internal data class BuildInfo(
val version: String = "$project.version.toString() ?: "unspecified"",
val name: String = "$project.name.toString() ?: "unspecified""
)
""".replace(" ", "").trim()
To be able to resolve this from IntelliJ IDEA, I added my new folder to project sources, and obviously wired up the dependencies, like so:
sourceSets.main.kotlin.srcDirs += generatedDir
project.afterEvaluate
compileJava.dependsOn generateBuildInfo
compileKotlin.dependsOn generateBuildInfo
This is all done in a separate file (to avoid polluting my main scripts). Due to this organization, after applying plugins, I just include the generator in my main script, like this:
apply from: "gradle/scripts/build-info-generator.gradle"
THE PROBLEM
It looks like the generator code is executed only once, after running assemble
when I first ran clean
on this module. This is not what I want, because when I change some of the project properties (like version
), the source does not get updated... as if compileJava
/compileKotlin
and my custom task are not executed.
They do not appear in build logs as executed.
Is there any way I can run this task every time I want to run my module's launcher? Sure, I can do some smart file comparison to see if generation is needed, but for now I just want it done each time. Am I missing something?
java gradle groovy kotlin build-script
|
show 2 more comments
INTRODUCTION
The project is in Kotlin and builds using Gradle. I'm trying to generate a basic data class with some build info, let's say for now that I need it [re]generated every time before running.
Here's the Gradle task I have now:
def generatedDir = "$buildDir/generated"
// noinspection GroovyAssignabilityCheck
task generateBuildInfo
inputs.property "version", rootProject.version.toString()
inputs.property "name", rootProject.name.toString()
outputs.dir generatedDir
outputs.upToDateWhen false
doFirst
def buildInfoFile = file("$generatedDir/BuildInfo.kt")
buildInfoFile.parentFile.mkdirs()
buildInfoFile.text = """
internal data class BuildInfo(
val version: String = "$project.version.toString() ?: "unspecified"",
val name: String = "$project.name.toString() ?: "unspecified""
)
""".replace(" ", "").trim()
To be able to resolve this from IntelliJ IDEA, I added my new folder to project sources, and obviously wired up the dependencies, like so:
sourceSets.main.kotlin.srcDirs += generatedDir
project.afterEvaluate
compileJava.dependsOn generateBuildInfo
compileKotlin.dependsOn generateBuildInfo
This is all done in a separate file (to avoid polluting my main scripts). Due to this organization, after applying plugins, I just include the generator in my main script, like this:
apply from: "gradle/scripts/build-info-generator.gradle"
THE PROBLEM
It looks like the generator code is executed only once, after running assemble
when I first ran clean
on this module. This is not what I want, because when I change some of the project properties (like version
), the source does not get updated... as if compileJava
/compileKotlin
and my custom task are not executed.
They do not appear in build logs as executed.
Is there any way I can run this task every time I want to run my module's launcher? Sure, I can do some smart file comparison to see if generation is needed, but for now I just want it done each time. Am I missing something?
java gradle groovy kotlin build-script
If I understand, correctly, you expect IntelliJ to run your gradle tasks when it internally builds and runs the project? That won't happen unless you explicitly configure it in IntelliJ, or if you configure IntelliJ to delegate the build/run actions to gradle. Otherwise, Gradle has its own build and run system. It just loads the dependencies and some other properties from the Gradle build when loading the project.
– JB Nizet
Mar 23 at 14:34
@JBNizet - Well, sort of. I expect IntelliJ to runcompileKotlin
in this case, thus running my task whichcompileKotlin
depends on. Is this not a reasonable expectation?
– milosmns
Mar 23 at 14:37
As I just said, no. IDEA has its own build system, indepenant from Gradle. You can configure it to run a Gradle task before its own build task. You can also configure it to delegate all the build/run tasks to Gradle. But that's not the default.
– JB Nizet
Mar 23 at 14:39
@JBNizet - Actually I just realized a very interesting thing... if I run the "Build" command from IntelliJ, it does not run my task at all (not even afterclean
). Since my Run configuration is currently set up to run this IntelliJ'sBuild
task before running (default setup), my task is thus not executed.
– milosmns
Mar 23 at 14:43
So is thisBuild
task from IntelliJ executing any Gradle tasks from my build script?
– milosmns
Mar 23 at 14:45
|
show 2 more comments
INTRODUCTION
The project is in Kotlin and builds using Gradle. I'm trying to generate a basic data class with some build info, let's say for now that I need it [re]generated every time before running.
Here's the Gradle task I have now:
def generatedDir = "$buildDir/generated"
// noinspection GroovyAssignabilityCheck
task generateBuildInfo
inputs.property "version", rootProject.version.toString()
inputs.property "name", rootProject.name.toString()
outputs.dir generatedDir
outputs.upToDateWhen false
doFirst
def buildInfoFile = file("$generatedDir/BuildInfo.kt")
buildInfoFile.parentFile.mkdirs()
buildInfoFile.text = """
internal data class BuildInfo(
val version: String = "$project.version.toString() ?: "unspecified"",
val name: String = "$project.name.toString() ?: "unspecified""
)
""".replace(" ", "").trim()
To be able to resolve this from IntelliJ IDEA, I added my new folder to project sources, and obviously wired up the dependencies, like so:
sourceSets.main.kotlin.srcDirs += generatedDir
project.afterEvaluate
compileJava.dependsOn generateBuildInfo
compileKotlin.dependsOn generateBuildInfo
This is all done in a separate file (to avoid polluting my main scripts). Due to this organization, after applying plugins, I just include the generator in my main script, like this:
apply from: "gradle/scripts/build-info-generator.gradle"
THE PROBLEM
It looks like the generator code is executed only once, after running assemble
when I first ran clean
on this module. This is not what I want, because when I change some of the project properties (like version
), the source does not get updated... as if compileJava
/compileKotlin
and my custom task are not executed.
They do not appear in build logs as executed.
Is there any way I can run this task every time I want to run my module's launcher? Sure, I can do some smart file comparison to see if generation is needed, but for now I just want it done each time. Am I missing something?
java gradle groovy kotlin build-script
INTRODUCTION
The project is in Kotlin and builds using Gradle. I'm trying to generate a basic data class with some build info, let's say for now that I need it [re]generated every time before running.
Here's the Gradle task I have now:
def generatedDir = "$buildDir/generated"
// noinspection GroovyAssignabilityCheck
task generateBuildInfo
inputs.property "version", rootProject.version.toString()
inputs.property "name", rootProject.name.toString()
outputs.dir generatedDir
outputs.upToDateWhen false
doFirst
def buildInfoFile = file("$generatedDir/BuildInfo.kt")
buildInfoFile.parentFile.mkdirs()
buildInfoFile.text = """
internal data class BuildInfo(
val version: String = "$project.version.toString() ?: "unspecified"",
val name: String = "$project.name.toString() ?: "unspecified""
)
""".replace(" ", "").trim()
To be able to resolve this from IntelliJ IDEA, I added my new folder to project sources, and obviously wired up the dependencies, like so:
sourceSets.main.kotlin.srcDirs += generatedDir
project.afterEvaluate
compileJava.dependsOn generateBuildInfo
compileKotlin.dependsOn generateBuildInfo
This is all done in a separate file (to avoid polluting my main scripts). Due to this organization, after applying plugins, I just include the generator in my main script, like this:
apply from: "gradle/scripts/build-info-generator.gradle"
THE PROBLEM
It looks like the generator code is executed only once, after running assemble
when I first ran clean
on this module. This is not what I want, because when I change some of the project properties (like version
), the source does not get updated... as if compileJava
/compileKotlin
and my custom task are not executed.
They do not appear in build logs as executed.
Is there any way I can run this task every time I want to run my module's launcher? Sure, I can do some smart file comparison to see if generation is needed, but for now I just want it done each time. Am I missing something?
java gradle groovy kotlin build-script
java gradle groovy kotlin build-script
edited Mar 23 at 14:48
milosmns
asked Mar 23 at 14:26
milosmnsmilosmns
1,78432232
1,78432232
If I understand, correctly, you expect IntelliJ to run your gradle tasks when it internally builds and runs the project? That won't happen unless you explicitly configure it in IntelliJ, or if you configure IntelliJ to delegate the build/run actions to gradle. Otherwise, Gradle has its own build and run system. It just loads the dependencies and some other properties from the Gradle build when loading the project.
– JB Nizet
Mar 23 at 14:34
@JBNizet - Well, sort of. I expect IntelliJ to runcompileKotlin
in this case, thus running my task whichcompileKotlin
depends on. Is this not a reasonable expectation?
– milosmns
Mar 23 at 14:37
As I just said, no. IDEA has its own build system, indepenant from Gradle. You can configure it to run a Gradle task before its own build task. You can also configure it to delegate all the build/run tasks to Gradle. But that's not the default.
– JB Nizet
Mar 23 at 14:39
@JBNizet - Actually I just realized a very interesting thing... if I run the "Build" command from IntelliJ, it does not run my task at all (not even afterclean
). Since my Run configuration is currently set up to run this IntelliJ'sBuild
task before running (default setup), my task is thus not executed.
– milosmns
Mar 23 at 14:43
So is thisBuild
task from IntelliJ executing any Gradle tasks from my build script?
– milosmns
Mar 23 at 14:45
|
show 2 more comments
If I understand, correctly, you expect IntelliJ to run your gradle tasks when it internally builds and runs the project? That won't happen unless you explicitly configure it in IntelliJ, or if you configure IntelliJ to delegate the build/run actions to gradle. Otherwise, Gradle has its own build and run system. It just loads the dependencies and some other properties from the Gradle build when loading the project.
– JB Nizet
Mar 23 at 14:34
@JBNizet - Well, sort of. I expect IntelliJ to runcompileKotlin
in this case, thus running my task whichcompileKotlin
depends on. Is this not a reasonable expectation?
– milosmns
Mar 23 at 14:37
As I just said, no. IDEA has its own build system, indepenant from Gradle. You can configure it to run a Gradle task before its own build task. You can also configure it to delegate all the build/run tasks to Gradle. But that's not the default.
– JB Nizet
Mar 23 at 14:39
@JBNizet - Actually I just realized a very interesting thing... if I run the "Build" command from IntelliJ, it does not run my task at all (not even afterclean
). Since my Run configuration is currently set up to run this IntelliJ'sBuild
task before running (default setup), my task is thus not executed.
– milosmns
Mar 23 at 14:43
So is thisBuild
task from IntelliJ executing any Gradle tasks from my build script?
– milosmns
Mar 23 at 14:45
If I understand, correctly, you expect IntelliJ to run your gradle tasks when it internally builds and runs the project? That won't happen unless you explicitly configure it in IntelliJ, or if you configure IntelliJ to delegate the build/run actions to gradle. Otherwise, Gradle has its own build and run system. It just loads the dependencies and some other properties from the Gradle build when loading the project.
– JB Nizet
Mar 23 at 14:34
If I understand, correctly, you expect IntelliJ to run your gradle tasks when it internally builds and runs the project? That won't happen unless you explicitly configure it in IntelliJ, or if you configure IntelliJ to delegate the build/run actions to gradle. Otherwise, Gradle has its own build and run system. It just loads the dependencies and some other properties from the Gradle build when loading the project.
– JB Nizet
Mar 23 at 14:34
@JBNizet - Well, sort of. I expect IntelliJ to run
compileKotlin
in this case, thus running my task which compileKotlin
depends on. Is this not a reasonable expectation?– milosmns
Mar 23 at 14:37
@JBNizet - Well, sort of. I expect IntelliJ to run
compileKotlin
in this case, thus running my task which compileKotlin
depends on. Is this not a reasonable expectation?– milosmns
Mar 23 at 14:37
As I just said, no. IDEA has its own build system, indepenant from Gradle. You can configure it to run a Gradle task before its own build task. You can also configure it to delegate all the build/run tasks to Gradle. But that's not the default.
– JB Nizet
Mar 23 at 14:39
As I just said, no. IDEA has its own build system, indepenant from Gradle. You can configure it to run a Gradle task before its own build task. You can also configure it to delegate all the build/run tasks to Gradle. But that's not the default.
– JB Nizet
Mar 23 at 14:39
@JBNizet - Actually I just realized a very interesting thing... if I run the "Build" command from IntelliJ, it does not run my task at all (not even after
clean
). Since my Run configuration is currently set up to run this IntelliJ's Build
task before running (default setup), my task is thus not executed.– milosmns
Mar 23 at 14:43
@JBNizet - Actually I just realized a very interesting thing... if I run the "Build" command from IntelliJ, it does not run my task at all (not even after
clean
). Since my Run configuration is currently set up to run this IntelliJ's Build
task before running (default setup), my task is thus not executed.– milosmns
Mar 23 at 14:43
So is this
Build
task from IntelliJ executing any Gradle tasks from my build script?– milosmns
Mar 23 at 14:45
So is this
Build
task from IntelliJ executing any Gradle tasks from my build script?– milosmns
Mar 23 at 14:45
|
show 2 more comments
1 Answer
1
active
oldest
votes
IDEA has its own build system, indepenant from Gradle.
You can configure it to run a Gradle task before its own build task.
You can also configure it to delegate all the build/run tasks to Gradle. But that's not the default.
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%2f55314717%2fgradle-task-not-running-as-demanded-before-compiling%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
IDEA has its own build system, indepenant from Gradle.
You can configure it to run a Gradle task before its own build task.
You can also configure it to delegate all the build/run tasks to Gradle. But that's not the default.
add a comment |
IDEA has its own build system, indepenant from Gradle.
You can configure it to run a Gradle task before its own build task.
You can also configure it to delegate all the build/run tasks to Gradle. But that's not the default.
add a comment |
IDEA has its own build system, indepenant from Gradle.
You can configure it to run a Gradle task before its own build task.
You can also configure it to delegate all the build/run tasks to Gradle. But that's not the default.
IDEA has its own build system, indepenant from Gradle.
You can configure it to run a Gradle task before its own build task.
You can also configure it to delegate all the build/run tasks to Gradle. But that's not the default.
answered Mar 23 at 14:49
JB NizetJB Nizet
553k629061029
553k629061029
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%2f55314717%2fgradle-task-not-running-as-demanded-before-compiling%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
If I understand, correctly, you expect IntelliJ to run your gradle tasks when it internally builds and runs the project? That won't happen unless you explicitly configure it in IntelliJ, or if you configure IntelliJ to delegate the build/run actions to gradle. Otherwise, Gradle has its own build and run system. It just loads the dependencies and some other properties from the Gradle build when loading the project.
– JB Nizet
Mar 23 at 14:34
@JBNizet - Well, sort of. I expect IntelliJ to run
compileKotlin
in this case, thus running my task whichcompileKotlin
depends on. Is this not a reasonable expectation?– milosmns
Mar 23 at 14:37
As I just said, no. IDEA has its own build system, indepenant from Gradle. You can configure it to run a Gradle task before its own build task. You can also configure it to delegate all the build/run tasks to Gradle. But that's not the default.
– JB Nizet
Mar 23 at 14:39
@JBNizet - Actually I just realized a very interesting thing... if I run the "Build" command from IntelliJ, it does not run my task at all (not even after
clean
). Since my Run configuration is currently set up to run this IntelliJ'sBuild
task before running (default setup), my task is thus not executed.– milosmns
Mar 23 at 14:43
So is this
Build
task from IntelliJ executing any Gradle tasks from my build script?– milosmns
Mar 23 at 14:45