Skip to content

Commit

Permalink
fixes & refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
JorisAerts committed Mar 16, 2024
1 parent 58b49d3 commit 3b1e8cf
Show file tree
Hide file tree
Showing 15 changed files with 132 additions and 39 deletions.
73 changes: 73 additions & 0 deletions .github/workflows/gradle-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-gradle

name: CI/CD [gradle]

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

jobs:
build:

runs-on: ubuntu-latest
permissions:
contents: read

steps:
- uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'

# Configure Gradle for optimal use in GiHub Actions, including caching of downloaded dependencies.
# See: https://github.com/gradle/actions/blob/main/setup-gradle/README.md
- name: Setup Gradle
uses: gradle/actions/setup-gradle@ec92e829475ac0c2315ea8f9eced72db85bb337a # v3.0.0

- name: Build with Gradle Wrapper
run: ./gradlew build
env:
USERNAME: ${{ github.actor }}
TOKEN: ${{ secrets.GITHUB_TOKEN }}

# NOTE: The Gradle Wrapper is the default and recommended way to run Gradle (https://docs.gradle.org/current/userguide/gradle_wrapper.html).
# If your project does not have the Gradle Wrapper configured, you can use the following configuration to run Gradle with a specified version.
#
# - name: Setup Gradle
# uses: gradle/actions/setup-gradle@ec92e829475ac0c2315ea8f9eced72db85bb337a # v3.0.0
# with:
# gradle-version: '8.5'
#
# - name: Build with Gradle 8.5
# run: gradle build

dependency-submission:

runs-on: ubuntu-latest
permissions:
contents: write

steps:
- uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'

# Generates and submits a dependency graph, enabling Dependabot Alerts for all project dependencies.
# See: https://github.com/gradle/actions/blob/main/dependency-submission/README.md
- name: Generate and submit dependency graph
uses: gradle/actions/dependency-submission@ec92e829475ac0c2315ea8f9eced72db85bb337a # v3.0.0
env:
USERNAME: ${{ github.actor }}
TOKEN: ${{ secrets.GITHUB_TOKEN }}
28 changes: 13 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,19 @@ Deployed to your local maven repository, so that gradle can find it:

#### 2) Configure the repo

By defining the _Github packages_ maven repo,
Gradle will be able to download the necessary packages:
_(Remember to correctly set your credentials first; see [GitHub Packages documentation](https://docs.github.com/en/packages))_

***settings.gradle***

```groovy
pluginManagement {
repositories {
maven {
name 'xomda packages'
url 'https://maven.pkg.github.com/xomda/xomda'
}
}
}
The repository will fetch XOMDA from GitHub Packages.
In order to do so, you'll need to configure access to GitHub Packages.

> ### Create a new GitHub token
>
> In your GitHub Profile, go to "Settings > Developer settings > Personal access tokens > Tokens (classic)".
> Create a new token with "read:packages" permissions.
You'll need to add your GitHub Access token to `~/.gradle/gradle.properties`:

```.properties
gpr.user=<GITHUB_USERNAME>
gpr.token=<PERSONAL_ACCESS_TOKEN>
```

## Build the project
Expand Down
14 changes: 14 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,18 @@ subprojects { p ->
file.deleteDir()
}
}

repositories {
mavenLocal()
mavenCentral()
maven {
name 'xomda packages'
url 'https://maven.pkg.github.com/xomda/xomda'
credentials {
username = System.getenv("USERNAME")
password = System.getenv("TOKEN")
}
}
}

}
9 changes: 3 additions & 6 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# This file was generated by the Gradle 'init' task.
# https://docs.gradle.org/current/userguide/platforms.html#sub::toml-dependencies-format

[versions]
guava = "33.0.0-jre"
junit-jupiter = "5.10.2"
Expand All @@ -12,9 +9,9 @@ xomda = "latest.release"
guava = { module = "com.google.guava:guava", version.ref = "guava" }
junit-jupiter = { module = "org.junit.jupiter:junit-jupiter", version.ref = "junit-jupiter" }
log4j = { module = "org.apache.logging.log4j:log4j-core", version.ref = "log4j" }
xomda-core = { module = "org.xomda:core", version.ref = "xomda" }
xomda-model = { module = "org.xomda:model", version.ref = "xomda" }
xomda-core = { module = "org.xomda:xomda-core", version.ref = "xomda" }
xomda-model = { module = "org.xomda:xomda-model", version.ref = "xomda" }
jackson-databind = { module = 'com.fasterxml.jackson.core:jackson-databind', version.ref = "jackson" }

[plugins]
xomda-plugin-gradle = { id = "xomda", version.ref = "xomda" }
xomda-plugin-gradle = { id = "org.xomda.xomda-plugin-gradle", version.ref = "xomda" }
7 changes: 6 additions & 1 deletion gradle/projectPlugins/settings.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
dependencyResolutionManagement {
repositories.gradlePluginPortal()
repositories.gradlePluginPortal()

// Reuse version catalog from the main build.
versionCatalogs {
create('libs', { from(files("../libs.versions.toml")) })
}
}

include("xomda-convention-plugins")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
// This plugin applies basic Java configuration on top of xomda-common
plugins {
id('xomda-common')
id('java')
id('xomda-common')
id('java')
}

java {
toolchain.languageVersion = JavaLanguageVersion.of(17) // 21?
version = libs.versions.xomda.get()
toolchain.languageVersion = JavaLanguageVersion.of(17) // 21?
version = libs.versions.xomda.get()
}

tasks.withType(JavaCompile).configureEach {
options.encoding = 'UTF-8'
options.encoding = 'UTF-8'
}

dependencies {
testImplementation libs.junit.jupiter
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
testImplementation libs.junit.jupiter
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
}

tasks.withType(Test) {
useJUnitPlatform()
useJUnitPlatform()
}

group "org.xomda"
Expand Down
8 changes: 7 additions & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,16 @@ pluginManagement {

repositories {
mavenLocal()
mavenCentral()
gradlePluginPortal()
maven {
name 'xomda packages'
url 'https://maven.pkg.github.com/xomda/xomda'

credentials {
username = System.getenv("USERNAME")
password = System.getenv("TOKEN")
}
}
}
}
Expand All @@ -25,7 +31,7 @@ void includeProjectsFrom(File file) {
}
}

rootProject.name = 'xomda-test'
rootProject.name = 'xomda-test-project'

includeProjectsFrom(rootProject.projectDir)
includeProjectsFrom(file("test-multi-project"))
2 changes: 1 addition & 1 deletion test-freemarker/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id "org.xomda.plugin-gradle" version "latest.release"
id "org.xomda.xomda-plugin-gradle" version "latest.release"
}

repositories {
Expand Down
2 changes: 1 addition & 1 deletion test-jte/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id "org.xomda.plugin-gradle" version "latest.release"
id "org.xomda.xomda-plugin-gradle" version "latest.release"
}

repositories {
Expand Down
2 changes: 1 addition & 1 deletion test-model/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
plugins {
id "application"
id "org.xomda.plugin-gradle" version "latest.release"
id "org.xomda.xomda-plugin-gradle" version "latest.release"
}

repositories {
Expand Down
2 changes: 1 addition & 1 deletion test-multi-model/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
plugins {
id "application"
id "org.xomda.plugin-gradle" version "latest.release"
id "org.xomda.xomda-plugin-gradle" version "latest.release"
}

repositories {
Expand Down
2 changes: 1 addition & 1 deletion test-multi-project/project-1/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
plugins {
id "java-library"
id "org.xomda.plugin-gradle" version "latest.release"
id "org.xomda.xomda-plugin-gradle" version "latest.release"
}

repositories {
Expand Down
2 changes: 1 addition & 1 deletion test-multi-project/project-2/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
plugins {
id "java-library"
id "org.xomda.plugin-gradle" version "latest.release"
id "org.xomda.xomda-plugin-gradle" version "latest.release"
}

repositories {
Expand Down
2 changes: 1 addition & 1 deletion test-multi-project/project-3/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
plugins {
id "java-library"
id "org.xomda.plugin-gradle" version "latest.release"
id "org.xomda.xomda-plugin-gradle" version "latest.release"
}

repositories {
Expand Down
2 changes: 1 addition & 1 deletion test-mustache/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id "org.xomda.plugin-gradle" version "latest.release"
id "org.xomda.xomda-plugin-gradle" version "latest.release"
}

repositories {
Expand Down

0 comments on commit 3b1e8cf

Please sign in to comment.