diff --git a/.classpath b/.classpath new file mode 100644 index 0000000..ef39f76 --- /dev/null +++ b/.classpath @@ -0,0 +1,7 @@ + + + + + + + diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml new file mode 100644 index 0000000..ca262b0 --- /dev/null +++ b/.github/workflows/build.yaml @@ -0,0 +1,104 @@ +name: Build + +on: + push: + branches: ["cicsts/v6.1"] + pull_request: + branches: ["cicsts/v6.1"] + schedule: + - cron: '0 0 * * *' + +permissions: + contents: read + +jobs: + check-copyright: + runs-on: ubuntu-latest + name: Check Copyright + if: ${{ !startsWith(github.head_ref, 'create-pull-request/') }} + permissions: + contents: write + pull-requests: write + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - id: copyright-action + uses: cicsdev/.github/.github/actions/samples-copyright-checker@4134522d8109169bb8c460db841f94167ec2802f + with: + directory: './cics-java-liberty-jdbc-app/' + file-extensions: '*.js *.java *.html' + base-copyright: 'Copyright IBM Corp. 2025' + token: ${{ secrets.GITHUB_TOKEN }} + + build-gradle: + name: Build Gradle + + runs-on: ubuntu-latest + strategy: + matrix: + jdk: [17, 21, 25] + steps: + - uses: actions/checkout@v4 + - name: Set up JDK ${{ matrix.jdk }} + uses: actions/setup-java@v4 + with: + java-version: ${{ matrix.jdk }} + distribution: 'semeru' + - uses: gradle/actions/setup-gradle@v4 + with: + gradle-version: 8.14.4 + - name: Build with Gradle + run: gradle clean build -Pjava_version=${{ matrix.jdk }} + + build-gradlew: + name: Build Gradle Wrapper + + runs-on: ubuntu-latest + strategy: + matrix: + jdk: [17, 21, 25] + steps: + - uses: actions/checkout@v4 + - name: Set up JDK ${{ matrix.jdk }} + uses: actions/setup-java@v4 + with: + java-version: ${{ matrix.jdk }} + distribution: 'semeru' + - name: Build with Gradle Wrapper + run: ./gradlew clean build -Pjava_version=${{ matrix.jdk }} + + build-maven: + name: Build Maven + + runs-on: ubuntu-latest + strategy: + matrix: + jdk: [17, 21, 25] + steps: + - uses: actions/checkout@v4 + - name: Set up JDK ${{ matrix.jdk }} + uses: actions/setup-java@v4 + with: + java-version: ${{ matrix.jdk }} + distribution: 'semeru' + cache: maven + - name: Build with Maven + run: mvn --batch-mode --update-snapshots -Djava.version=${{ matrix.jdk }} verify + + build-mvnw: + name: Build Maven Wrapper + + runs-on: ubuntu-latest + strategy: + matrix: + jdk: [17, 21, 25] + steps: + - uses: actions/checkout@v4 + - name: Set up JDK ${{ matrix.jdk }} + uses: actions/setup-java@v4 + with: + java-version: ${{ matrix.jdk }} + distribution: 'semeru' + - name: Build with Maven Wrapper + run: ./mvnw --batch-mode --update-snapshots -Djava.version=${{ matrix.jdk }} verify diff --git a/.github/workflows/cleanup-old-runs.yaml b/.github/workflows/cleanup-old-runs.yaml new file mode 100644 index 0000000..30da41c --- /dev/null +++ b/.github/workflows/cleanup-old-runs.yaml @@ -0,0 +1,23 @@ +name: Cleanup old workflow runs + +on: + schedule: + - cron: '0 0 * * 0' # Run weekly on Sunday at midnight UTC + workflow_dispatch: # Allow manual triggering + +permissions: + contents: read + +jobs: + cleanup: + runs-on: ubuntu-latest + permissions: + actions: write + steps: + - name: Delete old workflow runs + uses: Mattraks/delete-workflow-runs@v2 + with: + token: ${{ github.token }} + repository: ${{ github.repository }} + retain_days: 30 + keep_minimum_runs: 6 diff --git a/.github/workflows/java.yaml b/.github/workflows/java.yaml deleted file mode 100644 index 7dc74ff..0000000 --- a/.github/workflows/java.yaml +++ /dev/null @@ -1,64 +0,0 @@ -name: Build - -on: - push: - branches: ["cicsts/v6.1"] - pull_request: - branches: ["cicsts/v6.1"] - schedule: - - cron: '0 0 * * *' - -jobs: - check-copyright: - runs-on: ubuntu-latest - name: Check Copyright - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - id: copyright-action - uses: cicsdev/.github/.github/actions/samples-copyright-checker@4134522d8109169bb8c460db841f94167ec2802f - with: - directory: './cics-java-liberty-jdbc-web/' - file-extensions: '*.js *.java *.html' - base-copyright: 'Copyright IBM Corp. 2025' - token: ${{ secrets.GITHUB_TOKEN }} - - build-mvnw: - name: Build Maven Wrapper - - runs-on: ubuntu-latest - strategy: - matrix: - jdk: [17, 21] - steps: - - uses: actions/checkout@v3 - - name: Set up JDK ${{ matrix.jdk }} - uses: actions/setup-java@v3 - with: - java-version: ${{ matrix.jdk }} - distribution: "semeru" - cache: maven - - name: Build with Maven - run: ./mvnw --batch-mode --update-snapshots --file pom.xml -Djava.version=${{ matrix.jdk }} verify - - - build-gradlew: - name: Build Gradle Wrapper - - runs-on: ubuntu-latest - strategy: - matrix: - jdk: [17, 21] - steps: - - uses: actions/checkout@v3 - - name: Set up JDK ${{ matrix.jdk }} - uses: actions/setup-java@v4 - with: - java-version: ${{ matrix.jdk }} - distribution: 'semeru' - - uses: gradle/actions/setup-gradle@v3 - with: - gradle-version: 8.6 - - name: Build with Gradle - run: ./gradlew clean build -Pjava_version=${{ matrix.jdk }} diff --git a/.gitignore b/.gitignore index 313dbb0..888cf53 100644 --- a/.gitignore +++ b/.gitignore @@ -79,7 +79,7 @@ gradle-app.setting # Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored) !gradle-wrapper.jar -# Avoid ignore Gradle wrappper properties +# Avoid ignore Gradle wrapper properties !gradle-wrapper.properties # Cache of project diff --git a/.mvn/wrapper/MavenWrapperDownloader.java b/.mvn/wrapper/MavenWrapperDownloader.java deleted file mode 100644 index b901097..0000000 --- a/.mvn/wrapper/MavenWrapperDownloader.java +++ /dev/null @@ -1,117 +0,0 @@ -/* - * Copyright 2007-present the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import java.net.*; -import java.io.*; -import java.nio.channels.*; -import java.util.Properties; - -public class MavenWrapperDownloader { - - private static final String WRAPPER_VERSION = "0.5.6"; - /** - * Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided. - */ - private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/" - + WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar"; - - /** - * Path to the maven-wrapper.properties file, which might contain a downloadUrl property to - * use instead of the default one. - */ - private static final String MAVEN_WRAPPER_PROPERTIES_PATH = - ".mvn/wrapper/maven-wrapper.properties"; - - /** - * Path where the maven-wrapper.jar will be saved to. - */ - private static final String MAVEN_WRAPPER_JAR_PATH = - ".mvn/wrapper/maven-wrapper.jar"; - - /** - * Name of the property which should be used to override the default download url for the wrapper. - */ - private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl"; - - public static void main(String args[]) { - System.out.println("- Downloader started"); - File baseDirectory = new File(args[0]); - System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath()); - - // If the maven-wrapper.properties exists, read it and check if it contains a custom - // wrapperUrl parameter. - File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH); - String url = DEFAULT_DOWNLOAD_URL; - if(mavenWrapperPropertyFile.exists()) { - FileInputStream mavenWrapperPropertyFileInputStream = null; - try { - mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile); - Properties mavenWrapperProperties = new Properties(); - mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream); - url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url); - } catch (IOException e) { - System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'"); - } finally { - try { - if(mavenWrapperPropertyFileInputStream != null) { - mavenWrapperPropertyFileInputStream.close(); - } - } catch (IOException e) { - // Ignore ... - } - } - } - System.out.println("- Downloading from: " + url); - - File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH); - if(!outputFile.getParentFile().exists()) { - if(!outputFile.getParentFile().mkdirs()) { - System.out.println( - "- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'"); - } - } - System.out.println("- Downloading to: " + outputFile.getAbsolutePath()); - try { - downloadFileFromURL(url, outputFile); - System.out.println("Done"); - System.exit(0); - } catch (Throwable e) { - System.out.println("- Error downloading"); - e.printStackTrace(); - System.exit(1); - } - } - - private static void downloadFileFromURL(String urlString, File destination) throws Exception { - if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) { - String username = System.getenv("MVNW_USERNAME"); - char[] password = System.getenv("MVNW_PASSWORD").toCharArray(); - Authenticator.setDefault(new Authenticator() { - @Override - protected PasswordAuthentication getPasswordAuthentication() { - return new PasswordAuthentication(username, password); - } - }); - } - URL website = new URL(urlString); - ReadableByteChannel rbc; - rbc = Channels.newChannel(website.openStream()); - FileOutputStream fos = new FileOutputStream(destination); - fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE); - fos.close(); - rbc.close(); - } - -} diff --git a/.mvn/wrapper/maven-wrapper.properties b/.mvn/wrapper/maven-wrapper.properties index 642d572..8dea6c2 100644 --- a/.mvn/wrapper/maven-wrapper.properties +++ b/.mvn/wrapper/maven-wrapper.properties @@ -1,2 +1,3 @@ -distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.3/apache-maven-3.6.3-bin.zip -wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar +wrapperVersion=3.3.4 +distributionType=only-script +distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.12/apache-maven-3.9.12-bin.zip diff --git a/.settings/org.eclipse.buildship.core.prefs b/.settings/org.eclipse.buildship.core.prefs index b8c0199..e889521 100644 --- a/.settings/org.eclipse.buildship.core.prefs +++ b/.settings/org.eclipse.buildship.core.prefs @@ -1,13 +1,2 @@ -arguments= -auto.sync=false -build.scans.enabled=false -connection.gradle.distribution=GRADLE_DISTRIBUTION(WRAPPER) -connection.project.dir=cics-java-liberty-jdbc-web +connection.project.dir= eclipse.preferences.version=1 -gradle.user.home= -java.home= -jvm.arguments= -offline.mode=false -override.workspace.settings=false -show.console.view=false -show.executions.view=false \ No newline at end of file diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs index 5d2740f..62ef348 100644 --- a/.settings/org.eclipse.jdt.core.prefs +++ b/.settings/org.eclipse.jdt.core.prefs @@ -1,15 +1,9 @@ eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate org.eclipse.jdt.core.compiler.codegen.targetPlatform=17 -org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve org.eclipse.jdt.core.compiler.compliance=17 -org.eclipse.jdt.core.compiler.debug.lineNumber=generate -org.eclipse.jdt.core.compiler.debug.localVariable=generate -org.eclipse.jdt.core.compiler.debug.sourceFile=generate org.eclipse.jdt.core.compiler.problem.assertIdentifier=error org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled org.eclipse.jdt.core.compiler.problem.enumIdentifier=error org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning -org.eclipse.jdt.core.compiler.release=disabled -org.eclipse.jdt.core.compiler.source=17 \ No newline at end of file +org.eclipse.jdt.core.compiler.release=enabled +org.eclipse.jdt.core.compiler.source=17 diff --git a/CODEOWNERS b/CODEOWNERS new file mode 100644 index 0000000..4a08d1a --- /dev/null +++ b/CODEOWNERS @@ -0,0 +1,6 @@ +# CODEOWNERS - Defines maintainers for this CICS sample +# Docs: https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners +# Last reviewed: 2025-08 + +# For members of the team that maintains Java samples, see https://github.com/orgs/cicsdev/teams/cics-java-maintainers +* @cicsdev/cics-java-maintainers diff --git a/MAINTAINERS.md b/MAINTAINERS.md deleted file mode 100644 index ecc6ae6..0000000 --- a/MAINTAINERS.md +++ /dev/null @@ -1,8 +0,0 @@ -# Maintainers - -- Ivan D. Hargreaves [@IvanHargreaves](https://github.com/IvanHargreaves) -- Alex Brown [@AlexBrown](https://github.com/SoftlySplinter) -- Phil Wakelin [@PhilWakelin](https://github.com/PhilWakelin) -- Aaron Jhaj [@AaronJhaj](https://github.com/AaronJhaj) - -*Last reviewed:* June 2025 diff --git a/README.md b/README.md index 189a461..f91e1f8 100644 --- a/README.md +++ b/README.md @@ -1,217 +1,249 @@ # cics-java-liberty-jdbc -This sample demonstrates how to code, build, and deploy a CICS Java application that makes JDBC calls to Db2 from a web servlet in CICS Liberty. It makes use of the employee sample table supplied with Db2 for z/OS, and allows you to display employee information from the table EMP. +[![Build](https://github.com/cicsdev/cics-java-liberty-jdbc/actions/workflows/build.yaml/badge.svg)](https://github.com/cicsdev/cics-java-liberty-jdbc/actions/workflows/build.yaml) +[![License](https://img.shields.io/badge/License-Apache%202.0-green.svg)](https://www.apache.org/licenses/LICENSE-2.0) -## Contents -This is a set of sample Java projects for database interaction in CICS Java, demonstrating how you can use JDBC in a WAR in a Liberty JVM server, to allow it query items in Db2. +## Overview -This sample can use either Db2 type 2 or type 4 connectivity. +This sample demonstrates how to code, build, and deploy a CICS Java application that makes JDBC calls to Db2 from a web servlet running in a CICS Liberty JVM server. It uses the employee sample table (`EMP`) supplied with Db2 for z/OS, and allows you to display and query employee information. -* [`cics-java-liberty-jdbc-web`](cics-java-liberty-jdbc-web) - Dynamic web project containing the Java source. -* [`java-java-liberty-jdbc-bundle`](cics-java-liberty-jdbc-bundle) - CICS bundle plug-in based project, contains Web application bundle-parts. Use with Gradle and Maven builds. -* [`etc/config/liberty`](etc/config/liberty) - Liberty server configuration files -* [`etc/eclipse_projects/com.ibm.cics.server.examples.wlp.jdbc.bundle`](etc/eclipse_projects/com.ibm.cics.server.examples.wlp.jdbc.bundle) - CICS bundle project (CICS Explorer based CICS bundle project, contains Web application bundle-parts. Use with CICS Explorer 'Export to zFS' deployment capability.) +The sample uses the Jakarta EE 9 Servlet API and is targeted for deployment in a CICS TS V6.1 Liberty JVM server. It supports both Db2 type 2 and type 4 connectivity. -## Requirements -* CICS TS V6.1 or later -* A connected CICS DB2CONN resource. For more information, see [CONFIGURING](#configuring) -* A Liberty JVM server -* Java SE 17 or later on the workstation -* IBM Db2 V13 or later on z/OS +**Key Features:** +- Demonstrates JDBC connectivity to Db2 for z/OS from a Liberty JVM server +- Supports both Db2 type 2 (local) and type 4 (network) JDBC drivers +- Provides a REST-style servlet that queries the Db2 `EMP` sample table +- Includes a simple HTML front-end for browsing employee records -## Downloading +## Table of Contents -- Clone the repository using your IDEs support, such as the Eclipse Git plugin -- **or**, download the sample as a [ZIP](https://github.com/cicsdev/cics-java-liberty-jdbc/archive/cicsts/v6.1.zip) and unzip onto the workstation +1. [Overview](#overview) +2. [Prerequisites](#prerequisites) +3. [Reference](#reference) +4. [Downloading](#downloading) +5. [Building the Sample](#building-the-sample) +6. [Deploying to a CICS Liberty JVM server](#deploying-to-a-cics-liberty-jvm-server) +7. [Running the Sample](#running-the-sample) +8. [Additional Resources](#additional-resources) +9. [License](#license) +10. [Contributing](#contributing) -> [!TIP] -> Eclipse Git provides an 'Import existing Projects' check-box when cloning a repository. +## Prerequisites +- CICS TS V6.1 or later +- A configured Liberty JVM server in CICS +- Java SE 17 or later on the workstation +- Eclipse with the IBM CICS SDK for Java EE, Jakarta EE and Liberty (optional) +- Gradle or Apache Maven on the workstation (optional — wrappers are supplied) +- IBM Db2 V13 or later on z/OS with the `EMP` sample table +- A connected CICS `DB2CONN` resource (see [Deploying to a CICS Liberty JVM server](#deploying-to-a-cics-liberty-jvm-server)) -## Building +## Reference -You can build the sample in a variety of ways: -- Using the implicit compile/build of the Eclipse based CICS Explorer SDK -- Using the built-in Gradle or Maven support of your IDE (For example: *buildship* or *m2e* in Eclipse which integrate with the "Run As..." menu.) -- Using the supplied Gradle or Maven Wrapper scripts (no requirement for an IDE or Gradle/Maven install) -- or you can build it from the command line if you have Gradle or Maven installed on your workstation - +- Sample SQLJ Git repository: [cics-java-liberty-sqlj](https://github.com/cicsdev/cics-java-liberty-sqlj) +- CICS Knowledge Center: [Configuring a Liberty JVM server](https://www.ibm.com/docs/en/cics-ts/latest?topic=server-configuring-liberty-jvm) +- CICS Knowledge Center: [Configuring a JVM server to support Db2](https://www.ibm.com/docs/en/cics-ts/latest?topic=programs-configuring-jvm-server-support-db2) -> [!IMPORTANT] -> The sample comes pre-configured for use with a JDK 17 and CICS TS V6.1 Libraries for Jakarta EE 9. When you initially import the project to your IDE, if your IDE is not configured for a JDK 17, or does not have CICS Explorer SDK installed, you might experience local project compile errors. To resolve issues you should configure the Project's build-path to add/remove your preferred combination of CICS TS, JDK, and Liberty's Enterprise Java libraries (Java EE or Jakarta EE). Resolving errors might also depend on how you wish to build and deploy the sample. If you are building and deploying through CICS Explorer SDK and 'Export to zFS' you should edit the link-app's Project properties. Select 'Java Build Path', on the Libraries tab select 'Classpath', click 'Add Library', select 'CICS with Enterprise Java and Liberty' Library, and choose the appropriate CICS and Enterprise Java versions. -If you are building and deploying with Gradle or Maven then you don't necessarily need to fix the local errors, but to do so, you can do as above, or you can run a tooling refresh on the jdbc-web project. For example, in Eclipse: right-click on "Project", select "Gradle -> Refresh Gradle Project", **or** right-click on "Project", select "Maven -> Update Project...". +## Downloading -> [!TIP] -> In Eclipse, Gradle (buildship) is able to fully refresh and resolve the local classpath even if the project was previously updated by Maven. However, Maven (m2e) does not currently reciprocate that capability. If you previously refreshed the project with Gradle, you'll need to manually remove the 'Project Dependencies' entry on the Java build-path of your Project Properties to avoid duplication errors when performing a Maven Project Update. +**If using Eclipse:** the simplest approach is to clone the repository using the Eclipse Git plugin (EGit) perspective. +**If using the command line:** +```shell +git clone https://github.com/cicsdev/cics-java-liberty-jdbc +``` +Alternatively, download the sample as a [ZIP](https://github.com/cicsdev/cics-java-liberty-jdbc/archive/main.zip) and unzip onto the workstation. + +**If importing into Eclipse:** +1. In the **Git Repositories** view, right-click the repository → **Import as Project** + *(if you cloned from the command line, use **File → Import → Existing Projects into Workspace** instead, browse to the cloned directory, select all projects)* +2. Switch to the **Java EE** perspective +3. In the **Project Explorer**, right-click the `cics-java-liberty-jdbc-app` folder → **Import as Project** +4. Right-click the `cics-java-liberty-jdbc-cicsbundle` folder → **Import as Project** +5. Right-click the `cics-java-liberty-jdbc-cicsbundle-eclipse` folder → **Import as Project** +6. **Required:** Right-click the root project → **Gradle → Refresh Gradle Project** or **Maven → Update Project...** — this resolves CICS and framework dependencies into the project classpath. +**Package `com.ibm.cicsdev.liberty.jdbc`** +- [`DatabaseService`](cics-java-liberty-jdbc-app/src/main/java/com/ibm/cicsdev/liberty/jdbc/DatabaseService.java) — obtains a JDBC connection and runs a timestamp query +- [`DatabaseServlet`](cics-java-liberty-jdbc-app/src/main/java/com/ibm/cicsdev/liberty/jdbc/DatabaseServlet.java) — servlet that returns the current Db2 timestamp -### Option 1: Building with Eclipse +**Package `com.ibm.cicsdev.liberty.jdbc.employee`** +- [`Employee`](cics-java-liberty-jdbc-app/src/main/java/com/ibm/cicsdev/liberty/jdbc/employee/Employee.java) — model class for an employee record +- [`EmployeeService`](cics-java-liberty-jdbc-app/src/main/java/com/ibm/cicsdev/liberty/jdbc/employee/EmployeeService.java) — queries the `EMP` table via JDBC +- [`EmployeeServlet`](cics-java-liberty-jdbc-app/src/main/java/com/ibm/cicsdev/liberty/jdbc/employee/EmployeeServlet.java) — servlet that returns employee data as JSON -If you are using the Egit client to clone the repo, remember to tick the button to import all projects. Otherwise, you should manually Import the projects into CICS Explorer using File → Import → General → Existing projects into workspace, then follow the error resolution advice above. +**Supporting files:** +- [`etc/config/liberty/server.xml`](etc/config/liberty/server.xml) — Liberty server template +- [`etc/config/jvmprofile/DFHWLP.jvmprofile`](etc/config/jvmprofile/DFHWLP.jvmprofile) — JVM profile template -### Option 2: Building with Gradle +## Building the Sample -For a complete build you should run the settings.gradle file in the top-level 'cics-java-liberty-jdbc' directory which is designed to invoke the individual build.gradle files for each project. +You can build the sample using an IDE of your choice, or from the command line. Using the supplied Gradle or Maven wrapper is the recommended approach to get a consistent build tool version. -If successful, a WAR file is created inside the `cics-java-liberty-jdbc-web/build/libs` directory and a CICS bundle ZIP file inside the `cics-java-liberty-jdbc-bundle/build/distribution` directory. +The required build tasks are `clean build` for Gradle and `clean verify` for Maven. Gradle generates a WAR file in `cics-java-liberty-jdbc-app/build/libs`; Maven generates it in `cics-java-liberty-jdbc-app/target`. -[!NOTE] -In Eclipse, the output 'build' directory is often hidden by default. From the Package Explorer pane, select the three dot menu, choose filters and un-check the Gradle build folder to view its contents. +### Gradle Wrapper (command line) -The JVM server the CICS bundle is targeted at is controlled through the `cics.jvmserver` property, defined in the [`cics-java-liberty-jdbc-bundle/build.gradle`](cics-java-liberty-jdbc-bundle/build.gradle) file, or alternatively can be set on the command line: +On Linux or Mac: -**Gradle Wrapper (Linux/Mac):** ```shell ./gradlew clean build ``` -**Gradle Wrapper (Windows):** -```shell -gradle.bat clean build -``` -**Gradle (command-line):** -```shell -gradle clean build -``` -**Gradle (command-line & setting jvmserver):** + +On Windows: + ```shell -gradle clean build -Pcics.jvmserver=MYJVM +gradlew.bat clean build ``` -### Option 3: Building with Apache Maven +This creates a WAR file inside the `cics-java-liberty-jdbc-app/build/libs` directory. + +> **Note:** In Eclipse, the `build` directory may be hidden by default. To view it: **Package Explorer → ⋮ → Filters and Customization → uncheck "Gradle build folder"**. -For a complete build you should run the pom.xml file in the top-level 'cics-java-liberty-jdbc' directory. A WAR file is created inside the `cics-java-liberty-jdbc-web/target` directory and a CICS bundle ZIP file inside the `cics-java-liberty-jdbc-bundle/target` directory. +### Maven Wrapper (command line) -If building a CICS bundle ZIP the CICS JVM server name for the WAR bundle part should be modified in the - `cics.jvmserver` property, defined in [`cics-java-liberty-jdbc-bundle/pom.xml`](cics-java-liberty-jdbc-bundle/pom.xml) file under the `defaultjvmserver` configuration property, or alternatively can be set on the command line. +On Linux or Mac: -**Maven Wrapper (Linux/Mac):** ```shell ./mvnw clean verify ``` -**Maven Wrapper (Windows):** + +On Windows: + ```shell mvnw.cmd clean verify ``` -**Maven (command-line):** -```shell -mvn clean verify -``` -**Maven (command-line & setting jvmserver):** -```shell -mvn clean verify -Dcics.jvmserver=MYJVM -``` -## Configuring +This creates a WAR file inside the `cics-java-liberty-jdbc-app/target` directory. -### Configure CICS for Db2 -To allow your CICS region to connect to DB2, we need to add some configuration to the JCL. +### Building with Eclipse (IDE) -``` -// SET DB2=V13 - DB2 Version -... - -... -DB2CONN=YES - -//STEPLIB -... -// DD DISP=SHR,DSN=SYS2.DB2.&DB2..SDSNLOAD -// DD DISP=SHR,DSN=SYS2.DB2.&DB2..SDSNLOD2 -``` +Once imported (see [Downloading](#downloading)), use the IDE's built-in Gradle or Maven integration: + +**With Gradle (Buildship):** +1. Right-click the root project → **Run As → Gradle Build...** +2. Enter `clean build` in the Gradle Tasks field → **Run** +3. After the build completes, right-click the root project → **Gradle → Refresh Gradle Project** -### Configure the Liberty with DB2 -This sample uses the [EMP table](https://www.ibm.com/docs/en/db2-for-zos/latest?topic=tables-employee-table-dsn8d10emp) provided with the [Db2 sample tables](https://www.ibm.com/docs/en/db2-for-zos/latest?topic=zos-db2-sample-tables). -Configure the JVM profile of the Liberty JVM server to include the Db2 driver location. -> [!TIP] -> There are several options to configuring the database schema. The following config defines the schema in the JVM profile, however, the schema can be defined directly in the datasource in the server.xml in the datasource properties element. Or it can be defined in the application code itself once setting a connection. +**With Maven (m2e):** +1. Right-click the root project → **Maven → Update Project...** → check **Force Update of Snapshots/Releases** → **OK** +2. Right-click the root project → **Run As → Maven build...** → enter `clean verify` → **Run** + +## Deploying to a CICS Liberty JVM server + +### Configure CICS for Db2 -> Note: The name of your JVM profile is assumed to be 'DFHWLP' +Configure the JVM profile of the Liberty JVM server to include the Db2 driver location: ``` -Dcom.ibm.cics.jvmserver.wlp.jdbc.driver.location=/usr/lpp/db2v13/jdbc -Ddb2.jcc.override.currentSchema=DBADMIN ``` -> Note: This example is using db2v13, this version must be consistent to the version set in your JCL. -As an example, see the provided [JVM profile template](etc/config/jvmprofile/DFHWLP.jvmprofile). If necessary, restart the JVM server. +See the provided [JVM profile template](etc/config/jvmprofile/DFHWLP.jvmprofile). Restart the JVM server after changes. -Ensure you have the following feature defined in your Liberty server.xml: -* `jdbc-4.3` +Ensure the following feature is defined in your Liberty `server.xml`: -A template server.xml is provided [here](./etc/config/liberty/server.xml). +```xml + + cicsts:core-1.0 + servlet-5.0 + jdbc-4.3 + +``` + +A template `server.xml` is provided [here](./etc/config/liberty/server.xml). -### Option 1 - Configure the DB2CONN with CEDA at a terminal +### Install a CICS DB2CONN resource -Ensure a CICS DB2CONN is installed and connected. +Ensure a CICS `DB2CONN` is installed and connected: ``` CEDA DEFINE DB2CONN(JODBCONN) GROUP(CDEVJLDB) -``` -``` CEDA INSTALL DB2CONN(JODBCONN) GROUP(CDEVJLDB) ``` -### Option 2 - Configure the DB2CONN with CICS Explorer -1. Definitions > Db2 > Db2 Connection Definitions -2. Right-click > New... -3. Fill in the Name and Group with `CDEVJLDB` -4. Right-click and install the new definition -5. Ensure it is CONNECTED +### CICS Bundle Plugin Deployment (Gradle/Maven) -> Note: The DB2ID differs between DB2 versions and the system you are running your CICS region on. Consult your CICS system programmer if you are unsure. +**Configure your JVM server name** (default is `DFHWLP`): +Gradle: +```shell +./gradlew clean build "-Pcics.jvmserver=MYJVM" +``` ---- - -## Deploying to CICS - -### Option 1 - Deploying using CICS Explorer SDK and the provided CICS bundle project -1. Deploy the CICS bundle project 'com.ibm.cics.server.examples.wlp.jdbc.bundle' from CICS Explorer using the **Export Bundle Project to z/OS UNIX File System** wizard. This CICS bundle includes the WAR bundlepart to run the sample. +Maven: +```shell +./mvnw clean verify "-Dcics.jvmserver=MYJVM" +``` +**Deploy the bundle:** -### Option 2 - Deploying using CICS Explorer SDK with own CICS bundle project -1. Copy and paste the built WAR from your *projects/cics-java-liberty-jdbc-web/target* or *projects/cics-java-liberty-jdbc-web/build/libs* directory into a new Eclipse CICS bundle project. -2. Create a new bundlepart that references the WAR file. -3. Optionally customise the CICS bundle contents, perhaps adding a TRANDEF of your choice -4. Right click using the ** Export Bundle Project to z/OS UNIX File System ** wizard. +1. Upload the CICS bundle ZIP to zFS: + - Gradle: `cics-java-liberty-jdbc-cicsbundle/build/distributions/` + - Maven: `cics-java-liberty-jdbc-cicsbundle/target/` +2. On z/OS, extract the bundle: + ```shell + jar xf cics-java-liberty-jdbc-cicsbundle.zip + ``` +3. Create and install a CICS BUNDLE resource definition pointing to the extracted directory: + ``` + CEDA DEFINE BUNDLE(JDBCBNDL) GROUP(CDEVJLDB) BUNDLEDIR(/path/to/bundle) + CEDA INSTALL BUNDLE(JDBCBNDL) GROUP(CDEVJLDB) + ``` +### CICS Explorer SDK Deployment -### Option 3 - Deploying using CICS Explorer (Remote System Explorer) and CICS Bundle ZIP -1. Connect to USS on the host system -2. Create the bundle directory for the project. -3. Copy & paste the built CICS bundle ZIP file from your *projects/cics-java-liberty-jdbc-bundle/target* or *projects/cics-java-liberty-jdbc-bundle/build/distributions* directory to z/FS on the host system into the bundle directory. -4. Extract the ZIP by right-clicking on the ZIP file > User Action > unjar... -5. Refresh the bundle directory +This repository includes a pre-configured Eclipse CICS bundle project `cics-java-liberty-jdbc-cicsbundle-eclipse`. +1. Right-click `cics-java-liberty-jdbc-cicsbundle-eclipse` → **Export Bundle Project to z/OS UNIX File System** and follow the wizard. -### Option 4 - Deploying using command line tools -1. Upload the built CICS bundle ZIP file from your *projects/cics-java-liberty-jdbc-bundle/target* or *projects/cics-java-liberty-jdbc-bundle/build/distributions* directory to z/FS on the host system (e.g. FTP). -2. Connect to USS on the host system (e.g. SSH). -3. Create the bundle directory for the project. -4. Move the CICS bundle ZIP file into the bundle directory. -5. Change directory into the bundle directoy. -6. Extract the CICS bundle ZIP file. This can be done using the `jar` command. For example: - ```shell - jar xf file.zip - ``` +### Direct Liberty Application Deployment ---- +1. Build the WAR using Gradle or Maven (see [Building the Sample](#building-the-sample)) +2. Upload the WAR file to zFS +3. Add an `` element to your Liberty `server.xml`: +```xml + + + + + + + +``` -## Running the sample -The servlet is accessed with the following URL: [http://zos.example.com:9080/cics-java-liberty-jdbc-web/database](http://zos.example.com:9080/cics-java-liberty-jdbc-web/database). +## Running the Sample -If the test is successful, you will see a response similar to the following written to the browser: +1. Verify the application started successfully in Liberty by checking for `CWWKT0016I` in `messages.log`: + ``` + CWWKT0016I: Web application available (default_host): http://hostname:9080/cics-java-liberty-jdbc/ + ``` +2. Test basic Db2 connectivity at: + `http://hostname:9080/cics-java-liberty-jdbc/database` -`Db2 current timestamp: 2024-01-01 09:30:00.000000.` + If successful, you will see a response like: + ``` + Db2 current timestamp: 2024-01-01 09:30:00.000000. + ``` +3. If the `EMP` table is available, access the full employee browser at: + `http://hostname:9080/cics-java-liberty-jdbc/` -If the EMP table is available, the full sample can be accessed with the following URL: [http://zos.example.com:9080/cics-java-liberty-jdbc-web/](http://zos.example.com:9080/cics-java-liberty-jdbc-web/). This is a HTML page that communicates with a servlet backend to display the employees in the EMP table. + This HTML page communicates with the servlet backend to display employees from the `EMP` table. +## Additional Resources -## Reference -* Sample SQLJ Git repository [cics-java-liberty-sqlj](https://github.com/cicsdev/cics-java-liberty-sqlj) -* CICS Knowledge Center [Configuring a Liberty JVM server](https://www.ibm.com/docs/en/cics-ts/latest?topic=server-configuring-liberty-jvm) -* CICS Knowledge Center [Configuring a JVM server to support Db2](https://www.ibm.com/docs/en/cics-ts/latest?topic=programs-configuring-jvm-server-support-db2) +- [CICS TS Documentation](https://www.ibm.com/docs/en/cics-ts) +- [WebSphere Liberty Documentation](https://www.ibm.com/docs/en/was-liberty) +- [Db2 EMP sample table](https://www.ibm.com/docs/en/db2-for-zos/latest?topic=tables-employee-table-dsn8d10emp) +- [Db2 sample tables](https://www.ibm.com/docs/en/db2-for-zos/latest?topic=zos-db2-sample-tables) ## License + This project is licensed under [Apache License Version 2.0](LICENSE). + +## Contributing + +This sample is maintained by IBM CICS development. We welcome bug reports and feature requests via GitHub Issues. Contributions are welcome and reviewed on a case-by-case basis — please read the [contributing guidelines](https://github.com/cicsdev/.github/blob/main/CONTRIBUTING.md) before opening a pull request. For CICS product questions, contact IBM Support. diff --git a/cics-java-liberty-jdbc-web/.classpath b/cics-java-liberty-jdbc-app/.classpath similarity index 58% rename from cics-java-liberty-jdbc-web/.classpath rename to cics-java-liberty-jdbc-app/.classpath index b31ced1..4998c2e 100644 --- a/cics-java-liberty-jdbc-web/.classpath +++ b/cics-java-liberty-jdbc-app/.classpath @@ -6,11 +6,21 @@ - + - + + + + + + + + + + + diff --git a/cics-java-liberty-jdbc-web/.gitignore b/cics-java-liberty-jdbc-app/.gitignore similarity index 100% rename from cics-java-liberty-jdbc-web/.gitignore rename to cics-java-liberty-jdbc-app/.gitignore diff --git a/cics-java-liberty-jdbc-web/.project b/cics-java-liberty-jdbc-app/.project similarity index 78% rename from cics-java-liberty-jdbc-web/.project rename to cics-java-liberty-jdbc-app/.project index 4b11f7f..be7e40f 100644 --- a/cics-java-liberty-jdbc-web/.project +++ b/cics-java-liberty-jdbc-app/.project @@ -1,6 +1,6 @@ - cics-java-liberty-jdbc-web + cics-java-liberty-jdbc-app @@ -30,16 +30,6 @@ - - org.eclipse.pde.ManifestBuilder - - - - - org.eclipse.pde.SchemaBuilder - - - org.eclipse.jdt.core.javanature @@ -48,6 +38,5 @@ org.eclipse.jem.workbench.JavaEMFNature org.eclipse.buildship.core.gradleprojectnature org.eclipse.m2e.core.maven2Nature - org.eclipse.pde.PluginNature diff --git a/cics-java-liberty-jdbc-web/.settings/.jsdtscope b/cics-java-liberty-jdbc-app/.settings/.jsdtscope similarity index 100% rename from cics-java-liberty-jdbc-web/.settings/.jsdtscope rename to cics-java-liberty-jdbc-app/.settings/.jsdtscope diff --git a/cics-java-liberty-jdbc-app/.settings/org.eclipse.buildship.core.prefs b/cics-java-liberty-jdbc-app/.settings/org.eclipse.buildship.core.prefs new file mode 100644 index 0000000..e889521 --- /dev/null +++ b/cics-java-liberty-jdbc-app/.settings/org.eclipse.buildship.core.prefs @@ -0,0 +1,2 @@ +connection.project.dir= +eclipse.preferences.version=1 diff --git a/cics-java-liberty-jdbc-web/.settings/org.eclipse.core.resources.prefs b/cics-java-liberty-jdbc-app/.settings/org.eclipse.core.resources.prefs similarity index 100% rename from cics-java-liberty-jdbc-web/.settings/org.eclipse.core.resources.prefs rename to cics-java-liberty-jdbc-app/.settings/org.eclipse.core.resources.prefs diff --git a/cics-java-liberty-jdbc-app/.settings/org.eclipse.jdt.apt.core.prefs b/cics-java-liberty-jdbc-app/.settings/org.eclipse.jdt.apt.core.prefs new file mode 100644 index 0000000..d4313d4 --- /dev/null +++ b/cics-java-liberty-jdbc-app/.settings/org.eclipse.jdt.apt.core.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.apt.aptEnabled=false diff --git a/cics-java-liberty-jdbc-app/.settings/org.eclipse.jdt.core.prefs b/cics-java-liberty-jdbc-app/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..62ef348 --- /dev/null +++ b/cics-java-liberty-jdbc-app/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,9 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=17 +org.eclipse.jdt.core.compiler.compliance=17 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning +org.eclipse.jdt.core.compiler.release=enabled +org.eclipse.jdt.core.compiler.source=17 diff --git a/cics-java-liberty-jdbc-web/.settings/org.eclipse.m2e.core.prefs b/cics-java-liberty-jdbc-app/.settings/org.eclipse.m2e.core.prefs similarity index 100% rename from cics-java-liberty-jdbc-web/.settings/org.eclipse.m2e.core.prefs rename to cics-java-liberty-jdbc-app/.settings/org.eclipse.m2e.core.prefs diff --git a/cics-java-liberty-jdbc-app/.settings/org.eclipse.wst.common.component b/cics-java-liberty-jdbc-app/.settings/org.eclipse.wst.common.component new file mode 100644 index 0000000..9bd01dc --- /dev/null +++ b/cics-java-liberty-jdbc-app/.settings/org.eclipse.wst.common.component @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/cics-java-liberty-jdbc-web/.settings/org.eclipse.wst.common.project.facet.core.xml b/cics-java-liberty-jdbc-app/.settings/org.eclipse.wst.common.project.facet.core.xml similarity index 100% rename from cics-java-liberty-jdbc-web/.settings/org.eclipse.wst.common.project.facet.core.xml rename to cics-java-liberty-jdbc-app/.settings/org.eclipse.wst.common.project.facet.core.xml index 55ca3dd..d7fa677 100644 --- a/cics-java-liberty-jdbc-web/.settings/org.eclipse.wst.common.project.facet.core.xml +++ b/cics-java-liberty-jdbc-app/.settings/org.eclipse.wst.common.project.facet.core.xml @@ -1,9 +1,9 @@ - + - + diff --git a/cics-java-liberty-jdbc-web/.settings/org.eclipse.wst.jsdt.ui.superType.container b/cics-java-liberty-jdbc-app/.settings/org.eclipse.wst.jsdt.ui.superType.container similarity index 100% rename from cics-java-liberty-jdbc-web/.settings/org.eclipse.wst.jsdt.ui.superType.container rename to cics-java-liberty-jdbc-app/.settings/org.eclipse.wst.jsdt.ui.superType.container diff --git a/cics-java-liberty-jdbc-web/.settings/org.eclipse.wst.jsdt.ui.superType.name b/cics-java-liberty-jdbc-app/.settings/org.eclipse.wst.jsdt.ui.superType.name similarity index 100% rename from cics-java-liberty-jdbc-web/.settings/org.eclipse.wst.jsdt.ui.superType.name rename to cics-java-liberty-jdbc-app/.settings/org.eclipse.wst.jsdt.ui.superType.name diff --git a/cics-java-liberty-jdbc-app/.settings/org.eclipse.wst.validation.prefs b/cics-java-liberty-jdbc-app/.settings/org.eclipse.wst.validation.prefs new file mode 100644 index 0000000..2e240e7 --- /dev/null +++ b/cics-java-liberty-jdbc-app/.settings/org.eclipse.wst.validation.prefs @@ -0,0 +1,10 @@ +DELEGATES_PREFERENCE=delegateValidatorList +USER_BUILD_PREFERENCE=enabledBuildValidatorList +USER_MANUAL_PREFERENCE=enabledManualValidatorList +USER_PREFERENCE=overrideGlobalPreferencestruedisableAllValidationfalseversion1.3.100.v202407180051 +disabled=06target +eclipse.preferences.version=1 +override=true +suspend=false +vals/org.eclipse.jst.j2ee.internal.classpathdep.ClasspathDependencyValidator/global=FF +vf.version=3 diff --git a/cics-java-liberty-jdbc-app/build.gradle b/cics-java-liberty-jdbc-app/build.gradle new file mode 100644 index 0000000..0845e5e --- /dev/null +++ b/cics-java-liberty-jdbc-app/build.gradle @@ -0,0 +1,55 @@ +plugins +{ + id 'java' + id 'eclipse' + id 'idea' + id 'war' +} + +group = 'com.ibm.cicsdev' +version = '1.0.0' + +java +{ + toolchain + { + languageVersion = JavaLanguageVersion.of(java_version) + } +} + +// If in Eclipse, add Javadoc to the local project classpath and pin WTP context root/facet +eclipse +{ + classpath + { + downloadJavadoc = true + } + // Ensures Gradle Refresh sets the WTP context-root and web facet version correctly. + wtp + { + facet + { + facet name: 'jst.web', version: '5.0' + } + component + { + contextPath = 'cics-java-liberty-jdbc' + } + } +} + +repositories +{ + mavenCentral() +} + +war +{ + archiveFileName = 'cics-java-liberty-jdbc.war' +} + +dependencies +{ + compileOnly 'jakarta.servlet:jakarta.servlet-api:5.0.0' + compileOnly 'jakarta.annotation:jakarta.annotation-api:2.0.0' +} diff --git a/cics-java-liberty-jdbc-web/build.properties b/cics-java-liberty-jdbc-app/build.properties similarity index 70% rename from cics-java-liberty-jdbc-web/build.properties rename to cics-java-liberty-jdbc-app/build.properties index d90a22f..ab399a7 100644 --- a/cics-java-liberty-jdbc-web/build.properties +++ b/cics-java-liberty-jdbc-app/build.properties @@ -4,4 +4,4 @@ web.content.dir = src/main/webapp jre.compilation.profile = JavaSE-17 -war.name = cics-java-liberty-jdbc-web.war \ No newline at end of file +war.name = cics-java-liberty-jdbc.war \ No newline at end of file diff --git a/cics-java-liberty-jdbc-web/pom.xml b/cics-java-liberty-jdbc-app/pom.xml similarity index 71% rename from cics-java-liberty-jdbc-web/pom.xml rename to cics-java-liberty-jdbc-app/pom.xml index 87ab130..d9a5984 100644 --- a/cics-java-liberty-jdbc-web/pom.xml +++ b/cics-java-liberty-jdbc-app/pom.xml @@ -2,7 +2,7 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 @@ -11,19 +11,20 @@ 1.0.0 - cics-java-liberty-jdbc-web + cics-java-liberty-jdbc-app war - CICS Liberty JDBC Application - Web + CICS Liberty JDBC Application - App This module exposes information from Db2 in a servlet. + cics-java-liberty-jdbc - org.apache.maven.plugins - maven-war-plugin - 3.4.0 - + org.apache.maven.plugins + maven-war-plugin + 3.4.0 + false @@ -46,4 +47,4 @@ provided - \ No newline at end of file + diff --git a/cics-java-liberty-jdbc-web/src/main/java/com/ibm/cicsdev/liberty/jdbc/DatabaseService.java b/cics-java-liberty-jdbc-app/src/main/java/com/ibm/cicsdev/liberty/jdbc/DatabaseService.java similarity index 100% rename from cics-java-liberty-jdbc-web/src/main/java/com/ibm/cicsdev/liberty/jdbc/DatabaseService.java rename to cics-java-liberty-jdbc-app/src/main/java/com/ibm/cicsdev/liberty/jdbc/DatabaseService.java diff --git a/cics-java-liberty-jdbc-web/src/main/java/com/ibm/cicsdev/liberty/jdbc/DatabaseServlet.java b/cics-java-liberty-jdbc-app/src/main/java/com/ibm/cicsdev/liberty/jdbc/DatabaseServlet.java similarity index 100% rename from cics-java-liberty-jdbc-web/src/main/java/com/ibm/cicsdev/liberty/jdbc/DatabaseServlet.java rename to cics-java-liberty-jdbc-app/src/main/java/com/ibm/cicsdev/liberty/jdbc/DatabaseServlet.java diff --git a/cics-java-liberty-jdbc-web/src/main/java/com/ibm/cicsdev/liberty/jdbc/employee/Employee.java b/cics-java-liberty-jdbc-app/src/main/java/com/ibm/cicsdev/liberty/jdbc/employee/Employee.java similarity index 100% rename from cics-java-liberty-jdbc-web/src/main/java/com/ibm/cicsdev/liberty/jdbc/employee/Employee.java rename to cics-java-liberty-jdbc-app/src/main/java/com/ibm/cicsdev/liberty/jdbc/employee/Employee.java diff --git a/cics-java-liberty-jdbc-web/src/main/java/com/ibm/cicsdev/liberty/jdbc/employee/EmployeeService.java b/cics-java-liberty-jdbc-app/src/main/java/com/ibm/cicsdev/liberty/jdbc/employee/EmployeeService.java similarity index 100% rename from cics-java-liberty-jdbc-web/src/main/java/com/ibm/cicsdev/liberty/jdbc/employee/EmployeeService.java rename to cics-java-liberty-jdbc-app/src/main/java/com/ibm/cicsdev/liberty/jdbc/employee/EmployeeService.java diff --git a/cics-java-liberty-jdbc-web/src/main/java/com/ibm/cicsdev/liberty/jdbc/employee/EmployeeServlet.java b/cics-java-liberty-jdbc-app/src/main/java/com/ibm/cicsdev/liberty/jdbc/employee/EmployeeServlet.java similarity index 100% rename from cics-java-liberty-jdbc-web/src/main/java/com/ibm/cicsdev/liberty/jdbc/employee/EmployeeServlet.java rename to cics-java-liberty-jdbc-app/src/main/java/com/ibm/cicsdev/liberty/jdbc/employee/EmployeeServlet.java diff --git a/cics-java-liberty-jdbc-app/src/main/webapp/WEB-INF/ibm-web-ext.xml b/cics-java-liberty-jdbc-app/src/main/webapp/WEB-INF/ibm-web-ext.xml new file mode 100644 index 0000000..97f2520 --- /dev/null +++ b/cics-java-liberty-jdbc-app/src/main/webapp/WEB-INF/ibm-web-ext.xml @@ -0,0 +1,8 @@ + + + + diff --git a/cics-java-liberty-jdbc-web/src/main/webapp/WEB-INF/web.xml b/cics-java-liberty-jdbc-app/src/main/webapp/WEB-INF/web.xml similarity index 100% rename from cics-java-liberty-jdbc-web/src/main/webapp/WEB-INF/web.xml rename to cics-java-liberty-jdbc-app/src/main/webapp/WEB-INF/web.xml diff --git a/cics-java-liberty-jdbc-web/src/main/webapp/favicon-32x32.png b/cics-java-liberty-jdbc-app/src/main/webapp/favicon-32x32.png similarity index 100% rename from cics-java-liberty-jdbc-web/src/main/webapp/favicon-32x32.png rename to cics-java-liberty-jdbc-app/src/main/webapp/favicon-32x32.png diff --git a/cics-java-liberty-jdbc-web/src/main/webapp/index.html b/cics-java-liberty-jdbc-app/src/main/webapp/index.html similarity index 100% rename from cics-java-liberty-jdbc-web/src/main/webapp/index.html rename to cics-java-liberty-jdbc-app/src/main/webapp/index.html diff --git a/cics-java-liberty-jdbc-web/src/main/webapp/scripts/employee.js b/cics-java-liberty-jdbc-app/src/main/webapp/scripts/employee.js similarity index 100% rename from cics-java-liberty-jdbc-web/src/main/webapp/scripts/employee.js rename to cics-java-liberty-jdbc-app/src/main/webapp/scripts/employee.js diff --git a/cics-java-liberty-jdbc-web/src/main/webapp/styles/cics.css b/cics-java-liberty-jdbc-app/src/main/webapp/styles/cics.css similarity index 100% rename from cics-java-liberty-jdbc-web/src/main/webapp/styles/cics.css rename to cics-java-liberty-jdbc-app/src/main/webapp/styles/cics.css diff --git a/cics-java-liberty-jdbc-bundle/.settings/org.eclipse.buildship.core.prefs b/cics-java-liberty-jdbc-bundle/.settings/org.eclipse.buildship.core.prefs deleted file mode 100644 index 9d10e56..0000000 --- a/cics-java-liberty-jdbc-bundle/.settings/org.eclipse.buildship.core.prefs +++ /dev/null @@ -1,13 +0,0 @@ -arguments= -auto.sync=false -build.scans.enabled=false -connection.gradle.distribution=GRADLE_DISTRIBUTION(WRAPPER) -connection.project.dir=../cics-java-liberty-jdbc-web -eclipse.preferences.version=1 -gradle.user.home= -java.home= -jvm.arguments= -offline.mode=false -override.workspace.settings=false -show.console.view=false -show.executions.view=false \ No newline at end of file diff --git a/cics-java-liberty-jdbc-bundle/build.gradle b/cics-java-liberty-jdbc-bundle/build.gradle deleted file mode 100644 index ed6f4b6..0000000 --- a/cics-java-liberty-jdbc-bundle/build.gradle +++ /dev/null @@ -1,16 +0,0 @@ -plugins { - id 'com.ibm.cics.bundle' version "1.0.7" -} - -dependencies { - cicsBundlePart project(path: ':cics-java-liberty-jdbc-web', configuration: 'archives') -} - -cicsBundle { - build { - defaultJVMServer = project.findProperty("cics.jvmserver") ?: "DFHWLP" - } -} - -description = 'CICS Liberty JDBC Application - CICS Bundle' -version = "1.0.0" \ No newline at end of file diff --git a/etc/eclipse_projects/com.ibm.cicsdev.jdbc.web.cicsbundle/.project b/cics-java-liberty-jdbc-cicsbundle-eclipse/.project similarity index 76% rename from etc/eclipse_projects/com.ibm.cicsdev.jdbc.web.cicsbundle/.project rename to cics-java-liberty-jdbc-cicsbundle-eclipse/.project index dc61d40..d64e495 100644 --- a/etc/eclipse_projects/com.ibm.cicsdev.jdbc.web.cicsbundle/.project +++ b/cics-java-liberty-jdbc-cicsbundle-eclipse/.project @@ -1,6 +1,6 @@ - com.ibm.cics.server.examples.wlp.jdbc.bundle + cics-java-liberty-jdbc-cicsbundle-eclipse @@ -10,19 +10,19 @@ bundleID - com.ibm.cics.server.examples.wlp.jdbc.bundle + cics-java-liberty-jdbc-bundle majorVersion - + 1 microVersion - + 0 minorVersion - + 0 diff --git a/cics-java-liberty-jdbc-bundle/.settings/org.eclipse.core.resources.prefs b/cics-java-liberty-jdbc-cicsbundle-eclipse/.settings/org.eclipse.core.resources.prefs similarity index 100% rename from cics-java-liberty-jdbc-bundle/.settings/org.eclipse.core.resources.prefs rename to cics-java-liberty-jdbc-cicsbundle-eclipse/.settings/org.eclipse.core.resources.prefs diff --git a/etc/eclipse_projects/com.ibm.cicsdev.jdbc.web.cicsbundle/META-INF/cics.xml b/cics-java-liberty-jdbc-cicsbundle-eclipse/META-INF/cics.xml similarity index 57% rename from etc/eclipse_projects/com.ibm.cicsdev.jdbc.web.cicsbundle/META-INF/cics.xml rename to cics-java-liberty-jdbc-cicsbundle-eclipse/META-INF/cics.xml index 135c44e..6279e13 100644 --- a/etc/eclipse_projects/com.ibm.cicsdev.jdbc.web.cicsbundle/META-INF/cics.xml +++ b/cics-java-liberty-jdbc-cicsbundle-eclipse/META-INF/cics.xml @@ -1,7 +1,7 @@ - + 2017-08-01T09:50:06.715+01:00 - + diff --git a/cics-java-liberty-jdbc-cicsbundle-eclipse/cics-java-liberty-jdbc-app.warbundle b/cics-java-liberty-jdbc-cicsbundle-eclipse/cics-java-liberty-jdbc-app.warbundle new file mode 100644 index 0000000..03daa77 --- /dev/null +++ b/cics-java-liberty-jdbc-cicsbundle-eclipse/cics-java-liberty-jdbc-app.warbundle @@ -0,0 +1,2 @@ + + diff --git a/cics-java-liberty-jdbc-bundle/.project b/cics-java-liberty-jdbc-cicsbundle/.project similarity index 91% rename from cics-java-liberty-jdbc-bundle/.project rename to cics-java-liberty-jdbc-cicsbundle/.project index fe73fe3..c7c9c96 100644 --- a/cics-java-liberty-jdbc-bundle/.project +++ b/cics-java-liberty-jdbc-cicsbundle/.project @@ -1,6 +1,6 @@ - cics-java-liberty-jdbc-bundle + cics-java-liberty-jdbc-cicsbundle diff --git a/cics-java-liberty-jdbc-cicsbundle/.settings/org.eclipse.buildship.core.prefs b/cics-java-liberty-jdbc-cicsbundle/.settings/org.eclipse.buildship.core.prefs new file mode 100644 index 0000000..e889521 --- /dev/null +++ b/cics-java-liberty-jdbc-cicsbundle/.settings/org.eclipse.buildship.core.prefs @@ -0,0 +1,2 @@ +connection.project.dir= +eclipse.preferences.version=1 diff --git a/cics-java-liberty-jdbc-cicsbundle/.settings/org.eclipse.core.resources.prefs b/cics-java-liberty-jdbc-cicsbundle/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 0000000..99f26c0 --- /dev/null +++ b/cics-java-liberty-jdbc-cicsbundle/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +encoding/=UTF-8 diff --git a/cics-java-liberty-jdbc-bundle/.settings/org.eclipse.ltk.core.refactoring.prefs b/cics-java-liberty-jdbc-cicsbundle/.settings/org.eclipse.ltk.core.refactoring.prefs similarity index 100% rename from cics-java-liberty-jdbc-bundle/.settings/org.eclipse.ltk.core.refactoring.prefs rename to cics-java-liberty-jdbc-cicsbundle/.settings/org.eclipse.ltk.core.refactoring.prefs diff --git a/cics-java-liberty-jdbc-cicsbundle/build.gradle b/cics-java-liberty-jdbc-cicsbundle/build.gradle new file mode 100644 index 0000000..228c5ae --- /dev/null +++ b/cics-java-liberty-jdbc-cicsbundle/build.gradle @@ -0,0 +1,20 @@ +plugins +{ + id 'com.ibm.cics.bundle' version '1.0.8' +} + +description = 'CICS Enterprise Java Program - CICS Bundle' +version = "1.0.0" + +dependencies +{ + cicsBundlePart project(path: ':cics-java-liberty-jdbc-app', configuration: 'archives') +} + +cicsBundle +{ + build + { + defaultJVMServer = project.findProperty("cics.jvmserver") ?: "DFHWLP" + } +} diff --git a/cics-java-liberty-jdbc-bundle/pom.xml b/cics-java-liberty-jdbc-cicsbundle/pom.xml similarity index 50% rename from cics-java-liberty-jdbc-bundle/pom.xml rename to cics-java-liberty-jdbc-cicsbundle/pom.xml index 4ef1bef..f29e030 100644 --- a/cics-java-liberty-jdbc-bundle/pom.xml +++ b/cics-java-liberty-jdbc-cicsbundle/pom.xml @@ -2,7 +2,7 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 @@ -11,33 +11,31 @@ 1.0.0 - cics-java-liberty-jdbc-bundle - + cics-java-liberty-jdbc-cicsbundle CICS Liberty JDBC Application - CICS Bundle - This module packages the web module into a CICS bundle. - + cics-bundle ${project.groupId} - cics-java-liberty-jdbc-web + cics-java-liberty-jdbc-app ${project.version} war - - - com.ibm.cics - cics-bundle-maven-plugin - 1.0.7 - true - - ${cics.jvmserver} - - - + + + com.ibm.cics + cics-bundle-maven-plugin + 1.0.8 + true + + ${cics.jvmserver} + + + - \ No newline at end of file + diff --git a/cics-java-liberty-jdbc-web/.settings/org.eclipse.buildship.core.prefs b/cics-java-liberty-jdbc-web/.settings/org.eclipse.buildship.core.prefs deleted file mode 100644 index 60b1463..0000000 --- a/cics-java-liberty-jdbc-web/.settings/org.eclipse.buildship.core.prefs +++ /dev/null @@ -1,13 +0,0 @@ -arguments= -auto.sync=false -build.scans.enabled=false -connection.gradle.distribution=GRADLE_DISTRIBUTION(WRAPPER) -connection.project.dir= -eclipse.preferences.version=1 -gradle.user.home= -java.home= -jvm.arguments= -offline.mode=false -override.workspace.settings=false -show.console.view=false -show.executions.view=false \ No newline at end of file diff --git a/cics-java-liberty-jdbc-web/.settings/org.eclipse.jdt.apt.core.prefs b/cics-java-liberty-jdbc-web/.settings/org.eclipse.jdt.apt.core.prefs deleted file mode 100644 index f07424f..0000000 --- a/cics-java-liberty-jdbc-web/.settings/org.eclipse.jdt.apt.core.prefs +++ /dev/null @@ -1,5 +0,0 @@ -eclipse.preferences.version=1 -org.eclipse.jdt.apt.aptEnabled=false -org.eclipse.jdt.apt.genSrcDir=.apt_generated -org.eclipse.jdt.apt.genTestSrcDir=.apt_generated_tests -org.eclipse.jdt.apt.reconcileEnabled=true diff --git a/cics-java-liberty-jdbc-web/.settings/org.eclipse.jdt.core.prefs b/cics-java-liberty-jdbc-web/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index 5d2740f..0000000 --- a/cics-java-liberty-jdbc-web/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,15 +0,0 @@ -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate -org.eclipse.jdt.core.compiler.codegen.targetPlatform=17 -org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=17 -org.eclipse.jdt.core.compiler.debug.lineNumber=generate -org.eclipse.jdt.core.compiler.debug.localVariable=generate -org.eclipse.jdt.core.compiler.debug.sourceFile=generate -org.eclipse.jdt.core.compiler.problem.assertIdentifier=error -org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled -org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning -org.eclipse.jdt.core.compiler.release=disabled -org.eclipse.jdt.core.compiler.source=17 \ No newline at end of file diff --git a/cics-java-liberty-jdbc-web/.settings/org.eclipse.wst.common.component b/cics-java-liberty-jdbc-web/.settings/org.eclipse.wst.common.component deleted file mode 100644 index 0d23bd7..0000000 --- a/cics-java-liberty-jdbc-web/.settings/org.eclipse.wst.common.component +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/cics-java-liberty-jdbc-web/build.gradle b/cics-java-liberty-jdbc-web/build.gradle deleted file mode 100644 index fe3c236..0000000 --- a/cics-java-liberty-jdbc-web/build.gradle +++ /dev/null @@ -1,34 +0,0 @@ -plugins -{ - id 'java' - id 'eclipse' - id 'idea' - id 'war' -} - -group = 'com.ibm.cicsdev' -archivesBaseName='cics-java-liberty-jdbc' -version = '1.0.0' - - -// If in Eclipse, add Javadoc to the local project classpath -eclipse -{ - classpath - { - downloadJavadoc = true - } -} - - -repositories -{ - mavenCentral() -} - - -dependencies -{ - compileOnly 'jakarta.servlet:jakarta.servlet-api:5.0.0' - compileOnly 'jakarta.annotation:jakarta.annotation-api:2.0.0' -} diff --git a/etc/config/liberty/db2/type2.xml b/etc/config/liberty/db2/type2.xml index 29c5bd0..d24cc70 100644 --- a/etc/config/liberty/db2/type2.xml +++ b/etc/config/liberty/db2/type2.xml @@ -2,7 +2,8 @@ - + diff --git a/etc/eclipse_projects/com.ibm.cicsdev.jdbc.web.cicsbundle/.settings/org.eclipse.core.resources.prefs b/etc/eclipse_projects/com.ibm.cicsdev.jdbc.web.cicsbundle/.settings/org.eclipse.core.resources.prefs deleted file mode 100644 index 692386a..0000000 --- a/etc/eclipse_projects/com.ibm.cicsdev.jdbc.web.cicsbundle/.settings/org.eclipse.core.resources.prefs +++ /dev/null @@ -1,4 +0,0 @@ -eclipse.preferences.version=1 -encoding//META-INF/cics.xml=UTF-8 -encoding/=UTF-8 -encoding/cics-java-liberty-jdbc-web.warbundle=UTF-8 diff --git a/etc/eclipse_projects/com.ibm.cicsdev.jdbc.web.cicsbundle/cics-java-liberty-jdbc-web.warbundle b/etc/eclipse_projects/com.ibm.cicsdev.jdbc.web.cicsbundle/cics-java-liberty-jdbc-web.warbundle deleted file mode 100644 index 72f3b77..0000000 --- a/etc/eclipse_projects/com.ibm.cicsdev.jdbc.web.cicsbundle/cics-java-liberty-jdbc-web.warbundle +++ /dev/null @@ -1,2 +0,0 @@ - - \ No newline at end of file diff --git a/gradle.properties b/gradle.properties new file mode 100644 index 0000000..b9f0618 --- /dev/null +++ b/gradle.properties @@ -0,0 +1,13 @@ +java_version = 17 + +# Gradle daemon and parallel builds for better performance +org.gradle.daemon=true +org.gradle.parallel=true + +# Enable toolchain auto-provisioning to download JDKs if not found locally +# This allows builds to work even if the specific Java version isn't installed +org.gradle.java.installations.auto-detect=true +org.gradle.java.installations.auto-download=true + +# Configuration cache disabled due to CICS Bundle Plugin 1.0.8 incompatibility +# org.gradle.configuration-cache=true diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index a4b76b9..d64cd49 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index a80b22c..03b32a2 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,7 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip -networkTimeout=10000 -validateDistributionUrl=true +distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.4-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew index f5feea6..1aa94a4 100755 --- a/gradlew +++ b/gradlew @@ -15,8 +15,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # -# SPDX-License-Identifier: Apache-2.0 -# ############################################################################## # @@ -57,7 +55,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -86,8 +84,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s -' "$PWD" ) || exit +APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum diff --git a/gradlew.bat b/gradlew.bat index 9b42019..7101f8e 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -13,8 +13,6 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem -@rem SPDX-License-Identifier: Apache-2.0 -@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## diff --git a/mvnw b/mvnw index 41c0f0c..bd8896b 100755 --- a/mvnw +++ b/mvnw @@ -19,292 +19,277 @@ # ---------------------------------------------------------------------------- # ---------------------------------------------------------------------------- -# Maven Start Up Batch script -# -# Required ENV vars: -# ------------------ -# JAVA_HOME - location of a JDK home dir +# Apache Maven Wrapper startup batch script, version 3.3.4 # # Optional ENV vars # ----------------- -# M2_HOME - location of maven2's installed home dir -# MAVEN_OPTS - parameters passed to the Java VM when running Maven -# e.g. to debug Maven itself, use -# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 -# MAVEN_SKIP_RC - flag to disable loading of mavenrc files +# JAVA_HOME - location of a JDK home dir, required when download maven via java source +# MVNW_REPOURL - repo url base for downloading maven distribution +# MVNW_USERNAME/MVNW_PASSWORD - user and password for downloading maven +# MVNW_VERBOSE - true: enable verbose log; debug: trace the mvnw script; others: silence the output # ---------------------------------------------------------------------------- -if [ -z "$MAVEN_SKIP_RC" ] ; then - - if [ -f /etc/mavenrc ] ; then - . /etc/mavenrc - fi +set -euf +[ "${MVNW_VERBOSE-}" != debug ] || set -x - if [ -f "$HOME/.mavenrc" ] ; then - . "$HOME/.mavenrc" - fi +# OS specific support. +native_path() { printf %s\\n "$1"; } +case "$(uname)" in +CYGWIN* | MINGW*) + [ -z "${JAVA_HOME-}" ] || JAVA_HOME="$(cygpath --unix "$JAVA_HOME")" + native_path() { cygpath --path --windows "$1"; } + ;; +esac -fi +# set JAVACMD and JAVACCMD +set_java_home() { + # For Cygwin and MinGW, ensure paths are in Unix format before anything is touched + if [ -n "${JAVA_HOME-}" ]; then + if [ -x "$JAVA_HOME/jre/sh/java" ]; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + JAVACCMD="$JAVA_HOME/jre/sh/javac" + else + JAVACMD="$JAVA_HOME/bin/java" + JAVACCMD="$JAVA_HOME/bin/javac" -# OS specific support. $var _must_ be set to either true or false. -cygwin=false; -darwin=false; -mingw=false -case "`uname`" in - CYGWIN*) cygwin=true ;; - MINGW*) mingw=true;; - Darwin*) darwin=true - # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home - # See https://developer.apple.com/library/mac/qa/qa1170/_index.html - if [ -z "$JAVA_HOME" ]; then - if [ -x "/usr/libexec/java_home" ]; then - export JAVA_HOME="`/usr/libexec/java_home`" - else - export JAVA_HOME="/Library/Java/Home" + if [ ! -x "$JAVACMD" ] || [ ! -x "$JAVACCMD" ]; then + echo "The JAVA_HOME environment variable is not defined correctly, so mvnw cannot run." >&2 + echo "JAVA_HOME is set to \"$JAVA_HOME\", but \"\$JAVA_HOME/bin/java\" or \"\$JAVA_HOME/bin/javac\" does not exist." >&2 + return 1 fi fi - ;; -esac - -if [ -z "$JAVA_HOME" ] ; then - if [ -r /etc/gentoo-release ] ; then - JAVA_HOME=`java-config --jre-home` + else + JAVACMD="$( + 'set' +e + 'unset' -f command 2>/dev/null + 'command' -v java + )" || : + JAVACCMD="$( + 'set' +e + 'unset' -f command 2>/dev/null + 'command' -v javac + )" || : + + if [ ! -x "${JAVACMD-}" ] || [ ! -x "${JAVACCMD-}" ]; then + echo "The java/javac command does not exist in PATH nor is JAVA_HOME set, so mvnw cannot run." >&2 + return 1 + fi fi -fi - -if [ -z "$M2_HOME" ] ; then - ## resolve links - $0 may be a link to maven's home - PRG="$0" +} - # need this for relative symlinks - while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG="`dirname "$PRG"`/$link" - fi +# hash string like Java String::hashCode +hash_string() { + str="${1:-}" h=0 + while [ -n "$str" ]; do + char="${str%"${str#?}"}" + h=$(((h * 31 + $(LC_CTYPE=C printf %d "'$char")) % 4294967296)) + str="${str#?}" done + printf %x\\n $h +} - saveddir=`pwd` +verbose() { :; } +[ "${MVNW_VERBOSE-}" != true ] || verbose() { printf %s\\n "${1-}"; } - M2_HOME=`dirname "$PRG"`/.. +die() { + printf %s\\n "$1" >&2 + exit 1 +} - # make it fully qualified - M2_HOME=`cd "$M2_HOME" && pwd` +trim() { + # MWRAPPER-139: + # Trims trailing and leading whitespace, carriage returns, tabs, and linefeeds. + # Needed for removing poorly interpreted newline sequences when running in more + # exotic environments such as mingw bash on Windows. + printf "%s" "${1}" | tr -d '[:space:]' +} - cd "$saveddir" - # echo Using m2 at $M2_HOME -fi +scriptDir="$(dirname "$0")" +scriptName="$(basename "$0")" + +# parse distributionUrl and optional distributionSha256Sum, requires .mvn/wrapper/maven-wrapper.properties +while IFS="=" read -r key value; do + case "${key-}" in + distributionUrl) distributionUrl=$(trim "${value-}") ;; + distributionSha256Sum) distributionSha256Sum=$(trim "${value-}") ;; + esac +done <"$scriptDir/.mvn/wrapper/maven-wrapper.properties" +[ -n "${distributionUrl-}" ] || die "cannot read distributionUrl property in $scriptDir/.mvn/wrapper/maven-wrapper.properties" + +case "${distributionUrl##*/}" in +maven-mvnd-*bin.*) + MVN_CMD=mvnd.sh _MVNW_REPO_PATTERN=/maven/mvnd/ + case "${PROCESSOR_ARCHITECTURE-}${PROCESSOR_ARCHITEW6432-}:$(uname -a)" in + *AMD64:CYGWIN* | *AMD64:MINGW*) distributionPlatform=windows-amd64 ;; + :Darwin*x86_64) distributionPlatform=darwin-amd64 ;; + :Darwin*arm64) distributionPlatform=darwin-aarch64 ;; + :Linux*x86_64*) distributionPlatform=linux-amd64 ;; + *) + echo "Cannot detect native platform for mvnd on $(uname)-$(uname -m), use pure java version" >&2 + distributionPlatform=linux-amd64 + ;; + esac + distributionUrl="${distributionUrl%-bin.*}-$distributionPlatform.zip" + ;; +maven-mvnd-*) MVN_CMD=mvnd.sh _MVNW_REPO_PATTERN=/maven/mvnd/ ;; +*) MVN_CMD="mvn${scriptName#mvnw}" _MVNW_REPO_PATTERN=/org/apache/maven/ ;; +esac -# For Cygwin, ensure paths are in UNIX format before anything is touched -if $cygwin ; then - [ -n "$M2_HOME" ] && - M2_HOME=`cygpath --unix "$M2_HOME"` - [ -n "$JAVA_HOME" ] && - JAVA_HOME=`cygpath --unix "$JAVA_HOME"` - [ -n "$CLASSPATH" ] && - CLASSPATH=`cygpath --path --unix "$CLASSPATH"` -fi +# apply MVNW_REPOURL and calculate MAVEN_HOME +# maven home pattern: ~/.m2/wrapper/dists/{apache-maven-,maven-mvnd--}/ +[ -z "${MVNW_REPOURL-}" ] || distributionUrl="$MVNW_REPOURL$_MVNW_REPO_PATTERN${distributionUrl#*"$_MVNW_REPO_PATTERN"}" +distributionUrlName="${distributionUrl##*/}" +distributionUrlNameMain="${distributionUrlName%.*}" +distributionUrlNameMain="${distributionUrlNameMain%-bin}" +MAVEN_USER_HOME="${MAVEN_USER_HOME:-${HOME}/.m2}" +MAVEN_HOME="${MAVEN_USER_HOME}/wrapper/dists/${distributionUrlNameMain-}/$(hash_string "$distributionUrl")" + +exec_maven() { + unset MVNW_VERBOSE MVNW_USERNAME MVNW_PASSWORD MVNW_REPOURL || : + exec "$MAVEN_HOME/bin/$MVN_CMD" "$@" || die "cannot exec $MAVEN_HOME/bin/$MVN_CMD" +} -# For Mingw, ensure paths are in UNIX format before anything is touched -if $mingw ; then - [ -n "$M2_HOME" ] && - M2_HOME="`(cd "$M2_HOME"; pwd)`" - [ -n "$JAVA_HOME" ] && - JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" +if [ -d "$MAVEN_HOME" ]; then + verbose "found existing MAVEN_HOME at $MAVEN_HOME" + exec_maven "$@" fi -if [ -z "$JAVA_HOME" ]; then - javaExecutable="`which javac`" - if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then - # readlink(1) is not available as standard on Solaris 10. - readLink=`which readlink` - if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then - if $darwin ; then - javaHome="`dirname \"$javaExecutable\"`" - javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" - else - javaExecutable="`readlink -f \"$javaExecutable\"`" - fi - javaHome="`dirname \"$javaExecutable\"`" - javaHome=`expr "$javaHome" : '\(.*\)/bin'` - JAVA_HOME="$javaHome" - export JAVA_HOME - fi - fi -fi +case "${distributionUrl-}" in +*?-bin.zip | *?maven-mvnd-?*-?*.zip) ;; +*) die "distributionUrl is not valid, must match *-bin.zip or maven-mvnd-*.zip, but found '${distributionUrl-}'" ;; +esac -if [ -z "$JAVACMD" ] ; then - if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" - else - JAVACMD="$JAVA_HOME/bin/java" - fi - else - JAVACMD="`which java`" - fi +# prepare tmp dir +if TMP_DOWNLOAD_DIR="$(mktemp -d)" && [ -d "$TMP_DOWNLOAD_DIR" ]; then + clean() { rm -rf -- "$TMP_DOWNLOAD_DIR"; } + trap clean HUP INT TERM EXIT +else + die "cannot create temp dir" fi -if [ ! -x "$JAVACMD" ] ; then - echo "Error: JAVA_HOME is not defined correctly." >&2 - echo " We cannot execute $JAVACMD" >&2 - exit 1 -fi +mkdir -p -- "${MAVEN_HOME%/*}" -if [ -z "$JAVA_HOME" ] ; then - echo "Warning: JAVA_HOME environment variable is not set." +# Download and Install Apache Maven +verbose "Couldn't find MAVEN_HOME, downloading and installing it ..." +verbose "Downloading from: $distributionUrl" +verbose "Downloading to: $TMP_DOWNLOAD_DIR/$distributionUrlName" + +# select .zip or .tar.gz +if ! command -v unzip >/dev/null; then + distributionUrl="${distributionUrl%.zip}.tar.gz" + distributionUrlName="${distributionUrl##*/}" fi -CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher +# verbose opt +__MVNW_QUIET_WGET=--quiet __MVNW_QUIET_CURL=--silent __MVNW_QUIET_UNZIP=-q __MVNW_QUIET_TAR='' +[ "${MVNW_VERBOSE-}" != true ] || __MVNW_QUIET_WGET='' __MVNW_QUIET_CURL='' __MVNW_QUIET_UNZIP='' __MVNW_QUIET_TAR=v -# traverses directory structure from process work directory to filesystem root -# first directory with .mvn subdirectory is considered project base directory -find_maven_basedir() { +# normalize http auth +case "${MVNW_PASSWORD:+has-password}" in +'') MVNW_USERNAME='' MVNW_PASSWORD='' ;; +has-password) [ -n "${MVNW_USERNAME-}" ] || MVNW_USERNAME='' MVNW_PASSWORD='' ;; +esac - if [ -z "$1" ] - then - echo "Path not specified to find_maven_basedir" - return 1 - fi +if [ -z "${MVNW_USERNAME-}" ] && command -v wget >/dev/null; then + verbose "Found wget ... using wget" + wget ${__MVNW_QUIET_WGET:+"$__MVNW_QUIET_WGET"} "$distributionUrl" -O "$TMP_DOWNLOAD_DIR/$distributionUrlName" || die "wget: Failed to fetch $distributionUrl" +elif [ -z "${MVNW_USERNAME-}" ] && command -v curl >/dev/null; then + verbose "Found curl ... using curl" + curl ${__MVNW_QUIET_CURL:+"$__MVNW_QUIET_CURL"} -f -L -o "$TMP_DOWNLOAD_DIR/$distributionUrlName" "$distributionUrl" || die "curl: Failed to fetch $distributionUrl" +elif set_java_home; then + verbose "Falling back to use Java to download" + javaSource="$TMP_DOWNLOAD_DIR/Downloader.java" + targetZip="$TMP_DOWNLOAD_DIR/$distributionUrlName" + cat >"$javaSource" <<-END + public class Downloader extends java.net.Authenticator + { + protected java.net.PasswordAuthentication getPasswordAuthentication() + { + return new java.net.PasswordAuthentication( System.getenv( "MVNW_USERNAME" ), System.getenv( "MVNW_PASSWORD" ).toCharArray() ); + } + public static void main( String[] args ) throws Exception + { + setDefault( new Downloader() ); + java.nio.file.Files.copy( java.net.URI.create( args[0] ).toURL().openStream(), java.nio.file.Paths.get( args[1] ).toAbsolutePath().normalize() ); + } + } + END + # For Cygwin/MinGW, switch paths to Windows format before running javac and java + verbose " - Compiling Downloader.java ..." + "$(native_path "$JAVACCMD")" "$(native_path "$javaSource")" || die "Failed to compile Downloader.java" + verbose " - Running Downloader.java ..." + "$(native_path "$JAVACMD")" -cp "$(native_path "$TMP_DOWNLOAD_DIR")" Downloader "$distributionUrl" "$(native_path "$targetZip")" +fi - basedir="$1" - wdir="$1" - while [ "$wdir" != '/' ] ; do - if [ -d "$wdir"/.mvn ] ; then - basedir=$wdir - break +# If specified, validate the SHA-256 sum of the Maven distribution zip file +if [ -n "${distributionSha256Sum-}" ]; then + distributionSha256Result=false + if [ "$MVN_CMD" = mvnd.sh ]; then + echo "Checksum validation is not supported for maven-mvnd." >&2 + echo "Please disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties." >&2 + exit 1 + elif command -v sha256sum >/dev/null; then + if echo "$distributionSha256Sum $TMP_DOWNLOAD_DIR/$distributionUrlName" | sha256sum -c - >/dev/null 2>&1; then + distributionSha256Result=true fi - # workaround for JBEAP-8937 (on Solaris 10/Sparc) - if [ -d "${wdir}" ]; then - wdir=`cd "$wdir/.."; pwd` + elif command -v shasum >/dev/null; then + if echo "$distributionSha256Sum $TMP_DOWNLOAD_DIR/$distributionUrlName" | shasum -a 256 -c >/dev/null 2>&1; then + distributionSha256Result=true fi - # end of workaround - done - echo "${basedir}" -} - -# concatenates all lines of a file -concat_lines() { - if [ -f "$1" ]; then - echo "$(tr -s '\n' ' ' < "$1")" + else + echo "Checksum validation was requested but neither 'sha256sum' or 'shasum' are available." >&2 + echo "Please install either command, or disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties." >&2 + exit 1 + fi + if [ $distributionSha256Result = false ]; then + echo "Error: Failed to validate Maven distribution SHA-256, your Maven distribution might be compromised." >&2 + echo "If you updated your Maven version, you need to update the specified distributionSha256Sum property." >&2 + exit 1 fi -} - -BASE_DIR=`find_maven_basedir "$(pwd)"` -if [ -z "$BASE_DIR" ]; then - exit 1; fi -########################################################################################## -# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central -# This allows using the maven wrapper in projects that prohibit checking in binary data. -########################################################################################## -if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then - if [ "$MVNW_VERBOSE" = true ]; then - echo "Found .mvn/wrapper/maven-wrapper.jar" - fi +# unzip and move +if command -v unzip >/dev/null; then + unzip ${__MVNW_QUIET_UNZIP:+"$__MVNW_QUIET_UNZIP"} "$TMP_DOWNLOAD_DIR/$distributionUrlName" -d "$TMP_DOWNLOAD_DIR" || die "failed to unzip" else - if [ "$MVNW_VERBOSE" = true ]; then - echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..." - fi - if [ -n "$MVNW_REPOURL" ]; then - jarUrl="$MVNW_REPOURL/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" - else - jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" - fi - while IFS="=" read key value; do - case "$key" in (wrapperUrl) jarUrl="$value"; break ;; - esac - done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties" - if [ "$MVNW_VERBOSE" = true ]; then - echo "Downloading from: $jarUrl" - fi - wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" - if $cygwin; then - wrapperJarPath=`cygpath --path --windows "$wrapperJarPath"` - fi + tar xzf${__MVNW_QUIET_TAR:+"$__MVNW_QUIET_TAR"} "$TMP_DOWNLOAD_DIR/$distributionUrlName" -C "$TMP_DOWNLOAD_DIR" || die "failed to untar" +fi - if command -v wget > /dev/null; then - if [ "$MVNW_VERBOSE" = true ]; then - echo "Found wget ... using wget" - fi - if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then - wget "$jarUrl" -O "$wrapperJarPath" - else - wget --http-user=$MVNW_USERNAME --http-password=$MVNW_PASSWORD "$jarUrl" -O "$wrapperJarPath" - fi - elif command -v curl > /dev/null; then - if [ "$MVNW_VERBOSE" = true ]; then - echo "Found curl ... using curl" - fi - if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then - curl -o "$wrapperJarPath" "$jarUrl" -f - else - curl --user $MVNW_USERNAME:$MVNW_PASSWORD -o "$wrapperJarPath" "$jarUrl" -f - fi +# Find the actual extracted directory name (handles snapshots where filename != directory name) +actualDistributionDir="" - else - if [ "$MVNW_VERBOSE" = true ]; then - echo "Falling back to using Java to download" - fi - javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java" - # For Cygwin, switch paths to Windows format before running javac - if $cygwin; then - javaClass=`cygpath --path --windows "$javaClass"` - fi - if [ -e "$javaClass" ]; then - if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then - if [ "$MVNW_VERBOSE" = true ]; then - echo " - Compiling MavenWrapperDownloader.java ..." - fi - # Compiling the Java class - ("$JAVA_HOME/bin/javac" "$javaClass") - fi - if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then - # Running the downloader - if [ "$MVNW_VERBOSE" = true ]; then - echo " - Running MavenWrapperDownloader.java ..." - fi - ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR") - fi - fi - fi +# First try the expected directory name (for regular distributions) +if [ -d "$TMP_DOWNLOAD_DIR/$distributionUrlNameMain" ]; then + if [ -f "$TMP_DOWNLOAD_DIR/$distributionUrlNameMain/bin/$MVN_CMD" ]; then + actualDistributionDir="$distributionUrlNameMain" + fi fi -########################################################################################## -# End of extension -########################################################################################## -export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"} -if [ "$MVNW_VERBOSE" = true ]; then - echo $MAVEN_PROJECTBASEDIR -fi -MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" - -# For Cygwin, switch paths to Windows format before running java -if $cygwin; then - [ -n "$M2_HOME" ] && - M2_HOME=`cygpath --path --windows "$M2_HOME"` - [ -n "$JAVA_HOME" ] && - JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` - [ -n "$CLASSPATH" ] && - CLASSPATH=`cygpath --path --windows "$CLASSPATH"` - [ -n "$MAVEN_PROJECTBASEDIR" ] && - MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"` +# If not found, search for any directory with the Maven executable (for snapshots) +if [ -z "$actualDistributionDir" ]; then + # enable globbing to iterate over items + set +f + for dir in "$TMP_DOWNLOAD_DIR"/*; do + if [ -d "$dir" ]; then + if [ -f "$dir/bin/$MVN_CMD" ]; then + actualDistributionDir="$(basename "$dir")" + break + fi + fi + done + set -f fi -# Provide a "standardized" way to retrieve the CLI args that will -# work with both Windows and non-Windows executions. -MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@" -export MAVEN_CMD_LINE_ARGS +if [ -z "$actualDistributionDir" ]; then + verbose "Contents of $TMP_DOWNLOAD_DIR:" + verbose "$(ls -la "$TMP_DOWNLOAD_DIR")" + die "Could not find Maven distribution directory in extracted archive" +fi -WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain +verbose "Found extracted Maven distribution directory: $actualDistributionDir" +printf %s\\n "$distributionUrl" >"$TMP_DOWNLOAD_DIR/$actualDistributionDir/mvnw.url" +mv -- "$TMP_DOWNLOAD_DIR/$actualDistributionDir" "$MAVEN_HOME" || [ -d "$MAVEN_HOME" ] || die "fail to move MAVEN_HOME" -exec "$JAVACMD" \ - $MAVEN_OPTS \ - -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ - "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ - ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" +clean || : +exec_maven "$@" diff --git a/mvnw.cmd b/mvnw.cmd index 8611571..5761d94 100644 --- a/mvnw.cmd +++ b/mvnw.cmd @@ -1,182 +1,189 @@ -@REM ---------------------------------------------------------------------------- -@REM Licensed to the Apache Software Foundation (ASF) under one -@REM or more contributor license agreements. See the NOTICE file -@REM distributed with this work for additional information -@REM regarding copyright ownership. The ASF licenses this file -@REM to you under the Apache License, Version 2.0 (the -@REM "License"); you may not use this file except in compliance -@REM with the License. You may obtain a copy of the License at -@REM -@REM http://www.apache.org/licenses/LICENSE-2.0 -@REM -@REM Unless required by applicable law or agreed to in writing, -@REM software distributed under the License is distributed on an -@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -@REM KIND, either express or implied. See the License for the -@REM specific language governing permissions and limitations -@REM under the License. -@REM ---------------------------------------------------------------------------- - -@REM ---------------------------------------------------------------------------- -@REM Maven Start Up Batch script -@REM -@REM Required ENV vars: -@REM JAVA_HOME - location of a JDK home dir -@REM -@REM Optional ENV vars -@REM M2_HOME - location of maven2's installed home dir -@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands -@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending -@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven -@REM e.g. to debug Maven itself, use -@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 -@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files -@REM ---------------------------------------------------------------------------- - -@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' -@echo off -@REM set title of command window -title %0 -@REM enable echoing by setting MAVEN_BATCH_ECHO to 'on' -@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% - -@REM set %HOME% to equivalent of $HOME -if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") - -@REM Execute a user defined script before this one -if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre -@REM check for pre script, once with legacy .bat ending and once with .cmd ending -if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" -if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" -:skipRcPre - -@setlocal - -set ERROR_CODE=0 - -@REM To isolate internal variables from possible post scripts, we use another setlocal -@setlocal - -@REM ==== START VALIDATION ==== -if not "%JAVA_HOME%" == "" goto OkJHome - -echo. -echo Error: JAVA_HOME not found in your environment. >&2 -echo Please set the JAVA_HOME variable in your environment to match the >&2 -echo location of your Java installation. >&2 -echo. -goto error - -:OkJHome -if exist "%JAVA_HOME%\bin\java.exe" goto init - -echo. -echo Error: JAVA_HOME is set to an invalid directory. >&2 -echo JAVA_HOME = "%JAVA_HOME%" >&2 -echo Please set the JAVA_HOME variable in your environment to match the >&2 -echo location of your Java installation. >&2 -echo. -goto error - -@REM ==== END VALIDATION ==== - -:init - -@REM Find the project base dir, i.e. the directory that contains the folder ".mvn". -@REM Fallback to current working directory if not found. - -set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% -IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir - -set EXEC_DIR=%CD% -set WDIR=%EXEC_DIR% -:findBaseDir -IF EXIST "%WDIR%"\.mvn goto baseDirFound -cd .. -IF "%WDIR%"=="%CD%" goto baseDirNotFound -set WDIR=%CD% -goto findBaseDir - -:baseDirFound -set MAVEN_PROJECTBASEDIR=%WDIR% -cd "%EXEC_DIR%" -goto endDetectBaseDir - -:baseDirNotFound -set MAVEN_PROJECTBASEDIR=%EXEC_DIR% -cd "%EXEC_DIR%" - -:endDetectBaseDir - -IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig - -@setlocal EnableExtensions EnableDelayedExpansion -for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a -@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% - -:endReadAdditionalConfig - -SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" -set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" -set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain - -set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" - -FOR /F "tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( - IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B -) - -@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central -@REM This allows using the maven wrapper in projects that prohibit checking in binary data. -if exist %WRAPPER_JAR% ( - if "%MVNW_VERBOSE%" == "true" ( - echo Found %WRAPPER_JAR% - ) -) else ( - if not "%MVNW_REPOURL%" == "" ( - SET DOWNLOAD_URL="%MVNW_REPOURL%/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" - ) - if "%MVNW_VERBOSE%" == "true" ( - echo Couldn't find %WRAPPER_JAR%, downloading it ... - echo Downloading from: %DOWNLOAD_URL% - ) - - powershell -Command "&{"^ - "$webclient = new-object System.Net.WebClient;"^ - "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^ - "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^ - "}"^ - "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^ - "}" - if "%MVNW_VERBOSE%" == "true" ( - echo Finished downloading %WRAPPER_JAR% - ) -) -@REM End of extension - -@REM Provide a "standardized" way to retrieve the CLI args that will -@REM work with both Windows and non-Windows executions. -set MAVEN_CMD_LINE_ARGS=%* - -%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* -if ERRORLEVEL 1 goto error -goto end - -:error -set ERROR_CODE=1 - -:end -@endlocal & set ERROR_CODE=%ERROR_CODE% - -if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost -@REM check for post script, once with legacy .bat ending and once with .cmd ending -if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" -if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" -:skipRcPost - -@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' -if "%MAVEN_BATCH_PAUSE%" == "on" pause - -if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% - -exit /B %ERROR_CODE% +<# : batch portion +@REM ---------------------------------------------------------------------------- +@REM Licensed to the Apache Software Foundation (ASF) under one +@REM or more contributor license agreements. See the NOTICE file +@REM distributed with this work for additional information +@REM regarding copyright ownership. The ASF licenses this file +@REM to you under the Apache License, Version 2.0 (the +@REM "License"); you may not use this file except in compliance +@REM with the License. You may obtain a copy of the License at +@REM +@REM http://www.apache.org/licenses/LICENSE-2.0 +@REM +@REM Unless required by applicable law or agreed to in writing, +@REM software distributed under the License is distributed on an +@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +@REM KIND, either express or implied. See the License for the +@REM specific language governing permissions and limitations +@REM under the License. +@REM ---------------------------------------------------------------------------- + +@REM ---------------------------------------------------------------------------- +@REM Apache Maven Wrapper startup batch script, version 3.3.4 +@REM +@REM Optional ENV vars +@REM MVNW_REPOURL - repo url base for downloading maven distribution +@REM MVNW_USERNAME/MVNW_PASSWORD - user and password for downloading maven +@REM MVNW_VERBOSE - true: enable verbose log; others: silence the output +@REM ---------------------------------------------------------------------------- + +@IF "%__MVNW_ARG0_NAME__%"=="" (SET __MVNW_ARG0_NAME__=%~nx0) +@SET __MVNW_CMD__= +@SET __MVNW_ERROR__= +@SET __MVNW_PSMODULEP_SAVE=%PSModulePath% +@SET PSModulePath= +@FOR /F "usebackq tokens=1* delims==" %%A IN (`powershell -noprofile "& {$scriptDir='%~dp0'; $script='%__MVNW_ARG0_NAME__%'; icm -ScriptBlock ([Scriptblock]::Create((Get-Content -Raw '%~f0'))) -NoNewScope}"`) DO @( + IF "%%A"=="MVN_CMD" (set __MVNW_CMD__=%%B) ELSE IF "%%B"=="" (echo %%A) ELSE (echo %%A=%%B) +) +@SET PSModulePath=%__MVNW_PSMODULEP_SAVE% +@SET __MVNW_PSMODULEP_SAVE= +@SET __MVNW_ARG0_NAME__= +@SET MVNW_USERNAME= +@SET MVNW_PASSWORD= +@IF NOT "%__MVNW_CMD__%"=="" ("%__MVNW_CMD__%" %*) +@echo Cannot start maven from wrapper >&2 && exit /b 1 +@GOTO :EOF +: end batch / begin powershell #> + +$ErrorActionPreference = "Stop" +if ($env:MVNW_VERBOSE -eq "true") { + $VerbosePreference = "Continue" +} + +# calculate distributionUrl, requires .mvn/wrapper/maven-wrapper.properties +$distributionUrl = (Get-Content -Raw "$scriptDir/.mvn/wrapper/maven-wrapper.properties" | ConvertFrom-StringData).distributionUrl +if (!$distributionUrl) { + Write-Error "cannot read distributionUrl property in $scriptDir/.mvn/wrapper/maven-wrapper.properties" +} + +switch -wildcard -casesensitive ( $($distributionUrl -replace '^.*/','') ) { + "maven-mvnd-*" { + $USE_MVND = $true + $distributionUrl = $distributionUrl -replace '-bin\.[^.]*$',"-windows-amd64.zip" + $MVN_CMD = "mvnd.cmd" + break + } + default { + $USE_MVND = $false + $MVN_CMD = $script -replace '^mvnw','mvn' + break + } +} + +# apply MVNW_REPOURL and calculate MAVEN_HOME +# maven home pattern: ~/.m2/wrapper/dists/{apache-maven-,maven-mvnd--}/ +if ($env:MVNW_REPOURL) { + $MVNW_REPO_PATTERN = if ($USE_MVND -eq $False) { "/org/apache/maven/" } else { "/maven/mvnd/" } + $distributionUrl = "$env:MVNW_REPOURL$MVNW_REPO_PATTERN$($distributionUrl -replace "^.*$MVNW_REPO_PATTERN",'')" +} +$distributionUrlName = $distributionUrl -replace '^.*/','' +$distributionUrlNameMain = $distributionUrlName -replace '\.[^.]*$','' -replace '-bin$','' + +$MAVEN_M2_PATH = "$HOME/.m2" +if ($env:MAVEN_USER_HOME) { + $MAVEN_M2_PATH = "$env:MAVEN_USER_HOME" +} + +if (-not (Test-Path -Path $MAVEN_M2_PATH)) { + New-Item -Path $MAVEN_M2_PATH -ItemType Directory | Out-Null +} + +$MAVEN_WRAPPER_DISTS = $null +if ((Get-Item $MAVEN_M2_PATH).Target[0] -eq $null) { + $MAVEN_WRAPPER_DISTS = "$MAVEN_M2_PATH/wrapper/dists" +} else { + $MAVEN_WRAPPER_DISTS = (Get-Item $MAVEN_M2_PATH).Target[0] + "/wrapper/dists" +} + +$MAVEN_HOME_PARENT = "$MAVEN_WRAPPER_DISTS/$distributionUrlNameMain" +$MAVEN_HOME_NAME = ([System.Security.Cryptography.SHA256]::Create().ComputeHash([byte[]][char[]]$distributionUrl) | ForEach-Object {$_.ToString("x2")}) -join '' +$MAVEN_HOME = "$MAVEN_HOME_PARENT/$MAVEN_HOME_NAME" + +if (Test-Path -Path "$MAVEN_HOME" -PathType Container) { + Write-Verbose "found existing MAVEN_HOME at $MAVEN_HOME" + Write-Output "MVN_CMD=$MAVEN_HOME/bin/$MVN_CMD" + exit $? +} + +if (! $distributionUrlNameMain -or ($distributionUrlName -eq $distributionUrlNameMain)) { + Write-Error "distributionUrl is not valid, must end with *-bin.zip, but found $distributionUrl" +} + +# prepare tmp dir +$TMP_DOWNLOAD_DIR_HOLDER = New-TemporaryFile +$TMP_DOWNLOAD_DIR = New-Item -Itemtype Directory -Path "$TMP_DOWNLOAD_DIR_HOLDER.dir" +$TMP_DOWNLOAD_DIR_HOLDER.Delete() | Out-Null +trap { + if ($TMP_DOWNLOAD_DIR.Exists) { + try { Remove-Item $TMP_DOWNLOAD_DIR -Recurse -Force | Out-Null } + catch { Write-Warning "Cannot remove $TMP_DOWNLOAD_DIR" } + } +} + +New-Item -Itemtype Directory -Path "$MAVEN_HOME_PARENT" -Force | Out-Null + +# Download and Install Apache Maven +Write-Verbose "Couldn't find MAVEN_HOME, downloading and installing it ..." +Write-Verbose "Downloading from: $distributionUrl" +Write-Verbose "Downloading to: $TMP_DOWNLOAD_DIR/$distributionUrlName" + +$webclient = New-Object System.Net.WebClient +if ($env:MVNW_USERNAME -and $env:MVNW_PASSWORD) { + $webclient.Credentials = New-Object System.Net.NetworkCredential($env:MVNW_USERNAME, $env:MVNW_PASSWORD) +} +[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 +$webclient.DownloadFile($distributionUrl, "$TMP_DOWNLOAD_DIR/$distributionUrlName") | Out-Null + +# If specified, validate the SHA-256 sum of the Maven distribution zip file +$distributionSha256Sum = (Get-Content -Raw "$scriptDir/.mvn/wrapper/maven-wrapper.properties" | ConvertFrom-StringData).distributionSha256Sum +if ($distributionSha256Sum) { + if ($USE_MVND) { + Write-Error "Checksum validation is not supported for maven-mvnd. `nPlease disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties." + } + Import-Module $PSHOME\Modules\Microsoft.PowerShell.Utility -Function Get-FileHash + if ((Get-FileHash "$TMP_DOWNLOAD_DIR/$distributionUrlName" -Algorithm SHA256).Hash.ToLower() -ne $distributionSha256Sum) { + Write-Error "Error: Failed to validate Maven distribution SHA-256, your Maven distribution might be compromised. If you updated your Maven version, you need to update the specified distributionSha256Sum property." + } +} + +# unzip and move +Expand-Archive "$TMP_DOWNLOAD_DIR/$distributionUrlName" -DestinationPath "$TMP_DOWNLOAD_DIR" | Out-Null + +# Find the actual extracted directory name (handles snapshots where filename != directory name) +$actualDistributionDir = "" + +# First try the expected directory name (for regular distributions) +$expectedPath = Join-Path "$TMP_DOWNLOAD_DIR" "$distributionUrlNameMain" +$expectedMvnPath = Join-Path "$expectedPath" "bin/$MVN_CMD" +if ((Test-Path -Path $expectedPath -PathType Container) -and (Test-Path -Path $expectedMvnPath -PathType Leaf)) { + $actualDistributionDir = $distributionUrlNameMain +} + +# If not found, search for any directory with the Maven executable (for snapshots) +if (!$actualDistributionDir) { + Get-ChildItem -Path "$TMP_DOWNLOAD_DIR" -Directory | ForEach-Object { + $testPath = Join-Path $_.FullName "bin/$MVN_CMD" + if (Test-Path -Path $testPath -PathType Leaf) { + $actualDistributionDir = $_.Name + } + } +} + +if (!$actualDistributionDir) { + Write-Error "Could not find Maven distribution directory in extracted archive" +} + +Write-Verbose "Found extracted Maven distribution directory: $actualDistributionDir" +Rename-Item -Path "$TMP_DOWNLOAD_DIR/$actualDistributionDir" -NewName $MAVEN_HOME_NAME | Out-Null +try { + Move-Item -Path "$TMP_DOWNLOAD_DIR/$MAVEN_HOME_NAME" -Destination $MAVEN_HOME_PARENT | Out-Null +} catch { + if (! (Test-Path -Path "$MAVEN_HOME" -PathType Container)) { + Write-Error "fail to move MAVEN_HOME" + } +} finally { + try { Remove-Item $TMP_DOWNLOAD_DIR -Recurse -Force | Out-Null } + catch { Write-Warning "Cannot remove $TMP_DOWNLOAD_DIR" } +} + +Write-Output "MVN_CMD=$MAVEN_HOME/bin/$MVN_CMD" diff --git a/pom.xml b/pom.xml index 8bcf1cc..0ba4ae4 100644 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 com.ibm.cicsdev @@ -12,27 +12,12 @@ CICS Liberty JDBC Application Sample JDBC enterprise Java web application demonstrating how to access a Db2 database from a web servlet in CICS Liberty. - https://github.com/cicsdev/cics-java-liberty-jdbc/ - cics-java-liberty-jdbc-web - cics-java-liberty-jdbc-bundle + cics-java-liberty-jdbc-app + cics-java-liberty-jdbc-cicsbundle - - - Apache-2.0 - https://www.apache.org/licenses/LICENSE-2.0.txt - - - - - - IBM CICS Transaction Server for z/OS - https://www.ibm.com/products/cics-transaction-server - - - DFHWLP @@ -40,7 +25,18 @@ UTF-8 - ${java.version} - ${java.version} - \ No newline at end of file + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.13.0 + + ${java.version} + + + + + diff --git a/settings.gradle b/settings.gradle index 10bae5b..4464b4f 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,4 +1,9 @@ +plugins +{ + id 'org.gradle.toolchains.foojay-resolver-convention' version '0.8.0' +} + rootProject.name = 'cics-java-liberty-jdbc' -include(':cics-java-liberty-jdbc-web') -include(':cics-java-liberty-jdbc-bundle') \ No newline at end of file +include(':cics-java-liberty-jdbc-app') +include(':cics-java-liberty-jdbc-cicsbundle')