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
143 changes: 56 additions & 87 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,15 @@ plugins {
id 'jacoco'

// For publishing to Maven Central, we'll want these.
id 'maven-publish'
id 'signing'
id "com.vanniktech.maven.publish" version "0.36.0"

// To be able to use Spotless in the project, this will be needed.
id "com.diffplug.spotless" version "6.9.0"
id "com.diffplug.spotless" version "7.2.1"
}

group('io.github.lucasstarsz.fastj')
version('1.7.0-SNAPSHOT-2')
description('An open source, Java-based 2D game engine.')
group = 'io.github.lucasstarsz.fastj'
version = '1.7.0-SNAPSHOT'
description = 'An open source, Java-based 2D game engine.'

import org.gradle.api.internal.tasks.testing.results.DefaultTestResult

Expand All @@ -25,14 +24,12 @@ import org.gradle.api.internal.tasks.testing.results.DefaultTestResult
* ********************* */


sourceCompatibility = 18
targetCompatibility = 18
java.withSourcesJar()
java.withJavadocJar()
java.sourceCompatibility = 21
java.targetCompatibility = 21

javadoc.source(sourceSets.main.allJava)
javadoc.failOnError(false)
javadoc.options.links = ['https://docs.oracle.com/en/java/javase/18/docs/api/', 'https://www.slf4j.org/apidocs/']
javadoc.source = sourceSets.main.allJava
javadoc.failOnError = false
javadoc.options.links = ['https://docs.oracle.com/en/java/javase/21/docs/api/', 'https://www.slf4j.org/apidocs/']
javadoc.options.stylesheetFile = file("${projectDir}/src/fastjstyle.css")
javadoc.doLast {
copy {
Expand All @@ -42,17 +39,12 @@ javadoc.doLast {
}
}

sourcesJar.from(sourceSets.main.allSource)
javadocJar.from(javadoc.destinationDir)
artifacts.archives(sourcesJar)
artifacts.archives(javadocJar)

// Java modules need this in order for the module path to be inferred based on module-info.java files.
plugins.withType(JavaPlugin).configureEach {
java.modularity.inferModulePath = true
}

wrapper.gradleVersion = '7.5.1'
wrapper.gradleVersion = '8.14.3'
wrapper.distributionType = Wrapper.DistributionType.ALL

repositories.mavenCentral()
Expand All @@ -73,28 +65,25 @@ dependencies.testRuntimeOnly("org.junit.platform:junit-platform-launcher")
* ********************* */


tasks.withType(Test) {
tasks.withType(Test).configureEach {
useJUnitPlatform()
testLogging {

def totalTestTime = 0
def totalTestTime = 0

afterTest { desc, DefaultTestResult result ->
totalTestTime += result.endTime - result.startTime
}
afterTest { desc, DefaultTestResult result ->
totalTestTime += result.endTime - result.startTime
}

afterSuite { desc, DefaultTestResult result ->
if (!desc.parent) { // will match the outermost suite
def passFailSkip = "$result.successfulTestCount passed, $result.failedTestCount failed, $result.skippedTestCount skipped"
def results = "Test Suite Results: $result.resultType ($result.testCount tests, $passFailSkip) in $totalTestTime ms."
afterSuite { desc, DefaultTestResult result ->
if (!desc.parent) { // will match the outermost suite
def passFailSkip = "$result.successfulTestCount passed, $result.failedTestCount failed, $result.skippedTestCount skipped"
def results = "Test Suite Results: $result.resultType ($result.testCount tests, $passFailSkip) in $totalTestTime ms."

def startItem = '| '
def endItem = ' |'
def repeatLength = startItem.length() + results.length() + endItem.length()
def dashes = '-' * repeatLength
def startItem = '| '
def endItem = ' |'
def repeatLength = startItem.length() + results.length() + endItem.length()
def dashes = '-' * repeatLength

logger.info(String.format('%n%n%s%n%s%s%s%n%s%n%n', dashes, startItem, results, endItem, dashes))
}
logger.info(String.format('%n%n%s%n%s%s%s%n%s%n%n', dashes, startItem, results, endItem, dashes))
}
}
}
Expand Down Expand Up @@ -134,64 +123,44 @@ jacocoTestReport {
dependsOn(test) // tests are required to run before generating the report
reports.xml.required.set(true)
reports.csv.required.set(false)
reports.xml.destination(layout.buildDirectory.dir('build/reports/jacoco/test/jacocoTestReport.xml').get().asFile)
reports.xml.outputLocation = layout.buildDirectory.dir('build/reports/jacoco/test/jacocoTestReport.xml').get().asFile
}


/* ********************* *
* Publishing *
* ********************* */


def shouldPublish = System.getenv('ossrhUsername') != null && System.getenv('ossrhPassword') != null
publish.onlyIf { shouldPublish }

if (shouldPublish) {
publishing.publications {
fastjPublish(MavenPublication) {

groupId = project.group
version = project.version
artifactId = 'fastj-library'

pom {
name = 'FastJ Game Library'
description = project.description
url = 'https://github.com/fastjengine/FastJ'

scm {
connection = 'scm:git:https://github.com/fastjengine/FastJ.git'
developerConnection = 'scm:git:https://github.com/fastjengine/FastJ.git'
url = 'https://fastj.tech'
}

licenses {
license {
name = 'MIT License'
url = 'https://github.com/fastjengine/FastJ/blob/main/LICENSE.txt'
}
}

developers {
developer {
id = 'andrewd'
name = 'Andrew Dey'
email = 'andrewrcdey@gmail.com'
}
}
mavenPublishing {
publishToMavenCentral()
signAllPublications()
coordinates("io.github.lucasstarsz.fastj", "fastj-library", project.version as String)

pom {
name = 'FastJ Game Library'
description = 'An open source, Java-based 2D game engine.'
inceptionYear = "2020"
url = 'https://github.com/fastjengine/FastJ'

licenses {
license {
name = 'MIT License'
url = 'https://github.com/fastjengine/FastJ/blob/main/LICENSE.txt'
distribution = 'https://github.com/fastjengine/FastJ/blob/main/LICENSE.txt'
}

from(components.java)
}
developers {
developer {
id = 'andrewd'
name = 'Andrew Dey'
email = 'andrewrcdey@gmail.com'
url = 'https://github.com'
}
}
scm {
connection = 'scm:git:https://github.com/fastjengine/FastJ.git'
developerConnection = 'scm:git:https://github.com/fastjengine/FastJ.git'
url = 'https://fastj.tech'
}
}

publishing.repositories.maven {
url = 'https://oss.sonatype.org/service/local/staging/deploy/maven2/'
credentials.username = System.getenv('ossrhUsername')
credentials.password = System.getenv('ossrhPassword')
}

signing {
sign publishing.publications.fastjPublish
}
}
}
12 changes: 6 additions & 6 deletions examples/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ plugins {
id 'java'
}

group('io.github.lucasstarsz.fastj')
version('1.7.0-SNAPSHOT')
description('Example programs for the FastJ Game Engine.')
group = 'io.github.lucasstarsz.fastj'
version = '1.7.0-SNAPSHOT'
description = 'Example programs for the FastJ Game Engine.'

sourceCompatibility = 18
targetCompatibility = 18
java.sourceCompatibility = 21
java.targetCompatibility = 21

repositories {
mavenCentral()
Expand All @@ -23,7 +23,7 @@ sourceSets {
main.resources.srcDirs = ['resources']
}

task run(type: Exec) {
tasks.register('run', Exec) {
doFirst {
if (!project.hasProperty('toRun')) {
throw new IllegalArgumentException(
Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
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.5.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.3-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading
Loading