Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,16 @@ The previous definition would make examples and performance SourceSets, so that

That will cause the functionalCompile to extend from testCompile, and functionalRuntime to extend from testRuntime, since those are the configurations from the "test" SourceSet.

The source directory defaults to the name of the facet, but this can be overridden if necessary, e.g.

facets {
performance {
srcDir = 'perf'
}
}

This will create a performance SourceSet for code contained in src/perf/java.

Test Facets
--------------

Expand All @@ -42,12 +52,13 @@ If "Test" is in the facet name, then a Test task would be created (though it'll
integTest
}

This will create a test task called integTest in addition to the integTest SourceSet. The parent SourceSet can still be overriden like above, and the task name can be set:
This will create a test task called integTest in addition to the integTest SourceSet. The parent SourceSet can still be overriden like above, and the task name and source directory can be set:

facets {
integTest {
parentSourceSet = 'main'
testTaskName = 'integrationTest'
srcDir = 'integ-test'
}
}

Expand All @@ -57,6 +68,7 @@ Test facets may opt out of a dependency on the 'check' task by using `includeInC
integTest {
parentSourceSet = 'main'
testTaskName = 'integrationTest'
srcDir = 'integ-test'
includeInCheckLifecycle = false
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,13 @@ class FacetDefinition implements Named {

String name
String parentSourceSet
String srcDir

def getParentSourceSet() {
return parentSourceSet ?: 'main'
}

def getSrcDir() {
return srcDir ?: name
}
}
13 changes: 13 additions & 0 deletions src/main/groovy/nebula/plugin/responsible/NebulaFacetPlugin.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,19 @@ class NebulaFacetPlugin implements Plugin<Project> {
compileClasspath += parentSourceSet.output
compileClasspath += parentSourceSet.compileClasspath
runtimeClasspath += it.output + it.compileClasspath

if (set.srcDir != set.name) {
applySrcDirOverride(it, set.srcDir)
}
}
}

void applySrcDirOverride(SourceSet srcSet, String srcDir) {
def srcProperties = ['java', 'resources', 'antlr', 'groovy', 'scala']
srcProperties.each {
if (srcSet.hasProperty(it)) {
srcSet."$it".srcDirs = [ "src/${srcDir}/$it" ]
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,4 +123,23 @@ class NebulaFacetPluginSpec extends PluginProjectSpec {
it instanceof Task && ((Task) it).name == 'performanceTest'
}
}

def 'override source dir'() {
when:
project.apply plugin: 'java'
project.apply plugin: 'groovy'
project.apply plugin: NebulaFacetPlugin.class
project.facets {
integrationTest {
srcDir = 'integration-test'
}
}

then:
def integrationTest = project.sourceSets.find { it.name == 'integrationTest' } as SourceSet
integrationTest
integrationTest.allJava.srcDirs.find { it.path.endsWith('src/integration-test/java') }
integrationTest.allGroovy.srcDirs.find { it.path.endsWith('src/integration-test/groovy') }
integrationTest.resources.srcDirs.find { it.path.endsWith('src/integration-test/resources') }
}
}