grails / grails-spring-security-core

Grails Spring Security Core Plugin
Apache License 2.0
261 stars 223 forks source link

The "s2-quickstart" command fails to execute when the resources.groovy file does not exists #1001

Closed puneetbehl closed 3 weeks ago

puneetbehl commented 8 months ago

Expected Behavior

I believe it should automatically create the resources.groovy file if it does not exists, otherwise it should add to the existing file.

Actual Behaviour

The build failed while running the command

./gradlew runCommand -Pargs="s2-quickstart example.ssdemo User Role"

The Command Line Logs:

➜  ssdemo ./gradlew runCommand -Pargs="s2-quickstart com.package.app User Role"  

> Task :runCommand

Configuring Spring Security Core ...
... finished configuring Spring Security Core
Grails application running at http://localhost:0 in environment: development
| :runCommand
Creating User class User in package com.package.app
| 
Creating Role class Role in package com.package.app
Rendered template PersonWithoutInjection.groovy.template to destination grails-app/domain/com/package/app/User.groovy
Rendered template PersonPasswordEncoderListener.groovy.template to destination src/main/groovy/com/package/app/UserPasswordEncoderListener.groovy
| Error Command execution error: grails-app/conf/spring/resources.groovy (No such file or directory)

> Task :runCommand FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':runCommand'.
> Process 'command '/Users/behl/.sdkman/candidates/java/11.0.17-zulu/zulu-11.jdk/Contents/Home/bin/java'' finished with non-zero exit value 1

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 9s

Steps To Reproduce

  1. Either Forge from https://start.grails.org or create new Grails application from the Grails CLI.

    grails create-webapp example.ssdemo
  2. Add the Spring Security Core Plugin dependency to the build.gradle file, as:

    implementation("org.grails.plugins:spring-security-core:6.1.1")
  3. Execute the s2-quickstart command from Gradle as:

    ./gradlew runCommand -Pargs="s2-quickstart example.ssdemo User Role"

Environment Information

Example Application

No response

Version

6.1.2

pangeaos commented 7 months ago

Same issue!

monetschemist commented 7 months ago

@puneetbehl Rather than the problem being resources.groovy, in my experience it's the directory grails-app/conf/spring not being created beforehand. Whether that's something grails create-app should do or the s2-quickstart invocation should check and fix, I don't know.

But for sure / confirmed, if I create the grails-app/conf/spring directory before running s2-quickstart, all goes according to plan.

update

In my case, the s2-quickstart fails after creating User.groovy in the grails-app/domain directory and UserPasswordEncoderListener.groovy in the src/main/groovy directory. If I delete those two files and create the grails-app/conf/spring directory and then re-run s2-quickstart, I end up with a working situation and seemingly no ill effects.

puneetbehl commented 6 months ago

@monetschemist I believe the s2-quickstart command should work without the need for directory to exits beforehand.

monetschemist commented 6 months ago

@puneetbehl I think you must be correct. Do other parts of the Grails ecosystem use grails-app/conf/spring? If so, do they create the directory if necessary?

monetschemist commented 1 month ago

@puneetbehl today, 28 October 2024, I created my first project using Grails 6.2.1 and then ran s2-quickstart, forgetting to create the grails-app/conf/spring directory beforehand. Nevertheless, s2-quickstart ran fine. I attribute this to Grails 6.2.1 creating the directory, since I continue to use the same Spring Security Core plugin version 6.1.1 as before.