Gradle’s ‘application’ plugin is cool enough to create start scripts for *nix and Windows platforms but doesn’t have an easy way pass on the app directory ( install path ). Knowing where your app is installed is pretty useful if you are writing for the desktop.
Here’s one hacky way to pass it on as a system property:
// Pass $APP_HOME as system property.
// Note: this cannot be passed in applicationDefaultJvmArgs as there is no way to escape '$'
CreateStartScripts startScripts = project.startScripts
unixScript.text = unixScript.text.replaceFirst('(?<=DEFAULT_JVM_OPTS=)((\'|\")(.*)(\'|"))(?=\n)',
windowsScript.text = windowsScript.text.replaceFirst('(?<=DEFAULT_JVM_OPTS=)(.*)(?=\r\n)',
Reference – http://stackoverflow.com/a/25240099/206292
Just started work on a personal project to learn some new frameworks and decided on using Spring + Jetty + MongoDB. I somehow managed to get Spring + Jetty working by going through some tutorials online but got stuck when it came to integrating MongoDB.
The most difficult task was resolving all the dependent jars. Most tutorials used maven to resolve dependencies but I didn’t use it as the XML style configuration was quite intimidating for me and so went out to resolve all dependencies manually by searching online and downloading them one by one as and when I encountered the NoClassDefFoundError, little did I know that this would be futile. After wasting several hours, got really frustrated and gave a shot at Gradle.
Oh boy! what a really elegant build tool after all .. this is all it took to resolve the dependencies
apply plugin: 'eclipse'
version = '0.0.1-SNAPSHOT'
mainClassName = "com.myapp.Main"
applicationName = "myapp"