Switch both call sites from dynamic property access to NamedDomainObjectCollection.findByName(), which returns null safely, and fall back to conventional default paths when the java plugin is absent#1093
Conversation
…ectCollection.findByName(), which returns null safely, and fall back to conventional default paths when the java plugin is absent
cherylking
left a comment
There was a problem hiding this comment.
Where is the test that uses sourceSets? I looked through all the build.gradle files and did not see it.
The test intentionally has no sourceSets block. The ear/build.gradle deliberately applies only ear + liberty plugins to prove that DevTask handles a missing SourceSetContainer gracefully. The WAR and JAR submodules in the same test project do apply the java plugin and have valid sourceSets, so both the null path (EAR) and the normal path (WAR/JAR) are exercised within the same test run. |
Replace project.sourceSets.main direct property access with
extensions.findByType(SourceSetContainer)?.findByName('main')
in DeployTask and GenerateFeaturesTask, matching the same fix
already applied to DevTask.
Also bumps libertyCommonVersion from 1.8.42-SNAPSHOT to 1.8.42.
|
The end user had a sourceSets block. I get why you have the tests without (to test the null path), but why don't we also have a test with sourceSets. There is a lot of new logic here on how you are retrieving and using the sourceSets. |
Also some cleanups. Adding Internal annotation and changing methods to protected to make sure they are with gradle 9 standards
Tests added for sourceSet based projects for both devMode and deploy |
Fixes #1092
Fix: MissingPropertyException in DevTask when Java plugin is absent (EAR projects)
DevTask.action() and DevTask.getProjectModules() both accessed sourceSets via Groovy dynamic property dispatch (project.sourceSets.main). On projects that don't apply the java plugin — such as a pure EAR module — this property doesn't exist and throws MissingPropertyException at libertyDev startup.
Changes: