SlideShare une entreprise Scribd logo
1  sur  69
Single Page JavaScript
WebApps
A Gradle Story
Kon Soulianidis
MelbJVM July 2014
This talk is about
Our App
Why we picked Gradle
Gradle Plugins for JS / CSS
Organising your Build
Taking advantage of Java Features
They Who Built
The Proof of Concept that Grew
Our App
Single page app
Choose reports to run, filter by an order or client
Query the endpoint, Google BigQuery Datastore
with language specific APIs for Java + JavaScript
Return interactive charts
Libraries
JQuery
Bootstrap
Google API’s JS libraries
Google Charts & Visualisations API
The PoC that Grew
Proof of Concept Successful
At this stage a couple of monolithic JS files held
together by a static html page
Time to think about some proper JS tooling
Image Source: JHipster.github.io
To market, to market, to become a JS-
Hipster
Set proxy
$ npm config set https-
proxy="https://NTLMREALMuser:pword@proxy.corp.com:8080/"
$ npm config set
proxy=“http://NTLMREALMuser:pword@proxy.corp.com:8080/"
Run Npm…
$ npm install npm
npm http GET https://registry.npmjs.org/npm
npm http GET https://registry.npmjs.org/npm
npm http GET https://registry.npmjs.org/npm
… Looks Promising…
Victory Snatched by the Jaws of
Defeat
But alas, our clients site hit a problem
npm ERR! Error: tunneling socket could not be
established,
cause=140230033848128:error:140770FC:SSL
routines:SSL23_GET_SERVER_HELLO:unknown
protocol:../deps/openssl/openssl/ssl/s23_clnt.c:766:
SSL23_GET_SERVER_HELLO:unkno
wn protocol
Stack overflow features many casualties across all
kinds of staple unix tools that use HTTPS
Solutions say configure tool or proxy to not verify
SSL (you like man in the middle vulnerabilities?)
In corporate IT at client site we can’t & wont do
this.
So much for being a hipster
Image Source Photobucket
JS - Climbing the
development tools
tree,
Taking each branch on the fall down
1984
1984
The Big G
Gradle CSS & JS Plugins
Eric Wendelin
Gradle JS Plugin
Gradle Css Plugin
Google Closure Compiler
Yahoo UI Compressor
Getting Started
apply plugin: 'js'
apply plugin: 'css'
// then add some dependency and build script
dependencies
plugins.gradle.org
apply plugin: 'js'
apply plugin: 'css'
// define the dependencies gradle buildscript will use to build the app (not the app
itself)
buildscript {
repositories {
mavenLocal()
mavenCentral()
}
dependencies {
classpath 'com.eriwen:gradle-css-plugin:1.11.1'
classpath 'com.eriwen:gradle-js-plugin:1.11.1'
}
}
plugins.gradle.org
apply plugin: 'js'
apply plugin: 'css'
// define the dependencies gradle buildscript will use to build the app (not the app
itself)
buildscript {
repositories {
mavenLocal()
mavenCentral()
}
dependencies {
classpath 'com.eriwen:gradle-css-plugin:1.11.1'
classpath 'com.eriwen:gradle-js-plugin:1.11.1'
}
}
plugins.gradle.org
plugins.gradle.org
If something doesn't work take a look at issues and
pull requests in Github
Support
Gradle Tasks
Build tasks
-----------
combineCss - Combine many CSS files into one
combineJs - Combine many JavaScript files into one
gzipCss - GZip a given CSS file
gzipJs - GZip a given JavaScript file
lesscss - Compiles LESS files into CSS
minifyCss - Minify CSS using YUI Minifier
minifyJs - Minify JavaScript using Closure Compiler
props2js - Convert Java properties files for use with
JavaScript
requireJs - Run the r.js Optimizer to produce Require.js
output
Ok we are setup, now what?
Combination,
Minification
GZipping
Project Layout
Old Fashioned
Download dependencies
From the internet
Manually!
CSS
Lets combine and minify our CSS
CSS
// Declare your sources
css.source {
dev {
css {
srcDir "app/styles"
include "*.css"
exclude "*.min.css"
}
}
}
CSS
// Specify a collection of files to be combined, then
minified and finally GZip compressed.
combineCss {
source = css.source.dev.css.files
dest = "${buildDir}/all.css"
}
CSS
minifyCss {
source = combineCss
dest = "${buildDir}/all-min.css"
yuicompressor { // Optional
lineBreakPos = -1
}
}
CSS
gzipCss {
source = minifyCss
dest = "${buildDir}/all.min.css.gz"
}
Combine
kon@Kostas-MBP ~/Projects/gradle-summit-
presentation $ gradle combineCss
:combineCss
BUILD SUCCESSFUL
Total time: 5.812 secs
kon@Kostas-MBP ~/Projects/gradle-summit-
presentation $ ls build/
./ ../ all.css
CSS Minify In Action
kon@Kostas-MBP ~/Projects/gradle-summit-
presentation $ gradle minifyCss
:combineCss UP-TO-DATE
:minifyCss
BUILD SUCCESSFUL
Total time: 3.545 secs
CSS Minify In Action
kon@Kostas-MBP ~/Projects/gradle-summit-
presentation $ gradle minifyCss
:combineCss UP-TO-DATE
:minifyCss
BUILD SUCCESSFUL
Total time: 3.545 secs
kon@Kostas-MBP ~/Projects/gradle-summit-
presentation $ ls build
./ ../ all-min.css all.css
CSS Minify In Action
kon@Kostas-MBP ~/Projects/gradle-summit-presentation $ gradle minifyCss
:combineCss UP-TO-DATE
:minifyCss
BUILD SUCCESSFUL
Total time: 3.545 secs
kon@Kostas-MBP ~/Projects/gradle-summit-presentation $ ls build
./ ../ all-min.css all.css
kon@Kostas-MBP ~/Projects/gradle-summit-presentation $ cat build/all-min.css
body{padding-top:50px}.sub-header{padding-bottom:10px;border-bottom:1px solid
#eee}.sidebar{display:none}@media(min-
width:768px){.sidebar{position:fixed;top:51px;bottom:0;left:0;z-
index:1000;display:block;padding:20px;overflow-x:hidden;overflow-y:auto;background-
color:#f5f5f5;border-right:1px solid #eee}}.nav-sidebar{margin-right:-21px;margin-bottom:20px;margin-
left:-20px}.nav-sidebar>li>a{padding-right:20px;padding-left:20px}.nav-
sidebar>.active>a{color:#fff;background-color:#428bca}.main{padding:20px}@media(min-
width:768px){.main{padding-right:40px;padding-left:40px}}.main .page-header{margin-
top:0}.placeholders{margin-bottom:30px;text-align:center}.placeholders h4{margin-
bottom:0}.placeholder{margin-bottom:20px}.placeholder img{display:inline-block;border-
radius:50%}.navbar{background-image:url('../images/gradle_small.png');background-position-
x:30%;background-repeat:no-repeat;background-size:contain}
gzipCss
kon@Kostas-MBP ~/Projects/gradle-summit-
presentation $ gradle gzipCss
:combineCss UP-TO-DATE
:minifyCss UP-TO-DATE
:gzipCss
BUILD SUCCESSFUL
Total time: 4.881 secs
gzipCss
kon@Kostas-MBP ~/Projects/gradle-summit-presentation $ gradle gzipCss
:combineCss UP-TO-DATE
:minifyCss UP-TO-DATE
:gzipCss
BUILD SUCCESSFUL
Total time: 4.881 secs
kon@Kostas-MBP ~/Projects/gradle-summit-presentation $ ls -la build
total 24
drwxr-xr-x 5 kon wheel 170 10 Jun 19:05 ./
drwxr-xr-x 12 kon wheel 408 10 Jun 18:51 ../
-rw-r--r-- 1 kon wheel 917 10 Jun 18:55 all-min.css
-rw-r--r-- 1 kon wheel 1539 10 Jun 18:51 all.css
-rw-r--r-- 1 kon wheel 438 10 Jun 19:04 all.min.css.gz
gzipCss
kon@Kostas-MBP ~/Projects/gradle-summit-presentation $ gradle gzipCss
:combineCss UP-TO-DATE
:minifyCss UP-TO-DATE
:gzipCss
BUILD SUCCESSFUL
Total time: 4.881 secs
kon@Kostas-MBP ~/Projects/gradle-summit-presentation $ ls -la build
total 24
drwxr-xr-x 5 kon wheel 170 10 Jun 19:05 ./
drwxr-xr-x 12 kon wheel 408 10 Jun 18:51 ../
-rw-r--r-- 1 kon wheel 917 10 Jun 18:55 all-min.css
-rw-r--r-- 1 kon wheel 1539 10 Jun 18:51 all.css
-rw-r--r-- 1 kon wheel 438 10 Jun 19:04 all.min.css.gz
And Proof
kon@Kostas-MBP ~/Projects/gradle-summit-presentation $ cat build/all.min.css.gz
pnK?i?Cċ?%?g?(?D2?C?X‫?5??]-??++-ڦ‬XvN???3Ci?q?Ԓc?Sn????$
(????i?a|oA ?mQ?/?a/ϯ????x
h4??Q$-?tI^(?C??&??QH???2?g1Ke?I?9????"=k??*Gƻ`??W?ҙN
Re????g??P6?j~ ??;?N?‫ݤ‬w.Ͳ????
?]
x??M?c>?J???x?4ʫ???E}]???~?ZV|?-G=l?{$ۣ ??????2??f?r???n??#?㩠1*"~8??q???+??U??sJ????{?q???r]D?
u?!??뜺???>???2r|??+E??7w?‫ؗ‬=?{??_ox??????<~??1???C???kon@Kostas-MBP ~/Projects/gradle-summit-presentation $
combine, minify, gzip JS
combineJs {
// pull together the source from string & file lists
// eg. def core = ["$webAppDirName/init.js",...]
source = core + application + devmode + bigquery +
javascript.source.externalLibs.js.files +
dfpFilters + chartdef + uxFilters
// show the resolved files when gradle is run with -d
source.each{ logger.debug ("$it") }
dest = file("${buildDir}/all.js")
}
Configuring Sources
MinifyJS
minifyJs {
source = combineJs
dest = file("${buildDir}/all.min.js")
sourceMap = file("${buildDir}/all.sourcemap.json")
closure {
warningLevel = 'QUIET'
compilerOptions.defineReplacements =
['MY_DEBUG_FLAG':false]
}
}
Closure Compiler Options
A bit hard to find them all. You can find them in a
source file in the Closure compiler project.
https://github.com/google/closure-
compiler/blob/master/src/com/google/javascript/jsc
omp/CompilerOptions.java
defineReplacements
// config.js
/**
* Flag to indicate console and extra logging
throughout the app
* @define {boolean} allow the value of this bool to be
* overwritten at closure compiler / minification
time
* @const
* @type {boolean}
*/
var MY_DBUG_FLAG = true;
if (MY_DBUG_FLAG) {
$('.dashboard').append(
'&lt;p&gt;Here's some dev info you wouldn't
normally see&lt;/p&gt;'
);
}
Gzip
gzipJs {
source = minifyJs.dest
dest = file(“${buildDir}/all.min.js.gz”)
}
Chain Together
tasks.minifyJs.dependsOn tasks.combineJs
tasks.gzipJs.dependsOn tasks.minifyJs
Break It Down
Multiple Project Builds
Break It Down
Referenced from build.gradle
Deploy to a Container
Use Tomcat Plugin
Run Tomcat
PrintGCTimeStampsPrint
Your Own Tasks
Write your own tasks to change code
Head.js or direct script include in different
environments
–Johnny Appleseed
“Type a quote here.”PrintGCTimeStampsPrint
Bringing Java Back
Servlet Security Demo
–Johnny Appleseed
“Type a quote here.”PrintGCTimeStampsPrint
Grunt
Remember!
Gradle works for building HTML/ JS / CSS assets
Embedded Server from Checkout
End 2 End Visibility
Proxies
Thanks
Blog goes into more detail
http://blog.shinetech.com/2014/03/19/javascript-webapps-
with-gradle/
Photos
Tom Botton - MelbJVM September
Brigitte Schuckert - Gradleware Keynote
Kon Soulianidis - Pisa & Monkey looking in lens
Climbing the Tree - Mary Evans. Licensed
Shipping Containers - Jim Bahn. Flickr. CC License
Animated Gifs - Photobucket
Duke, Grunt, Gradle logos, respective owners

Contenu connexe

Tendances

CodeIgniter PHP MVC Framework
CodeIgniter PHP MVC FrameworkCodeIgniter PHP MVC Framework
CodeIgniter PHP MVC FrameworkBo-Yi Wu
 
Symfony tips and tricks
Symfony tips and tricksSymfony tips and tricks
Symfony tips and tricksJavier Eguiluz
 
WordPress 2017 with VueJS and GraphQL
WordPress 2017 with VueJS and GraphQLWordPress 2017 with VueJS and GraphQL
WordPress 2017 with VueJS and GraphQLhouzman
 
Keeping the frontend under control with Symfony and Webpack
Keeping the frontend under control with Symfony and WebpackKeeping the frontend under control with Symfony and Webpack
Keeping the frontend under control with Symfony and WebpackIgnacio Martín
 
Build your application in seconds and optimize workflow as much as you can us...
Build your application in seconds and optimize workflow as much as you can us...Build your application in seconds and optimize workflow as much as you can us...
Build your application in seconds and optimize workflow as much as you can us...Alex S
 
Chrome enchanted 2015
Chrome enchanted 2015Chrome enchanted 2015
Chrome enchanted 2015Chang W. Doh
 
Enjoy the vue.js
Enjoy the vue.jsEnjoy the vue.js
Enjoy the vue.jsTechExeter
 
Single Page Applications in Drupal
Single Page Applications in DrupalSingle Page Applications in Drupal
Single Page Applications in DrupalChris Tankersley
 
Play Framework on Google App Engine - Productivity Stack
Play Framework on Google App Engine - Productivity StackPlay Framework on Google App Engine - Productivity Stack
Play Framework on Google App Engine - Productivity StackMarcin Stepien
 
Clojure Web Development
Clojure Web DevelopmentClojure Web Development
Clojure Web DevelopmentHong Jiang
 
Hybrid Apps (Native + Web) via QtWebKit
Hybrid Apps (Native + Web) via QtWebKitHybrid Apps (Native + Web) via QtWebKit
Hybrid Apps (Native + Web) via QtWebKitAriya Hidayat
 
125 고성능 web view-deview 2013 발표 자료_공유용
125 고성능 web view-deview 2013 발표 자료_공유용125 고성능 web view-deview 2013 발표 자료_공유용
125 고성능 web view-deview 2013 발표 자료_공유용NAVER D2
 
Spark IT 2011 - Developing RESTful Web services with JAX-RS
Spark IT 2011 - Developing RESTful Web services with JAX-RSSpark IT 2011 - Developing RESTful Web services with JAX-RS
Spark IT 2011 - Developing RESTful Web services with JAX-RSArun Gupta
 
Aligning Ember.js with Web Standards
Aligning Ember.js with Web StandardsAligning Ember.js with Web Standards
Aligning Ember.js with Web StandardsMatthew Beale
 
Build Your Own CMS with Apache Sling
Build Your Own CMS with Apache SlingBuild Your Own CMS with Apache Sling
Build Your Own CMS with Apache SlingBob Paulin
 
Micronaut: Changing the Micro Future
Micronaut: Changing the Micro FutureMicronaut: Changing the Micro Future
Micronaut: Changing the Micro FutureZachary Klein
 
Java REST API Framework Comparison - PWX 2021
Java REST API Framework Comparison - PWX 2021Java REST API Framework Comparison - PWX 2021
Java REST API Framework Comparison - PWX 2021Matt Raible
 
JAX-RS JavaOne Hyderabad, India 2011
JAX-RS JavaOne Hyderabad, India 2011JAX-RS JavaOne Hyderabad, India 2011
JAX-RS JavaOne Hyderabad, India 2011Shreedhar Ganapathy
 
Java REST API Framework Comparison - UberConf 2021
Java REST API Framework Comparison - UberConf 2021Java REST API Framework Comparison - UberConf 2021
Java REST API Framework Comparison - UberConf 2021Matt Raible
 

Tendances (20)

CodeIgniter PHP MVC Framework
CodeIgniter PHP MVC FrameworkCodeIgniter PHP MVC Framework
CodeIgniter PHP MVC Framework
 
Symfony tips and tricks
Symfony tips and tricksSymfony tips and tricks
Symfony tips and tricks
 
WordPress 2017 with VueJS and GraphQL
WordPress 2017 with VueJS and GraphQLWordPress 2017 with VueJS and GraphQL
WordPress 2017 with VueJS and GraphQL
 
Keeping the frontend under control with Symfony and Webpack
Keeping the frontend under control with Symfony and WebpackKeeping the frontend under control with Symfony and Webpack
Keeping the frontend under control with Symfony and Webpack
 
Build your application in seconds and optimize workflow as much as you can us...
Build your application in seconds and optimize workflow as much as you can us...Build your application in seconds and optimize workflow as much as you can us...
Build your application in seconds and optimize workflow as much as you can us...
 
Chrome enchanted 2015
Chrome enchanted 2015Chrome enchanted 2015
Chrome enchanted 2015
 
Enjoy the vue.js
Enjoy the vue.jsEnjoy the vue.js
Enjoy the vue.js
 
Single Page Applications in Drupal
Single Page Applications in DrupalSingle Page Applications in Drupal
Single Page Applications in Drupal
 
Play Framework on Google App Engine - Productivity Stack
Play Framework on Google App Engine - Productivity StackPlay Framework on Google App Engine - Productivity Stack
Play Framework on Google App Engine - Productivity Stack
 
Clojure Web Development
Clojure Web DevelopmentClojure Web Development
Clojure Web Development
 
Hybrid Apps (Native + Web) via QtWebKit
Hybrid Apps (Native + Web) via QtWebKitHybrid Apps (Native + Web) via QtWebKit
Hybrid Apps (Native + Web) via QtWebKit
 
125 고성능 web view-deview 2013 발표 자료_공유용
125 고성능 web view-deview 2013 발표 자료_공유용125 고성능 web view-deview 2013 발표 자료_공유용
125 고성능 web view-deview 2013 발표 자료_공유용
 
Geb presentation
Geb presentationGeb presentation
Geb presentation
 
Spark IT 2011 - Developing RESTful Web services with JAX-RS
Spark IT 2011 - Developing RESTful Web services with JAX-RSSpark IT 2011 - Developing RESTful Web services with JAX-RS
Spark IT 2011 - Developing RESTful Web services with JAX-RS
 
Aligning Ember.js with Web Standards
Aligning Ember.js with Web StandardsAligning Ember.js with Web Standards
Aligning Ember.js with Web Standards
 
Build Your Own CMS with Apache Sling
Build Your Own CMS with Apache SlingBuild Your Own CMS with Apache Sling
Build Your Own CMS with Apache Sling
 
Micronaut: Changing the Micro Future
Micronaut: Changing the Micro FutureMicronaut: Changing the Micro Future
Micronaut: Changing the Micro Future
 
Java REST API Framework Comparison - PWX 2021
Java REST API Framework Comparison - PWX 2021Java REST API Framework Comparison - PWX 2021
Java REST API Framework Comparison - PWX 2021
 
JAX-RS JavaOne Hyderabad, India 2011
JAX-RS JavaOne Hyderabad, India 2011JAX-RS JavaOne Hyderabad, India 2011
JAX-RS JavaOne Hyderabad, India 2011
 
Java REST API Framework Comparison - UberConf 2021
Java REST API Framework Comparison - UberConf 2021Java REST API Framework Comparison - UberConf 2021
Java REST API Framework Comparison - UberConf 2021
 

En vedette

Responsible introduction of tel in an organization
Responsible introduction of tel in an organizationResponsible introduction of tel in an organization
Responsible introduction of tel in an organizationAirina Volungeviciene
 
2014 OTEN Online Learning Support: Responsive design
2014 OTEN Online Learning Support: Responsive design2014 OTEN Online Learning Support: Responsive design
2014 OTEN Online Learning Support: Responsive designJennyPang2012
 
Serious Fun - How to publish a Mobile English Learning Adventure For Kids. --...
Serious Fun - How to publish a Mobile English Learning Adventure For Kids. --...Serious Fun - How to publish a Mobile English Learning Adventure For Kids. --...
Serious Fun - How to publish a Mobile English Learning Adventure For Kids. --...Linda Kruse
 
Lessons learnt from BOL
Lessons learnt from BOLLessons learnt from BOL
Lessons learnt from BOLMirza Shakeel
 
Poverty And Crime (Global Perspectives)
Poverty And Crime (Global Perspectives)Poverty And Crime (Global Perspectives)
Poverty And Crime (Global Perspectives)Joel Alexander
 
Marketing Communication Training Presentation
Marketing Communication Training PresentationMarketing Communication Training Presentation
Marketing Communication Training PresentationCody Krell
 
Encefalopatía de wernicke (ey r)
Encefalopatía de wernicke (ey r)Encefalopatía de wernicke (ey r)
Encefalopatía de wernicke (ey r)Fernanda Pineda Gea
 
16 Hollywood Faces Who are Killed by Drugs
16 Hollywood Faces Who are Killed by Drugs16 Hollywood Faces Who are Killed by Drugs
16 Hollywood Faces Who are Killed by DrugsDr. Omer Hameed
 
Content Marketing: The Approach and Opportunity
Content Marketing: The Approach and OpportunityContent Marketing: The Approach and Opportunity
Content Marketing: The Approach and OpportunityJoe Pulizzi
 
15 Powerful Team Building Quotes to Inspire Successful Teamwork
15 Powerful Team Building Quotes to Inspire Successful Teamwork15 Powerful Team Building Quotes to Inspire Successful Teamwork
15 Powerful Team Building Quotes to Inspire Successful TeamworkWeekdone.com
 
Beyond DevOps - How Netflix Bridges the Gap
Beyond DevOps - How Netflix Bridges the GapBeyond DevOps - How Netflix Bridges the Gap
Beyond DevOps - How Netflix Bridges the GapJosh Evans
 

En vedette (15)

Resume 6.27.15
Resume 6.27.15Resume 6.27.15
Resume 6.27.15
 
Ush2127
Ush2127Ush2127
Ush2127
 
Responsible introduction of tel in an organization
Responsible introduction of tel in an organizationResponsible introduction of tel in an organization
Responsible introduction of tel in an organization
 
2014 OTEN Online Learning Support: Responsive design
2014 OTEN Online Learning Support: Responsive design2014 OTEN Online Learning Support: Responsive design
2014 OTEN Online Learning Support: Responsive design
 
rajiv cv
rajiv cv rajiv cv
rajiv cv
 
Cuestionario de drivers
Cuestionario de driversCuestionario de drivers
Cuestionario de drivers
 
Serious Fun - How to publish a Mobile English Learning Adventure For Kids. --...
Serious Fun - How to publish a Mobile English Learning Adventure For Kids. --...Serious Fun - How to publish a Mobile English Learning Adventure For Kids. --...
Serious Fun - How to publish a Mobile English Learning Adventure For Kids. --...
 
Lessons learnt from BOL
Lessons learnt from BOLLessons learnt from BOL
Lessons learnt from BOL
 
Poverty And Crime (Global Perspectives)
Poverty And Crime (Global Perspectives)Poverty And Crime (Global Perspectives)
Poverty And Crime (Global Perspectives)
 
Marketing Communication Training Presentation
Marketing Communication Training PresentationMarketing Communication Training Presentation
Marketing Communication Training Presentation
 
Encefalopatía de wernicke (ey r)
Encefalopatía de wernicke (ey r)Encefalopatía de wernicke (ey r)
Encefalopatía de wernicke (ey r)
 
16 Hollywood Faces Who are Killed by Drugs
16 Hollywood Faces Who are Killed by Drugs16 Hollywood Faces Who are Killed by Drugs
16 Hollywood Faces Who are Killed by Drugs
 
Content Marketing: The Approach and Opportunity
Content Marketing: The Approach and OpportunityContent Marketing: The Approach and Opportunity
Content Marketing: The Approach and Opportunity
 
15 Powerful Team Building Quotes to Inspire Successful Teamwork
15 Powerful Team Building Quotes to Inspire Successful Teamwork15 Powerful Team Building Quotes to Inspire Successful Teamwork
15 Powerful Team Building Quotes to Inspire Successful Teamwork
 
Beyond DevOps - How Netflix Bridges the Gap
Beyond DevOps - How Netflix Bridges the GapBeyond DevOps - How Netflix Bridges the Gap
Beyond DevOps - How Netflix Bridges the Gap
 

Similaire à Single Page JavaScript WebApps... A Gradle Story

Gradle: The Build system you have been waiting for
Gradle: The Build system you have been waiting forGradle: The Build system you have been waiting for
Gradle: The Build system you have been waiting forCorneil du Plessis
 
Getting started with building your own standalone Gradle plugin
Getting started with building your own standalone Gradle pluginGetting started with building your own standalone Gradle plugin
Getting started with building your own standalone Gradle plugintobiaspreuss
 
The new static resources framework
The new static resources frameworkThe new static resources framework
The new static resources frameworkmarcplmer
 
Get Grulping with JavaScript Task Runners (Matt Gifford)
Get Grulping with JavaScript Task Runners (Matt Gifford)Get Grulping with JavaScript Task Runners (Matt Gifford)
Get Grulping with JavaScript Task Runners (Matt Gifford)Future Insights
 
Gradle: The Build System you have been waiting for!
Gradle: The Build System you have been waiting for!Gradle: The Build System you have been waiting for!
Gradle: The Build System you have been waiting for!Corneil du Plessis
 
[Coscup 2012] JavascriptMVC
[Coscup 2012] JavascriptMVC[Coscup 2012] JavascriptMVC
[Coscup 2012] JavascriptMVCAlive Kuo
 
Deploying configurable frontend web application containers
Deploying configurable frontend web application containersDeploying configurable frontend web application containers
Deploying configurable frontend web application containersJosé Moreira
 
What makes me "Grunt"?
What makes me "Grunt"? What makes me "Grunt"?
What makes me "Grunt"? Fabien Doiron
 
Javascript unit testing, yes we can e big
Javascript unit testing, yes we can   e bigJavascript unit testing, yes we can   e big
Javascript unit testing, yes we can e bigAndy Peterson
 
Gradle - time for a new build
Gradle - time for a new buildGradle - time for a new build
Gradle - time for a new buildIgor Khotin
 
How to Webpack your Django!
How to Webpack your Django!How to Webpack your Django!
How to Webpack your Django!David Gibbons
 
Building with Firebase
Building with FirebaseBuilding with Firebase
Building with FirebaseMike Fowler
 
[DEPRECATED]Gradle the android
[DEPRECATED]Gradle the android[DEPRECATED]Gradle the android
[DEPRECATED]Gradle the androidJun Liu
 
Considerations with Writing JavaScript in your DotNetNuke site
Considerations with Writing JavaScript in your DotNetNuke siteConsiderations with Writing JavaScript in your DotNetNuke site
Considerations with Writing JavaScript in your DotNetNuke siteEngage Software
 

Similaire à Single Page JavaScript WebApps... A Gradle Story (20)

Gradle: The Build system you have been waiting for
Gradle: The Build system you have been waiting forGradle: The Build system you have been waiting for
Gradle: The Build system you have been waiting for
 
Getting started with building your own standalone Gradle plugin
Getting started with building your own standalone Gradle pluginGetting started with building your own standalone Gradle plugin
Getting started with building your own standalone Gradle plugin
 
The new static resources framework
The new static resources frameworkThe new static resources framework
The new static resources framework
 
Get Grulping with JavaScript Task Runners (Matt Gifford)
Get Grulping with JavaScript Task Runners (Matt Gifford)Get Grulping with JavaScript Task Runners (Matt Gifford)
Get Grulping with JavaScript Task Runners (Matt Gifford)
 
GradleFX
GradleFXGradleFX
GradleFX
 
Google app engine by example
Google app engine by exampleGoogle app engine by example
Google app engine by example
 
Gradle: The Build System you have been waiting for!
Gradle: The Build System you have been waiting for!Gradle: The Build System you have been waiting for!
Gradle: The Build System you have been waiting for!
 
[Coscup 2012] JavascriptMVC
[Coscup 2012] JavascriptMVC[Coscup 2012] JavascriptMVC
[Coscup 2012] JavascriptMVC
 
Deploying configurable frontend web application containers
Deploying configurable frontend web application containersDeploying configurable frontend web application containers
Deploying configurable frontend web application containers
 
Meetup Performance
Meetup PerformanceMeetup Performance
Meetup Performance
 
What makes me "Grunt"?
What makes me "Grunt"? What makes me "Grunt"?
What makes me "Grunt"?
 
Having Fun with Play
Having Fun with PlayHaving Fun with Play
Having Fun with Play
 
Javascript unit testing, yes we can e big
Javascript unit testing, yes we can   e bigJavascript unit testing, yes we can   e big
Javascript unit testing, yes we can e big
 
Gradle - time for a new build
Gradle - time for a new buildGradle - time for a new build
Gradle - time for a new build
 
How to Webpack your Django!
How to Webpack your Django!How to Webpack your Django!
How to Webpack your Django!
 
Sprockets
SprocketsSprockets
Sprockets
 
Building with Firebase
Building with FirebaseBuilding with Firebase
Building with Firebase
 
[DEPRECATED]Gradle the android
[DEPRECATED]Gradle the android[DEPRECATED]Gradle the android
[DEPRECATED]Gradle the android
 
RequireJS
RequireJSRequireJS
RequireJS
 
Considerations with Writing JavaScript in your DotNetNuke site
Considerations with Writing JavaScript in your DotNetNuke siteConsiderations with Writing JavaScript in your DotNetNuke site
Considerations with Writing JavaScript in your DotNetNuke site
 

Dernier

Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataBradBedford3
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...ICS
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - InfographicHr365.us smith
 
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyFrank van der Linden
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptkotipi9215
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...soniya singh
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackVICTOR MAESTRE RAMIREZ
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfjoe51371421
 
XpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software SolutionsXpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software SolutionsMehedi Hasan Shohan
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxTier1 app
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWave PLM
 
Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...aditisharan08
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEOrtus Solutions, Corp
 
The Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfThe Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfPower Karaoke
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 

Dernier (20)

Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - Infographic
 
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The Ugly
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.ppt
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStack
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdf
 
XpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software SolutionsXpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software Solutions
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need It
 
Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
 
The Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfThe Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdf
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 

Single Page JavaScript WebApps... A Gradle Story

  • 1. Single Page JavaScript WebApps A Gradle Story Kon Soulianidis MelbJVM July 2014
  • 2. This talk is about Our App Why we picked Gradle Gradle Plugins for JS / CSS Organising your Build Taking advantage of Java Features
  • 3.
  • 4. They Who Built The Proof of Concept that Grew
  • 5. Our App Single page app Choose reports to run, filter by an order or client Query the endpoint, Google BigQuery Datastore with language specific APIs for Java + JavaScript Return interactive charts
  • 6.
  • 7.
  • 8.
  • 9. Libraries JQuery Bootstrap Google API’s JS libraries Google Charts & Visualisations API
  • 10. The PoC that Grew Proof of Concept Successful At this stage a couple of monolithic JS files held together by a static html page Time to think about some proper JS tooling
  • 12. To market, to market, to become a JS- Hipster Set proxy $ npm config set https- proxy="https://NTLMREALMuser:pword@proxy.corp.com:8080/" $ npm config set proxy=“http://NTLMREALMuser:pword@proxy.corp.com:8080/" Run Npm… $ npm install npm npm http GET https://registry.npmjs.org/npm npm http GET https://registry.npmjs.org/npm npm http GET https://registry.npmjs.org/npm … Looks Promising…
  • 13. Victory Snatched by the Jaws of Defeat But alas, our clients site hit a problem npm ERR! Error: tunneling socket could not be established, cause=140230033848128:error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol:../deps/openssl/openssl/ssl/s23_clnt.c:766:
  • 14. SSL23_GET_SERVER_HELLO:unkno wn protocol Stack overflow features many casualties across all kinds of staple unix tools that use HTTPS Solutions say configure tool or proxy to not verify SSL (you like man in the middle vulnerabilities?) In corporate IT at client site we can’t & wont do this.
  • 15. So much for being a hipster Image Source Photobucket
  • 16. JS - Climbing the development tools tree, Taking each branch on the fall down
  • 17. 1984
  • 18. 1984
  • 20. Gradle CSS & JS Plugins Eric Wendelin Gradle JS Plugin Gradle Css Plugin Google Closure Compiler Yahoo UI Compressor
  • 21. Getting Started apply plugin: 'js' apply plugin: 'css' // then add some dependency and build script dependencies
  • 22. plugins.gradle.org apply plugin: 'js' apply plugin: 'css' // define the dependencies gradle buildscript will use to build the app (not the app itself) buildscript { repositories { mavenLocal() mavenCentral() } dependencies { classpath 'com.eriwen:gradle-css-plugin:1.11.1' classpath 'com.eriwen:gradle-js-plugin:1.11.1' } }
  • 23. plugins.gradle.org apply plugin: 'js' apply plugin: 'css' // define the dependencies gradle buildscript will use to build the app (not the app itself) buildscript { repositories { mavenLocal() mavenCentral() } dependencies { classpath 'com.eriwen:gradle-css-plugin:1.11.1' classpath 'com.eriwen:gradle-js-plugin:1.11.1' } }
  • 26. If something doesn't work take a look at issues and pull requests in Github Support
  • 27. Gradle Tasks Build tasks ----------- combineCss - Combine many CSS files into one combineJs - Combine many JavaScript files into one gzipCss - GZip a given CSS file gzipJs - GZip a given JavaScript file lesscss - Compiles LESS files into CSS minifyCss - Minify CSS using YUI Minifier minifyJs - Minify JavaScript using Closure Compiler props2js - Convert Java properties files for use with JavaScript requireJs - Run the r.js Optimizer to produce Require.js output
  • 28. Ok we are setup, now what? Combination, Minification GZipping
  • 29.
  • 31.
  • 33. CSS Lets combine and minify our CSS
  • 34. CSS // Declare your sources css.source { dev { css { srcDir "app/styles" include "*.css" exclude "*.min.css" } } }
  • 35. CSS // Specify a collection of files to be combined, then minified and finally GZip compressed. combineCss { source = css.source.dev.css.files dest = "${buildDir}/all.css" }
  • 36. CSS minifyCss { source = combineCss dest = "${buildDir}/all-min.css" yuicompressor { // Optional lineBreakPos = -1 } }
  • 37. CSS gzipCss { source = minifyCss dest = "${buildDir}/all.min.css.gz" }
  • 38. Combine kon@Kostas-MBP ~/Projects/gradle-summit- presentation $ gradle combineCss :combineCss BUILD SUCCESSFUL Total time: 5.812 secs kon@Kostas-MBP ~/Projects/gradle-summit- presentation $ ls build/ ./ ../ all.css
  • 39. CSS Minify In Action kon@Kostas-MBP ~/Projects/gradle-summit- presentation $ gradle minifyCss :combineCss UP-TO-DATE :minifyCss BUILD SUCCESSFUL Total time: 3.545 secs
  • 40. CSS Minify In Action kon@Kostas-MBP ~/Projects/gradle-summit- presentation $ gradle minifyCss :combineCss UP-TO-DATE :minifyCss BUILD SUCCESSFUL Total time: 3.545 secs kon@Kostas-MBP ~/Projects/gradle-summit- presentation $ ls build ./ ../ all-min.css all.css
  • 41. CSS Minify In Action kon@Kostas-MBP ~/Projects/gradle-summit-presentation $ gradle minifyCss :combineCss UP-TO-DATE :minifyCss BUILD SUCCESSFUL Total time: 3.545 secs kon@Kostas-MBP ~/Projects/gradle-summit-presentation $ ls build ./ ../ all-min.css all.css kon@Kostas-MBP ~/Projects/gradle-summit-presentation $ cat build/all-min.css body{padding-top:50px}.sub-header{padding-bottom:10px;border-bottom:1px solid #eee}.sidebar{display:none}@media(min- width:768px){.sidebar{position:fixed;top:51px;bottom:0;left:0;z- index:1000;display:block;padding:20px;overflow-x:hidden;overflow-y:auto;background- color:#f5f5f5;border-right:1px solid #eee}}.nav-sidebar{margin-right:-21px;margin-bottom:20px;margin- left:-20px}.nav-sidebar>li>a{padding-right:20px;padding-left:20px}.nav- sidebar>.active>a{color:#fff;background-color:#428bca}.main{padding:20px}@media(min- width:768px){.main{padding-right:40px;padding-left:40px}}.main .page-header{margin- top:0}.placeholders{margin-bottom:30px;text-align:center}.placeholders h4{margin- bottom:0}.placeholder{margin-bottom:20px}.placeholder img{display:inline-block;border- radius:50%}.navbar{background-image:url('../images/gradle_small.png');background-position- x:30%;background-repeat:no-repeat;background-size:contain}
  • 42. gzipCss kon@Kostas-MBP ~/Projects/gradle-summit- presentation $ gradle gzipCss :combineCss UP-TO-DATE :minifyCss UP-TO-DATE :gzipCss BUILD SUCCESSFUL Total time: 4.881 secs
  • 43. gzipCss kon@Kostas-MBP ~/Projects/gradle-summit-presentation $ gradle gzipCss :combineCss UP-TO-DATE :minifyCss UP-TO-DATE :gzipCss BUILD SUCCESSFUL Total time: 4.881 secs kon@Kostas-MBP ~/Projects/gradle-summit-presentation $ ls -la build total 24 drwxr-xr-x 5 kon wheel 170 10 Jun 19:05 ./ drwxr-xr-x 12 kon wheel 408 10 Jun 18:51 ../ -rw-r--r-- 1 kon wheel 917 10 Jun 18:55 all-min.css -rw-r--r-- 1 kon wheel 1539 10 Jun 18:51 all.css -rw-r--r-- 1 kon wheel 438 10 Jun 19:04 all.min.css.gz
  • 44. gzipCss kon@Kostas-MBP ~/Projects/gradle-summit-presentation $ gradle gzipCss :combineCss UP-TO-DATE :minifyCss UP-TO-DATE :gzipCss BUILD SUCCESSFUL Total time: 4.881 secs kon@Kostas-MBP ~/Projects/gradle-summit-presentation $ ls -la build total 24 drwxr-xr-x 5 kon wheel 170 10 Jun 19:05 ./ drwxr-xr-x 12 kon wheel 408 10 Jun 18:51 ../ -rw-r--r-- 1 kon wheel 917 10 Jun 18:55 all-min.css -rw-r--r-- 1 kon wheel 1539 10 Jun 18:51 all.css -rw-r--r-- 1 kon wheel 438 10 Jun 19:04 all.min.css.gz And Proof kon@Kostas-MBP ~/Projects/gradle-summit-presentation $ cat build/all.min.css.gz pnK?i?Cċ?%?g?(?D2?C?X‫?5??]-??++-ڦ‬XvN???3Ci?q?Ԓc?Sn????$ (????i?a|oA ?mQ?/?a/ϯ????x h4??Q$-?tI^(?C??&??QH???2?g1Ke?I?9????"=k??*Gƻ`??W?ҙN Re????g??P6?j~ ??;?N?‫ݤ‬w.Ͳ???? ?] x??M?c>?J???x?4ʫ???E}]???~?ZV|?-G=l?{$ۣ ??????2??f?r???n??#?㩠1*"~8??q???+??U??sJ????{?q???r]D? u?!??뜺???>???2r|??+E??7w?‫ؗ‬=?{??_ox??????<~??1???C???kon@Kostas-MBP ~/Projects/gradle-summit-presentation $
  • 45. combine, minify, gzip JS combineJs { // pull together the source from string & file lists // eg. def core = ["$webAppDirName/init.js",...] source = core + application + devmode + bigquery + javascript.source.externalLibs.js.files + dfpFilters + chartdef + uxFilters // show the resolved files when gradle is run with -d source.each{ logger.debug ("$it") } dest = file("${buildDir}/all.js") }
  • 47. MinifyJS minifyJs { source = combineJs dest = file("${buildDir}/all.min.js") sourceMap = file("${buildDir}/all.sourcemap.json") closure { warningLevel = 'QUIET' compilerOptions.defineReplacements = ['MY_DEBUG_FLAG':false] } }
  • 48. Closure Compiler Options A bit hard to find them all. You can find them in a source file in the Closure compiler project. https://github.com/google/closure- compiler/blob/master/src/com/google/javascript/jsc omp/CompilerOptions.java
  • 49. defineReplacements // config.js /** * Flag to indicate console and extra logging throughout the app * @define {boolean} allow the value of this bool to be * overwritten at closure compiler / minification time * @const * @type {boolean} */ var MY_DBUG_FLAG = true;
  • 50. if (MY_DBUG_FLAG) { $('.dashboard').append( '&lt;p&gt;Here's some dev info you wouldn't normally see&lt;/p&gt;' ); }
  • 51. Gzip gzipJs { source = minifyJs.dest dest = file(“${buildDir}/all.min.js.gz”) }
  • 53. Break It Down Multiple Project Builds
  • 56. Deploy to a Container
  • 57.
  • 60. Your Own Tasks Write your own tasks to change code
  • 61.
  • 62. Head.js or direct script include in different environments
  • 63. –Johnny Appleseed “Type a quote here.”PrintGCTimeStampsPrint
  • 66. –Johnny Appleseed “Type a quote here.”PrintGCTimeStampsPrint
  • 67. Grunt
  • 68. Remember! Gradle works for building HTML/ JS / CSS assets Embedded Server from Checkout End 2 End Visibility Proxies
  • 69. Thanks Blog goes into more detail http://blog.shinetech.com/2014/03/19/javascript-webapps- with-gradle/ Photos Tom Botton - MelbJVM September Brigitte Schuckert - Gradleware Keynote Kon Soulianidis - Pisa & Monkey looking in lens Climbing the Tree - Mary Evans. Licensed Shipping Containers - Jim Bahn. Flickr. CC License Animated Gifs - Photobucket Duke, Grunt, Gradle logos, respective owners

Notes de l'éditeur

  1. Initially app was only JavaScript client talking directly to the datasource. Users auth’d with BigQuery directly
  2. So people usually ask when I tell them we used Gradle to make a single page web app , why not Grunt or Gulp, or whatever else is fancy and in vogue? Dream of being a JS hipster aka Instant Gratification Monkey Now the chance to learn all the cool stuff Angular Grunt Bower I took this picture from a site There is a project called JHipster that combines Maven, Grunt & Spring MVC, AngularJS with Yeoman. A few weeks ago it had a minor release that added Gradle support. JHipster is a Yeoman generator, used to create a Maven + Spring + AngularJS project, with full hot reload of Java and JavaScript code. Yeoman needs npm, so does grunt so still a fail for us. But going in the right direction.
  3. JavaScript has been climbing the tree of software development tools, then reaching the top and falling, taking every branch on the tree down.
  4. So far we’ve just got some cookie cutter setup for the first version You can see pretty simply, the html, js and css driving the show But we’ve got this libs folder…
  5. Our dependencies bring in their own things into the mix. Bootstrap has 3 resources folders, css, js and fonts directories Holder and Jquery bring in their js libs. Most libraries provide both minified and regular versions of their libs Some have map files that we may want to deploy with the minified versions so we can debug in chrome/firefox And just for the fun of it, bootstrap decides to include fonts And this build.gradle file just seems out of place in the web folder
  6. GASP SHOCK HORROR! Find Sound Effects and Clip art (eg 1950’s woman with hands around mouth). Sound effects of screams, shrieks In todays talk we’ll build from the ground up an application to interact with a RESTful API To start with, we’ll use Twitter Bootstrap’s dashboard theme
  7. For learning Gradle using another language is a great experience
  8. For learning Gradle using another language is a great experience
  9. For learning Gradle using another language is a great experience
  10. Notice the gz is only 438 bytes
  11. And proof
  12. show build-tomcat.gradle
  13. build-webserver.gradle
  14. ScriptRunnerServlet