This question already has answers here:
Using Gradle to build a JAR with dependencies
(19 answers)
Closed last year.
I am trying to build a very simple Program.
I only have one dependency, the msql-jdbc.
Every build succeds. But if i try to run the jar this exception ist thrown:
Error: Could not find or load main class metaDataDB-0.5-msSQL.jar
Caused by: java.lang.ClassNotFoundException: metaDataDB-0.5-msSQL.jar
If i look into the jar, for example 7zip, I see all my compiled Classes.
The content of MANIFEST.MF is as follows:
Manifest-Version: 1.0
Main-Class: metaDataDB.Main
Maybe this helps:
Project Structure in Intellij
Here is my full build:
plugins {
id 'java'
}
jar{
manifest {
attributes 'Main-Class': 'metaDataDB.Main'
}
}
repositories {
mavenCentral()
}
group 'com.dvb'
//version '1.0-SNAPSHOT'
version '0.5-msSQL'
sourceCompatibility = 17
dependencies {
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.2'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.2'
// https://mvnrepository.com/artifact/org.postgresql/postgresql
//implementation group: 'org.postgresql', name: 'postgresql', version: '42.3.1'
// / https://mvnrepository.com/artifact/com.microsoft.sqlserver/mssql-jdbc
// https://mvnrepository.com/artifact/com.microsoft.sqlserver/mssql-jdbc
implementation group: 'com.microsoft.sqlserver', name: 'mssql-jdbc', version: '9.5.0.jre17-preview'
}
test {
useJUnitPlatform()
}
Did I setup something wrong? Is this an Intellij error?
I am really confused. I think it should work...
EDIT:
I did the mistake that i did a wrong java command.
The way i did it before:
java metaDataDB-0.5-msSQL.jar -login:login.txt
The right way to do it:
java -jar metaDataDB-0.5-msSQL.jar -login:login.txt
But know I have another Problem. My jdbc driver isn't included in the Jarfile
the problem exists in msSQL.jar, there are some missing classes I guess, you can go to https://mvnrepository.com/artifact/com.microsoft.sqlserver/mssql-jdbc and Implement the right jar for your JRE or experiment with different versions.
The first problem was,
that I ecexuted the Jar file in a wrong way.
I did
java metaDataDB-0.5-msSQL.jar -login:login.txt
The right way to do it:
java -jar metaDataDB-0.5-msSQL.jar -login:login.txt
After that, I realized that I didn't include the dependency needed into my Jar.
I've learned what a Fat Jar File is.
So I needed to add this to my gradle jar task:
from{
configurations.runtimeClasspath.collect {it.isDirectory() ? it: zipTree(it)}
}
For referencere my whole build.gradle file:
plugins {
id 'java'
}
jar{
manifest {
attributes ('Main-Class': 'metaDataDB.Main')
}
from{
configurations.runtimeClasspath.collect {it.isDirectory() ? it: zipTree(it)}
}
}
repositories {
mavenCentral()
}
group 'com.dvb'
//version '1.0-SNAPSHOT'
version '0.5-msSQL'
sourceCompatibility = 17
dependencies {
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.2'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.2'
// https://mvnrepository.com/artifact/org.postgresql/postgresql
// implementation group: 'org.postgresql', name: 'postgresql', version: '42.3.1'
implementation 'com.microsoft.sqlserver:mssql-jdbc:10.1.0.jre17-preview'
// / https://mvnrepository.com/artifact/com.microsoft.sqlserver/mssql-jdbc
// https://mvnrepository.com/artifact/com.microsoft.sqlserver/mssql-jdbc
//implementation 'com.microsoft.sqlserver:mssql-jdbc:9.2.1.jre15'
}
test {
useJUnitPlatform()
}
That worked for the postgressql Driver.
For the Microsoft SQL Drivers a new Problem came up.
java -jar metaDataDB-0.5-msSQL.jar -login:ms.txt
Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.SecurityException: Invalid signature file digest for Manifest main attributes
at java.base/sun.security.util.SignatureFileVerifier.processImpl(SignatureFileVerifier.java:340)
at java.base/sun.security.util.SignatureFileVerifier.process(SignatureFileVerifier.java:282)
at java.base/java.util.jar.JarVerifier.processEntry(JarVerifier.java:277)
at java.base/java.util.jar.JarVerifier.update(JarVerifier.java:234)
at java.base/java.util.jar.JarFile.initializeVerifier(JarFile.java:762)
at java.base/java.util.jar.JarFile.ensureInitialization(JarFile.java:1033)
at java.base/java.util.jar.JavaUtilJarAccessImpl.ensureInitialization(JavaUtilJarAccessImpl.java:72)
at java.base/jdk.internal.loader.URLClassPath$JarLoader$2.getManifest(URLClassPath.java:883)
at java.base/jdk.internal.loader.BuiltinClassLoader.defineClass(BuiltinClassLoader.java:848)
at java.base/jdk.internal.loader.BuiltinClassLoader.findClassOnClassPathOrNull(BuiltinClassLoader.java:760)
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(BuiltinClassLoader.java:681)
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:639)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520)
at java.base/java.lang.Class.forName0(Native Method)
at java.base/java.lang.Class.forName(Class.java:467)
at java.base/sun.launcher.LauncherHelper.loadMainClass(LauncherHelper.java:780)
at java.base/sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:675)
here a link to the exception:
https://learn.microsoft.com/de-de/dotnet/api/system.security.securityexception?view=net-6.0
I tried it to run in adminstrator mode, but that failed too...
But I guess this is a new question, and hasn't to do anything with gradle.
I guess the answer to "Building a Jar using gradle - Jar hasn't sql dependency" is answered.
I will create a new Question for the microsoft sql driver and link it here.
(I hope I did everything right)
Related
I am trying to build an jar artefact from this repository. I imported apache commons io and org.json as libraries. When extracting the artifact I find a Manifest file which only contains the information of org.json. You can find the jar here. The manifest file in my Project is not reflected at all. Any help is appreciated. When I run the jar in console with java -jar I get the
Error: No Main Manifest Attribute in XXX.jar.
From the project you provided on github i made the following changes to make it run with java -jar. But first and foremost the project you linked on github does not build with gradle build on a fresh pull.
to make this run you need to add commons io and org.json to you build.gradle file. this makes the build.gradle file look like:
plugins {
id 'java'
}
version '1.0-SNAPSHOT'
sourceCompatibility = 1.8
repositories {
mavenCentral()
}
dependencies {
compile group: 'commons-io', name: 'commons-io', version: '2.6'
compile group: 'org.json', name: 'json', version: '20190722'
testCompile group: 'junit', name: 'junit', version: '4.12'
}
jar {
manifest {
attributes(
'Main-Class': 'de.bergwacht.esslingen.Main'
)
}
}
your project also has alot of unused dependencies that should be removed that were creating gradle warnings.
in AnweseneheitsTableModel remove the imports:
import com.sun.org.apache.xpath.internal.operations.Bool;
in DienstprotokollInvalidArgumentException remove the imports:
import com.sun.javaws.exceptions.InvalidArgumentException;
in MainForm remove the imports:
import com.sun.org.apache.xpath.internal.operations.Bool;
import com.sun.xml.internal.fastinfoset.algorithm.BooleanEncodingAlgorithm;
at this point you can run ./gradlew jar and this will create a jar for you under build/libs
you can run that jar with java -jar build/libs/BWOrgaTool-1.0-SNAPSHOT.jar
that command will run it, it will encounter a NPE:
Exception in thread "main" java.lang.NullPointerException
at de.bergwacht.esslingen.forms.MainForm.<init>(MainForm.java:138)
at de.bergwacht.esslingen.Main.main(Main.java:42)
but thats another problem all together, you can start debugging your program at that point.
I am trying to run CnnSentenceClassification from deeplearning4j example. I moved this file to my Gradle project. When I run the class from the eclipse it works fine. However when I run it from ./gradlew run I get following error:
Exception in thread "main" java.lang.ExceptionInInitializerError
at
main.CnnSentenceClassification.main(CnnSentenceClassification.java:75)
Caused by: java.lang.RuntimeException:
org.nd4j.linalg.factory.Nd4jBackend$NoAvailableBackendException:
Please ensure that you have an nd4j backend on your classpath. Please
see: http://nd4j.org/getstarted.html
at org.nd4j.linalg.factory.Nd4j.initContext(Nd4j.java:6089)
at org.nd4j.linalg.factory.Nd4j.<clinit>(Nd4j.java:201)
... 1 more
Caused by:
org.nd4j.linalg.factory.Nd4jBackend$NoAvailableBackendException:
Please ensure that you have an nd4j backend on your classpath. Please
see: http://nd4j.org/getstarted.html
at org.nd4j.linalg.factory.Nd4jBackend.load(Nd4jBackend.java:258)
at org.nd4j.linalg.factory.Nd4j.initContext(Nd4j.java:6086)
... 2 more
I checked and nd4j-api-0.9.1.jar is in my classpath. This is my build.gradle:
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'application'
repositories {
jcenter()
}
mainClassName="main.CnnSentenceClassification"
dependencies {
compile group: 'org.deeplearning4j', name: 'deeplearning4j-core', version: '0.9.1'
compile group: 'org.deeplearning4j', name: 'deeplearning4j-nlp', version: '0.9.1'
testCompile group: 'org.nd4j', name: 'nd4j-native-platform', version: '0.9.1'
compile group: 'org.nd4j', name: 'nd4j-api', version: '0.9.1'
compile "org.slf4j:slf4j-simple:1.7.25"
compile "org.slf4j:slf4j-api:1.7.25"
}
I was having the same problem. You need an ND4J backend, which means updating your dependency tree.
For Maven builds, add the following dependency to your project's pom:
<dependency>
<groupId>org.nd4j</groupId>
<artifactId>nd4j-native</artifactId>
<version>0.9.1</version>
</dependency>
For Gradle builds, just add the following line in your dependencies:
compile "org.nd4j:nd4j-native:0.9.1"
This native backend uses the CPU for computations.
There is another dependency for a CUDA-enabled graphics card.
I found this link helpful:
DL4J Performance Debugging
Edit: new link is here. https://deeplearning4j.konduit.ai/config/backends
Old content below:
You have test scope on the nd4j backend. An nd4j backend is NEVER optional.
https://nd4j.org/backend.html
The error is right in the message. We even give you a link with an explanation right in the stack trace.
I attempted to create a normal Kotlin project (non-android, just desktop/command line project) with Android Studio 2.3.3.
I followed the steps as laid out here but with different build.gradle content whose content I shared here.
Actually that content of build.gradle I copied from build.gradle file after generating a new project with IntelliJ Community Edition (2017.2).
Then I create a configuration to be able to run it on desktop with proper set up like Main Class, Working directory, and Use classpath of module. You can see in the image below.
and following is the project file structure I have
Then I sync the project, it succeeds. But error kicks in when I try to Run the project. I got the following error.
"/Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java" -Didea.launcher.port=7534 "-Didea.launcher.bin.path=/Applications/Android Studio.app/Contents/bin" -Dfile.encoding=UTF-8 -classpath "/Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/jre/lib/charsets.jar:/Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/jre/lib/ext/cldrdata.jar:/Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/jre/lib/ext/dnsns.jar:/Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/jre/lib/ext/jaccess.jar:/Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/jre/lib/ext/localedata.jar:/Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/jre/lib/ext/nashorn.jar:/Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/jre/lib/ext/sunec.jar:/Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/jre/lib/ext/sunjce_provider.jar:/Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/jre/lib/ext/sunpkcs11.jar:/Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/jre/lib/ext/zipfs.jar:/Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/jre/lib/jce.jar:/Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/jre/lib/jsse.jar:/Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/jre/lib/management-agent.jar:/Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/jre/lib/resources.jar:/Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/jre/lib/rt.jar:/Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/lib/dt.jar:/Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/lib/jconsole.jar:/Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/lib/sa-jdi.jar:/Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/lib/tools.jar:/Users/haxpor/.gradle/caches/modules-2/files-2.1/org.jetbrains/annotations/13.0/919f0dfe192fb4e063e7dacadee7f8bb9a2672a9/annotations-13.0.jar:/Users/haxpor/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-jre7/1.1.4-2/272a21c30432c943d618008fbbd34762eb0d6c8a/kotlin-stdlib-jre7-1.1.4-2.jar:/Users/haxpor/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.1.4-2/fec983b2608a8a91a1b87dba18d247d692cf6b51/kotlin-stdlib-1.1.4-2.jar:/Users/haxpor/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-jre8/1.1.4-2/168cc3f45c307edda6c867dd0635a7d451257551/kotlin-stdlib-jre8-1.1.4-2.jar:/Applications/Android Studio.app/Contents/lib/idea_rt.jar" com.intellij.rt.execution.application.AppMain io.wasin.testjavaapp.Main
Exception in thread "main" java.lang.ClassNotFoundException: io.wasin.testjavaapp.Main
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:264)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:123)
Process finished with exit code 1
I saw the classpath parameter as supplied in above /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java has no related directory to my project. I don't know how to add classpath directory via gradle despite I set up it in configurations already.
How can I solve this problem?
Update:
The following is my Main.kt code. It's just for testing purpose. So just printing something out.
package io.wasin.testjavaapp
object Main {
#JvmStatic fun main(arg: Array<String>) {
println("Hello world")
}
}
Also I updated build.gradle for Kotlin version to match the version of Kotlin plugin on Android Studio. It's now ext.kotlin_version = '1.1.4-2'. Although still doesn't solve the problem.
Update 2
I checked inside build directory at the same level of src directory. There are no .class or intermediates files generated/built over there, only kotlin-build/caches/version.txt and that's it. No other files. So the problem might be due to the source files are not compiled at all?
Update 3
I tried creating a new module to see if it's the root cause or not. Also created assets folder just to act as Working Directory, rearranged source folder again to be as following.
We now have 2 modules.
testJavaApp - root one
desktop - consists of Main.kt and used as desktop executable
testJavaApp has the following code for build.gradle
group 'io.wasin'
version '1.0-SNAPSHOT'
// Top-level build file where you can add configuration options common to
all sub-projects/modules.
buildscript {
ext.kotlin_version = '1.1.4-2'
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
also desktop module has following code for build.gradle
apply plugin: 'kotlin'
sourceSets.main.java.srcDirs = [ "src/" ]
project.ext.mainClassName = "io.wasin.testjavaapp.Main"
project.ext.assetsDir = new File("../assets");
dependencies {
testCompile group: 'junit', name: 'junit', version: '4.12'
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
}
repositories {
mavenCentral()
}
task run(dependsOn: classes, type: JavaExec) {
main = project.mainClassName
classpath = sourceSets.main.runtimeClasspath
standardInput = System.in
workingDir = project.assetsDir
ignoreExitValue = true
}
Unfortunately, it still didn't work and it's the same error that shown up.
Update 4
#aristotll provided info in a comment that he tested with Android Studio and faced the same problem, but not with IntelliJ. He said it might be Android Studio bug. So I guess, I would try a few more times then decide whether it's solid enough to report as a bug. Thanks for taking time to testing out.
I also met this problem and solved it.
Add runtimeClasspath files("build/classes/kotlin/main") in build.gradle
dependencies {
// This dependency is found on compile classpath of this component and consumers.
compile 'com.google.guava:guava:23.0'
// Use JUnit test framework
testCompile 'junit:junit:4.12'
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
compile group: 'dom4j', name: 'dom4j', version: '1.6.1'
runtimeClasspath files("build/classes/kotlin/main")
}
because Android Studio doesn't find classes in build/classes/kotlin/main. Add runtimeClasspath and it works!
I am using Gradle to build my Java project in Eclipse. gradle.build is as follows
apply plugin: 'java'
repositories {
mavenCentral()
}
dependencies {
compile group: 'com.flowpowered', name: 'flow-nbt', version: '1.0.0'
compile group: 'org.reflections', name: 'reflections', version: '0.9.10'
}
All libraries are functioning properly when run through Eclipse. But sometimes it is useful to work on the command line. When run on the command line, the runtime error Exception in thread "main" java.lang.NoClassDefFoundError: com/flowpowered/nbt/regionfile/SimpleRegionFileReader occurs, even though the build is successful and the code contains imports from those libraries. I have tried cleans and rebuilds, along with gradlew build --refresh-dependencies, but I still encounter the same runtime error.
I would assume that the libraries are just never actually imported? Or that they are not being stored where the java project thinks they are? I'm unfamiliar with Gradle, so any advice on this is welcome.
Based on the posted build.gradle file you are not packaging the application as an executable JAR.
First apply the application plugin. But this will not be enough as you won't be able to run the executable as a single JAR without all of its dependencies. Apply the shadow plugin too.
These two plugins will give you access to the following tasks:
run: execute the application from gradle's command line.
runShadow: execute the application but with all dependencies packaged in a single JAR, alongside your compiled classes and resources.
shadowJar: create a single "fat JAR" with compiled classes and all dependencies.
Thus your build.gradle may look like this
plugins {
id 'java'
id 'application'
id 'com.github.johnrengelman.shadow' version '1.2.4'
}
mainClassName = 'com.acme.YourMainClassName'
repositories {
mavenCentral()
}
dependencies {
compile group: 'com.flowpowered', name: 'flow-nbt', version: '1.0.0'
compile group: 'org.reflections', name: 'reflections', version: '0.9.10'
}
Plugin documentation:
https://github.com/johnrengelman/shadow
https://docs.gradle.org/3.4/userguide/application_plugin.html#useApplicationPlugin
Another solution without using any plugins and still end up with a runnable fat jar
jar {
archiveName = 'NameOfYourApp.jar'
manifest {
attributes 'Main-Class': 'uk.co.cdl.Main',
'Class-Path': configurations.runtime.files.collect { "lib/$it.name" }.join(' '),
'Implementation-Version': project.version
}
from(configurations.compile.collect { it.isDirectory() ? it : zipTree(it) }) {
include/exclude anything if need to if not take the curlys off
}
}
I'm trying to run ./gradlew build for a nested multi project structure and I'm running into issues that only seem to appear for projects with test source roots. Being new to both java and gradle I'm sure I'm breaking more than one convention, but I still think this should be working.
Essentially, all the dependencies seem to be added fine, but when I have one project that only has a Test srcDir that depends on another project that has a Test srcDir, it doesn't recognize packages/symbols in that root project. However, projects with regular srcDirs (not test) don't seem to have a problem.
My project has more going on than this, but here is the simplest setup I've tried that illustrates the problem.
My project structure:
qatests
/Applications
/AppGroupName
/AppBasePageObjects
/src
/AppBaseTests
/src
/BasePageObjects
/src
/BaseTests
/src
My settings.gradle in qatests:
rootProject.name = 'QaTests'
include 'BasePageObjects'
include 'BaseTests'
include 'Applications:AppGroupName'
include 'Applications:AppGroupName:AppBasePageObjects'
include 'Applications:AppGroupName:AppBaseTests'
My build.gradle in qatests:
version '1.0-SNAPSHOT'
allprojects {
repositories {
mavenCentral()
}
}
subprojects{
if(project.name.contains("Tests")){
apply plugin: 'java'
sourceCompatibility = 1.8
dependencies {
testCompile group: 'junit', name: 'junit', version: '4.11'
compile group: 'org.seleniumhq.selenium', name: 'selenium-java', version: '2.+'
}
if(project.name != "BaseTests")
{
println "$project.name depends on BaseTests"
dependencies {
testCompile project(':BaseTests')
}
}
sourceSets {
test {
java {
srcDir 'src'
}
}
}
}
if(project.name.contains("PageObjects")){
apply plugin: 'java'
sourceCompatibility = 1.8
dependencies {
compile group: 'org.seleniumhq.selenium', name: 'selenium-java', version: '2.+'
}
if(project.name !="BasePageObjects")
{
dependencies {
compile project(':BasePageObjects')
}
}
sourceSets {
main {
java {
srcDir 'src'
}
}
}
}
}
I won't include my build.grade for the BaseTest project since that seems to compile fine during the gradlew build, but here is my build.gradle for AppBaseTests:
version '1.0-SNAPSHOT'
dependencies {
compile 'org.apache.commons:commons-lang3:3.4'
compile project(':Applications:AppGroupName:AppBasePageObjects')
}
When I run ./gradlew build in the qatests root, the BaseTests, BasePageObjects, and AppBasePageObjects projects seem to compile fine and AppBasePageObjects successfully uses packages and symbols from BasePageObjects. For some reason however, AppBaseTests can't seem to recognize packages and symbols in BaseTests.
If I clone this project from scratch, IntelliJ runs the gradle scripts scripts automatically and everything seems to work out of the box just fine with the dependencies, so this just confuses me even more.
I've tried adding compile and testcompile for all the project dependencies since that's the only real difference between AppBasePageObjects which works and AppBaseTests which doesn't work. I've also tried adding compileJava.dependsOn(':BaseTests:build') to the AppBaseTests build.gradle file. And a few other rabbit holes, but nothing seems to have any effect on this dependency issue.
For what it's worth, here is the first error I see in the actual build:
error: package Tests does not exist import Tests.BaseTest;
Any help or suggestions are greatly appreciated. If you would like to distribute some harsh insults I'll take those as well. Thank you.
I believe I found an answer while reading another solution here:
Multi-project test dependencies with gradle
It seems I needed to use testCompile project(':BaseTests').sourceSets.test.output for command line builds as well as testCompile project(':BaseTests') for IDE functionality in my root build.gradle file. This only seems to be required for the test projects.
Here are the actual changes in my root build.gradle file:
if(project.name != "BaseTests")
{
println "$project.name depends on BaseTests"
dependencies {
testCompile project(':BaseTests')
testCompile project(':BaseTests').sourceSets.test.output
}
}
This seems a bit hacky but works, if somebody has a more thorough and intelligent answer please post!