Groovy Scripting - Home.apache

2y ago
8 Views
2 Downloads
6.22 MB
46 Pages
Last View : 1m ago
Last Download : 3m ago
Upload by : Aydin Oneil
Transcription

Groovy Scripting

Why Scripting Languages? Some tasks are hard using Bash & friends The same tasks might be too small for afull-blown project Rapid feedback & bug fixing Many scripting languages around‣ Perl, Tcl, Python, Ruby

Getting Hooked On amel-gr8conf

Behind The Scenes Creates an Ivy repository in " /.groovy" Stores transitive dependencies Setup a Camel route using embedded Jetty Script executed by Groovy interpreter

Good Old Maven Way Write a pom.xml declaring dependencies Configure the “ AppAssembler MavenPlugin” to create a command lineapplication Maybe tinker with “Maven Ant Plugin” tocreate an executable shell script Upload/download distributable

The Side Project Useful but not important things Perfect for “bridging days” Stretch your skills Bring back the fun

Siegfried’s Side Project Automate test user documentation Set of test users changes every few months Each test users has one or more products‣ Account, credit cart, pension . Excel sheet created manually

The Problem At Hand User id for disposer “9422753404”? Any test user with a “Building Saving Plan”? When do we get the newest Excel sheet?

Idea Before Christmas Let’s make one QA guy happy Make a few REST calls to gather data Create a HTML document with that data Could be done for all test environments Let's implement it in Groovy

Groovy First Contact

Plans are only good intentionsunless they immediatelydegenerate into hard work.Peter Drucker

Hard Work Ahead Classes to hold a user and its products Implement command line parser Read user & credentials from a CSV file Invoke REST endpoints to get products Transform user and their products todocumentation

Groovy Classes

Groovy Classes

Grape Dependency Manager

Reading CSV

Groovy HTTPBuilder

Groovy HTTPBuilder

Groovy CLIBuilder

Groovy ConfigSlurper

Groovy JSONOutput

Where Are We Now? Holders for users and its products Using a command line parser Read user & credentials from a CSV file REST client to fetch user products JSON file containing user products

JSON To HTML

The Problem Ahead With XML I would use XSLT‣ Could somehow dump XML‣ XSLT is hard if you don't know it Maybe transform JSON to Markdown?‣ JSON & Markdown are everywhere

JSON To Markdown The cool kids say ‘node.js'‣ But they always say ‘node.js’ We could implement it in Groovy‣ Groovy’s MarkupBuilder looks hard‣ Using Apache Velocity & JSONPath?

Groovy Velocity CLI See https://github.com/sgoeschl/velocity-cli See https://github.com/jayway/JsonPath Wire Velocity templates with JSON Path Supports CSV & JSON transformations

GitHubREST APIExample

GitHub REST API

Groovy Velocity CLI

Groovy Velocity CLI

Groovy Velocity CLI

Test UserDocument

Groovlets Implement Java Servlets in Groovy Uses GroovyServlet to map servletrequest to Groovy scripts Usually deployed within servlet container But there is a simpler way

Groovlet Example

Things To Take Home

Things To Take Home Groovy is easy for Java developers Groovy is nice for non-trivial scripts Groovy works with your favourite libraries IDE allows debugging Groovy scripts The “Groovy Goodness Notebook”

Things To Take Home ASF top-level project Embedded in applications‣ SoapUI Groovy for integration‣ Spring Boot, Apache Camel Grails Web Framework

Questions & Answers

Resources der

Good Old Maven Way Write a pom.xml declaring dependencies Configure the “ AppAssembler Maven Plugin” to create a command line application Maybe tinker with “Maven Ant Plugin” to create a

Related Documents:

Getting Started with the Cloud . Apache Bigtop Apache Kudu Apache Spark Apache Crunch Apache Lucene Apache Sqoop Apache Druid Apache Mahout Apache Storm Apache Flink Apache NiFi Apache Tez Apache Flume Apache Oozie Apache Tika Apache Hadoop Apache ORC Apache Zeppelin

Dynamic programming with Groovy 9 1 Table of Contents . Part I: The Groovy language 1 Your way to Groovy 2 Overture: The Groovy basics 3 The simple Groovy datatypes 4 The collective Groovy datatypes 5 Working with closures 6 Groovy control structures 7 Object orientation, Groovy styl

Groovy compiles straight to Java bytecode. Java projects can contain anything from zero percent to one hundred percent Groovy. Groovy seamlessly and transparently integrates and interoperates with Java and any third-party libraries. Groovy is an agile and dynamic language that extends Java with scripting capabilities. It has a concise,

CDH: Cloudera’s Distribution Including Apache Hadoop Coordination Data Integration Fast Read/Write Access Languages / Compilers Workflow Scheduling Metadata APACHE ZOOKEEPER APACHE FLUME, APACHE SQOOP APACHE HBASE APACHE PIG, APACHE HIVE APACHE OOZIE APACHE OOZIE APACHE HIVE File System Mount UI

Using Groovy on a Java project Groovy has access to all java classes, in fact Groovy classes ARE Java classes and can be run by the JVM directly. If you are working on a Java project, using Groovy as a simple scripting language to interact with your java code is a no-brainer. To make things even better, nearly any Java class can be renamed to .

tions and developers are beginning to use Groovy at various levels on their projects, and I think the time is ripe for major Groovy adoption in the industry. Groovy version 1.5 was released on December 7, 2007. Grails ([Roc06], [Rud07]),7 built using Groovy and Java, is a dynamic web development framework based on “coding by convention.” It .

Groovy Roadmap Groovy 2.5 2.5.8 released Macros, AST transformation improvements, various misc. features JDK 7 minimum, runs on JDK 9/10/11 with warnings Groovy 3.0 Beta-3 out now, RC-1 in the next week or two, GA later in 2019 Parrot parser, various misc. features JDK 8 minimum, address most JDK 9/10/11 issues Groovy 4.0 Alphas out soon

Visual Builder Groovy Scripting Reference Chapter 1 Introduction 1 Introduction Groovy is a standard, dynamic scripting language for the Java platform for which Visual Builder provides deep support. This document explains the basics of how you will use the Groovy scripting language to enhance your applications.