Skip to content

Commit

Permalink
Upgrade Gradle to 7.4 and Node.js to 16.x
Browse files Browse the repository at this point in the history
- Migrate build scripts to be compatible
- Bump Node.js version to one which supports ARM/Silicon builds
- Configure the node-gradle-plugin
  • Loading branch information
scroix committed Mar 18, 2024
1 parent 15ade0e commit 9e05637
Show file tree
Hide file tree
Showing 5 changed files with 2,889 additions and 85 deletions.
6 changes: 3 additions & 3 deletions nodel-framework/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import org.apache.tools.ant.filters.ReplaceTokens
import org.joda.time.DateTime;

apply plugin: 'java'
apply plugin: 'maven'
apply plugin: 'maven-publish'
apply plugin: 'eclipse'

buildscript {
Expand Down Expand Up @@ -49,8 +49,8 @@ jar {
}

dependencies {
compile 'joda-time:joda-time:2.6'
compile 'org.slf4j:slf4j-api:1.7.10'
implementation 'joda-time:joda-time:2.6'
implementation 'org.slf4j:slf4j-api:1.7.10'

// SSH features
implementation group: 'com.jcraft', name: 'jsch', version: '0.1.55'
Expand Down
73 changes: 42 additions & 31 deletions nodel-jyhost/build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
apply plugin: 'java'
apply plugin: 'application'
apply plugin: 'maven'
apply plugin: 'eclipse'
plugins {
id 'java'
id 'application'
id 'maven-publish'
id 'eclipse'
}

repositories {
mavenCentral()
Expand All @@ -21,62 +23,71 @@ rev = rev.replaceAll(/[^a-zA-Z0-9]/, '')

def buildSummary = gitId

mainClassName = "org.nodel.jyhost.Launch"
application {
mainClass = 'org.nodel.jyhost.Launch'
}

jar {
from "$buildDir/output"
baseName = 'nodel-jyhost'
archiveBaseName = 'nodel-jyhost'
manifest {
attributes 'Implementation-Title': 'Nodel JyHost',
'Implementation-Version': version
}
attributes 'Implementation-Title': 'Nodel JyHost',
'Implementation-Version': version
}
}

task fatJar(type: Jar) {
tasks.register('fatJar', Jar) {
manifest {
attributes 'Implementation-Title': 'Nodel JyHost',
'Implementation-Version': version,
'Main-Class': mainClassName
attributes 'Implementation-Title': 'Nodel JyHost',
'Implementation-Version': version,
'Main-Class': application.mainClass
}
appendix = branch
baseName = 'nodelhost'
classifier = 'rev' + rev
destinationDir new File(buildDir, 'distributions/standalone')
from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } }
archiveAppendix = branch
archiveBaseName = 'nodelhost'
archiveClassifier = 'rev' + rev
destinationDirectory = new File(buildDir, 'distributions/standalone')
from { configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) } }
with jar
exclude 'META-INF/*.RSA', 'META-INF/*.SF','META-INF/*.DSA'
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}

task unversioned(dependsOn:'fatJar', type: Copy) {
tasks.register('unversioned', Copy) {
dependsOn 'fatJar'
from(new File(buildDir, 'distributions/standalone')) {
rename '.*($version)*', 'nodelhost.jar'
}

into new File(buildDir, 'distributions/standalone')
}

build.finalizedBy(fatJar)
tasks.build {
finalizedBy 'fatJar'
}

dependencies {
compile project(':nodel-webui-js')
compile project(':nodel-framework')
compile 'commons-daemon:commons-daemon:1.0.15'
compile 'org.slf4j:slf4j-api:1.7.10'
compile 'org.python:jython-standalone:2.5.4-rc1'
implementation project(':nodel-webui-js')
implementation project(':nodel-framework')
implementation 'commons-daemon:commons-daemon:1.0.15'
implementation 'org.slf4j:slf4j-api:1.7.10'
implementation 'org.python:jython-standalone:2.5.4-rc1'

// for the Nodel HTTP client:
compile group: 'org.apache.httpcomponents', name: 'httpclient', version: '4.5.5'
implementation group: 'org.apache.httpcomponents', name: 'httpclient', version: '4.5.5'

// convenience dependency: required *only* for 'recipe sync' node
compile 'org.eclipse.jgit:org.eclipse.jgit:3.7.1.+'
implementation 'org.eclipse.jgit:org.eclipse.jgit:3.7.1.+'

// convenience dependency: required for new SNMP-based nodes
compile('org.snmp4j:snmp4j:2.5.8') {
// convenience dependency: required for new SNMP-based nodes
implementation('org.snmp4j:snmp4j:2.5.8') {
exclude group:'log4j', module:'log4j' // (brings one extra dependency: log4j; can explicity exclude it because it's optional at runtime)
}

// convenience dependency: JWTs (JSON Web Tokens), see https://github.com/museumsvictoria/nodel/discussions/297
implementation 'io.jsonwebtoken:jjwt-api:0.11.5'
runtimeOnly 'io.jsonwebtoken:jjwt-impl:0.11.5'
runtimeOnly 'io.jsonwebtoken:jjwt-orgjson:0.11.5'
}
runtimeOnly 'io.jsonwebtoken:jjwt-orgjson:0.11.5'

// Add joda-time dependency
implementation 'joda-time:joda-time:2.10.14'
}
124 changes: 83 additions & 41 deletions nodel-webui-js/build.gradle
Original file line number Diff line number Diff line change
@@ -1,28 +1,36 @@
import org.apache.tools.ant.filters.ReplaceTokens
import org.joda.time.DateTime;
import org.joda.time.DateTime

buildscript {
repositories {
mavenCentral()
jcenter()
gradlePluginPortal()
}

dependencies {
classpath 'joda-time:joda-time:2.6'
classpath 'joda-time:joda-time:2.10.10'
}
}

plugins {
id 'java'
id 'eclipse'
id 'maven'
id 'com.github.node-gradle.node' version '3.0.1'
id 'maven-publish'
id 'com.github.node-gradle.node' version '3.4.0'
}

def hostname = InetAddress.getLocalHost().getHostName().toUpperCase();
repositories {
mavenCentral()
gradlePluginPortal()
}

dependencies {
implementation 'joda-time:joda-time:2.10.10'
implementation 'org.joda:joda-convert:2.2.1'
}

def now = DateTime.now().toString();
def hostname = InetAddress.getLocalHost().getHostName().toUpperCase()
def now = DateTime.now().toString()

def gitBranch = 'git rev-parse --abbrev-ref HEAD'.execute().text.trim()
def gitId = 'git rev-parse HEAD'.execute().text.trim()
Expand All @@ -34,7 +42,6 @@ if (branch.equals("master"))
branch = "dev"

def rev = gitRev
// strip out non-alphanumeric (e.g. the '+' in '1234+')
rev = rev.replaceAll(/[^a-zA-Z0-9]/, '')

def buildSummary = gitId
Expand All @@ -43,67 +50,102 @@ if (!branch.equals("stable"))
version project.version + "-" + branch + "_r" + rev

node {
version = '12.19.0'
version = '16.20.2'
download = true

workDir = file("${project.buildDir}/nodejs")
nodeModulesDir = file("${project.projectDir}")
npmInstallCommand = System.getenv("CI") ? 'ci' : 'install'
}

tasks.register('installGruntCli', NpmTask) {
args = ['install', 'grunt-cli', '--save-dev', '--legacy-peer-deps']
}

task gruntRun(type: NpmTask, dependsOn: [npmInstall]) {
tasks.register('gruntRun', NpmTask) {
dependsOn installGruntCli
args = ['run-script', 'run-grunt']
inputs.file("Gruntfile.js")
inputs.dir("src")
inputs.dir("node_modules")
outputs.dir("build/grunt")
}

tasks.named('clean') {
doFirst {
delete "${projectDir}/node_modules/"
delete "${projectDir}/temp/"
}
}

clean.doFirst {
delete "${projectDir}/node_modules/"
delete "${projectDir}/temp/"
tasks.register('checkDistDirectory', Task) {
dependsOn gruntRun
doLast {
def distDir = file("${project.buildDir}/dist")
if (distDir.exists()) {
println "Contents of 'dist' directory:"
distDir.eachFile { file ->
println file.name
}
} else {
println "'dist' directory does not exist"
}
}
}

task copyContent(type: Copy, dependsOn: [gruntRun]) {
from new File(project.buildDir, 'grunt')
into new File(project.buildDir, 'www-content_stage')
tasks.register('copyContent', Copy) {
dependsOn gruntRun, checkDistDirectory
from file("${project.buildDir}/grunt")
into file("${project.buildDir}/www-content_stage")
exclude 'build.json'
}

task filterContentTemplates(type: Copy) {
tasks.register('filterContentTemplates', Copy) {
from 'src'
into new File(project.buildDir, 'www-content_stage')
into file("${project.buildDir}/www-content_stage")
include 'build.json'
filter(ReplaceTokens, tokens: [
buildSummary: project.name + "-" + project.version + " " + buildSummary + " (" + hostname + ") " + now,
buildOrigin: gitOrigin,
buildProject: project.name,
buildBranch : branch,
buildVersion: project.version,
buildId : buildSummary,
buildRev : rev,
buildHost : hostname,
buildDate : now
buildSummary: project.name + "-" + project.version + " " + buildSummary + " (" + hostname + ") " + now,
buildOrigin: gitOrigin,
buildProject: project.name,
buildBranch : branch,
buildVersion: project.version,
buildId : buildSummary,
buildRev : rev,
buildHost : hostname,
buildDate : now
])
}

task zipContentInterface(type: Zip, dependsOn: [copyContent, filterContentTemplates]) {
from new File(project.buildDir, 'www-content_stage')
// ... (previous code remains the same)

tasks.register('zipContentInterface', Zip) {
dependsOn copyContent, filterContentTemplates
from file("${project.buildDir}/www-content_stage")
archiveName 'content.zip'
destinationDir new File(project.buildDir, 'www-content/org/nodel/host')
destinationDirectory = file("${project.buildDir}/www-content/org/nodel/host")
}

task copyBuildInfo(type: Copy, dependsOn: [copyContent, filterContentTemplates]) {
from new File(project.buildDir, 'www-content_stage')
tasks.register('copyBuildInfo', Copy) {
dependsOn copyContent, filterContentTemplates
from file("${project.buildDir}/www-content_stage")
include 'build.json'
destinationDir new File(project.buildDir, 'www-content/org/nodel')
into file("${project.buildDir}/www-content/org/nodel")
}

sourceSets {
main {
resources.srcDir new File(project.buildDir, 'www-content')
resources.srcDirs = [file("${project.buildDir}/www-content")]
}
}

compileJava.dependsOn(zipContentInterface)
compileJava.dependsOn(copyBuildInfo)
tasks.named('compileJava') {
dependsOn zipContentInterface, copyBuildInfo
}

dependencies {
compile 'joda-time:joda-time:2.6'
compile 'org.joda:joda-convert:1.7'
tasks.named('processResources') {
dependsOn zipContentInterface, copyBuildInfo
}

dependencies {
implementation 'joda-time:joda-time:2.10.10'
implementation 'org.joda:joda-convert:2.2.1'
}
Loading

0 comments on commit 9e05637

Please sign in to comment.