Skip to content

Commit

Permalink
Move to buildSrc plugins instead of subProjects
Browse files Browse the repository at this point in the history
Use version catalogues to keep versions in sync
Update to gradle 8.8
  • Loading branch information
jaredlll08 committed Feb 10, 2025
1 parent a024ca3 commit ec43160
Show file tree
Hide file tree
Showing 26 changed files with 357 additions and 392 deletions.
16 changes: 3 additions & 13 deletions CodeModel/build.gradle
Original file line number Diff line number Diff line change
@@ -1,16 +1,6 @@
// Note: "common.gradle" in the root project contains additional initialization
// for this project. This initialization is applied in the "build.gradle"
// of the root project.

// NetBeans will automatically add "run" and "debug" tasks relying on the
// "mainClass" property. You may however define the property prior executing
// tasks by passing a "-PmainClass=<QUALIFIED_CLASS_NAME>" argument.
//
// Note however, that you may define your own "run" and "debug" task if you
// prefer. In this case NetBeans will not add these tasks but you may rely on
// your own implementation.
if (!hasProperty('mainClass')) {
ext.mainClass = ''
plugins {
id 'zencode-common'
id 'zencode-publish'
}

dependencies {
Expand Down
22 changes: 4 additions & 18 deletions JavaAnnotations/build.gradle
Original file line number Diff line number Diff line change
@@ -1,18 +1,4 @@
// Note: "common.gradle" in the root project contains additional initialization
// for this project. This initialization is applied in the "build.gradle"
// of the root project.

// NetBeans will automatically add "run" and "debug" tasks relying on the
// "mainClass" property. You may however define the property prior executing
// tasks by passing a "-PmainClass=<QUALIFIED_CLASS_NAME>" argument.
//
// Note however, that you may define your own "run" and "debug" task if you
// prefer. In this case NetBeans will not add these tasks but you may rely on
// your own implementation.
if (!hasProperty('mainClass')) {
ext.mainClass = ''
}

dependencies {
// no dependencies
}
plugins {
id 'zencode-common'
id 'zencode-publish'
}
20 changes: 5 additions & 15 deletions JavaBytecodeCompiler/build.gradle
Original file line number Diff line number Diff line change
@@ -1,21 +1,11 @@
// Note: "common.gradle" in the root project contains additional initialization
// for this project. This initialization is applied in the "build.gradle"
// of the root project.

// NetBeans will automatically add "run" and "debug" tasks relying on the
// "mainClass" property. You may however define the property prior executing
// tasks by passing a "-PmainClass=<QUALIFIED_CLASS_NAME>" argument.
//
// Note however, that you may define your own "run" and "debug" task if you
// prefer. In this case NetBeans will not add these tasks but you may rely on
// your own implementation.
if (!hasProperty('mainClass')) {
ext.mainClass = ''
plugins {
id 'zencode-common'
id 'zencode-publish'
}

dependencies {
api group: 'org.ow2.asm', name: 'asm', version: '9.3'
api group: 'org.ow2.asm', name: 'asm-commons', version: '9.3'
api libs.asm
api libs.asm.commons
api project(':CodeModel')
api project(':JavaShared')
}
16 changes: 3 additions & 13 deletions JavaIntegration/build.gradle
Original file line number Diff line number Diff line change
@@ -1,16 +1,6 @@
// Note: "common.gradle" in the root project contains additional initialization
// for this project. This initialization is applied in the "build.gradle"
// of the root project.

// NetBeans will automatically add "run" and "debug" tasks relying on the
// "mainClass" property. You may however define the property prior executing
// tasks by passing a "-PmainClass=<QUALIFIED_CLASS_NAME>" argument.
//
// Note however, that you may define your own "run" and "debug" task if you
// prefer. In this case NetBeans will not add these tasks but you may rely on
// your own implementation.
if (!hasProperty('mainClass')) {
ext.mainClass = ''
plugins {
id 'zencode-common'
id 'zencode-publish'
}

dependencies {
Expand Down
29 changes: 11 additions & 18 deletions JavaScripting/build.gradle
Original file line number Diff line number Diff line change
@@ -1,21 +1,14 @@
repositories {
mavenCentral()
}

dependencies {
implementation 'org.ow2.asm:asm-debug-all:6.0_BETA'
plugins {
id 'zencode-common'
id 'zencode-publish'
}

def javaScriptingProjects = [':JavaIntegration', ':JavaAnnotations', ':JavaBytecodeCompiler', ':JavaShared', ':Validator', ':Parser', ':CodeModel', ':Shared']
jar {
dependsOn javaScriptingProjects.collect { it + ":compileJava" }
from files(javaScriptingProjects.collect { project(it).sourceSets.main.output })
}
sourcesJar {
from files(javaScriptingProjects.collect { project(it).sourceSets.main.allSource })
}
//install {
// repositories.mavenInstaller {
// pom.artifactId = 'zencode-javascripting'
// }
//}

dependencies {
implementation libs.asm.debug
javaScriptingProjects.each {
outputJava project(path: it, configuration: 'outputJava')
outputResources project(path: it, configuration: 'outputResources')
}
}
2 changes: 0 additions & 2 deletions JavaScripting/configuration.gradle

This file was deleted.

18 changes: 4 additions & 14 deletions JavaShared/build.gradle
Original file line number Diff line number Diff line change
@@ -1,18 +1,8 @@
// Note: "common.gradle" in the root project contains additional initialization
// for this project. This initialization is applied in the "build.gradle"
// of the root project.

// NetBeans will automatically add "run" and "debug" tasks relying on the
// "mainClass" property. You may however define the property prior executing
// tasks by passing a "-PmainClass=<QUALIFIED_CLASS_NAME>" argument.
//
// Note however, that you may define your own "run" and "debug" task if you
// prefer. In this case NetBeans will not add these tasks but you may rely on
// your own implementation.
if (!hasProperty('mainClass')) {
ext.mainClass = ''
plugins {
id 'zencode-common'
id 'zencode-publish'
}

dependencies {
api project(':CodeModel')
}
}
6 changes: 0 additions & 6 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,4 @@ pipeline {
}
}
}

post {
always {
archiveArtifacts '*/build/libs/**.jar'
}
}
}
16 changes: 3 additions & 13 deletions Parser/build.gradle
Original file line number Diff line number Diff line change
@@ -1,16 +1,6 @@
// Note: "common.gradle" in the root project contains additional initialization
// for this project. This initialization is applied in the "build.gradle"
// of the root project.

// NetBeans will automatically add "run" and "debug" tasks relying on the
// "mainClass" property. You may however define the property prior executing
// tasks by passing a "-PmainClass=<QUALIFIED_CLASS_NAME>" argument.
//
// Note however, that you may define your own "run" and "debug" task if you
// prefer. In this case NetBeans will not add these tasks but you may rely on
// your own implementation.
if (!hasProperty('mainClass')) {
ext.mainClass = ''
plugins {
id 'zencode-common'
id 'zencode-publish'
}

dependencies {
Expand Down
15 changes: 4 additions & 11 deletions ScriptingEngineTester/build.gradle
Original file line number Diff line number Diff line change
@@ -1,19 +1,12 @@
plugins {
id 'java'
}

group 'org.example'
version 'unspecified'

repositories {
mavenCentral()
id 'zencode-common'
}

dependencies {
api project(':Shared')
implementation 'org.junit.jupiter:junit-jupiter-api:5.9.0'
implementation 'org.junit.platform:junit-platform-engine:1.9.0'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.9.0'
implementation libs.jupiter.api
implementation libs.junit.platform.engine
testRuntimeOnly libs.jupiter.engine
}

test {
Expand Down
28 changes: 14 additions & 14 deletions ScriptingExample/build.gradle
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
// Note: "common.gradle" in the root project contains additional initialization
// for this project. This initialization is applied in the "build.gradle"
// of the root project.
plugins {
id 'zencode-common'
}

// NetBeans will automatically add "run" and "debug" tasks relying on the
// "mainClass" property. You may however define the property prior executing
// tasks by passing a "-PmainClass=<QUALIFIED_CLASS_NAME>" argument.
//
// Note however, that you may define your own "run" and "debug" task if you
// prefer. In this case NetBeans will not add these tasks but you may rely on
// your own implementation.
if (!hasProperty('mainClass')) {
ext.mainClass = 'org.openzen.zenscript.scriptingexample.Main'
}

configurations {
register("stdLibs") {
canBeResolved = true
}
}

dependencies {
api project(':JavaIntegration')
testImplementation project(':ScriptingEngineTester')
testImplementation group: "org.junit.jupiter", name: "junit-jupiter", version: "5.9.0"
testRuntimeOnly group: "org.junit.jupiter", name: "junit-jupiter", version: "5.9.0"
testImplementation libs.jupiter
testRuntimeOnly libs.jupiter
stdLibs project(path: ":StdLibs", configuration: "zip")
}

processResources {
dependsOn(":StdLibs:zipItUp")
from files(evaluationDependsOn(":StdLibs").tasks.getByName("zipItUp").outputs)
dependsOn(configurations.stdLibs)
from(configurations.stdLibs)
}

test {
Expand Down
28 changes: 4 additions & 24 deletions Shared/build.gradle
Original file line number Diff line number Diff line change
@@ -1,24 +1,4 @@
// Note: "common.gradle" in the root project contains additional initialization
// for this project. This initialization is applied in the "build.gradle"
// of the root project.

// NetBeans will automatically add "run" and "debug" tasks relying on the
// "mainClass" property. You may however define the property prior executing
// tasks by passing a "-PmainClass=<QUALIFIED_CLASS_NAME>" argument.
//
// Note however, that you may define your own "run" and "debug" task if you
// prefer. In this case NetBeans will not add these tasks but you may rely on
// your own implementation.
if (!hasProperty('mainClass')) {
ext.mainClass = ''
}

dependencies {
// TODO: Add dependencies here
// but note that JUnit should have already been added in parent.gradle.
// By default, only the Maven Central Repository is specified in
// parent.gradle.
//
// You can read more about how to add dependency here:
// http://www.gradle.org/docs/current/userguide/dependency_management.html#sec:how_to_declare_your_dependencies
}
plugins {
id 'zencode-common'
id 'zencode-publish'
}
2 changes: 1 addition & 1 deletion StdLibs
Submodule StdLibs updated 1 files
+33 −1 build.gradle
16 changes: 3 additions & 13 deletions Validator/build.gradle
Original file line number Diff line number Diff line change
@@ -1,16 +1,6 @@
// Note: "common.gradle" in the root project contains additional initialization
// for this project. This initialization is applied in the "build.gradle"
// of the root project.

// NetBeans will automatically add "run" and "debug" tasks relying on the
// "mainClass" property. You may however define the property prior executing
// tasks by passing a "-PmainClass=<QUALIFIED_CLASS_NAME>" argument.
//
// Note however, that you may define your own "run" and "debug" task if you
// prefer. In this case NetBeans will not add these tasks but you may rely on
// your own implementation.
if (!hasProperty('mainClass')) {
ext.mainClass = ''
plugins {
id 'zencode-common'
id 'zencode-publish'
}

dependencies {
Expand Down
21 changes: 0 additions & 21 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,21 +0,0 @@
apply plugin: 'base' // To add "clean" task to the root project.

subprojects {
apply from: rootProject.file('common.gradle')
}

task mergedJavadoc(type: Javadoc, description: 'Creates Javadoc from all the projects.') {
title = 'All modules'
destinationDir = new File(project.buildDir, 'merged-javadoc')

// Note: The closures below are executed lazily.
source {
subprojects*.sourceSets*.main*.allSource
}
classpath.from {
subprojects*.configurations*.compile*.copyRecursive({ !(it instanceof ProjectDependency) })*.resolve()
}
}

dependencies {
}
3 changes: 3 additions & 0 deletions buildSrc/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
plugins {
id 'groovy-gradle-plugin'
}
68 changes: 68 additions & 0 deletions buildSrc/src/main/groovy/zencode-common.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
import java.nio.charset.StandardCharsets

plugins {
id 'java-library'
}

String branchName = (System.getenv('BRANCH_NAME') ?: 'master').replaceAll('[^A-Za-z-_0-9]', '_')
if (!branchName.equalsIgnoreCase('master')) {
version = branchName + '-' + version
}

if (System.getenv('BUILD_NUMBER') != null) {
version += '.' + System.getenv('BUILD_NUMBER')
}

repositories {
mavenCentral()
}

java {
toolchain.languageVersion = JavaLanguageVersion.of(8)
withSourcesJar()
withJavadocJar()
}

configurations {
outputJava {
canBeResolved = true
canBeConsumed = true
}
outputResources {
canBeResolved = true
canBeConsumed = true
}
}

artifacts {
outputJava sourceSets.main.java.sourceDirectories.singleFile
outputResources sourceSets.main.resources.sourceDirectories.singleFile
}

tasks.named('compileJava', JavaCompile) {
dependsOn(configurations.outputJava)
source(configurations.outputJava)
}

processResources {
dependsOn(configurations.outputResources)
from(configurations.outputResources)
}

tasks.named('javadoc', Javadoc) {
dependsOn(configurations.outputJava)
source(configurations.outputJava)
options {
encoding = StandardCharsets.UTF_8
if (it instanceof StandardJavadocDocletOptions) {
(it as StandardJavadocDocletOptions).addStringOption("Xdoclint:none", "-quiet")
}
}
}

tasks.named('sourcesJar', Jar) {
dependsOn(configurations.outputJava)
from(configurations.outputJava)
dependsOn(configurations.outputResources)
from(configurations.outputResources)
}
Loading

0 comments on commit ec43160

Please sign in to comment.