Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#
# https://help.github.com/articles/dealing-with-line-endings/
#
# Linux start script should use lf
/gradlew text eol=lf

# These are Windows script files and should use crlf
*.bat text eol=crlf

# Binary files should be left untouched
*.jar binary

45 changes: 45 additions & 0 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# SPDX-FileCopyrightText: Copyright Contributors to the GXF project
#
# SPDX-License-Identifier: Apache-2.0
name: Gradle Pipeline

on:
push:
branches: [ "main" ]
tags: [ "v**" ]
pull_request:
branches: [ "main" ]


permissions: write-all

jobs:
build:
name: Gradle build and publish
timeout-minutes: 30
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
with:
fetch-depth: 0
- name: Set up JDK 21
uses: actions/setup-java@v5
with:
java-version: '21'
distribution: 'temurin'
cache: 'gradle'
- name: Setup Gradle to generate and submit dependency graphs
uses: gradle/actions/setup-gradle@v4
with:
dependency-graph: generate-and-submit
- name: Build with Gradle
run: ./gradlew protoJar
env:
GITHUB_ACTOR: ${{ github.actor }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Publish Maven artifacts
if: github.ref == 'refs/heads/main' || github.ref_type == 'tag'
run: ./gradlew publish
env:
GITHUB_ACTOR: ${{ github.actor }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.gradle
.idea
build
66 changes: 66 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import java.net.URI
import org.gradle.api.publish.PublishingExtension
import org.gradle.api.publish.maven.MavenPublication

group = "org.lfenergy.gxf.oslp-protobuf"

val semVerRegex = Regex("""^v?(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:[-+][\w\.-]+)?$""")

version = System.getenv("GITHUB_REF_NAME")
?.replace("/", "-")
?.lowercase()
?.let { if(semVerRegex.matches(it)) it.removePrefix("v") else "${it}-SNAPSHOT" }
?: "develop"

plugins {
id("java")
`maven-publish`
alias(libs.plugins.protobuf)
}

repositories {
mavenCentral()
}

dependencies {
implementation(libs.protoJava)
}

protobuf {
protoc {
artifact = libs.protoc.get().toString()
}
}

sourceSets {
named("main") {
java {
srcDir("src/generated/main/java")
}
}
}

extensions.configure<PublishingExtension> {
repositories {
mavenLocal()
maven {
name = "GXFGithubPackages"
url = URI("https://maven.pkg.github.com/osgp/oslp-protobuf")
credentials {
username = System.getenv("GITHUB_ACTOR")
password = System.getenv("GITHUB_TOKEN")
}
}
}

publications {
create<MavenPublication>("java") {
from(components.getByName("java"))
}
}
}

tasks.register<Jar>("protoJar") {
archiveClassifier.set("proto")
from("src/generated/main/java")
}
5 changes: 5 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# This file was generated by the Gradle 'init' task.
# https://docs.gradle.org/current/userguide/build_environment.html#sec:gradle_configuration_properties

org.gradle.configuration-cache=true

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

[versions]
protobuf = "4.32.1"
protobufPlugin = "0.9.5"

[libraries]
protoJava = { group = "com.google.protobuf", name = "protobuf-java", version.ref = "protobuf" }
protoc = { group = "com.google.protobuf", name = "protoc", version.ref = "protobuf" }

[plugins]
protobuf = { id = "com.google.protobuf", version.ref = "protobufPlugin" }
Binary file added gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
7 changes: 7 additions & 0 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-9.1.0-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading
Loading