Skip to content

Commit

Permalink
Automated build that will use gradle or raw javac commands if no buil…
Browse files Browse the repository at this point in the history
…d.gradle file
  • Loading branch information
edgriebel committed Oct 27, 2023
1 parent 22eece2 commit 42bc86f
Showing 1 changed file with 34 additions and 7 deletions.
41 changes: 34 additions & 7 deletions .github/workflows/simple_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 42bc86f

Please sign in to comment.