mirror of
https://github.com/ethauvin/kobalt.git
synced 2025-04-26 08:27:12 -07:00
Fix the duplicate sources problem.
This commit is contained in:
parent
7c20a0313f
commit
0da885e094
6 changed files with 12 additions and 12 deletions
|
@ -44,7 +44,7 @@ open public class Project(
|
|||
return sources
|
||||
}
|
||||
|
||||
var sourceDirectories : ArrayList<String> = arrayListOf()
|
||||
var sourceDirectories : HashSet<String> = hashSetOf()
|
||||
get() = if (field.isEmpty()) projectInfo.defaultSourceDirectories else field
|
||||
set(value) {
|
||||
field = value
|
||||
|
@ -57,7 +57,7 @@ open public class Project(
|
|||
return sources
|
||||
}
|
||||
|
||||
var sourceDirectoriesTest : ArrayList<String> = arrayListOf()
|
||||
var sourceDirectoriesTest : HashSet<String> = hashSetOf()
|
||||
get() = if (field.isEmpty()) projectInfo.defaultTestDirectories
|
||||
else field
|
||||
set(value) {
|
||||
|
@ -94,7 +94,7 @@ open public class Project(
|
|||
val projectName: String get() = name
|
||||
}
|
||||
|
||||
public class Sources(val project: Project, val sources: ArrayList<String>) {
|
||||
public class Sources(val project: Project, val sources: HashSet<String>) {
|
||||
@Directive
|
||||
public fun path(vararg paths: String) {
|
||||
sources.addAll(paths)
|
||||
|
|
|
@ -12,8 +12,8 @@ import java.util.*
|
|||
* Abstract base class for the build generators that use build-template.mustache.
|
||||
*/
|
||||
abstract class BuildGenerator : IInitContributor {
|
||||
abstract val defaultSourceDirectories : ArrayList<String>
|
||||
abstract val defaultTestDirectories : ArrayList<String>
|
||||
abstract val defaultSourceDirectories : HashSet<String>
|
||||
abstract val defaultTestDirectories : HashSet<String>
|
||||
abstract val directive : String
|
||||
abstract val name : String
|
||||
abstract val fileMatch : (String) -> Boolean
|
||||
|
|
|
@ -6,6 +6,6 @@ import java.util.*
|
|||
* Data that is useful for projects to have but should not be specified in the DSL.
|
||||
*/
|
||||
interface IProjectInfo {
|
||||
val defaultSourceDirectories: ArrayList<String>
|
||||
val defaultTestDirectories: ArrayList<String>
|
||||
val defaultSourceDirectories: HashSet<String>
|
||||
val defaultTestDirectories: HashSet<String>
|
||||
}
|
||||
|
|
|
@ -89,7 +89,7 @@ public class JavaPlugin @Inject constructor(
|
|||
return result
|
||||
}
|
||||
|
||||
private fun findSourceFiles(dir: String, sourceDirectories: List<String>): List<String> {
|
||||
private fun findSourceFiles(dir: String, sourceDirectories: Collection<String>): List<String> {
|
||||
val projectDir = File(dir)
|
||||
return files.findRecursively(projectDir,
|
||||
sourceDirectories.map { File(it) }) { it: String -> it.endsWith(".java") }
|
||||
|
|
|
@ -5,6 +5,6 @@ import com.google.inject.Singleton
|
|||
|
||||
@Singleton
|
||||
class JavaProjectInfo : IProjectInfo {
|
||||
override val defaultSourceDirectories = arrayListOf("src/main/java", "src/main/resources")
|
||||
override val defaultTestDirectories = arrayListOf("src/test/java", "src/test/resources")
|
||||
override val defaultSourceDirectories = hashSetOf("src/main/java", "src/main/resources")
|
||||
override val defaultTestDirectories = hashSetOf("src/test/java", "src/test/resources")
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@ import com.google.inject.Singleton
|
|||
|
||||
@Singleton
|
||||
class KotlinProjectInfo : IProjectInfo {
|
||||
override val defaultSourceDirectories = arrayListOf("src/main/kotlin", "src/main/resources")
|
||||
override val defaultTestDirectories = arrayListOf("src/test/kotlin", "src/test/resources")
|
||||
override val defaultSourceDirectories = hashSetOf("src/main/kotlin", "src/main/resources")
|
||||
override val defaultTestDirectories = hashSetOf("src/test/kotlin", "src/test/resources")
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue