-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add support for IntelliJ IDEA via plugin
This change adds a plugin for IntelliJ that replaces the Gradle plugin jar with its own shaded compiler plugin in order to support the Kotlin compiler within IntelliJ. Fixes #4
- Loading branch information
1 parent
e6c7c09
commit 19895ec
Showing
15 changed files
with
309 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...ain/resources/META-INF/services/org.jetbrains.kotlin.compiler.plugin.CommandLineProcessor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
nl.fabianm.kotlin.plugin.generated.GeneratedCommandLineProcessor | ||
nl.fabianm.kotlin.plugin.generated.compiler.GeneratedCommandLineProcessor |
2 changes: 1 addition & 1 deletion
2
.../main/resources/META-INF/services/org.jetbrains.kotlin.compiler.plugin.ComponentRegistrar
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
nl.fabianm.kotlin.plugin.generated.GeneratedComponentRegistrar | ||
nl.fabianm.kotlin.plugin.generated.compiler.GeneratedComponentRegistrar |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/* | ||
* Copyright 2019 Fabian Mastenbroek. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile | ||
|
||
plugins { | ||
kotlin("jvm") | ||
id("org.jlleitschuh.gradle.ktlint") | ||
id("org.jetbrains.intellij") version "0.4.8" | ||
} | ||
|
||
description = "IntelliJ IDEA plugin for marking Kotlin-generated code with an annotation." | ||
|
||
repositories { | ||
jcenter() | ||
} | ||
|
||
dependencies { | ||
compile(kotlin("stdlib")) | ||
compile(project(":plugin-compiler")) | ||
} | ||
|
||
/* Compilation */ | ||
tasks.withType<KotlinCompile> { | ||
kotlinOptions { | ||
jvmTarget = "1.8" | ||
} | ||
} | ||
|
||
tasks.jar { | ||
manifest { | ||
attributes["Specification-Title"] = project.name | ||
attributes["Specification-Version"] = project.version | ||
attributes["Implementation-Title"] = "nl.fabianm.kotlin.plugin.generated.gradle" | ||
attributes["Implementation-Version"] = project.version | ||
} | ||
} | ||
|
||
/* IntelliJ */ | ||
intellij { | ||
pluginName = "kotlin-plugin-generated" | ||
version = "2019.1" | ||
setPlugins("gradle", "org.jetbrains.kotlin:1.3.31-release-IJ2019.1-1") | ||
} |
35 changes: 35 additions & 0 deletions
35
...a/src/main/kotlin/nl/fabianm/kotlin/plugin/generated/idea/GeneratedGradleImportHandler.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* | ||
* Copyright 2019 Fabian Mastenbroek. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package nl.fabianm.kotlin.plugin.generated.idea | ||
|
||
import com.intellij.openapi.externalSystem.model.DataNode | ||
import com.intellij.openapi.externalSystem.model.project.ModuleData | ||
import org.jetbrains.kotlin.idea.configuration.GradleProjectImportHandler | ||
import org.jetbrains.kotlin.idea.facet.KotlinFacet | ||
import org.jetbrains.plugins.gradle.model.data.GradleSourceSetData | ||
|
||
class GeneratedGradleImportHandler : GradleProjectImportHandler { | ||
override fun importBySourceSet(facet: KotlinFacet, sourceSetNode: DataNode<GradleSourceSetData>) { | ||
GeneratedImportHandler.modifyCompilerArguments(facet, PLUGIN_GRADLE_JAR) | ||
} | ||
|
||
override fun importByModule(facet: KotlinFacet, moduleNode: DataNode<ModuleData>) { | ||
GeneratedImportHandler.modifyCompilerArguments(facet, PLUGIN_GRADLE_JAR) | ||
} | ||
|
||
private val PLUGIN_GRADLE_JAR = "plugin-gradle" | ||
} |
Oops, something went wrong.