Last active
August 29, 2015 14:06
-
-
Save zachlendon/2b708b9d941298c1c77b to your computer and use it in GitHub Desktop.
genericized Api build.gradle with Gradle/Swagger from Bloom
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
| import com.github.jengelman.gradle.plugins.shadow.transformers.AppendingTransformer | |
| import com.github.jengelman.gradle.plugins.shadow.transformers.ManifestResourceTransformer | |
| import com.github.jengelman.gradle.plugins.shadow.transformers.ServiceFileTransformer | |
| buildscript { | |
| repositories { | |
| mavenLocal() | |
| mavenCentral() | |
| jcenter() | |
| maven { | |
| url 'http://repo.jfrog.org/artifactory/gradle-plugins' | |
| } | |
| maven { | |
| name 'Gradle Shadow' | |
| url 'http://dl.bintray.com/content/johnrengelman/gradle-plugins' | |
| } | |
| } | |
| dependencies { | |
| classpath "net.saliman:gradle-cobertura-plugin:1.1.0" | |
| classpath 'org.jfrog.buildinfo:build-info-extractor-gradle:2.0.16' | |
| classpath 'com.github.jengelman.gradle.plugins:shadow:0.8' | |
| } | |
| } | |
| apply plugin: 'cobertura' | |
| apply plugin: 'codenarc' | |
| apply plugin: 'groovy' | |
| apply plugin: 'maven' | |
| apply plugin: 'shadow' | |
| configurations { | |
| all*.exclude group: 'commons-digester' | |
| all*.exclude group: 'commons-logging' | |
| all*.exclude group: 'com.sun.jmx' | |
| all*.exclude group: 'com.sun.jdmk' | |
| all*.exclude group: 'javax.jms' | |
| } | |
| version=currentVersion | |
| group=currentGroup | |
| task wrapper(type: Wrapper) { | |
| gradleVersion = '1.9' | |
| } | |
| // Run code narc before the test phase begins | |
| test.dependsOn codenarcMain | |
| repositories { | |
| mavenLocal() | |
| mavenCentral() | |
| // Spock snapshots are available from the Sonatype OSS snapshot repository | |
| maven { url "http://oss.sonatype.org/content/repositories/snapshots/" } | |
| maven { | |
| name 'bintray' | |
| url 'http://dl.bintray.com/kyleboon/swagger-jaxrs-groovydoclet' | |
| } | |
| maven { | |
| name 'bintray' | |
| url 'http://dl.bintray.com/kyleboon/enhanced-groovydoc' | |
| } | |
| maven { | |
| url 'https://repository-federecio1.forge.cloudbees.com/snapshot' | |
| } | |
| } | |
| dependencies { | |
| String springVersion = "3.2.8.RELEASE" | |
| //compile project(':Api-Project1') | |
| //compile project(':Api-Project2') | |
| //compile project(':Api-Project3') | |
| //compile project(':Api-Project4') | |
| compile(group: 'org.codehaus.groovy', name: 'enhanced-groovydoc', version: '0.6') | |
| compile 'com.wordnik:swagger-jaxrs_2.10:1.3.2' | |
| compile "com.bloomhealthco:swagger-jaxrs-groovydoclet:0.2.0" | |
| groovy "org.codehaus.groovy:groovy-all:${groovyVersion}" | |
| compile 'com.newrelic.agent.java:newrelic-api:3.5.0' | |
| compile 'com.newrelic.agent.java:newrelic-agent:3.5.0' | |
| compile 'com.federecio:dropwizard-swagger:0.1-SNAPSHOT' | |
| compile "com.yammer.dropwizard:dropwizard-core:${dropwizardVersion}" | |
| compile "com.yammer.dropwizard:dropwizard-testing:${dropwizardVersion}" | |
| compile "com.yammer.dropwizard:dropwizard-hibernate:${dropwizardVersion}" | |
| compile "com.yammer.dropwizard:dropwizard-migrations:${dropwizardVersion}" | |
| compile "com.yammer.dropwizard:dropwizard-auth:${dropwizardVersion}" | |
| compile "com.yammer.dropwizard:dropwizard-client:${dropwizardVersion}" | |
| compile "com.yammer.dropwizard:dropwizard-views:${dropwizardVersion}" | |
| compile "com.codahale.metrics:metrics-core:3.0.1" | |
| compile 'com.codahale.metrics:metrics-graphite:3.0.1' | |
| compile 'com.hmsonline:dropwizard-spring:0.3.0' | |
| compile 'com.h2database:h2:1.3.170' | |
| runtime 'org.eclipse.jetty:jetty-util:8.1.5.v20120716' | |
| runtime 'jetty:org.mortbay.jetty.plus:5.1.10' | |
| compile 'org.eclipse.jetty:jetty-servlets:8.1.10.v20130312' | |
| compile "org.springframework:spring-core:${springVersion}" | |
| compile "org.springframework:spring-beans:${springVersion}" | |
| compile "org.springframework:spring-context:${springVersion}" | |
| compile "org.springframework:spring-context-support:${springVersion}" | |
| compile "org.springframework:spring-jdbc:${springVersion}" | |
| compile "org.springframework:spring-orm:${springVersion}" | |
| compile "org.springframework:spring-context:${springVersion}" | |
| compile "org.springframework:spring-tx:${springVersion}" | |
| compile "org.springframework:spring-web:${springVersion}" | |
| testCompile "com.yammer.dropwizard:dropwizard-testing:${dropwizardVersion}" | |
| testCompile "org.spockframework:spock-core:1.0-groovy-2.0-SNAPSHOT" | |
| testCompile 'junit:junit:4.8.1' | |
| testRuntime "cglib:cglib-nodep:2.2.2" // allows mocking of classes (in addition to interfaces) | |
| testRuntime "org.objenesis:objenesis:1.2" // allows mocking of classes without default constructor (together with CGLIB) | |
| // needed for validation tests so logging in hibernate validator does not throw exception | |
| compile 'ch.qos.logback:logback-classic:1.0.7' | |
| } | |
| jar { | |
| manifest { | |
| attributes 'Main-Class': "${mainClass}" | |
| attributes 'Built-Date': new Date() //now | |
| attributes 'Built-By': System.getProperty('user.name') | |
| attributes 'Build-Jdk': System.getProperty('java.version') | |
| attributes 'Implementation-Title': project.name | |
| attributes 'Implementation-Version': project.version | |
| attributes 'Implementation-Vendor-Id': project.group | |
| } | |
| } | |
| cobertura { | |
| coverageFormats = ['xml', 'html'] | |
| coverageIncludes = ['**/*.java', '**/*.groovy'] | |
| coverageSourceDirs = [sourceSets.main.allSource.srcDirs] | |
| } | |
| codenarc { | |
| configFile = rootProject.file('Api-REST/codenarcrule.groovy') | |
| reportFormat = System.properties['codeNarcOutput'] ?: 'html' | |
| } | |
| shadow { | |
| exclude 'META-INF/*.DSA' | |
| exclude 'META-INF/*.RSA' | |
| exclude 'license/*' | |
| exclude 'license' | |
| exclude 'META-INF/*.SF' | |
| exclude 'META-INF/*.INF' | |
| transformer(ServiceFileTransformer) | |
| transformer(ManifestResourceTransformer) { | |
| mainClass = "com.hotelone.api.service.HotelOneService" | |
| } | |
| transformer(AppendingTransformer) { | |
| resource = "META-INF/spring.handlers" | |
| } | |
| transformer(AppendingTransformer) { | |
| resource = "META-INF/spring.schemas" | |
| } | |
| } | |
| //remove newrelic if not using... | |
| task run(dependsOn: 'shadowJar', group: 'dropwizard', description: "Run service using dev configuration") << { | |
| // Grab any dw. properties that are specified on the command line and pass to the Java process (i.e. dw.http.port=8080) | |
| def props = project.ext.properties.findAll { it.key.startsWith('dw') || | |
| it.key.startsWith('globalweb') || it.key.startsWith('tangosol') } | |
| println "shadow path: ${shadow.shadowJar.getPath()}, props: ${props}, project.ext.properties: ${project.ext.properties}" | |
| javaexec { | |
| main = '-jar' | |
| args = ["${shadow.shadowJar.getPath()}", 'server', 'dev_config.yml'] | |
| systemProperties = props | |
| jvmArgs "-javaagent:newrelic/newrelic.jar", "-Xdebug", "-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005", "-Xmx1600m", "-Xms256m", "-XX:MaxPermSize=1024m", "-XX:+CMSClassUnloadingEnabled", "-XX:+HeapDumpOnOutOfMemoryError" | |
| } | |
| } | |
| task migrate(dependsOn: 'shadowJar', group: 'dropwizard', description: "Run migrations using the dev configuration") << { | |
| javaexec { | |
| main = '-jar' | |
| args = ["${shadow.shadowJar.getPath()}", 'db', 'migrate', 'dev_config.yml'] | |
| } | |
| } | |
| task dropAll(dependsOn: 'shadowJar', group: 'dropwizard', description: "Run drop-all database command") << { | |
| javaexec { | |
| main = '-jar' | |
| args = ["${shadow.shadowJar.getPath()}", 'db', 'drop-all', 'dev_config.yml', '--confirm-delete-everything'] | |
| } | |
| } | |
| task swagger << { | |
| ant.taskdef(name: "docca", classname: "org.codehaus.groovy.enhancedgroovydoc.DocletGroovyDoc", classpath: configurations.compile.asPath) | |
| ant.docca( | |
| destdir: "build/apidocs", | |
| sourcepath:"src/main/groovy", | |
| packagenames:"**.*", | |
| use:"true", | |
| windowtitle:"test", | |
| doctitle:"test", | |
| header:"test", | |
| footer:"test", | |
| private:"false", | |
| { | |
| doclet(name:"com.bloomhealthco.apidocs.ServiceDoclet"){ | |
| param(name:"-d", value:"build/apidocs") | |
| param(name:"-apiVersion", value:"1") | |
| param(name:"-docBasePath", value:"http://localhost:8084/apidocs") | |
| param(name:"-apiBasePath", value:"http://localhost:8084") | |
| } | |
| } | |
| ) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment