I am on a Linux machine with Idea IntelliJ and I would like to create a Dropwizard project with gradle. With maven archetypes this job would be very easy.
mvn archetype:generate
-DarchetypeGroupId=io.dropwizard.archetypes
-DarchetypeArtifactId=java-simple
-DarchetypeVersion=[REPLACE ME WITH A VALID DROPWIZARD VERSION]
For gradle I am struggling to get going. As I checked out other post I was wondering if what I did was correct:
// Needed Instead of the Shade plug in
plugins {
id 'com.github.johnrengelman.shadow' version '2.0.1'
}
version '1.0-SNAPSHOT'
group 'org.example.sampleName'
description 'Sample Dropwizard REST '
apply plugin: 'java'
apply plugin: 'application'
repositories {
mavenCentral()
}
dependencies {
compile 'io.dropwizard:dropwizard-core:1.2.0'
testCompile 'junit:junit:4.12'
}
mainClassName = 'org.example.sampleName.SampleApplication'
run {
args = ['server', 'config.yml']
}
shadowJar {
mergeServiceFiles()
exclude 'META-INF/*.DSA', 'META-INF/*.RSA', 'META-INF/*.SF'
}
jar {
manifest {
attributes 'Main-Class': mainClassName
}
}
Then I just run gradle shadowJar
and then run java -jar build/SampleApplication.jar server config.yml
. Is this correct? And is the line testCompile 'junit:junit:4.12'
enough for the unit test?
You could use this Yeoman generator:
https://www.npmjs.com/package/generator-dropwizard-gradle
If you have npm installed.
The line testCompile 'junit:junit:4.12'
is sufficient, yes.
You can also search on github for examples, like this one: https://github.com/kishaningithub/dropwizard-gradle
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.