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/create gradle page plugin #5

Merged
merged 3 commits into from
Feb 20, 2018
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
49 changes: 5 additions & 44 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,50 +1,11 @@

plugins {
id "com.moowork.node" version "1.2.0"
}

def currentDir = project.projectDir

subprojects {
apply plugin: 'com.moowork.node'
apply plugin: 'distribution'
apply plugin: BonitaPagePlugin

node {
version = '8.9.4'
bonitaPage {
nodeVersion = '8.9.4'
npmVersion = '5.6.0'
download = true

workDir = file("${currentDir}/.gradle/nodejs")
npmWorkDir = file("${currentDir}/.gradle/npm")
}

tasks.npm_install.configure {
inputs.files('package.json', 'package-lock.json')
outputs.dirs('node_modules')
}

def buildNpm = task buildNpm(type: NpmTask, dependsOn: npm_install) {
args = ['run', 'build']
inputs.files('package.json', 'package-lock.json')
inputs.dir('src')
}

tasks.distZip.dependsOn buildNpm

def cleanNpm = task cleanNpm {
doFirst {
delete 'dist'
}
frontendBuildDir = 'dist'
}

tasks.clean.dependsOn cleanNpm

distributions{
main {
contents {
from('resources') { into '/' }
from('dist') { into '/resources' }
}
}
}
}
}
9 changes: 9 additions & 0 deletions buildSrc/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
repositories {
mavenLocal()
maven { url 'http://repositories.rd.lan/maven/releases/' }
maven { url 'https://plugins.gradle.org/m2/' }
}

dependencies {
compile 'com.moowork.gradle:gradle-node-plugin:1.2.0'
}
62 changes: 62 additions & 0 deletions buildSrc/src/main/groovy/BonitaPagePlugin.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import org.gradle.api.Plugin
import org.gradle.api.Project

class BonitaPagePlugin implements Plugin<Project> {

@Override
void apply(Project project) {
def extension = project.extensions.create('bonitaPage', BonitaPagePluginExtension)
project.plugins.apply('com.moowork.node')
project.plugins.apply('distribution')
def currentDir = project.rootProject.projectDir


project.node {
download = true

workDir = project.file("${currentDir}/.gradle/nodejs")
npmWorkDir = project.file("${currentDir}/.gradle/npm")
}

project.afterEvaluate {
project.node {
version = extension.nodeVersion
npmVersion = extension.npmVersion
}
}

project.tasks.npm_install.configure {
inputs.files('package.json', 'package-lock.json')
outputs.dirs('node_modules')
}

def buildPage = project.task([type: com.moowork.gradle.node.npm.NpmTask, dependsOn: project.tasks.npm_install], 'buildPage') {
args = ['run', 'build']
inputs.files('package.json', 'package-lock.json')
inputs.dir('src')
}

project.tasks.distZip.dependsOn buildPage

def cleanNpm = project.task([:], 'cleanNpm') {
doFirst {
project.delete extension.frontendBuildDir
}
}

project.tasks.clean.dependsOn cleanNpm

project.distributions {
main {
contents {
from('resources') { into '/' }
from({ extension.frontendBuildDir }) {
into '/resources'
}
}
}
}

}

}
5 changes: 5 additions & 0 deletions buildSrc/src/main/groovy/BonitaPagePluginExtension.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class BonitaPagePluginExtension {
String nodeVersion
String npmVersion
String frontendBuildDir
}
3 changes: 2 additions & 1 deletion page-hello-world-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@
"name": "page-hello-world-react",
"version": "0.1.0",
"private": true,
"homepage": ".",
"dependencies": {
"react": "^16.2.0",
"react-dom": "^16.2.0",
"react-scripts": "1.1.1"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"build": "react-scripts build && mv build dist || move build dist",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
},
Expand Down
1 change: 1 addition & 0 deletions page-hello-world-react/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link rel="stylesheet" href="../theme/theme.css">
<title>Hello World with React</title>
</head>
<body>
Expand Down
5 changes: 5 additions & 0 deletions page-hello-world-react/resources/page.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
name=custompage_helloWorldReact
displayName=hello world react
description=simple hello world page using react
resources=[]
contentType=page
2 changes: 1 addition & 1 deletion page-hello-world/resources/page.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name=custompage_hello_world
name=custompage_helloWorld
displayName=hello world
description=simple hello world page
resources=[]
Expand Down
11 changes: 6 additions & 5 deletions page-hello-world/src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@
</head>
<body>

<div class="jumbotron">
<h1>Hello, world!</h1>
<p>...</p>
<p><a class="btn btn-primary btn-lg" href="#" role="button">Learn more</a></p>
<div class="container">
<div class="jumbotron">
<h1>Hello, world!</h1>
<p>...</p>
<p><a class="btn btn-primary btn-lg" href="#" role="button">Learn more</a></p>
</div>
</div>

</body>
</html>
1 change: 1 addition & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ pluginManagement {
}

include 'page-hello-world'
include 'page-hello-world-react'

rootProject.name = 'bonita-web-pages'

Expand Down