-
-
Notifications
You must be signed in to change notification settings - Fork 957
#14729 - Corrupt Jar & War Files #14745
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
Conversation
d51d0a4
to
ce686fe
Compare
Hold off on this review, groovydoc isn't generating docs for this change correctly. |
I reverted the java 17 cleanup - groovydoc still has an older language level set to it. I've reached out to both the Gradle Community & Paul to see if we can get this fixed longer term. |
I also do not error on find main task if it's a plugin (so we do not need the enhancement from bullet 4) |
(this is ready to review, we merged the spring boot change separately so the tests can run with the correct version once it's published) |
Issue for point 4: #14748 |
grails-gradle/plugins/src/main/groovy/org/grails/gradle/plugin/run/FindMainClassTask.groovy
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great job James!
What's the story about the updated license headers?
@@ -46,6 +46,12 @@ ext { | |||
|
|||
allprojects { | |||
repositories { | |||
// workaround for https://github.com/spring-gradle-plugins/dependency-management-plugin/issues/164 | |||
maven { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm starting to think we should ditch the Dependency Management Plugin, and only use Gradle Platforms.
We are actually adding the grails-bom
as a platform
in generated apps.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I 100% agree but we need the ability for end users to easily set versions. I am debating whats better: ditch the dependency plugin inside of grails core or keep it to align with what end user apps use. If gradle platforms supported property overrides, I would have suggested we already switch. I came close to writing a Gradle plugin to just add this support too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think property version overrides are a really good feature but when needed it can be accomplished with Gradle Platforms as well, only not as easily, as you have to declare the dependency you want to be able to override beforehand.
We should rip that band-aid, it causes confusion to do both.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still maintain we shouldn't use both in end user apps - we should one or the other. The property overrides make it very easy to set versions. We should discuss this more outside of this PR.
grails-gradle/plugins/src/main/groovy/org/grails/gradle/plugin/core/GrailsGradlePlugin.groovy
Outdated
Show resolved
Hide resolved
grails-gradle/plugins/src/main/groovy/org/grails/gradle/plugin/core/GrailsGradlePlugin.groovy
Show resolved
Hide resolved
grails-gradle/plugins/src/main/groovy/org/grails/gradle/plugin/core/GrailsGradlePlugin.groovy
Show resolved
Hide resolved
grails-gradle/plugins/src/main/groovy/org/grails/gradle/plugin/core/GrailsGradlePlugin.groovy
Outdated
Show resolved
Hide resolved
grails-gradle/plugins/src/main/groovy/org/grails/gradle/plugin/core/GrailsGradlePlugin.groovy
Outdated
Show resolved
Hide resolved
IntelliJ was updating these. Looks like I need to adjust its header. I will revert these changes. |
6098d29
to
745f5d5
Compare
|
Fixes #14729
This is a rather large change. There are multiple changes in this PR, including:
by guaranteeing order of the AST Transformations, a side effect was that grails-plugin.xml & grails.factories are now properly generating for all projects in grails core. This meant any existing copy of those files that was checked into resources had to be removed. These duplicate files were 1 cause of the duplicated jar file
AbstractFileResolvingResource.exists incorrectly reports result for resources inside of spring-boot executable jar spring-projects/spring-framework#34796 affected nested jar files and versions of spring boot after 3.4.3 all include the affected version of spring. There doesn't appear to be a "spring-dependencies" equivalent of spring framework like there is for spring boot. This means to override the spring version, every spring library has to be added to the bom and overridden. Worse, Maven / Gradle do not yet support exclusions so this is actually a difficult problem that significantly complicates our bom. For this reason, I've rolled us back to 3.4.3 until 3.5.0 comes out with the 6.2.7 spring framework fix.
In Gradle 8, tasks now run in process isolation via the worker api. This means that the version of groovy can be different than Gradle. The problem is the grails-gradle-model doesn't export the version of groovy since it assumes there isn't isolation. So now it exports the version of gradle that it was built with since this library is used by both tasks and plugins
reworks the FindMainTask to properly set the main class and fail if a bootJar / bootRun are enabled, but no Application class exists. I discussed this behavior with @jamesfredley, and I think end grails app developers need to understand that those tasks will generate invalid jars so it's important to fail.
grails-geb
is a good example of this, adding bootJar.enabled = false / bootRun.enabled = false will prevent the failure. We could alternatively just log a warning, but the type of failures caused by invalid jars are incredibly hard to diagnosis. Forcing a failure is a time saver. This change will likely affect plugins the most. We could make a further enhancement to detect if it's a plugin, and not hard fail in that case. @jamesfredley should we ticket this optional enhancement?removes the 'doc' method on the grails plugin since it's been deprecated since Grails 1 from when Grails used to be both a Build System & an app. This method previously generated documentation.
Cleans up the Upgrade7.MD for any entry that's been added to the grails-doc.
Removes the duplicated codec plugin that is deprecated. Updates the docs to reflect this change similar to the changes in gsp where we had other files in this scenario.
removes the remaining pathingJar code since gradle properly handles this with bootRun and our start scripts handle it otherwise. People can use a shadowJar if they need to have their end application perform this function.
Fixes the grails-gsp plugin so that it properly nests files in the jar again.
In
DataBindingUtils
, I found some code that was calling class.getClass() and believe this is a bug in the domain databinding. Tests pass after this change, and the original change that changed this from class to class.getClass() claimed it was done for tests.As part of reviewing the gradle output to debug the invalid docs, I've cleaned up several warnings that I thought were straight forward changes via intellij refactoring.
This change revealed there is a lack of test coverage for jar & war file starts. We know that from the profiles a GroovyMXBean can be used to stop an application. I think we should add tests that actually start each test app via jar / war file. There aren't changes to address this in this PR, but we should likely ticket this.
There's a rather major problem with the functional tests: they pull the bom from the upstream repo instead of locally. This is really only a problem when changing a dependency, which we don't often do. This is due to Referencing a BOM project in a multi-project build spring-gradle-plugins/dependency-management-plugin#164 since we can't use the bom in the same gradle project. As a "workaround" I've added a local repo that only contains the grails-bom to make testing the functional tests with version changes. Running the task './gradlew :grails-bom:publishMavenPublicationToLocalBomRepository` will publish to that local repo, which typically will be empty, and then the functional tests will pull the dependencies.
removes SDKman workflow, which was used prior to Grails 6. The release to SDKman occurs in grails-forge: https://github.com/apache/grails-forge/blob/7.0.x/.github/workflows/release.yml#L91
Since we do publish a valid gradle module for the bom, we could switch to using platforms exclusively in the functional tests, but I think that will defeat the purpose of these tests - end users are still using the spring dependency management plugin since gradle platforms do not support properties. So until gradle upstream implements a property override for the platform versions, we need to continue to test with the dependency management plugin. I think the workaround proposed here needs documented in a ticket and we need to track this longer term on how to fix this.