Fix Maven build due to recent changes to CLI arguments

This commit is contained in:
Alexander Udalov
2014-07-24 20:04:47 +04:00
parent 3a59465f29
commit 485cc906a4
8 changed files with 13 additions and 30 deletions
@@ -26,11 +26,7 @@ class Html2CompilerPlugin(private val compilerArguments: KDocArguments) : Doclet
private val srcOutputRoot = File(docOutputRoot, names.htmlSourceDirName)
private val sourceDirs: List<File> =
compilerArguments
.src
.orEmpty()
.split(File.pathSeparatorChar)
.map { path -> File(path).getCanonicalFile() }
compilerArguments.freeArgs.orEmpty().map { path -> File(path).getCanonicalFile() }
private val sourceDirPaths: List<String> = sourceDirs.map { d -> d.getPath() }
@@ -5,19 +5,16 @@ import org.jetbrains.jet.cli.common.CompilerPlugin
import org.jetbrains.jet.cli.common.CompilerPluginContext
import org.jetbrains.kotlin.doc.KDocArguments
/** Base class for any compiler plugin which needs to process a KModel */
abstract class KModelCompilerPlugin(
// TODO: fix compiler and make protected
val arguments: KDocArguments)
: CompilerPlugin
{
public override fun processFiles(context: CompilerPluginContext) {
val bindingContext = context.getContext()
val sources = context.getFiles()
val sourceDirs: List<File> = arguments.src.orEmpty().split(File.pathSeparatorChar).map { path -> File(path) }
val sourceDirs: List<File> = arguments.freeArgs.orEmpty().map { path -> File(path) }
val model = KModel(bindingContext, arguments.apply(), sourceDirs, sources.requireNoNulls())
processModel(model)
@@ -22,7 +22,7 @@ class HtmlVisitorTest {
val args = K2JVMCompilerArguments()
args.kotlinHome = "../../../dist/kotlinc"
args.src = srcDir.toString()
args.freeArgs = listOf(srcDir.toString())
args.outputDir = File(dir, "target/classes-htmldocs").toString()
val compiler = K2JVMCompiler()
@@ -40,7 +40,7 @@ class KDocSampleTest {
val args = KDocArguments()
args.kotlinHome = "../../../dist/kotlinc"
args.src = "src/test/sample"
args.freeArgs = listOf("src/test/sample")
val outputDir = File("target/apidocs-sample")
outputDir.rmrf()
@@ -58,7 +58,4 @@ class KDocSampleTest {
val exitCode = compiler.exec(System.err, args)
Assert.assertEquals(ExitCode.OK, exitCode)
}
}
@@ -27,10 +27,9 @@ class KDocTest {
val args = KDocArguments()
//args.module = moduleName
args.kotlinHome = "../../../dist/kotlinc"
val sourceDirs = listOf("../../stdlib/src",
args.freeArgs = listOf("../../stdlib/src",
"../../kunit/src/main/kotlin",
"../../kotlin-jdbc/src/main/kotlin")
args.src = sourceDirs.makeString(File.pathSeparator)
args.outputDir = "target/classes-stdlib"
args.noStdlib = true
args.classpath = "../runtime/target/kotlin-runtime-0.1-SNAPSHOT.jar${File.pathSeparator}../../lib/junit-4.9.jar"
@@ -99,11 +99,7 @@ public open class KotlinCompile(): AbstractCompile() {
return
}
val customSources = args.src;
if (customSources == null || customSources.isEmpty()) {
args.src = sources.map { it.getAbsolutePath() } .makeString(File.pathSeparator)
}
args.freeArgs = sources.map { it.getAbsolutePath() }
if (StringUtils.isEmpty(kotlinOptions.classpath)) {
val existingClasspathEntries = getClasspath().filter(KSpec<File?>({ it != null && it.exists() }))
@@ -182,11 +178,11 @@ public open class KDoc(): SourceTask() {
cfg.packageSummaryText.putAll(kdocOptions.packageSummaryText)
// KDoc compiler does not accept list of files as input. Try to pass directories instead.
args.src = getSource().map { it.getParentFile()!!.getAbsolutePath() }.toSet().makeString(File.pathSeparator)
args.freeArgs = getSource().map { it.getParentFile()!!.getAbsolutePath() }
// Drop compiled sources to temp. Why KDoc compiles anything after all?!
args.outputDir = getTemporaryDir()?.getAbsolutePath()
getLogger().warn(args.src)
getLogger().warn(args.freeArgs.toString())
val embeddedAnnotations = getAnnotations(getProject(), getLogger())
val userAnnotations = (kdocArgs.annotations ?: "").split(File.pathSeparatorChar).toList()
val allAnnotations = if (kdocArgs.noJdkAnnotations) userAnnotations else userAnnotations.plus(embeddedAnnotations.map {it.getPath()})
@@ -160,10 +160,8 @@ public class K2JSCompilerMojo extends KotlinCompileMojo {
k2jsArgs.verbose = true;
}
List<String> sources = getSources();
if (sources.size() > 0) {
k2jsArgs.sourceFiles = sources.toArray(new String[sources.size()]);
}
getLog().info("Compiling Kotlin src from " + Arrays.asList(k2jsArgs.sourceFiles) + " to JavaScript at: " + outputFile);
k2jsArgs.freeArgs.addAll(sources);
getLog().info("Compiling Kotlin src from " + sources + " to JavaScript at: " + outputFile);
}
}
@@ -293,11 +293,11 @@ public abstract class KotlinCompileMojoBase extends AbstractMojo {
arguments.module = module;
}
else {
if (sources.size() <= 0)
if (sources.isEmpty())
throw new MojoExecutionException("No source roots to compile");
arguments.src = join(sources, File.pathSeparator);
log.info("Compiling Kotlin sources from " + arguments.src);
arguments.freeArgs.addAll(sources);
log.info("Compiling Kotlin sources from " + sources);
// TODO: Move it compiler
classpathList.addAll(sources);