Skip to content

Instantly share code, notes, and snippets.

@dmikurube
Created February 28, 2017 13:37
Show Gist options
  • Save dmikurube/c73b74e55170abeb80ed3e5ffc31c3bc to your computer and use it in GitHub Desktop.
Save dmikurube/c73b74e55170abeb80ed3e5ffc31c3bc to your computer and use it in GitHub Desktop.
Flat Gradle example
apply plugin: 'java'
repositories {
mavenCentral()
}
dependencies {
testCompile 'junit:junit:4.+'
}
sourceSets {
main {
java {
srcDir '.'
exclude 'Test*.java'
}
}
test {
java {
srcDir '.'
include 'Test*.java'
}
}
}
test {
testLogging {
events 'passed', 'skipped', 'failed', 'standardOut', 'standardError'
}
}
task run(type:JavaExec) {
main = project.hasProperty('main') ? project.getProperty('main') : 'GradleFlat'
classpath = sourceSets.main.runtimeClasspath
}
public class GradleFlat {
public static void main(String[] args) {
System.out.println("Hello, Gradle.");
}
}
import org.junit.Assert;
import org.junit.Test;
public class TestGradleFlat {
@Test
public void test() {
System.out.println("Hello, Test.");
Assert.assertEquals(1 + 1, 2);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment