Skip to content

Conversation

codeconsole
Copy link
Contributor

@codeconsole codeconsole commented Oct 9, 2025

build is hardcoded in the plugin and results in an exception if you specify any other directory

./gradlew bootRun --project-prop buildDir=build-7.0.0-SNAPSHOT 

results in

java.io.FileNotFoundException: /grails-demo/build/.grailspid (No such file or directory)
        at java.base/java.io.FileOutputStream.open0(Native Method)
        at java.base/java.io.FileOutputStream.open(FileOutputStream.java:255)
        at java.base/java.io.FileOutputStream.<init>(FileOutputStream.java:210)
        at java.base/java.io.FileOutputStream.<init>(FileOutputStream.java:171)
        at java.base/java.io.FileWriter.<init>(FileWriter.java:98)
        at grails.util.Environment.writeDevToolsPidFile(Environment.groovy:383)
        at grails.util.Environment.isDevtoolsRestart(Environment.groovy:370)

Motivation - Run 2 Different Versions of Grails on Different Ports with the Same Source

./gradlew bootRun --project-prop buildDir=build-7.0.0-RC2 -PgrailsVersion=7.0.0-RC2 --args="--server.port=8081"
./gradlew bootRun --project-prop buildDir=build-7.0.0-SNAPSHOT -PgrailsVersion=7.0.0-SNAPSHOT --args="--server.port=8082"

@CompileStatic
protected String configureGrailsBuildSettings(Project project) {
System.setProperty(BuildSettings.APP_BASE_DIR, project.projectDir.absolutePath)
System.setProperty(BuildSettings.PROJECT_TARGET_DIR, project.layout.buildDirectory.get().asFile.name)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Going back to April 2024, this never appears to have been set previously. Why set it now?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't believe this is needed because configureForkSettings copies any grails property and sets it on javaexec / test.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jdaugherty the build dir should be customizable and not hard coded.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We haven't allowed that to be set since the retirement of the original grails build configuration. What's the use case for this? I'm not saying we shouldn't allow this, but for 7.0.0 it's a feature, not a bug. My concern is scope for 7.0.0 release.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jdaugherty the reason I am calling it a bug is because it results in an exception java.io.FileNotFoundException: /grails-demo/build/.grailspid (No such file or directory)
If it works, let's put it in 7.0.1

BASE_DIR = System.getProperty(APP_BASE_DIR) ? new File(System.getProperty(APP_BASE_DIR)) : (IOUtils.findApplicationDirectoryFile() ?: new File('.'))
GRAILS_APP_DIR_PRESENT = new File(BASE_DIR, 'grails-app').exists() || new File(BASE_DIR, 'Application.groovy').exists()
TARGET_DIR = new File(BASE_DIR, 'build')
TARGET_DIR = System.getProperty(PROJECT_TARGET_DIR) ? new File(BASE_DIR, System.getProperty(PROJECT_TARGET_DIR)) : new File(BASE_DIR, 'build')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the use case for having this set? The reason we removed PROJECT_TARGET_DIR is because it wasn't used. You can easily inject this via gradle, and BuildSettings is really a left over artifact from the original grails build system. We are trying to remove this functionality over time since it's specific to dev mode and gradle is the better place for that logic.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is a breaking change too. Going back to 3/29/24 in the logs, this never overrode TARGET_DIR.

Copy link
Contributor Author

@codeconsole codeconsole Oct 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you set a buildDir via gradle in anything other than build, bootRun fails.

./gradlew bootRun --project-prop buildDir=build-7.0.0-RC2 

@jdaugherty how is it breaking? if it is not set, it reverts to the way it was previously.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a breaking change b/c it didn't previously behave like this. We're introducing a function here and I still am not clear why we need to support this. Why do we need to support a custom build directory? We're trying to remove BuildSettings.groovy completely in the longer run.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jdaugherty because you shouldn't hard code build. It is not a guaranteed directory name and customizable by gradle. This doesn't have to go in 7.0.0. This is just trying to fix java.io.FileNotFoundException: /grails-demo/build/.grailspid (No such file or directory) which is caused because build directory is not automatically created.

@CompileStatic
protected String configureGrailsBuildSettings(Project project) {
System.setProperty(BuildSettings.APP_BASE_DIR, project.projectDir.absolutePath)
System.setProperty(BuildSettings.PROJECT_TARGET_DIR, project.layout.buildDirectory.get().asFile.name)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't believe this is needed because configureForkSettings copies any grails property and sets it on javaexec / test.

@matrei
Copy link
Contributor

matrei commented Oct 14, 2025

I think this is a possible candidate for 7.0.1.
We need to ship 7.0.0 to lay some stable ground so we can continue moving from there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants