From 42bc86fdc7a88f824c984148de5a185deab1f5c6 Mon Sep 17 00:00:00 2001 From: Ed Griebel Date: Fri, 27 Oct 2023 00:45:03 -0400 Subject: [PATCH] Automated build that will use gradle or raw javac commands if no build.gradle file --- .github/workflows/simple_build.yml | 41 +++++++++++++++++++++++++----- 1 file changed, 34 insertions(+), 7 deletions(-) diff --git a/.github/workflows/simple_build.yml b/.github/workflows/simple_build.yml index f2e49c4..49c9bb0 100644 --- a/.github/workflows/simple_build.yml +++ b/.github/workflows/simple_build.yml @@ -5,24 +5,51 @@ name: Java CI on: push: - branches: [ master ] pull_request: - branches: [ master ] jobs: - build: - + # Test for presence of build.gradle file + # Only run these raw javac if not found + build-with-shell: + if: ${{ hashFiles('build.gradle') == '' }} runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Set up JDK 1.8 - uses: actions/setup-java@v1 + uses: actions/setup-java@v3 with: java-version: 1.8 - name: Build Java Code run: javac -cp lib/hamcrest-core-1.3.jar:lib/junit-4.12.jar *.java - name: Run Unit Tests run: java -cp .:lib/hamcrest-core-1.3.jar:lib/junit-4.12.jar org.junit.runner.JUnitCore EdgeConnectorTest + # Display the files that the action sees in the home directory - name: List files - run: ls -l + run: tree + + # If there's a build.gradle file then run gradle on it + build-with-gradle: + if: ${{ hashFiles('build.gradle') != '' }} + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + # JDK17 compatible with Gradle 7.2 + - name: Set up JDK 17 + uses: actions/setup-java@v3 + with: + distribution: 'zulu' + java-version: 17 + - name: Setup Gradle + uses: gradle/gradle-build-action@v2 + with: + gradle-version: 7.2 + + - name: Execute Gradle wrapper build + if: ${{ hashFiles('gradlew') != '' }} + run: ./gradlew build + + - name: Execute Gradle build + if: ${{ hashFiles('gradlew') == '' }} + run: gradle test