Skip to content

Commit

Permalink
Merge pull request #902 from arunvenmany-ibm/gradle_deprecation_fix1.0
Browse files Browse the repository at this point in the history
Gradle deprecation fix1.0
  • Loading branch information
cherylking authored Sep 4, 2024
2 parents c29bf04 + c70a00c commit 999102d
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 54 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* (C) Copyright IBM Corporation 2014, 2020.
* (C) Copyright IBM Corporation 2014, 2024.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -15,8 +15,10 @@
*/
package io.openliberty.tools.gradle.extensions

import org.gradle.util.ConfigureUtil
import org.gradle.api.NamedDomainObjectContainer
import org.gradle.api.Action
import org.gradle.api.model.ObjectFactory

import javax.inject.Inject

class LibertyExtension {

Expand All @@ -29,35 +31,43 @@ class LibertyExtension {

// For overriding the group, name or version of the libertyRuntime installed from Maven Central repository.
// Default is group 'io.openliberty', name 'openliberty-kernel' and version '[19.0.0.9,)' which gets the latest version.
Properties runtime = new Properties()
Properties runtime = new Properties();

CompileJSPExtension jsp = new CompileJSPExtension()
CompileJSPExtension jsp

InstallExtension install = new InstallExtension()
SpringBootExtension thin = new SpringBootExtension()
InstallExtension install
SpringBootExtension thin
ServerExtension server

ServerExtension server = server = new ServerExtension()
DevExtension dev;

DevExtension dev = new DevExtension();
@Inject
LibertyExtension(ObjectFactory objectFactory) {
this.jsp = objectFactory.newInstance(CompileJSPExtension.class)
this.install = objectFactory.newInstance(InstallExtension.class)
this.thin = objectFactory.newInstance(SpringBootExtension.class)
this.server = objectFactory.newInstance(ServerExtension.class)
this.dev = objectFactory.newInstance(DevExtension.class)
}

def jsp(Closure closure) {
ConfigureUtil.configure(closure, jsp)
def jsp(Action action) {
action.execute(jsp)
}

def thin(Closure closure) {
ConfigureUtil.configure(closure, thin)
def thin(Action action) {
action.execute(thin)
}

def install(Closure closure) {
ConfigureUtil.configure(closure, install)
def install(Action action) {
action.execute(install)
}

def server(Closure closure){
ConfigureUtil.configure(closure, server)
def server(Action action) {
action.execute(server)
}

def dev(Closure closure) {
ConfigureUtil.configure(closure, dev)
def dev(Action action) {
action.execute(dev)
}

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* (C) Copyright IBM Corporation 2017, 2023.
* (C) Copyright IBM Corporation 2017, 2024.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -16,9 +16,10 @@

package io.openliberty.tools.gradle.extensions

import org.gradle.util.ConfigureUtil
import org.gradle.api.Task
import java.util.Properties
import org.gradle.api.Action
import org.gradle.api.model.ObjectFactory

import javax.inject.Inject

class ServerExtension {
//Server properties
Expand Down Expand Up @@ -51,47 +52,59 @@ class ServerExtension {

int verifyAppStartTimeout = 0

FeatureExtension features = new FeatureExtension()
UninstallFeatureExtension uninstallfeatures = new UninstallFeatureExtension()
CleanExtension cleanDir = new CleanExtension()

DeployExtension deploy = new DeployExtension()
UndeployExtension undeploy = new UndeployExtension()

PackageExtension packageLiberty = new PackageExtension()
DumpExtension dumpLiberty = new DumpExtension()
DumpExtension javaDumpLiberty = new DumpExtension()
FeatureExtension features
UninstallFeatureExtension uninstallfeatures
CleanExtension cleanDir

DeployExtension deploy
UndeployExtension undeploy

PackageExtension packageLiberty
DumpExtension dumpLiberty
DumpExtension javaDumpLiberty

@Inject
ServerExtension(ObjectFactory objectFactory) {
this.features = objectFactory.newInstance(FeatureExtension.class)
this.uninstallfeatures = objectFactory.newInstance(UninstallFeatureExtension.class)
this.cleanDir = objectFactory.newInstance(CleanExtension.class)
this.deploy = objectFactory.newInstance(DeployExtension.class)
this.undeploy = objectFactory.newInstance(UndeployExtension.class)
this.packageLiberty = objectFactory.newInstance(PackageExtension.class)
this.dumpLiberty = objectFactory.newInstance(DumpExtension.class)
this.javaDumpLiberty = objectFactory.newInstance(DumpExtension.class)
}

def uninstallfeatures(Closure closure) {
ConfigureUtil.configure(closure, uninstallfeatures)
def uninstallfeatures(Action action) {
action.execute(uninstallfeatures)
}

def features(Closure closure) {
ConfigureUtil.configure(closure, features)
def features(Action action) {
action.execute(features)
}

def cleanDir(Closure closure) {
ConfigureUtil.configure(closure, cleanDir)
def cleanDir(Action action) {
action.execute(cleanDir)
}

def deploy(Closure closure) {
ConfigureUtil.configure(closure, deploy)
def deploy(Action action) {
action.execute(deploy)
}

def undeploy(Closure closure) {
ConfigureUtil.configure(closure, undeploy)
def undeploy(Action action) {
action.execute(undeploy)
}

def packageLiberty(Closure closure) {
ConfigureUtil.configure(closure, packageLiberty)
def packageLiberty(Action action) {
action.execute(packageLiberty)
}

def dumpLiberty(Closure closure) {
ConfigureUtil.configure(closure, dumpLiberty)
def dumpLiberty(Action action) {
action.execute(dumpLiberty)
}

def javaDumpLiberty(Closure closure) {
ConfigureUtil.configure(closure, javaDumpLiberty)
def javaDumpLiberty(Action action) {
action.execute(javaDumpLiberty)
}

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* (C) Copyright IBM Corporation 2019
* (C) Copyright IBM Corporation 2019,2024
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -15,15 +15,13 @@
*/
package io.openliberty.tools.gradle

import static org.junit.Assert.*


import org.gradle.testkit.runner.BuildResult
import org.gradle.testkit.runner.GradleRunner

import org.junit.BeforeClass
import org.junit.Test
import org.gradle.api.GradleException
import org.gradle.api.artifacts.ResolveException

class InstallLiberty_DefaultNoMavenRepo extends AbstractIntegrationTest{
static File resourceDir = new File("build/resources/test/liberty-test")
Expand All @@ -45,6 +43,6 @@ class InstallLiberty_DefaultNoMavenRepo extends AbstractIntegrationTest{
.buildAndFail()

String output = result.getOutput()
assert output.contains("org.gradle.api.artifacts.ResolveException") : "Expected installLiberty to fail with ResolveException"
assert output.contains("org.gradle.internal.resolve.ModuleVersionNotFoundException") : "Expected installLiberty to fail with TypedResolveException"
}
}

0 comments on commit 999102d

Please sign in to comment.