Last active
June 22, 2018 08:36
-
-
Save Blastman/e79fce29f2e9bdc36cf7126d5b2211f8 to your computer and use it in GitHub Desktop.
NodeJS using Gradle
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
buildscript { | |
ext { | |
springBootVersion = '1.3.3.RELEASE' | |
} | |
repositories { | |
mavenCentral() | |
jcenter() | |
} | |
dependencies { | |
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}") | |
classpath 'com.moowork.gradle:gradle-node-plugin:0.12' | |
} | |
} | |
apply plugin: 'java' | |
apply plugin: 'eclipse' | |
apply plugin: 'spring-boot' | |
apply plugin: 'war' | |
apply plugin: "com.moowork.node" | |
node { | |
version = '5.8.0' | |
npmVersion = '3.8.0' | |
download = true | |
// distBaseUrl = Custom artifactory location here for node/npm. | |
} | |
war { | |
baseName = 'gradlenpm' | |
version = '0.0.1-SNAPSHOT' | |
} | |
sourceCompatibility = 1.8 | |
targetCompatibility = 1.8 | |
repositories { | |
mavenCentral() | |
} | |
configurations { | |
providedRuntime | |
} | |
dependencies { | |
compile('org.springframework.boot:spring-boot-starter-web') | |
providedRuntime('org.springframework.boot:spring-boot-starter-tomcat') | |
testCompile('org.springframework.boot:spring-boot-starter-test') | |
} | |
eclipse { | |
classpath { | |
containers.remove('org.eclipse.jdt.launching.JRE_CONTAINER') | |
containers 'org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8' | |
} | |
} | |
task wrapper(type: Wrapper) { | |
gradleVersion = '2.12' | |
} | |
clean.delete << file('node_modules') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
echo Running Project Level npm | |
node_modules/.bin/npm.cmd %* |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
echo "Running Project Level npm" | |
node_modules/.bin/npm "$@" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
task npmInstallSave(type: NpmTask, dependsOn: 'npmInstall'){ | |
def dep = project.properties['dep'] | |
if (!dep) { | |
throw new GradleException('depName required. Use -Pdep=SomeNpmPackage as a command line parameter (e.g., "gradlew npmInstallSave -PdepName=react"') | |
} | |
args = ['install', '-save', dep] | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "gradle-npm", | |
"version": "0.0.1", | |
"description": "NodeJS/npm using gradle example", | |
"scripts": {}, | |
"devDependencies": {}, | |
"dependencies": {} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment