mirror of
https://github.com/ethauvin/kobalt.git
synced 2025-04-27 00:38:11 -07:00
Fix source jar file.
This commit is contained in:
parent
2f840a44fd
commit
986f1b01be
7 changed files with 49 additions and 30 deletions
|
@ -38,7 +38,7 @@ class JarGenerator @Inject constructor(val dependencyManager: DependencyManager)
|
|||
filesNotExcluded.forEach {
|
||||
fileSpecs.add(IFileSpec.FileSpec(it.path.toString().substring(prefixPath.toString().length + 1)))
|
||||
}
|
||||
result.add(IncludedFile(From(prefixPath.toString() + "/"), To(""), fileSpecs))
|
||||
result.add(IncludedFile(From(project.directory + "/" + prefixPath.toString() + "/"), To(""), fileSpecs))
|
||||
|
||||
// Resources, if applicable
|
||||
context.variant.resourceDirectories(project).forEach {
|
||||
|
|
|
@ -48,9 +48,9 @@ class PackagingPlugin @Inject constructor(val dependencyManager : DependencyMana
|
|||
files.forEach { includedFile ->
|
||||
val includedSpecs = arrayListOf<IFileSpec>()
|
||||
includedFile.specs.forEach { spec ->
|
||||
val fromPath = directory + "/" + includedFile.from
|
||||
val fromPath = includedFile.from
|
||||
if (File(fromPath).exists()) {
|
||||
spec.toFiles(fromPath).forEach { file ->
|
||||
spec.toFiles(directory, fromPath).forEach { file ->
|
||||
val fullFile = File(fromPath, file.path)
|
||||
if (! fullFile.exists()) {
|
||||
throw AssertionError("File should exist: $fullFile")
|
||||
|
@ -245,7 +245,7 @@ class PackageConfig(val project: Project) : AttributeHolder {
|
|||
jar {
|
||||
name = "${project.name}-${project.version}-sources.jar"
|
||||
project.sourceDirectories.forEach {
|
||||
include(from(it), to(""), glob("src/**"))
|
||||
include(from(project.directory + "/" + it), to(""), glob("**"))
|
||||
}
|
||||
}
|
||||
jar {
|
||||
|
|
|
@ -6,11 +6,8 @@ import com.beust.kobalt.maven.DependencyManager
|
|||
import com.google.inject.Inject
|
||||
|
||||
class ZipGenerator @Inject constructor(val dependencyManager: DependencyManager){
|
||||
fun findIncludedFiles(project: Project, context: KobaltContext, zip: Zip)
|
||||
= PackagingPlugin.findIncludedFiles(project.directory, zip.includedFiles, zip.excludes)
|
||||
|
||||
fun generateZip(project: Project, context: KobaltContext, zip: Zip) {
|
||||
val allFiles = findIncludedFiles(project, context, zip)
|
||||
val allFiles = PackagingPlugin.findIncludedFiles(project.directory, zip.includedFiles, zip.excludes)
|
||||
PackagingPlugin.generateArchive(project, context, zip.name, ".zip", allFiles)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
package com.beust.kobalt
|
||||
|
||||
import com.beust.kobalt.misc.From
|
||||
import com.beust.kobalt.misc.IncludedFile
|
||||
import com.beust.kobalt.misc.To
|
||||
import org.testng.Assert
|
||||
import org.testng.annotations.BeforeClass
|
||||
import org.testng.annotations.DataProvider
|
||||
|
@ -45,7 +48,16 @@ class IncludeExcludeTest : KobaltTest() {
|
|||
@Test(dataProvider = "dp")
|
||||
fun shouldInclude(root: File, includedSpec: List<String>, excludedSpec: List<String>, expectedFiles: List<String>) {
|
||||
val g = IFileSpec.GlobSpec(includedSpec)
|
||||
val files = g.toFiles(root.path, excludedSpec.map { Glob(it) })
|
||||
val files = g.toFiles("", root.path, excludedSpec.map { Glob(it) })
|
||||
Assert.assertEquals(files.map { it.name }, expectedFiles)
|
||||
}
|
||||
|
||||
@Test
|
||||
private fun f() {
|
||||
val spec = IFileSpec.GlobSpec("src/**")
|
||||
val files = spec.toFiles(homeDir("kotlin/kobalt"), "src/main/kotlin")
|
||||
val inc = IncludedFile(From("src/main/kotlin"), To(""), listOf(IFileSpec.GlobSpec("**")))
|
||||
// val files = inc.allFromFiles(homeDir("kotlin/kobalt"))
|
||||
println("FILES: " + files)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue