Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure Grails plugin assemble task produces a JAR artifact #369

Open
wants to merge 2 commits into
base: 6.2.x
Choose a base branch
from

Conversation

matrei
Copy link
Contributor

@matrei matrei commented Dec 11, 2024

Previously, running the assemble task in a Grails plugin project only generated *.war and *-plain.war artifacts. This change ensures that the task also produces the expected JAR artifact, aligning with typical plugin packaging needs.

Previously, running the `assemble` task in a Grails plugin project only generated `*.war` and `*-plain.war` artifacts. This change ensures that the task also produces the expected JAR artifact, aligning with typical plugin packaging needs.
@matrei
Copy link
Contributor Author

matrei commented Dec 11, 2024

grails/grails-forge#457

@codeconsole
Copy link
Contributor

codeconsole commented Dec 12, 2024

exclude logback-spring.xml as well?

@matrei
Copy link
Contributor Author

matrei commented Dec 12, 2024

exclude logback-spring.xml as well?

@codeconsole logback-spring.xml wasn't introduced until 7.0.x. I had planned to exclude it after this is merged up.

@codeconsole codeconsole self-requested a review December 14, 2024 07:46
Copy link
Contributor

@codeconsole codeconsole left a comment

Choose a reason for hiding this comment

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

Will the tasks bootWar, bootDistZip, bootDistTar, bootStartScripts, distZip, distTar still continue to run? if so, should they be disabled as well?

why generate a war and a war-plain? should that be disabled as well?

Probably best in tbe end, bootRun should work and assemble should just produce 1 jar.

@davydotcom
Copy link
Contributor

Just confirming we aren't breaking non jar packaging. I use wars on tomcat and not the self contained jar for example

@matrei
Copy link
Contributor Author

matrei commented Dec 14, 2024

@codeconsole @davydotcom This is the current behavior. Is this what you would expect from assemble in a plugin project?

PS C:\Users\matti\test\g622plugin> ./gradlew assemble --console=plain                                                                                                               
> Task :compileAstJava NO-SOURCE                                                                                                                                                    
> Task :compileAstGroovy NO-SOURCE
> Task :processAstResources NO-SOURCE
> Task :astClasses UP-TO-DATE
> Task :compileJava NO-SOURCE
> Task :configScript
> Task :compileGroovy FROM-CACHE
> Task :copyAstClasses NO-SOURCE
> Task :assetPluginPackage FROM-CACHE
> Task :buildProperties
> Task :copyCommands NO-SOURCE
> Task :copyTemplates NO-SOURCE
> Task :processResources
> Task :classes
> Task :bootWarMainClassName
> Task :compileWebappGroovyPages NO-SOURCE
> Task :compileGroovyPages
> Task :bootWar
> Task :bootStartScripts
> Task :bootDistTar
> Task :bootDistZip
> Task :jar
> Task :startScripts
> Task :distTar
> Task :distZip
> Task :war
> Task :assemble

BUILD SUCCESSFUL in 14s
16 actionable tasks: 14 executed, 2 from cache
PS C:\Users\matti\test\g622plugin> dir build/libs


    Directory: C:\Users\matti\test\g622plugin\build\libs


Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
-a----        2024-12-14     14:00       66098817 g622plugin-0.1-plain.war
-a----        2024-12-14     14:00        1070159 g622plugin-0.1.jar
-a----        2024-12-14     14:00       73550518 g622plugin-0.1.war

@codeconsole
Copy link
Contributor

codeconsole commented Dec 14, 2024

Just confirming we aren't breaking non jar packaging. I use wars on tomcat and not the self contained jar for example

@davydotcom this is just for grails plugins. You run a plugin from a war file?

@codeconsole
Copy link
Contributor

@matrei so why is g622plugin-0.1-plain.war needed? what would that be used for?

@codeconsole
Copy link
Contributor

codeconsole commented Dec 14, 2024

This is all that is needed for bootRun:

> Task :compileAstJava NO-SOURCE
> Task :compileAstGroovy NO-SOURCE
> Task :processAstResources NO-SOURCE
> Task :astClasses UP-TO-DATE
> Task :compileJava NO-SOURCE
> Task :configScript
> Task :compileGroovy
> Task :copyAstClasses NO-SOURCE
> Task :generateGitProperties FROM-CACHE
> Task :assetPluginPackage FROM-CACHE
> Task :buildProperties
> Task :copyCommands NO-SOURCE
> Task :copyTemplates NO-SOURCE
> Task :processResources
> Task :classes
> Task :compileWebappGroovyPages
> Task :compileGroovyPages
> Task :jar
`
> Task :resolveMainClassName

> Task :bootRun

@matrei Why do we need these to build a plugin?

> Task :bootWar
> Task :bootStartScripts
> Task :bootDistTar
> Task :bootDistZip
> Task :startScripts
> Task :distTar
> Task :distZip
> Task :war

@matrei
Copy link
Contributor Author

matrei commented Dec 14, 2024

so why is g622plugin-0.1-plain.war needed? what would that be used for?

I don't know. Should I disable the bootWar and war tasks as well?

@codeconsole
Copy link
Contributor

@matrei I would disable ALL of these:

> Task :bootWar
> Task :bootStartScripts
> Task :bootDistTar
> Task :bootDistZip
> Task :startScripts
> Task :distTar
> Task :distZip
> Task :war

@codeconsole
Copy link
Contributor

BTW, bootRun is currently failing for freshly created 6.2.2 plugins:

% grails create-plugin g622plugin
| Application created at ~/Documents/workspace/grails/g622plugin
% cd g622plugin                  
%  ./gradlew bootRun --console=plain
Starting a Gradle Daemon, 1 busy Daemon could not be reused, use --status for details
> Task :compileAstJava NO-SOURCE
> Task :compileAstGroovy NO-SOURCE
> Task :processAstResources NO-SOURCE
> Task :astClasses UP-TO-DATE
> Task :compileJava NO-SOURCE
> Task :configScript
> Task :compileGroovy
> Task :copyAstClasses NO-SOURCE
> Task :copyCommands NO-SOURCE
> Task :copyTemplates NO-SOURCE
> Task :processResources
> Task :classes
> Task :bootRunMainClassName

> Task :bootRun FAILED
2024-12-14 06:41:49.335 ERROR --- [           main] o.s.b.d.LoggingFailureAnalysisReporter   : 

***************************
APPLICATION FAILED TO START
***************************

Description:

Web application could not be started as there was no org.springframework.boot.web.servlet.server.ServletWebServerFactory bean defined in the context.

Action:

Check your application's dependencies for a supported servlet web server.
Check the configured web application type.


FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':bootRun'.
> Process 'command '~/.sdkman/candidates/java/17.0.13-librca/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 1m 22s
5 actionable tasks: 5 executed

@matrei
Copy link
Contributor Author

matrei commented Dec 14, 2024

BTW, bootRun is currently failing for freshly created 6.2.2 plugins:

I think you have to do: grails create-web-plugin

mattias@mattias-xps:~/test$ grails -V
Grails Version: 6.2.2
JVM Version: 11.0.20
mattias@mattias-xps:~/test$ grails create-web-plugin g622plugin
| Application created at /home/mattias/test/g622plugin
mattias@mattias-xps:~/test$ cd g622plugin
mattias@mattias-xps:~/test/g622plugin$ ./gradlew bootRun --console=plain
> Task :compileAstJava NO-SOURCE
> Task :compileAstGroovy NO-SOURCE
> Task :processAstResources NO-SOURCE
> Task :astClasses UP-TO-DATE
> Task :compileJava NO-SOURCE
> Task :configScript
> Task :compileGroovy
> Task :copyAstClasses NO-SOURCE
> Task :assetPluginPackage
> Task :buildProperties
> Task :copyCommands NO-SOURCE
> Task :copyTemplates NO-SOURCE
> Task :processResources
> Task :classes
> Task :bootRunMainClassName

> Task :bootRun
Grails application running at http://localhost:8080 in environment: development

@codeconsole
Copy link
Contributor

codeconsole commented Dec 14, 2024

I think you have to do: grails create-web-plugin

interesting. didn't pre-forge just be create-plugin ?

are the following dependencies expected for a non web plugin?

    profile "org.grails.profiles:web"
    implementation "org.grails:grails-plugin-interceptors"
    implementation "org.grails:grails-plugin-rest"
    implementation "org.grails:grails-plugin-url-mappings"
    implementation "org.grails:grails-web-boot"
    implementation "org.grails.plugins:gsp"

I created a new issue for that, let's limit this PR to disabling bootWar, bootStartScripts, bootDistTar, bootDistZip, startScripts, distTar, distZip, war as well

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.

6 participants