Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat nodejsgradle #209

Merged
merged 3 commits into from
Apr 6, 2021
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
36 changes: 9 additions & 27 deletions BUILDING.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Building from scratch
* **gradle** is the primary build tool for the main Java project (runs on **Java**)
* **grunt** (runs on **Node.js**, installed via **npm**) is used by the **nodel-webui-js** project component


The steps below describe usage on both Windows and Linux
* The example refers to **Windows**
Expand All @@ -12,22 +12,17 @@ The steps below describe usage on both Windows and Linux
1. **Java JDK 8**, see [latest versions](https://adoptopenjdk.net/releases.html)
* latest Windows [OpenJDK8U-jdk_x64_windows_hotspot_8u242b08.zip](https://github.com/AdoptOpenJDK/openjdk8-binaries/releases/download/jdk8u242-b08/OpenJDK8U-jdk_x64_windows_hotspot_8u242b08.zip)
* latest Linux [OpenJDK8U-jdk_x64_linux_hotspot_8u242b08.tar.gz](https://github.com/AdoptOpenJDK/openjdk8-binaries/releases/download/jdk8u242-b08/OpenJDK8U-jdk_x64_linux_hotspot_8u242b08.tar.gz)
2. **Node.js**, see [latest versions](https://nodejs.org/en/download/)
* latest Windows [node-v12.16.2-win-x64.zip](https://nodejs.org/dist/v12.16.2/node-v12.16.2-win-x64.zip)
* latest Linux [node-v12.16.2-linux-x64.tar.xz](https://nodejs.org/dist/v12.16.2/node-v12.16.2-linux-x64.tar.xz)
3. **Git**, see [latest versions](https://git-scm.com/download)
3. **Git**, see [latest versions](https://git-scm.com/download)
* latest Windows [PortableGit-2.26.0-64-bit.7z.exe](https://github.com/git-for-windows/git/releases/download/v2.26.0.windows.1/PortableGit-2.26.0-64-bit.7z.exe)
* Linux install `apt-get install git`

* all support "portable" installation, examples here are extracted to `C:\Apps`

## STEP 2: ENSURE SECONDARY DEPENDENCIES ARE 'INSTALLED'
* ensure primary dependencies, above, are on path, e.g. on Windows:
## STEP 2: ENSURE DEPENDENCIES ARE 'READY'
* ensure dependencies, above, are on path, e.g. on Windows:
```bat
set PATH=%PATH%;C:\Apps\node-v12.16.2-win-x64;C:\Apps\git\bin;C:\Apps\jdk8u242-b08\bin
set PATH=%PATH%;C:\Apps\git\bin;C:\Apps\jdk8u242-b08\bin
```
* install **grunt** and **lodash** into the "global" location (sits alongside **Node.js** binaries)
* `npm install -g grunt-cli lodash-cli`

## STEP 3: ENSURE REPOSITORY IS CLONED
* ensure primary dependencies, above, are on path (see example in STEP 2, above)
Expand All @@ -54,30 +49,18 @@ wget https://github.com/AdoptOpenJDK/openjdk8-binaries/releases/download/jdk8u24
tar xf OpenJDK8U-jdk_x64_linux_hotspot_8u242b08.tar.gz
# ends up in ./jdk8u242-b08

# download and extract Node.js (and npm)
wget https://nodejs.org/dist/v12.16.2/node-v12.16.2-linux-x64.tar.xz
tar xf node-v12.16.2-linux-x64.tar.xz
# ends up in ./node-v12.16.2-linux-x64

# (git is normally already available)

# adjust PATH
export PATH=$PATH:~/jdk8u242-b08/bin/:~/node-v12.16.2-linux-x64/bin/

# install 'grunt' and 'lodash' in "global" location
npm install -g grunt-cli lodash-cli
export PATH=$PATH:~/jdk8u242-b08/bin/

# quickly verify versions of all dependencies

java -version
# e.g. >> openjdk version "1.8.0_242"
node --version
# e.g. >> v12.16.2

git version
# e.g. >> git version 2.25.1
grunt --version
# e.g. >> grunt-cli v1.3.2
lodash --version
# e.g. >> 4.17.5

# clone repo
git clone https://github.com/museumsvictoria/nodel nodel-build
Expand Down Expand Up @@ -108,9 +91,8 @@ git clean -fxd
**Full cleanup**
```bash
rm -fr ~/jdk8u242-b08
rm -fr ~/node-v12.16.2-linux-x64
rm -fr ~/nodel-build
```

---
¹ For OSX, adjust to suit.
¹ For macOS, adjust to suit.
53 changes: 24 additions & 29 deletions nodel-webui-js/build.gradle
Original file line number Diff line number Diff line change
@@ -1,20 +1,25 @@
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'maven'

import org.apache.tools.ant.filters.ReplaceTokens
import org.joda.time.DateTime;

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

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

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

def hostname = InetAddress.getLocalHost().getHostName().toUpperCase();

def now = DateTime.now().toString();
Expand All @@ -36,32 +41,24 @@ def buildSummary = gitId
if (!branch.equals("stable"))
version project.version + "-" + branch + "_r" + rev

// <!-- grunt is embedded (via npm via node.js)
node {
version = '12.19.0'
download = true

task npmInstall(type:Exec) {
if (System.getProperty('os.name').toLowerCase(Locale.ROOT).contains('windows'))
commandLine 'npm.cmd', 'install'
else
commandLine 'npm', 'install'
workingDir "${projectDir}"
workDir = file("${project.buildDir}/nodejs")
nodeModulesDir = file("${project.projectDir}")
}

task grunt(type:Exec, dependsOn: [npmInstall]) {
if (System.getProperty('os.name').toLowerCase(Locale.ROOT).contains('windows'))
commandLine 'grunt.cmd'
else
commandLine 'grunt'
workingDir "${projectDir}"
task gruntRun(type: NpmTask, dependsOn: [npmInstall]) {
args = ['run-script', 'run-grunt']
}

clean.doFirst {
delete "${projectDir}/node_modules/"
delete "${projectDir}/temp/"
}

// grunt --!>

task copyContent(type: Copy, dependsOn: [grunt]) {
task copyContent(type: Copy, dependsOn: [gruntRun]) {
from new File(project.buildDir, 'grunt')
into new File(project.buildDir, 'www-content_stage')
exclude 'build.json'
Expand All @@ -70,16 +67,16 @@ task copyContent(type: Copy, dependsOn: [grunt]) {
task filterContentTemplates(type: Copy) {
from 'src'
into new File(project.buildDir, 'www-content_stage')
include 'build.json'
filter(ReplaceTokens, tokens: [
include 'build.json'
filter(ReplaceTokens, tokens: [
buildSummary: project.name + "-" + project.version + " " + buildSummary + " (" + hostname + ") " + now,
buildProject: project.name,
buildBranch: branch,
buildBranch : branch,
buildVersion: project.version,
buildId: buildSummary,
buildRev: rev,
buildHost: hostname,
buildDate: now
buildId : buildSummary,
buildRev : rev,
buildHost : hostname,
buildDate : now
])
}

Expand All @@ -104,9 +101,7 @@ sourceSets {
compileJava.dependsOn(zipContentInterface)
compileJava.dependsOn(copyBuildInfo)


dependencies {
compile 'joda-time:joda-time:2.6'
compile 'org.joda:joda-convert:1.7'
}

7 changes: 6 additions & 1 deletion nodel-webui-js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,12 @@
"mkdirp": "^0.5.1",
"tslib": "^1.10.0",
"uglify-js": "^3.6.0",
"uglifycss": "0.0.29"
"uglifycss": "0.0.29",
"grunt-cli": "^1.3.2",
"lodash-cli": "^4.17.5"
},
"scripts": {
"run-grunt": "node_modules/.bin/grunt"
},
"license": "MPL-2.0",
"repository": {
Expand Down