diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 610f8db..1413c06 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,6 +1,7 @@ name: Build on: + workflow_dispatch: push: branches: [main] pull_request: @@ -17,6 +18,8 @@ jobs: steps: - name: Check out repository uses: actions/checkout@v4 + with: + fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis - name: Set up Java uses: actions/setup-java@v4 @@ -27,5 +30,20 @@ jobs: - name: Set up Gradle uses: gradle/actions/setup-gradle@v4 + - name: Cache SonarQube packages + uses: actions/cache@v4 + with: + path: ~/.sonar/cache + key: ${{ runner.os }}-sonar + restore-keys: ${{ runner.os }}-sonar + - name: Build and test run: ./gradlew build + + - name: SonarQube analysis + # Analysis is advisory: a failed or unconfigured scan must not fail the build. + continue-on-error: true + env: + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }} + run: ./gradlew sonar --info diff --git a/build.gradle b/build.gradle index a9bb3d3..7b92be2 100644 --- a/build.gradle +++ b/build.gradle @@ -1,5 +1,13 @@ plugins { id 'application' + id "org.sonarqube" version "7.3.1.8318" +} + +sonar { + properties { + property "sonar.projectKey", "deprecated-java-api-demo-2" + property "sonar.projectName", "deprecated-java-api-demo-2" + } } group = 'dev.trly.java.example.primitive.wrappers'