I just converted a Maven Java/Kotlin project to Gradle and it seems to be working well in general (it's my first time using Gradle). But I have a habit of right-clicking on my sources-root folder (src/main/java
) to run both Rebuild '<default>'
and Run 'All Tests'
(at separate times). Now when I do that to run tests, I get a little yellow balloon:
Tests were not found in module "MyProject.main". Use module "MyProject.test" instead
I can train myself to right-click, Run 'All Tests'
from the test-sources-root folder (src/test/java
). But it's odd that IDEA would offer to do something that it can't do.
I wonder if I need to specify something differently/better in my build.gradle
or possibly settings.gradle
files? Or maybe adjust an IntelliJ setting somewhere? With a Maven project, I would suspect that I just need to tell IDEA to auto-refresh its project whenever I change the Maven one.
My entire project is checked into Github: TestUtils
If you don't want to click, here's my build.gradle file:
/*
* This file was generated by the Gradle 'init' task.
*/
plugins {
id 'java'
id 'maven-publish'
id 'org.jetbrains.kotlin.jvm' version '1.3.21'
}
repositories {
mavenLocal()
maven {
url = 'http://repo.maven.apache.org/maven2'
}
}
dependencies {
compile 'junit:junit:4.12'
compile 'javax.servlet:javax.servlet-api:4.0.1'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
}
task sourcesJar(type: Jar) {
classifier = 'sources'
from(sourceSets.main.allJava)
}
task javadocJar(type: Jar) {
classifier = 'javadoc'
from(javadoc.destinationDir)
}
group = 'org.organicdesign.testUtils'
version = '0.0.8'
description = 'TestUtils'
sourceCompatibility = '1.8'
publishing {
publications {
maven(MavenPublication) {
from(components.java)
artifact(sourcesJar)
artifact(javadocJar)
}
}
}
Here's settings.gradle:
/*
* This file was generated by the Gradle 'init' task.
*/
rootProject.name = 'TestUtils'