mirror of
https://github.com/JetBrains/intellij-platform-plugin-template.git
synced 2024-10-27 20:44:05 +00:00
Rewrite Gradle script to us Kotlin DSL, code cleanup
This commit is contained in:
parent
3f83267e99
commit
f7af65b00a
36
build.gradle
36
build.gradle
@ -1,36 +0,0 @@
|
|||||||
plugins {
|
|
||||||
id 'java'
|
|
||||||
id 'org.jetbrains.intellij' version '0.4.18'
|
|
||||||
}
|
|
||||||
|
|
||||||
group pluginGroup
|
|
||||||
version pluginVersion
|
|
||||||
|
|
||||||
sourceCompatibility = 1.8
|
|
||||||
|
|
||||||
repositories {
|
|
||||||
mavenCentral()
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// https://github.com/JetBrains/gradle-intellij-plugin
|
|
||||||
|
|
||||||
intellij {
|
|
||||||
pluginName pluginName
|
|
||||||
version ideaVersion
|
|
||||||
type ideaType
|
|
||||||
plugins = ['java']
|
|
||||||
// updateSinceUntilBuild = false
|
|
||||||
downloadSources Boolean.valueOf(sources)
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
patchPluginXml {
|
|
||||||
version project.version
|
|
||||||
// sinceBuild sinceBuild
|
|
||||||
}
|
|
||||||
|
|
||||||
publishPlugin {
|
|
||||||
token 'ssdfhasdfASDaq23jhnasdkjh'
|
|
||||||
channels 'nightly'
|
|
||||||
}
|
|
59
build.gradle.kts
Normal file
59
build.gradle.kts
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
||||||
|
|
||||||
|
plugins {
|
||||||
|
id("java")
|
||||||
|
id("org.jetbrains.kotlin.jvm") version "1.3.72"
|
||||||
|
id("org.jetbrains.intellij") version "0.4.18"
|
||||||
|
}
|
||||||
|
|
||||||
|
val pluginGroup: String by project
|
||||||
|
val pluginName: String by project
|
||||||
|
val pluginVersion: String by project
|
||||||
|
val ideaVersion: String by project
|
||||||
|
val ideaType: String by project
|
||||||
|
val sources: String by project
|
||||||
|
|
||||||
|
group = pluginGroup
|
||||||
|
version = pluginVersion
|
||||||
|
|
||||||
|
tasks.withType<JavaCompile> {
|
||||||
|
sourceCompatibility = "1.8"
|
||||||
|
targetCompatibility = "1.8"
|
||||||
|
}
|
||||||
|
listOf("compileKotlin", "compileTestKotlin").forEach {
|
||||||
|
tasks.getByName<KotlinCompile>(it) {
|
||||||
|
kotlinOptions.jvmTarget = "1.8"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
implementation(kotlin("stdlib-jdk8"))
|
||||||
|
}
|
||||||
|
|
||||||
|
// https://github.com/JetBrains/gradle-intellij-plugin
|
||||||
|
|
||||||
|
intellij {
|
||||||
|
pluginName = pluginName
|
||||||
|
version = ideaVersion
|
||||||
|
type = ideaType
|
||||||
|
updateSinceUntilBuild = false
|
||||||
|
downloadSources = sources.toBoolean()
|
||||||
|
setPlugins("java")
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks {
|
||||||
|
patchPluginXml {
|
||||||
|
version(pluginVersion)
|
||||||
|
// changeNotes("")
|
||||||
|
// sinceBuild sinceBuild
|
||||||
|
}
|
||||||
|
|
||||||
|
// publishPlugin {
|
||||||
|
// token("ssdfhasdfASDaq23jhnasdkjh")
|
||||||
|
// channels("nightly")
|
||||||
|
// }
|
||||||
|
}
|
@ -8,9 +8,11 @@ import org.jetbrains.annotations.PropertyKey
|
|||||||
private const val BUNDLE = "messages.TemplateBundle"
|
private const val BUNDLE = "messages.TemplateBundle"
|
||||||
|
|
||||||
object TemplateBundle : DynamicBundle(BUNDLE) {
|
object TemplateBundle : DynamicBundle(BUNDLE) {
|
||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun message(@PropertyKey(resourceBundle = BUNDLE) key: String, vararg params: Any): String = getMessage(key, *params)
|
fun message(@PropertyKey(resourceBundle = BUNDLE) key: String, vararg params: Any): String = getMessage(key, *params)
|
||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun messagePointer(@PropertyKey(resourceBundle = BUNDLE) key: String, vararg params: Any): () -> String = { message(key, *params) }
|
fun messagePointer(@PropertyKey(resourceBundle = BUNDLE) key: String, vararg params: Any): () -> String = { message(key, *params) }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -6,18 +6,17 @@ import com.intellij.openapi.components.ServiceManager
|
|||||||
import org.jetbrains.plugins.template.services.MyApplicationService
|
import org.jetbrains.plugins.template.services.MyApplicationService
|
||||||
|
|
||||||
internal class MyDynamicPluginListener : DynamicPluginListener {
|
internal class MyDynamicPluginListener : DynamicPluginListener {
|
||||||
|
|
||||||
override fun beforePluginLoaded(pluginDescriptor: IdeaPluginDescriptor) {
|
override fun beforePluginLoaded(pluginDescriptor: IdeaPluginDescriptor) {
|
||||||
ServiceManager.getService(MyApplicationService::class.java)
|
ServiceManager.getService(MyApplicationService::class.java)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun pluginLoaded(pluginDescriptor: IdeaPluginDescriptor) {
|
override fun pluginLoaded(pluginDescriptor: IdeaPluginDescriptor) {}
|
||||||
println("xx")
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun beforePluginUnload(pluginDescriptor: IdeaPluginDescriptor, isUpdate: Boolean) {}
|
override fun beforePluginUnload(pluginDescriptor: IdeaPluginDescriptor, isUpdate: Boolean) {}
|
||||||
|
|
||||||
override fun checkUnloadPlugin(pluginDescriptor: IdeaPluginDescriptor) {
|
override fun checkUnloadPlugin(pluginDescriptor: IdeaPluginDescriptor) {}
|
||||||
}
|
|
||||||
|
|
||||||
override fun pluginUnloaded(pluginDescriptor: IdeaPluginDescriptor, isUpdate: Boolean) {}
|
override fun pluginUnloaded(pluginDescriptor: IdeaPluginDescriptor, isUpdate: Boolean) {}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,9 @@ import com.intellij.openapi.project.ProjectManagerListener
|
|||||||
import org.jetbrains.plugins.template.services.MyProjectService
|
import org.jetbrains.plugins.template.services.MyProjectService
|
||||||
|
|
||||||
internal class MyProjectManagerListener : ProjectManagerListener {
|
internal class MyProjectManagerListener : ProjectManagerListener {
|
||||||
|
|
||||||
override fun projectOpened(project: Project) {
|
override fun projectOpened(project: Project) {
|
||||||
project.getService(MyProjectService::class.java)
|
project.getService(MyProjectService::class.java)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,11 @@
|
|||||||
package org.jetbrains.plugins.template.services
|
package org.jetbrains.plugins.template.services
|
||||||
|
|
||||||
|
import org.jetbrains.plugins.template.TemplateBundle
|
||||||
|
|
||||||
class MyApplicationService {
|
class MyApplicationService {
|
||||||
|
|
||||||
init {
|
init {
|
||||||
println("MyApplicationService")
|
println(TemplateBundle.message("applicationService"))
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,9 @@ import com.intellij.openapi.project.Project
|
|||||||
import org.jetbrains.plugins.template.TemplateBundle
|
import org.jetbrains.plugins.template.TemplateBundle
|
||||||
|
|
||||||
class MyProjectService(project: Project) {
|
class MyProjectService(project: Project) {
|
||||||
|
|
||||||
init {
|
init {
|
||||||
println(TemplateBundle.message("projectService", project.name))
|
println(TemplateBundle.message("projectService", project.name))
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,2 +1,3 @@
|
|||||||
name=Template Plugin
|
name=Template Plugin
|
||||||
|
applicationService=Application service
|
||||||
projectService=Project service: {0}
|
projectService=Project service: {0}
|
||||||
|
Loading…
Reference in New Issue
Block a user