|
| 1 | +/******************************************************************************* |
| 2 | + * Copyright (c) 2024 IBM Corporation and others. |
| 3 | + * All rights reserved. This program and the accompanying materials |
| 4 | + * are made available under the terms of the Eclipse Public License 2.0 |
| 5 | + * which accompanies this distribution, and is available at |
| 6 | + * http://www.eclipse.org/legal/epl-2.0/ |
| 7 | + * |
| 8 | + * SPDX-License-Identifier: EPL-2.0 |
| 9 | + * |
| 10 | + * Contributors: |
| 11 | + * IBM Corporation - initial API and implementation |
| 12 | + *******************************************************************************/ |
| 13 | +// To create this WAR file (ex: ./gradlew build...) for newer versions of Java (typically early access ones) before gradle supports it |
| 14 | +// See the README.md file |
| 15 | +// Change the installDir setting if your Liberty is located outside of /wlp |
| 16 | + |
| 17 | +apply plugin: 'war' |
| 18 | + |
| 19 | +description = "Basic Liberty repo" |
| 20 | + |
| 21 | +tasks.withType(JavaCompile) { |
| 22 | + options.encoding = 'UTF-8' |
| 23 | +} |
| 24 | + |
| 25 | +compileJava { |
| 26 | + //inputs.property("moduleName", moduleName) |
| 27 | + doFirst { |
| 28 | + options.compilerArgs = [ |
| 29 | + '--module-path', classpath.asPath, |
| 30 | + '--enable-preview' |
| 31 | + ] |
| 32 | + classpath = files() |
| 33 | + options.warnings = true |
| 34 | + options.deprecation = true |
| 35 | + options.debug = true |
| 36 | + options.incremental = false |
| 37 | + } |
| 38 | +} |
| 39 | +test { |
| 40 | + useJUnitPlatform() |
| 41 | +} |
| 42 | + |
| 43 | +java { |
| 44 | + toolchain { |
| 45 | + languageVersion = JavaLanguageVersion.of(22) |
| 46 | + } |
| 47 | +} |
| 48 | + |
| 49 | +buildscript { |
| 50 | + repositories { |
| 51 | + mavenCentral() |
| 52 | + } |
| 53 | + dependencies { |
| 54 | + classpath 'io.openliberty.tools:liberty-gradle-plugin:3.0' |
| 55 | + } |
| 56 | +} |
| 57 | + |
| 58 | +repositories { |
| 59 | + mavenCentral() |
| 60 | +} |
| 61 | + |
| 62 | +configurations { |
| 63 | + serverLibs |
| 64 | +} |
| 65 | + |
| 66 | +dependencies { |
| 67 | + compileOnly group: 'javax.ws.rs', name: 'javax.ws.rs-api', version: '2.1.1' |
| 68 | +// compileOnly group: 'javax.persistence', name: 'javax.persistence-api', version: '2.2' |
| 69 | + compileOnly group: 'javax.xml.bind', name: 'jaxb-api', version: '2.3.1' |
| 70 | + compileOnly group: 'javax.enterprise', name: 'cdi-api', version: '2.0' |
| 71 | +// compileOnly group: 'javax.annotation', name: 'javax.annotation-api', version: '1.3.2' |
| 72 | +// compileOnly group: 'javax.transaction', name: 'javax.transaction-api', version: '1.3' |
| 73 | +// libertyRuntime group: 'io.openliberty', name: 'openliberty-runtime', version: '22.0.0.12' |
| 74 | +// serverLibs group: 'org.apache.derby', name: 'derby', version: '10.14.2.0' // '10.15.1.3' |
| 75 | +} |
| 76 | + |
| 77 | +ext { |
| 78 | + appUrl = 'http://localhost:9080/io.openliberty.java.internal_fat_22/' |
| 79 | +} |
| 80 | + |
| 81 | +task copyServerLibs(type: Copy) { |
| 82 | + from configurations.serverLibs |
| 83 | + // Default location of local Liberty server |
| 84 | + into "/wlp/usr/servers/${project.name}Server/lib" |
| 85 | +} |
| 86 | + |
| 87 | +// Not currently working, must manually handle |
| 88 | +tasks.register('copyEnvFiles', Copy) { |
| 89 | + println "Start of copyEnvFiles" |
| 90 | + from file('run/jvm.options') |
| 91 | +// Default location of local Liberty server |
| 92 | + into new File("/wlp/usr/servers/${project.name}Server") |
| 93 | + from file('run/server.env') |
| 94 | +// Default location of local Liberty server |
| 95 | + into new File("/wlp/usr/servers/${project.name}Server") |
| 96 | + println "End of copyEnvFiles" |
| 97 | +} |
| 98 | + |
| 99 | +task openBrowser { |
| 100 | + description = "Open browser to ${appUrl}" |
| 101 | + doLast { |
| 102 | + java.awt.Desktop.desktop.browse "${appUrl}".toURI() |
| 103 | + } |
| 104 | +} |
| 105 | + |
0 commit comments