Skip to content

Commit

Permalink
Standardize builds (#69)
Browse files Browse the repository at this point in the history
* Standardize builds

Issues: IN-440

* Align Gradle version

Issues: IN-440

* Align Gradle build with standard

Issues: IN-440

* Update to JDK 17 (LTS)

Issues: IN-440

* Setting executable for tests dos not work with gradle 7.6

Issues: IN-440

---------

Co-authored-by: Michel Hartmann <[email protected]>
  • Loading branch information
MichelHartmann and Michel Hartmann authored Oct 5, 2023
1 parent 6155f0b commit 9dcfd29
Show file tree
Hide file tree
Showing 8 changed files with 84 additions and 68 deletions.
13 changes: 10 additions & 3 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
version: 2
updates:
- directory: /
schedule:
interval: daily
package-ecosystem: gradle
schedule:
interval: weekly
assignees:
- MichelHartmann
- meiXXI
- directory: /
package-ecosystem: github-actions
schedule:
interval: weekly
assignees:
- MichelHartmann
- MichelHartmann
31 changes: 0 additions & 31 deletions .github/workflows/build.yml

This file was deleted.

14 changes: 4 additions & 10 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,12 @@ jobs:
# Learn more about CodeQL language support at https://git.io/codeql-language-support

steps:
- name: Setup JDK 16
uses: actions/setup-java@v2
with:
distribution: 'temurin'
java-version: 16

- name: Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v4

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
Expand All @@ -59,7 +53,7 @@ jobs:
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v1
uses: github/codeql-action/autobuild@v2

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl
Expand All @@ -73,4 +67,4 @@ jobs:
# make release

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
uses: github/codeql-action/analyze@v2
17 changes: 17 additions & 0 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Pull-Request

# This build process is triggered in case a new pull request on master has been created.
# This process takes the latest changes of the branch, and build and test the new version. The process's aim is to
# check validity of changes prior to merging to master.

on:
pull_request:
branches: [ main ]

jobs:
call-workflow:
name: 🏭
uses: cip4/.github/.github/workflows/pull-request.yml@master
with:
java-version: 17
codecov-enabled: true
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
name: 🏭
uses: cip4/.github/.github/workflows/tool-release.yml@master
with:
java-version: 16
java-version: 17
confluence-label: alces
confluence-content-id: 1181122563
apple-bundle-id: org.cip4.alces
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/snapshot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ jobs:
name: 🏭
uses: cip4/.github/.github/workflows/tool-snapshot.yml@master
with:
java-version: 16
java-version: 17
codecov-enabled: true
confluence-label: alces
confluence-content-id: 1457554021
apple-bundle-id: org.cip4.alces
Expand Down
70 changes: 49 additions & 21 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import org.apache.tools.ant.filters.ReplaceTokens
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import org.gradle.api.tasks.testing.logging.TestLogEvent

plugins {
id 'org.springframework.boot' version '2.7.0'
Expand All @@ -9,18 +11,24 @@ plugins {
id 'jacoco'
}

mainClassName = 'org.cip4.tools.alces.Application'
def simpleProjectName = "Alces"
mainClassName = 'org.cip4.tools.alces.Application'
group = 'org.cip4.tools.alces'
description = 'CIP4 ' + simpleProjectName
version = project.hasProperty('projectVersion') ? project.projectVersion : 'development'

sourceCompatibility = 16
targetCompatibility = 16

if (project.hasProperty('projectVersion')) {
version = project.projectVersion
} else {
version = 'development'
java {
archivesBaseName = simpleProjectName
withJavadocJar()
withSourcesJar()
toolchain {
languageVersion = JavaLanguageVersion.of(17)
}
}

compileJava.options.encoding = "UTF-8"
compileTestJava.options.encoding = "UTF-8"

repositories {
mavenCentral()
maven {
Expand All @@ -30,9 +38,10 @@ repositories {

processResources {
filesMatching(['**/*.properties', '**/*.yml']) {
filter(ReplaceTokens, tokens: [
filter(ReplaceTokens, tokens: [
'name': project.properties['name'],
'version': project.properties['version'],
'artifactId': project.properties['name'],
'timestamp': new Date().format('yyyy-MM-dd HH:mm:ss')
])
}
Expand All @@ -42,10 +51,6 @@ application {
mainClass = 'org.cip4.tools.alces.Application'
}

test {
useJUnitPlatform()
}

dependencies {
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.codehaus.groovy:groovy:+'
Expand Down Expand Up @@ -105,23 +110,46 @@ runtime {
}
}

test {
dependsOn(jre)
useJUnitPlatform()
executable = jre.getJreDir().dir("bin").file("java").getAsFile().getAbsolutePath()
}

jacocoTestReport {
dependsOn test
reports {
xml.required = true
html.required = false
}
}
test {
useJUnitPlatform()
dependsOn(jre)
if (GradleVersion.current() >= GradleVersion.version("8.0")) {
executable = jre.getJreDir().dir("bin").file("java").getAsFile().getAbsolutePath()
}
}

java {
archivesBaseName = simpleProjectName

jar {
manifest {
attributes(
"Implementation-Title": project.description,
"Implementation-Version": project.version,
"Implementation-Vendor-Id": project.group,
"Specification-Title": project.description,
"Specification-Version": project.version,
"Build-Jdk": JavaVersion.current(),
)
}
}

startScripts {
applicationName = simpleProjectName
}

tasks.withType(Test) {
testLogging {
events TestLogEvent.FAILED,
TestLogEvent.SKIPPED
exceptionFormat TestExceptionFormat.FULL
showExceptions true
showCauses true
showStackTraces true
}
}
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

0 comments on commit 9dcfd29

Please sign in to comment.