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

Multi module Gradle application failed to deploy into liberty server

Open jagraj opened this issue 2 years ago • 13 comments

I am trying to deploy multi module Gradle application into Liberty server and it is failing to deploy into apps folder. I followed this documentation and I could not deploy into liberty server.

apply plugin: 'liberty'

dependencies {
    libertyApp 'example:app:1.0'
}

I tried both looseApplication=false and true options and it did not work. Here is my gradle.build file below.

apply plugin: 'liberty'

buildscript {
    repositories {
        mavenCentral()
        maven {
            name = 'Sonatype Nexus Snapshots'
            url = 'https://oss.sonatype.org/content/repositories/snapshots/'
        }
    }
    dependencies {
        classpath 'io.openliberty.tools:liberty-gradle-plugin:3.3.1'
    }
}

description = 'GarageSaleRuntime'
def libertyInstallDir = "C:\\MyData\\LibertyInstalls\\wlp"

dependencies {
  libertyApp project(':GarageSaleLibertyEAR')
  libertyRuntime group: 'com.ibm.websphere.appserver.runtime', name: 'wlp-jakartaee9', version: '22.0.0.5'
}

liberty {
    installDir="${libertyInstallDir}"
    server {
        name = "garageSaleServer"
        serverXmlFile = file('publish/servers/server.xml')
        jvmOptionsFile = file('publish/files/jvm.options')
        configDirectory = file('publish/config')
        looseApplication = false
        stripVersion = true
        stripVersion = true
        	features {
            	name = ["${projectDir}/publish/files/WASPersonaWebServicesHandlerFeature_1.0.0.202110181027.esa"]
            	acceptLicense = true
        	}
    }
}

task copyDB2Jars(type: Copy) {
    from 'publish/databaseDrivers/db2V9Drivers'
    into "${buildDir}/wlp/usr/shared/resources/db2drivers"
} 

task copyJaxRSThirdPartyJars(type: Copy) {
    from 'publish/jaxrsThirdPartyJars'
    into "${buildDir}/wlp/usr/shared/resources/jaxrsThirdPartyJars"
}

task copyMyEAR(type: Copy) {
	from '../GarageSaleLibertyEAR/build/libs/GarageSaleLibertyEAR.ear'
	into "${buildDir}/wlp/usr/servers/garageSaleServer/apps"
}

//libertyCreate.finalizedBy 'copyMyEAR', 'copyDB2Jars', 'copyJaxRSThirdPartyJars'
libertyCreate.finalizedBy 'copyDB2Jars', 'copyJaxRSThirdPartyJars'
build.dependsOn 'deploy'

jagraj avatar Jun 24 '22 20:06 jagraj

I did some testing with this project and it seems that there were a couple more pieces needed to get the ear file deployed.

  • Specifying the configuration to use for the libertyApp dependency -> libertyApp project(path: ':GarageSaleLibertyEAR', configuration: 'archives')
  • Binding the ear task from GarageSaleLibertyEAR to deploy -> deploy.dependsOn ':GarageSaleLibertyEAR:ear'

mattbsox avatar Jun 24 '22 20:06 mattbsox

@jagraj Is this resolved? Can we close the issue?

cherylking avatar Jul 26 '22 20:07 cherylking

@cherylking I got the application deployed with the above changes recommended by Matt. I would like to verify looseApplication=true scenario with multi module projects and this is not working. I was able to verify with liberty maven plugin but I am not able to get it working with Gradle plugin.

jagraj avatar Aug 03 '22 12:08 jagraj

@jagraj Multi module support has not been added to the Gradle plugin for dev mode. Issue #625 is open for that. But your scenario does not involve dev mode correct?

cherylking avatar Aug 03 '22 15:08 cherylking

@cherylking Yes, my scenario is not involved with dev mode. My application was working fine with old version of liberty plugin liberty-gradle-plugin:2.1.1-SNAPSHOT and the same app fails to deploy with the latest version of gradle plugin liberty-gradle-plugin:3.3.1 after migrating my application for Jakarta EE9 development.

jagraj avatar Jan 09 '23 19:01 jagraj

@jagraj We have made some fixes around loose application deployment in recent releases. Would you mind trying our most recent 3.6 version of the plugin and see if it resolves the problem you were seeing?

cherylking avatar May 24 '23 16:05 cherylking

@cherylking Sure, I will rerun my scenario early next week and get back to you. I have been working on other releases this week. Thanks for the fixes.

jagraj avatar May 24 '23 17:05 jagraj