-
Notifications
You must be signed in to change notification settings - Fork 72
Add pluginClasspaths to the configuration #23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
7379cd5
0def979
c85aa65
6707daa
6f37d94
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -65,6 +65,11 @@ class KotlinCompilation { | |
| */ | ||
| var classpaths: List<File> = emptyList() | ||
|
|
||
| /** | ||
| * Paths to plugins to be made available in the compilation | ||
| */ | ||
| var pluginClasspaths: List<File> = emptyList() | ||
|
|
||
| /** Source files to be compiled */ | ||
| var sources: List<SourceFile> = emptyList() | ||
|
|
||
|
|
@@ -326,6 +331,8 @@ class KotlinCompilation { | |
| it.destination = classesDir.absolutePath | ||
| it.classpath = commonClasspaths().joinToString(separator = File.pathSeparator) | ||
|
|
||
| it.pluginClasspaths = pluginClasspaths.map(File::getAbsolutePath).toTypedArray() | ||
|
|
||
| if(jdkHome != null) { | ||
| it.jdkHome = jdkHome!!.absolutePath | ||
| } | ||
|
|
@@ -403,6 +410,13 @@ class KotlinCompilation { | |
|
|
||
| /** Performs the 1st and 2nd compilation step to generate stubs and run annotation processors */ | ||
| private fun stubsAndApt(sourceFiles: List<File>): ExitCode { | ||
| pluginClasspaths.forEach { filepath -> | ||
| if (!filepath.exists()) { | ||
| error("Plugin $filepath not found") | ||
| return ExitCode.INTERNAL_ERROR | ||
| } | ||
| } | ||
|
|
||
|
Comment on lines
+413
to
+419
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this should probably be moved to the calling function, where writing of the source files happens as well.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please, which function? And previously, the writing of the source files appears: Though I don't find an error checking section like the one I found in
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think I would just put it after |
||
| if(annotationProcessors.isEmpty()) { | ||
| log("No services were given. Not running kapt steps.") | ||
| return ExitCode.OK | ||
|
|
@@ -473,10 +487,12 @@ class KotlinCompilation { | |
| } | ||
| } | ||
|
|
||
| if (pluginClasspaths.isNotEmpty()) | ||
| warn("Included plugins in pluginsClasspaths will be executed twice.") | ||
|
|
||
| val k2JvmArgs = commonK2JVMArgs().also { | ||
| it.freeArgs = sourcePaths | ||
| it.pluginClasspaths = (it.pluginClasspaths?.toList() ?: emptyList<String>() + getResourcesPath()) | ||
| .distinct().toTypedArray() | ||
| it.pluginClasspaths = (it.pluginClasspaths ?: emptyArray()) + arrayOf(getResourcesPath()) | ||
| } | ||
|
|
||
| val compilerMessageCollector = PrintingMessageCollector( | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
commonK2JVMArgswill be used in both steps:stubsAndAptandcompileKotlin. So given compiler plugins will be run both times. Is this the desired behaviour? Unless the kapt plugin prevents the compiler from continuing with other plugins, like it short circuits the regular compilation. @Foso may know more.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I didn't have that problem because I didn't provide
annotationProcessors, sostubsAndAptfinished in the first conditional. Let's see the opinion by @Foso.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This issue still deserves some attention. Are we really sure that compiler plugins should be executed in both steps?