Skip to content

Commit

Permalink
Merge pull request #61 from Over-Run/jdk23
Browse files Browse the repository at this point in the history
  • Loading branch information
squid233 authored Sep 1, 2024
2 parents 20c82ed + b1c7291 commit 4ffcbda
Show file tree
Hide file tree
Showing 207 changed files with 1,168 additions and 5,864 deletions.
11 changes: 8 additions & 3 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
strategy:
matrix:
java: [
22
23-ea
]
os: [ ubuntu-latest, windows-latest, macos-latest ]
runs-on: ${{ matrix.os }}
Expand All @@ -38,10 +38,15 @@ jobs:
uses: gradle/actions/setup-gradle@v3
- name: Execute Gradle build
run: ./gradlew build --parallel
- name: Upload build reports
uses: actions/upload-artifact@v4
with:
name: build-reports-${{ runner.os }}-jdk${{ matrix.java }}
path: |
modules/samples/build/reports/
- name: Capture build artifacts
if: ${{ runner.os == 'Linux' && matrix.java == '22' }}
uses: actions/upload-artifact@v4
with:
name: artifacts
name: artifacts-${{ runner.os }}-jdk${{ matrix.java }}
path: |
modules/**/build/libs/
2 changes: 1 addition & 1 deletion .github/workflows/javadoc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
uses: actions/setup-java@v4
with:
java-version: |
22
23-ea
distribution: 'temurin'
- name: Grant execute permission for gradlew
if: ${{ runner.os != 'Windows' }}
Expand Down
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

![License](https://img.shields.io/github/license/Over-Run/overrungl)

![Maven Central](https://img.shields.io/maven-central/v/io.github.over-run/overrungl)
[//]: # (![Maven Central](https://img.shields.io/maven-central/v/io.github.over-run/overrungl))
![Sonatype Nexus (Snapshots)](https://img.shields.io/nexus/s/io.github.over-run/overrungl?server=https%3A%2F%2Fs01.oss.sonatype.org)

[![Java CI with Gradle](https://github.com/Over-Run/overrungl/actions/workflows/gradle.yml/badge.svg?event=push)](https://github.com/Over-Run/overrungl/actions/workflows/gradle.yml)
[![OpenSSF Best Practices](https://www.bestpractices.dev/projects/8279/badge)](https://www.bestpractices.dev/projects/8279)

## Introduction

Overrun Game Library is a high-performance library implemented with Java 22,
Overrun Game Library is a high-performance library implemented with Java 23,
which enables cross-platform access to a set of C/C++ library bindings, and provides some useful utilities.

### OverrunGL vs. LWJGL
Expand All @@ -29,8 +29,7 @@ the [samples](modules/samples/src/main/java/overrungl/demo).

We provided a modules customizer [here](https://over-run.github.io/overrungl-gen/).

Currently, we are developing with the first version,
and it uses preview features, which prevent users from using newer JDKs,
Currently, OverrunGL uses preview features, which prevent users from using newer JDKs,
so you have to use `-SNAPSHOT` version.

You can import with `io.github.over-run:overrungl-bom:{the version}` and other submodules.
Expand Down
229 changes: 4 additions & 225 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,119 +1,22 @@
import org.gradle.plugins.ide.idea.model.IdeaModel

plugins {
`java-platform`
`maven-publish`
signing
}

val projGroupId: String by project
val projArtifactId: String by project
val projName: String by project
val projVersion: String by project
val projVcs: String by project
val projBranch: String by project
val projLicenseYear: String by project
val projLicenseFileName: String by project
val orgName: String by project
val orgUrl: String by project

val jdkVersion: String by rootProject
val jdkEnablePreview: String by rootProject
val jdkEarlyAccessDoc: String? by rootProject
val kotlinTargetJdkVersion: String by rootProject

val targetJavaVersion = jdkVersion.toInt()

group = projGroupId
version = projVersion

val artifactNameMap = buildMap {
Artifact.values().forEach { put(it.subprojectName, it.artifactName) }
put(":samples", "overrungl-samples")
}

artifactNameMap.forEach { (subprojectName, artifactName) ->
project(subprojectName) {
apply(plugin = "java-library")
apply(plugin = "idea")

group = projGroupId
version = projVersion

repositories {
mavenCentral()
// temporary maven repositories
maven { url = uri("https://s01.oss.sonatype.org/content/repositories/snapshots") }
maven { url = uri("https://s01.oss.sonatype.org/content/repositories/releases") }
}

val compileOnly by configurations
dependencies {
compileOnly("org.jetbrains:annotations:24.1.0")
if (project.name != "core") {
compileOnly(project(Artifact.CORE.subprojectName))
constraints { api("io.github.over-run:overrungl:$projVersion") }
}
}

tasks.withType<JavaCompile> {
options.encoding = "UTF-8"
if (jdkEnablePreview.toBoolean()) options.compilerArgs.add("--enable-preview")
options.release.set(targetJavaVersion)
}

tasks.withType<Test> {
if (jdkEnablePreview.toBoolean()) jvmArgs("--enable-preview")
}

extensions.configure<JavaPluginExtension>("java") {
toolchain.languageVersion.set(JavaLanguageVersion.of(targetJavaVersion))
withJavadocJar()
withSourcesJar()
}

tasks.named<Jar>("jar") {
manifestContentCharset = "utf-8"
metadataCharset = "utf-8"
manifest.attributes(
"Specification-Title" to projName,
"Specification-Vendor" to "Overrun Organization",
"Specification-Version" to projVersion.split('.', limit = 2)[0],
"Implementation-Title" to projName,
"Implementation-Vendor" to "Overrun Organization",
"Implementation-Version" to projVersion
)
archiveBaseName.set(artifactName)
from(rootProject.file(projLicenseFileName)).rename(
projLicenseFileName,
"${projLicenseFileName}_$artifactName"
)
}

tasks.named<Jar>("sourcesJar") {
dependsOn(tasks["classes"])
archiveBaseName.set(artifactName)
archiveClassifier.set("sources")
from(sourceSets["main"].allSource)
}

tasks.named<Jar>("javadocJar") {
val javadoc by tasks
dependsOn(javadoc)
archiveBaseName.set(artifactName)
archiveClassifier.set("javadoc")
from(javadoc)
}

artifacts {
archives(tasks["sourcesJar"])
archives(tasks["javadocJar"])
}

the<IdeaModel>().module.inheritOutputDirs = true
}
}

allprojects {
tasks.withType<Javadoc> {
options {
Expand Down Expand Up @@ -144,145 +47,27 @@ allprojects {
)

bottom =
"<a href=\"https://github.com/Over-Run/overrungl/issues\">Report a bug or suggest an enhancement</a><br>" +
"Copyright © 2022-$projLicenseYear Overrun Organization<br>" +
"<b>$projVersion</b>"
"""<a href="https://github.com/Over-Run/overrungl/issues">Report a bug or suggest an enhancement</a><br>""" +
"Copyright © $projLicenseYear Overrun Organization<br>" +
"<b>$projVersion (env ${Runtime.version()})</b>"
}
}
encoding = "UTF-8"
locale = "en_US"
windowTitle = "OverrunGL $projVersion"
jFlags("-Duser.language=en-US")
}
title = "OverrunGL $projVersion"
isFailOnError = false
}
}

Artifact.values().forEach {
project(it.subprojectName) {
val javaComponent = components.findByName("java") as AdhocComponentWithVariants
// Add a different runtime variant for each platform
it.nativeBinding?.platforms?.forEach { platform ->
val nativeFileName = it.nativeFileName(platform)
val file = File("${rootProject.projectDir}/natives/$nativeFileName")

if (file.exists()) {
val archiveTaskName = "${it.nativeBinding?.bindingName}${platform.classifier}Jar"

val nativeJar = tasks.register<Jar>(archiveTaskName) {
archiveBaseName.set(it.artifactName)
archiveClassifier.set(platform.classifier)
from(file) { into(File(nativeFileName).parent) }
}

val nativeRuntimeElements = configurations.create(platform.classifier + "RuntimeElements") {
isCanBeConsumed = true; isCanBeResolved = false
attributes {
attribute(Category.CATEGORY_ATTRIBUTE, objects.named(Category.LIBRARY))
attribute(Bundling.BUNDLING_ATTRIBUTE, objects.named(Bundling.EXTERNAL))
attribute(TargetJvmVersion.TARGET_JVM_VERSION_ATTRIBUTE, targetJavaVersion)
attribute(LibraryElements.LIBRARY_ELEMENTS_ATTRIBUTE, objects.named(LibraryElements.JAR))
attribute(Usage.USAGE_ATTRIBUTE, objects.named(Usage.JAVA_RUNTIME))
attributes.attribute(
OperatingSystemFamily.OPERATING_SYSTEM_ATTRIBUTE,
objects.named(platform.osFamilyName)
)
attributes.attribute(MachineArchitecture.ARCHITECTURE_ATTRIBUTE, objects.named(platform.osArch))
}
outgoing.artifact(tasks.named("jar"))
outgoing.artifact(nativeJar)
extendsFrom(configurations["runtimeElements"])
}
javaComponent.addVariantsFromConfiguration(nativeRuntimeElements) {}
}
}
}
}

publishing.publications {
fun MavenPom.setupPom(pomName: String, pomDescription: String, pomPackaging: String) {
name.set(pomName)
description.set(pomDescription)
url.set("https://github.com/$projVcs")
packaging = pomPackaging
licenses {
license {
name.set("MIT")
url.set("https://raw.githubusercontent.com/$projVcs/$projBranch/LICENSE")
}
}
organization {
name.set(orgName)
url.set(orgUrl)
}
developers {
developer {
id = "squid233"
url = "https://github.com/squid233"
organization = orgName
organizationUrl = orgUrl
}
}
scm {
connection.set("scm:git:https://github.com/${projVcs}.git")
developerConnection.set("scm:git:https://github.com/${projVcs}.git")
url.set("https://github.com/${projVcs}.git")
}
}

Artifact.values().forEach { module ->
create<MavenPublication>("maven${module.name}") {
groupId = projGroupId
artifactId = module.artifactName
version = projVersion
description = module.projectDescription
from(project(module.subprojectName).components["java"])
pom {
setupPom(module.projectName, module.projectDescription, "jar")
}
}
}

create<MavenPublication>("overrunglBOM") {
from(components["javaPlatform"])
artifactId = "overrungl-bom"
pom {
fun org.w3c.dom.Node.appendBOM(platform: NativePlatform?, module: Artifact) {
ownerDocument.createElement("dependency").also(::appendChild).apply {
appendChild(
ownerDocument.createElement("groupId").also(::appendChild)
.apply { textContent = "io.github.over-run" })
appendChild(
ownerDocument.createElement("artifactId").also(::appendChild)
.apply { textContent = module.artifactName })
appendChild(
ownerDocument.createElement("version").also(::appendChild)
.apply { textContent = projVersion })
if (platform != null) {
appendChild(
ownerDocument.createElement("classifier").also(::appendChild)
.apply { textContent = platform.classifier })
}
}
}

setupPom("OverrunGL BOM", "OverrunGL Bill of Materials.", "pom")
withXml {
asElement().getElementsByTagName("dependencyManagement").item(0).apply {
asElement().getElementsByTagName("dependencies").item(0).apply {
Artifact.values().forEach { module ->
if (module.nativeBinding != null) {
module.nativeBinding!!.platforms.forEach { appendBOM(it, module) }
} else {
appendBOM(null, module)
}
}
}
}

// Workaround for https://github.com/gradle/gradle/issues/7529
asNode()
}
}
}
}
Expand Down Expand Up @@ -310,9 +95,3 @@ signing {
if (!projVersion.endsWith("-SNAPSHOT") && System.getProperty("gpg.signing", "true").toBoolean())
sign(publishing.publications)
}

dependencies {
constraints {
Artifact.values().forEach { api("io.github.over-run:${it.artifactName}:$projVersion") }
}
}
12 changes: 12 additions & 0 deletions buildSrc/src/main/kotlin/OverrunGLModuleExtension.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import org.gradle.api.provider.Property
import org.gradle.api.provider.Provider

/**
* @author squid233
* @since 0.1.0
*/
abstract class OverrunGLModuleExtension {
abstract val artifactName: Property<String>
abstract val publishInfo: Property<Artifact>
abstract val nativeBinding: Property<NativeBinding>
}
8 changes: 8 additions & 0 deletions buildSrc/src/main/kotlin/accessors.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import org.gradle.api.Action
import org.gradle.api.Project

val Project.overrunglModule: OverrunGLModuleExtension
get() = extensions.getByName("overrunglModule") as OverrunGLModuleExtension

fun Project.overrunglModule(configure: Action<OverrunGLModuleExtension>) =
extensions.configure("overrunglModule", configure)
Loading

0 comments on commit 4ffcbda

Please sign in to comment.