ci.gradle icon indicating copy to clipboard operation
ci.gradle copied to clipboard

LooseEarConfiguration is missing resources directories

Open dgeissl opened this issue 4 years ago • 3 comments

Using liberyDev creates a loose configuration. this configuration is broken for multimodule projects that should be deployed as ear . The reason is that all resources are not present in the loose config xml.

Here is a example of a project with a ear containing a ejb-jar (with JPA - thus requiring a persistence.xml) and a web-war (paths shortened for readability):

<?xml version="1.0" encoding="UTF-8"?>
<archive>
    <file sourceOnDisk="...\EAR\build\tmp\ear\application.xml" targetInArchive="/META-INF/application.xml"/>
    <archive targetInArchive="/P99_Web.war">
        <dir sourceOnDisk="...\Web\build\classes\java\main" targetInArchive="/WEB-INF/classes"/>
        <file sourceOnDisk="...\EAR\build\tmp\META-INF\MANIFEST.MF" targetInArchive="/META-INF/MANIFEST.MF"/>
    </archive>
    <archive targetInArchive="/P99_Services.jar">
        <dir sourceOnDisk="...\Services\build\classes\java\main" targetInArchive="/"/>
        <file sourceOnDisk="...\EAR\build\tmp\META-INF\MANIFEST.MF" targetInArchive="/META-INF/MANIFEST.MF"/>
    </archive>
    <file sourceOnDisk="...\EAR\build\tmp\META-INF\MANIFEST.MF" targetInArchive="/META-INF/MANIFEST.MF"/>
</archive>

This is what the file should look like:

<?xml version="1.0" encoding="UTF-8"?>
<archive>
    <file sourceOnDisk="...\EAR\build\tmp\ear\application.xml" targetInArchive="/META-INF/application.xml"/>
    <archive targetInArchive="/P99_Web.war">
        <dir sourceOnDisk="...\Web\build\classes\java\main" targetInArchive="/WEB-INF/classes"/>
        <dir sourceOnDisk="...\Web\build\resources\main" targetInArchive="/WEB-INF/classes"/> <!-- currently missing -->
        <file sourceOnDisk="...\EAR\build\tmp\META-INF\MANIFEST.MF" targetInArchive="/META-INF/MANIFEST.MF"/>
    </archive>
    <archive targetInArchive="/P99_Services.jar">
        <dir sourceOnDisk="...\Services\build\classes\java\main" targetInArchive="/"/>
        <dir sourceOnDisk="...\Services\build\resources\main" targetInArchive="/"/> <!-- currently missing -->
        <file sourceOnDisk="...\EAR\build\tmp\META-INF\MANIFEST.MF" targetInArchive="/META-INF/MANIFEST.MF"/>
    </archive>
    <file sourceOnDisk="...\EAR\build\tmp\META-INF\MANIFEST.MF" targetInArchive="/META-INF/MANIFEST.MF"/>
</archive>

The patch most likely has to be applied to the LooseEarConfiguration class, e.g. for jar files:

https://github.com/OpenLiberty/ci.gradle/blob/155707feab649c79549fd58daadf75fa8a41d3ac/src/main/groovy/io/openliberty/tools/gradle/utils/LooseEarApplication.groovy#L50-L55

dgeissl avatar Sep 06 '21 08:09 dgeissl

This is related to #625 and would be fixed as part of that enhancement request.

cherylking avatar Oct 01 '21 13:10 cherylking