From ac6907c5f14708e7e0225ce93450424c709c08dc Mon Sep 17 00:00:00 2001 From: "R. Tyler Croy" Date: Sun, 18 Dec 2016 10:16:53 -0800 Subject: [PATCH] Bootstrap a simple Dropwizard(.io) application --- build.gradle | 23 +++++++++++-- gradle.properties | 1 + .../io/lasagna/httpwizard/HttpWizard.groovy | 24 ++++++++++++-- .../httpwizard/HttpWizardConfiguration.groovy | 32 +++++++++++++++++++ 4 files changed, 75 insertions(+), 5 deletions(-) create mode 100644 gradle.properties create mode 100644 src/main/groovy/io/lasagna/httpwizard/HttpWizardConfiguration.groovy diff --git a/build.gradle b/build.gradle index e83bd38..df7ae86 100644 --- a/build.gradle +++ b/build.gradle @@ -1,15 +1,34 @@ +plugins { + /* Used for generating version manifests for the applications */ + id 'org.ajoberstar.grgit' version '1.6.0' + /* Used for rendering the documentation for the applications */ + id 'org.asciidoctor.gradle.asciidoctor' version '1.5.1' +} +/* Application plugin for creating tarballs of our app */ +apply plugin: 'application' +/* Groovy plugin sets up the tasks for building the Groovy app */ apply plugin: 'groovy' +/* Enforce code-style checks on the Groovy code */ apply plugin: 'codenarc' + +/* Set some basic project properties */ +version = '0.0.1' +group = 'io.lasagna' +description = 'HttpWizard is a simple application for playing with HTTP' +mainClassName = 'io.lasagna.httpwizard.HttpWizard' +/* Force our target compatibility to JDK8 always */ +project.targetCompatibility = 1.8 +/**********************************************************************/ + repositories { jcenter() } dependencies { compile localGroovy() - // The production code uses the SLF4J logging API at compile time - compile 'org.slf4j:slf4j-api:1.7.18' + compile "io.dropwizard:dropwizard-core:${dropwizardVersion}" // Declare the dependency for your favourite test framework you want to use in your tests. // TestNG is also supported by the Gradle Test task. Just change the diff --git a/gradle.properties b/gradle.properties new file mode 100644 index 0000000..4d95925 --- /dev/null +++ b/gradle.properties @@ -0,0 +1 @@ +dropwizardVersion=1.0.5 diff --git a/src/main/groovy/io/lasagna/httpwizard/HttpWizard.groovy b/src/main/groovy/io/lasagna/httpwizard/HttpWizard.groovy index 580897f..6ea24f4 100644 --- a/src/main/groovy/io/lasagna/httpwizard/HttpWizard.groovy +++ b/src/main/groovy/io/lasagna/httpwizard/HttpWizard.groovy @@ -18,9 +18,27 @@ package io.lasagna.httpwizard +import io.dropwizard.Application +import io.dropwizard.setup.Bootstrap +import io.dropwizard.setup.Environment -class HttpWizard { - static void main(String[] argv) { - println 'Hello world' +/** + * HttpWizard is the main Dropwizard application class + */ +class HttpWizard extends Application { + /** Run the HttpWizard application */ + static void main(String[] args) throws Exception { + new HttpWizard().run(args) + } + + @Override + void run(HttpWizardConfiguration configuration, + Environment env) { + /* nothing to do yet */ + } + + @Override + void initialize(Bootstrap bootstrap) { + /* nothing to do yet */ } } diff --git a/src/main/groovy/io/lasagna/httpwizard/HttpWizardConfiguration.groovy b/src/main/groovy/io/lasagna/httpwizard/HttpWizardConfiguration.groovy new file mode 100644 index 0000000..7ccb7e4 --- /dev/null +++ b/src/main/groovy/io/lasagna/httpwizard/HttpWizardConfiguration.groovy @@ -0,0 +1,32 @@ +/* + * Copyright (C) 2016 R. Tyler Croy + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +package io.lasagna.httpwizard + +import io.dropwizard.Configuration +import org.hibernate.validator.constraints.NotEmpty + + +/** + * HttpWizardConfiguration contains the basic configuration schema for the + * application + */ +class HttpWizardConfiguration extends Configuration { + @NotEmpty + private String appVersion +}