1
0
Fork 0
mirror of https://github.com/ethauvin/kobalt.git synced 2025-04-27 00:38:11 -07:00

Fix rootDir problem.

This commit is contained in:
Cedric Beust 2016-02-19 05:15:51 +04:00
parent 2f386a622d
commit 77ca480f57
2 changed files with 21 additions and 14 deletions

View file

@ -42,19 +42,24 @@ sealed class IFileSpec {
val includes = Glob(*spec.toTypedArray()) val includes = Glob(*spec.toTypedArray())
if (File(filePath).isDirectory) { if (File(filePath).isDirectory) {
val rootDir = if (File(filePath).isAbsolute) Paths.get(filePath) val rootDir = (if (File(filePath).isAbsolute) Paths.get(filePath)
else if (baseDir != null) Paths.get(baseDir, filePath) else if (baseDir != null) Paths.get(baseDir, filePath)
else Paths.get(filePath) else Paths.get(filePath)).run { normalize() }
Files.walkFileTree(rootDir, object : SimpleFileVisitor<Path>() { if (rootDir.toFile().exists()) {
override fun visitFile(path: Path, attrs: BasicFileAttributes): FileVisitResult { Files.walkFileTree(rootDir, object : SimpleFileVisitor<Path>() {
val rel = if (baseDir != null && !baseDir.isEmpty()) Paths.get(baseDir).relativize(path) override fun visitFile(p: Path, attrs: BasicFileAttributes): FileVisitResult {
else path val path = p.normalize()
if (isIncluded(includes, excludes, path)) { val rel = rootDir.relativize(path)
result.add(rel.toFile()) if (isIncluded(includes, excludes, path)) {
log(2, " including file " + rel.toFile() + " from rootDir $rootDir")
result.add(rel.toFile())
}
return FileVisitResult.CONTINUE
} }
return FileVisitResult.CONTINUE })
} } else {
}) throw AssertionError("$rootDir should exist")
}
} else { } else {
if (isIncluded(includes, excludes, Paths.get(filePath))) { if (isIncluded(includes, excludes, Paths.get(filePath))) {
result.add(File(filePath)) result.add(File(filePath))

View file

@ -50,7 +50,7 @@ class PackagingPlugin @Inject constructor(val dependencyManager : DependencyMana
val includedSpecs = arrayListOf<IFileSpec>() val includedSpecs = arrayListOf<IFileSpec>()
includedFile.specs.forEach { spec -> includedFile.specs.forEach { spec ->
val fromPath = includedFile.from val fromPath = includedFile.from
if (File(fromPath).exists()) { if (File(directory, fromPath).exists()) {
spec.toFiles(directory, fromPath).forEach { file -> spec.toFiles(directory, fromPath).forEach { file ->
val fullFile = File(KFiles.joinDir(directory, fromPath, file.path)) val fullFile = File(KFiles.joinDir(directory, fromPath, file.path))
if (! fullFile.exists()) { if (! fullFile.exists()) {
@ -247,12 +247,14 @@ class PackageConfig(val project: Project) : AttributeHolder {
jar { jar {
name = "${project.name}-${project.version}-sources.jar" name = "${project.name}-${project.version}-sources.jar"
project.sourceDirectories.forEach { project.sourceDirectories.forEach {
include(from(project.directory + "/" + it), to(""), glob("**")) if (File(project.directory, it).exists()) {
include(from(it), to(""), glob("**"))
}
} }
} }
jar { jar {
name = "${project.name}-${project.version}-javadoc.jar" name = "${project.name}-${project.version}-javadoc.jar"
include(from(project.buildDirectory + "/" + JvmCompilerPlugin.DOCS_DIRECTORY), to(""), glob("**")) include(from(JvmCompilerPlugin.DOCS_DIRECTORY), to(""), glob("**"))
} }
mainJarAttributes.forEach { mainJarAttributes.forEach {