diff --git a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/BuildScript.kt b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/BuildScript.kt index c3c8981c..f22bb567 100644 --- a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/BuildScript.kt +++ b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/BuildScript.kt @@ -58,4 +58,4 @@ fun authRepos(vararg repos : HostConfig) { fun authRepo(init: HostConfig.() -> Unit) = HostConfig().apply { init() } @Directive -fun glob(g: String) : IFileSpec.Glob = IFileSpec.Glob(g) +fun glob(g: String) : IFileSpec.GlobSpec = IFileSpec.GlobSpec(g) diff --git a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/FileSpec.kt b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/FileSpec.kt index 28e4ea00..60252367 100644 --- a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/FileSpec.kt +++ b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/FileSpec.kt @@ -9,16 +9,16 @@ sealed class IFileSpec { abstract fun toFiles(directory: String): List class FileSpec(val spec: String) : IFileSpec() { - override public fun toFiles(directory: String) = arrayListOf(File(spec)) + override public fun toFiles(directory: String) = listOf(File(spec)) override public fun toString() = spec } - class Glob(val spec: String) : IFileSpec() { + class GlobSpec(val spec: String) : IFileSpec() { override public fun toFiles(directory: String): List { val result = arrayListOf() - val matcher = FileSystems.getDefault().getPathMatcher("glob:${spec}") + val matcher = FileSystems.getDefault().getPathMatcher("glob:$spec") Files.walkFileTree(Paths.get(directory), object : SimpleFileVisitor() { override public fun visitFile(path: Path, attrs: BasicFileAttributes): FileVisitResult { val rel = Paths.get(directory).relativize(path) diff --git a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/misc/JarUtils.kt b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/misc/JarUtils.kt index b13dffc7..68fd7a11 100644 --- a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/misc/JarUtils.kt +++ b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/misc/JarUtils.kt @@ -29,9 +29,9 @@ public class JarUtils { } private val DEFAULT_JAR_EXCLUDES = arrayListOf( - IFileSpec.Glob("META-INF/*.SF"), - IFileSpec.Glob("META-INF/*.DSA"), - IFileSpec.Glob("META-INF/*.RSA")) + IFileSpec.GlobSpec("META-INF/*.SF"), + IFileSpec.GlobSpec("META-INF/*.DSA"), + IFileSpec.GlobSpec("META-INF/*.RSA")) public fun addSingleFile(directory: String, file: IncludedFile, outputStream: ZipOutputStream, expandJarFiles: Boolean, onError: (Exception) -> Unit = DEFAULT_HANDLER) { @@ -57,7 +57,7 @@ public class JarUtils { outputStream.closeEntry() } } - val includedFile = IncludedFile(From(source.path), To(""), listOf(IFileSpec.Glob("**"))) + val includedFile = IncludedFile(From(source.path), To(""), listOf(IFileSpec.GlobSpec("**"))) addSingleFile(".", includedFile, outputStream, expandJarFiles) } else { if (expandJarFiles and source.name.endsWith(".jar")) { diff --git a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/misc/KFiles.kt b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/misc/KFiles.kt index 7eb68455..c35e7181 100644 --- a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/misc/KFiles.kt +++ b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/misc/KFiles.kt @@ -277,9 +277,9 @@ class KFiles { fun makeOutputTestDir(project: Project) : File = makeDir(project, KFiles.TEST_CLASSES_DIR) - fun isExcluded(file: File, excludes: List) = isExcluded(file.path, excludes) + fun isExcluded(file: File, excludes: List) = isExcluded(file.path, excludes) - fun isExcluded(file: String, excludes: List) : Boolean { + fun isExcluded(file: String, excludes: List) : Boolean { if (excludes.isEmpty()) { return false } else { diff --git a/src/main/kotlin/com/beust/kobalt/app/remote/GetDependenciesCommand.kt b/src/main/kotlin/com/beust/kobalt/app/remote/GetDependenciesCommand.kt index 72dfe779..9a121abe 100644 --- a/src/main/kotlin/com/beust/kobalt/app/remote/GetDependenciesCommand.kt +++ b/src/main/kotlin/com/beust/kobalt/app/remote/GetDependenciesCommand.kt @@ -54,7 +54,8 @@ class GetDependenciesCommand @Inject constructor(val executors: KobaltExecutors, val pluginDependencies = pluginUrls.map { File(it.toURI()) }.map { FileDependency(it.absolutePath) } projects.forEach { project -> val compileDependencies = pluginDependencies.map { toDependencyData(it, "compile")} + - allDeps(project.compileDependencies).map { toDependencyData(it, "compile") } + allDeps(project.compileDependencies).map { toDependencyData(it, "compile") } + + allDeps(project.compileProvidedDependencies).map { toDependencyData(it, "compile") } val testDependencies = allDeps(project.testDependencies).map { toDependencyData(it, "testCompile") } @Suppress("UNCHECKED_CAST") diff --git a/src/main/kotlin/com/beust/kobalt/plugin/packaging/PackagingPlugin.kt b/src/main/kotlin/com/beust/kobalt/plugin/packaging/PackagingPlugin.kt index ce32cae2..77779c9a 100644 --- a/src/main/kotlin/com/beust/kobalt/plugin/packaging/PackagingPlugin.kt +++ b/src/main/kotlin/com/beust/kobalt/plugin/packaging/PackagingPlugin.kt @@ -2,7 +2,7 @@ package com.beust.kobalt.plugin.packaging import com.beust.kobalt.* import com.beust.kobalt.IFileSpec.FileSpec -import com.beust.kobalt.IFileSpec.Glob +import com.beust.kobalt.IFileSpec.GlobSpec import com.beust.kobalt.api.* import com.beust.kobalt.api.annotation.Directive import com.beust.kobalt.api.annotation.ExportedProjectProperty @@ -43,7 +43,7 @@ class PackagingPlugin @Inject constructor(val dependencyManager : DependencyMana const val TASK_INSTALL: String = "install" - fun findIncludedFiles(directory: String, files: List, excludes: List) + fun findIncludedFiles(directory: String, files: List, excludes: List) : List { val result = arrayListOf() files.forEach { includedFile -> @@ -313,7 +313,7 @@ class PackageConfig(val project: Project) : AttributeHolder { open class Zip(open var name: String? = null) { // internal val includes = arrayListOf() - internal val excludes = arrayListOf() + internal val excludes = arrayListOf() @Directive public fun from(s: String) = From(s) @@ -323,11 +323,11 @@ open class Zip(open var name: String? = null) { @Directive public fun exclude(vararg files: String) { - files.forEach { excludes.add(Glob(it)) } + files.forEach { excludes.add(GlobSpec(it)) } } @Directive - public fun exclude(vararg specs: Glob) { + public fun exclude(vararg specs: GlobSpec) { specs.forEach { excludes.add(it) } } @@ -342,7 +342,7 @@ open class Zip(open var name: String? = null) { } @Directive - public fun include(from: From, to: To, vararg specs: Glob) { + public fun include(from: From, to: To, vararg specs: GlobSpec) { includedFiles.add(IncludedFile(from, to, listOf(*specs))) } diff --git a/src/main/kotlin/com/beust/kobalt/plugin/packaging/WarGenerator.kt b/src/main/kotlin/com/beust/kobalt/plugin/packaging/WarGenerator.kt index a4bfc761..46cb8728 100644 --- a/src/main/kotlin/com/beust/kobalt/plugin/packaging/WarGenerator.kt +++ b/src/main/kotlin/com/beust/kobalt/plugin/packaging/WarGenerator.kt @@ -24,8 +24,8 @@ class WarGenerator @Inject constructor(val dependencyManager: DependencyManager) // src/main/web app and classes // val result = arrayListOf( - IncludedFile(From("src/main/webapp"), To(""), listOf(IFileSpec.Glob("**"))), - IncludedFile(From("kobaltBuild/classes"), To("WEB-INF/classes"), listOf(IFileSpec.Glob("**"))) + IncludedFile(From("src/main/webapp"), To(""), listOf(IFileSpec.GlobSpec("**"))), + IncludedFile(From("kobaltBuild/classes"), To("WEB-INF/classes"), listOf(IFileSpec.GlobSpec("**"))) ) // @@ -55,7 +55,7 @@ class WarGenerator @Inject constructor(val dependencyManager: DependencyManager) KFiles.copy(Paths.get(it.absolutePath), Paths.get(fullDir, it.name)) } - result.add(IncludedFile(From(fullDir), To(WEB_INF), listOf(IFileSpec.Glob("**")))) + result.add(IncludedFile(From(fullDir), To(WEB_INF), listOf(IFileSpec.GlobSpec("**")))) return result } diff --git a/src/main/kotlin/com/beust/kobalt/plugin/publish/JCenterApi.kt b/src/main/kotlin/com/beust/kobalt/plugin/publish/JCenterApi.kt index cb903371..e562fa69 100644 --- a/src/main/kotlin/com/beust/kobalt/plugin/publish/JCenterApi.kt +++ b/src/main/kotlin/com/beust/kobalt/plugin/publish/JCenterApi.kt @@ -53,16 +53,17 @@ open public class UnauthenticatedJCenterApi @Inject constructor(open val http: H } public class JCenterApi @Inject constructor (@Nullable @Assisted("username") val username: String?, - @Nullable @Assisted("password") val password: String?, + @Nullable @Assisted("password") val password: String?, @Nullable @Assisted("org") val org: String?, override val http: Http, val gpg: Gpg, val executors: KobaltExecutors) : UnauthenticatedJCenterApi(http) { interface IFactory { fun create(@Nullable @Assisted("username") username: String?, - @Nullable @Assisted("password") password: String?) : JCenterApi + @Nullable @Assisted("password") password: String?, + @Nullable @Assisted("org") org: String?) : JCenterApi } fun packageExists(packageName: String) : Boolean { - val url = arrayListOf(UnauthenticatedJCenterApi.BINTRAY_URL_API, "packages", username!!, "maven", packageName) + val url = arrayListOf(UnauthenticatedJCenterApi.BINTRAY_URL_API, "packages", org ?: username!!, "maven", packageName) .joinToString("/") val jcResponse = parseResponse(http.get(username, password, url)) @@ -90,7 +91,7 @@ public class JCenterApi @Inject constructor (@Nullable @Assisted("username") val val fileToPath: (File) -> String = { f: File -> arrayListOf( UnauthenticatedJCenterApi.BINTRAY_URL_API_CONTENT, - username!!, + org ?: username!!, "maven", project.name, project.version!!, @@ -107,7 +108,7 @@ public class JCenterApi @Inject constructor (@Nullable @Assisted("username") val fun uploadFile(file: File, url: String, config: JCenterConfig, generateMd5: Boolean = false, generateAsc: Boolean = false) = upload(arrayListOf(file), config, { - f: File -> "${UnauthenticatedJCenterApi.BINTRAY_URL_API_CONTENT}/$username/generic/$url"}, + f: File -> "${UnauthenticatedJCenterApi.BINTRAY_URL_API_CONTENT}/${org ?: username}/generic/$url"}, generateMd5, generateAsc) private fun upload(files: List, config: JCenterConfig?, fileToPath: (File) -> String, diff --git a/src/main/kotlin/com/beust/kobalt/plugin/publish/PublishPlugin.kt b/src/main/kotlin/com/beust/kobalt/plugin/publish/PublishPlugin.kt index 22237a81..91dbbfc3 100644 --- a/src/main/kotlin/com/beust/kobalt/plugin/publish/PublishPlugin.kt +++ b/src/main/kotlin/com/beust/kobalt/plugin/publish/PublishPlugin.kt @@ -29,6 +29,7 @@ public class PublishPlugin @Inject constructor(val files: KFiles, val factory: P private const val PROPERTY_BINTRAY_USER = "bintray.user" private const val PROPERTY_BINTRAY_PASSWORD = "bintray.apikey" + private const val PROPERTY_BINTRAY_ORG = "bintray.organization" } @Suppress("UNUSED_FUNCTION_LITERAL") @@ -90,8 +91,9 @@ public class PublishPlugin @Inject constructor(val files: KFiles, val factory: P val docUrl = DocUrl.PUBLISH_PLUGIN_URL val user = localProperties.get(PROPERTY_BINTRAY_USER, docUrl) val password = localProperties.get(PROPERTY_BINTRAY_PASSWORD, docUrl) + val org = localProperties.get(PROPERTY_BINTRAY_ORG, docUrl) - val jcenter = jcenterFactory.create(user, password) + val jcenter = jcenterFactory.create(user, password, org) var success = false val configuration = jcenterConfigurations[project.name] val messages = arrayListOf() diff --git a/src/test/kotlin/com/beust/kobalt/misc/IncludedFileTest.kt b/src/test/kotlin/com/beust/kobalt/misc/IncludedFileTest.kt index a988b2cb..52a9eb69 100644 --- a/src/test/kotlin/com/beust/kobalt/misc/IncludedFileTest.kt +++ b/src/test/kotlin/com/beust/kobalt/misc/IncludedFileTest.kt @@ -9,7 +9,7 @@ import java.io.File class IncludedFileTest { fun simple() { val from = "src/main/kotlin/" - val inf = IncludedFile(From(from), To(""), listOf(IFileSpec.Glob("**.kt"))) + val inf = IncludedFile(From(from), To(""), listOf(IFileSpec.GlobSpec("**.kt"))) inf.allFromFiles().map { File(from, it.path) }.forEach { Assert.assertTrue(it.exists(), "Should exist: $it") }