JPS Build: fix building buildSrc
This commit is contained in:
@@ -172,7 +172,8 @@ private fun getArtifactElements(
|
|||||||
is PDependency.Library -> artifacts += ProjectLibrary(dependency.name)
|
is PDependency.Library -> artifacts += ProjectLibrary(dependency.name)
|
||||||
is PDependency.ModuleLibrary -> {
|
is PDependency.ModuleLibrary -> {
|
||||||
val files = dependency.library.classes
|
val files = dependency.library.classes
|
||||||
artifacts += files.map(if (extractDependencies) ::ExtractedDirectory else ::FileCopy)
|
if (extractDependencies) files.mapTo(artifacts) { ExtractedDirectory(it) }
|
||||||
|
else files.mapTo(artifacts) { FileCopy(it) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -235,53 +235,56 @@ private fun parseSourceRoots(project: Project): List<PSourceRoot> {
|
|||||||
|
|
||||||
val sourceRoots = mutableListOf<PSourceRoot>()
|
val sourceRoots = mutableListOf<PSourceRoot>()
|
||||||
|
|
||||||
for (sourceSet in (project.sourceSets ?: emptyList())) {
|
val sourceSets = project.sourceSets
|
||||||
val kotlinCompileTask = kotlinTasksBySourceSet[sourceSet.name]
|
if (sourceSets != null) {
|
||||||
val kind = if (sourceSet.isTestSourceSet) Kind.TEST else Kind.PRODUCTION
|
for (sourceSet in sourceSets) {
|
||||||
|
val kotlinCompileTask = kotlinTasksBySourceSet[sourceSet.name]
|
||||||
|
val kind = if (sourceSet.isTestSourceSet) Kind.TEST else Kind.PRODUCTION
|
||||||
|
|
||||||
fun Any.getKotlin(): SourceDirectorySet {
|
fun Any.getKotlin(): SourceDirectorySet {
|
||||||
val kotlinMethod = javaClass.getMethod("getKotlin")
|
val kotlinMethod = javaClass.getMethod("getKotlin")
|
||||||
val oldIsAccessible = kotlinMethod.isAccessible
|
val oldIsAccessible = kotlinMethod.isAccessible
|
||||||
try {
|
try {
|
||||||
kotlinMethod.isAccessible = true
|
kotlinMethod.isAccessible = true
|
||||||
return kotlinMethod(this) as SourceDirectorySet
|
return kotlinMethod(this) as SourceDirectorySet
|
||||||
} finally {
|
} finally {
|
||||||
kotlinMethod.isAccessible = oldIsAccessible
|
kotlinMethod.isAccessible = oldIsAccessible
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
val kotlinSourceDirectories = (sourceSet as HasConvention).convention
|
val kotlinSourceDirectories = (sourceSet as HasConvention).convention
|
||||||
.plugins["kotlin"]?.getKotlin()?.srcDirs
|
.plugins["kotlin"]?.getKotlin()?.srcDirs
|
||||||
?: emptySet()
|
?: emptySet()
|
||||||
|
|
||||||
val directories = (sourceSet.java.sourceDirectories.files + kotlinSourceDirectories).toList()
|
val directories = (sourceSet.java.sourceDirectories.files + kotlinSourceDirectories).toList()
|
||||||
.filter { it.exists() }
|
.filter { it.exists() }
|
||||||
.takeIf { it.isNotEmpty() }
|
.takeIf { it.isNotEmpty() }
|
||||||
?: continue
|
?: continue
|
||||||
|
|
||||||
val kotlinOptions = kotlinCompileTask?.let { getKotlinOptions(it) }
|
val kotlinOptions = kotlinCompileTask?.let { getKotlinOptions(it) }
|
||||||
|
|
||||||
for (resourceRoot in sourceSet.resources.sourceDirectories.files) {
|
for (resourceRoot in sourceSet.resources.sourceDirectories.files) {
|
||||||
if (!resourceRoot.exists() || resourceRoot in directories) {
|
if (!resourceRoot.exists() || resourceRoot in directories) {
|
||||||
continue
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
val resourceRootKind = when (kind) {
|
||||||
|
Kind.PRODUCTION -> Kind.RESOURCES
|
||||||
|
Kind.TEST -> Kind.TEST_RESOURCES
|
||||||
|
else -> error("Invalid source root kind $kind")
|
||||||
|
}
|
||||||
|
|
||||||
|
sourceRoots += PSourceRoot(resourceRoot, resourceRootKind, kotlinOptions)
|
||||||
}
|
}
|
||||||
|
|
||||||
val resourceRootKind = when (kind) {
|
for (directory in directories) {
|
||||||
Kind.PRODUCTION -> Kind.RESOURCES
|
sourceRoots += PSourceRoot(directory, kind, kotlinOptions)
|
||||||
Kind.TEST -> Kind.TEST_RESOURCES
|
|
||||||
else -> error("Invalid source root kind $kind")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sourceRoots += PSourceRoot(resourceRoot, resourceRootKind, kotlinOptions)
|
for (root in parseResourceRootsProcessedByProcessResourcesTask(project, sourceSet)) {
|
||||||
}
|
if (sourceRoots.none { it.path == root.path }) {
|
||||||
|
sourceRoots += root
|
||||||
for (directory in directories) {
|
}
|
||||||
sourceRoots += PSourceRoot(directory, kind, kotlinOptions)
|
|
||||||
}
|
|
||||||
|
|
||||||
for (root in parseResourceRootsProcessedByProcessResourcesTask(project, sourceSet)) {
|
|
||||||
if (sourceRoots.none { it.path == root.path }) {
|
|
||||||
sourceRoots += root
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -104,7 +104,7 @@ fun Project.projectTest(taskName: String = "test", parallel: Boolean = false, bo
|
|||||||
|
|
||||||
var subProjectTempRoot: Path? = null
|
var subProjectTempRoot: Path? = null
|
||||||
doFirst {
|
doFirst {
|
||||||
val teamcity = rootProject.findProperty("teamcity") as? Map<*, *>
|
val teamcity = rootProject.findProperty("teamcity") as? Map<Any?, *>
|
||||||
val systemTempRoot =
|
val systemTempRoot =
|
||||||
// TC by default doesn't switch `teamcity.build.tempDir` to 'java.io.tmpdir' so it could cause to wasted disk space
|
// TC by default doesn't switch `teamcity.build.tempDir` to 'java.io.tmpdir' so it could cause to wasted disk space
|
||||||
// Should be fixed soon on Teamcity side
|
// Should be fixed soon on Teamcity side
|
||||||
|
|||||||
Reference in New Issue
Block a user