diff --git a/README.md b/README.md index 2b63959..6790212 100644 --- a/README.md +++ b/README.md @@ -1 +1,3 @@ -# intellij-plugin-template \ No newline at end of file +IntelliJ Plugin Template +======================== + diff --git a/build.gradle b/build.gradle index a2abc9d..3bacf43 100644 --- a/build.gradle +++ b/build.gradle @@ -1,6 +1,6 @@ plugins { id 'java' - id "org.jetbrains.intellij" version "0.4.16" + id 'org.jetbrains.intellij' version '0.4.18' } group pluginGroup @@ -12,16 +12,25 @@ repositories { mavenCentral() } -patchPluginXml { - version = project.version -} + +// https://github.com/JetBrains/gradle-intellij-plugin intellij { + pluginName pluginName version ideaVersion type ideaType - pluginName pluginName - updateSinceUntilBuild = false + plugins = ['java'] +// updateSinceUntilBuild = false downloadSources Boolean.valueOf(sources) - plugins 'java' +} + +patchPluginXml { + version project.version +// sinceBuild sinceBuild +} + +publishPlugin { + token 'ssdfhasdfASDaq23jhnasdkjh' + channels 'nightly' } diff --git a/gradle.properties b/gradle.properties index 7e2f1dd..6d9ab71 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,18 +2,11 @@ # https://www.jetbrains.com/intellij-repository/releases # https://www.jetbrains.com/intellij-repository/snapshots -ideaVersion = LATEST-EAP-SNAPSHOT -ideaType = IC -sources = true -isEAP = false - -kotlinVersion = 1.3.61 - pluginGroup = org.jetbrains.plugins.template pluginName = Template pluginVersion = 0.0.1 -publishPluginId = 0 -publishUsername = hsz -publishPassword = -publishChannel = +ideaVersion = 2020.1 +ideaType = IC +sources = true +isEAP = false diff --git a/src/main/java/org/jetbrains/plugins/template/MyProjectService.java b/src/main/java/org/jetbrains/plugins/template/MyProjectService.java deleted file mode 100644 index 3be9e75..0000000 --- a/src/main/java/org/jetbrains/plugins/template/MyProjectService.java +++ /dev/null @@ -1,10 +0,0 @@ -package org.jetbrains.plugins.template; - -import com.intellij.openapi.project.Project; -import org.jetbrains.annotations.NotNull; - -public class MyProjectService { - public MyProjectService(@NotNull Project project) { - System.out.println("MyProjectService"); - } -} diff --git a/src/main/java/org/jetbrains/plugins/template/TemplateBundle.java b/src/main/java/org/jetbrains/plugins/template/TemplateBundle.java new file mode 100644 index 0000000..20ba1fd --- /dev/null +++ b/src/main/java/org/jetbrains/plugins/template/TemplateBundle.java @@ -0,0 +1,46 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2018 hsz Jakub Chrzanowski + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package org.jetbrains.plugins.template; + +import com.intellij.DynamicBundle; +import org.jetbrains.annotations.NonNls; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.PropertyKey; + +public class TemplateBundle extends DynamicBundle { + @NonNls + public static final String BUNDLE = "messages.TemplateBundle"; + + private static final TemplateBundle INSTANCE = new TemplateBundle(); + + private TemplateBundle() { + super(BUNDLE); + } + + @NotNull + public static String message(@NotNull @PropertyKey(resourceBundle = BUNDLE) String key, Object... params) { + return INSTANCE.getMessage(key, params); + } +} diff --git a/src/main/java/org/jetbrains/plugins/template/listeners/MyDynamicPluginListener.java b/src/main/java/org/jetbrains/plugins/template/listeners/MyDynamicPluginListener.java new file mode 100644 index 0000000..1ea1dc9 --- /dev/null +++ b/src/main/java/org/jetbrains/plugins/template/listeners/MyDynamicPluginListener.java @@ -0,0 +1,35 @@ +package org.jetbrains.plugins.template.listeners; + +import com.intellij.ide.plugins.CannotUnloadPluginException; +import com.intellij.ide.plugins.DynamicPluginListener; +import com.intellij.ide.plugins.IdeaPluginDescriptor; +import com.intellij.openapi.components.ServiceManager; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.plugins.template.services.MyApplicationService; + +class MyDynamicPluginListener implements DynamicPluginListener { + @Override + public void beforePluginLoaded(@NotNull IdeaPluginDescriptor pluginDescriptor) { + ServiceManager.getService(MyApplicationService.class); + } + + @Override + public void pluginLoaded(@NotNull IdeaPluginDescriptor pluginDescriptor) { + System.out.println("xx"); + } + + @Override + public void beforePluginUnload(@NotNull IdeaPluginDescriptor pluginDescriptor, boolean isUpdate) { + + } + + @Override + public void checkUnloadPlugin(@NotNull IdeaPluginDescriptor pluginDescriptor) throws CannotUnloadPluginException { + + } + + @Override + public void pluginUnloaded(@NotNull IdeaPluginDescriptor pluginDescriptor, boolean isUpdate) { + + } +} diff --git a/src/main/java/org/jetbrains/plugins/template/listeners/MyProjectManagerListener.java b/src/main/java/org/jetbrains/plugins/template/listeners/MyProjectManagerListener.java new file mode 100644 index 0000000..07cd73e --- /dev/null +++ b/src/main/java/org/jetbrains/plugins/template/listeners/MyProjectManagerListener.java @@ -0,0 +1,13 @@ +package org.jetbrains.plugins.template.listeners; + +import com.intellij.openapi.project.Project; +import com.intellij.openapi.project.ProjectManagerListener; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.plugins.template.services.MyProjectService; + +class MyProjectManagerListener implements ProjectManagerListener { + @Override + public void projectOpened(@NotNull Project project) { + project.getService(MyProjectService.class); + } +} diff --git a/src/main/java/org/jetbrains/plugins/template/MyApplicationService.java b/src/main/java/org/jetbrains/plugins/template/services/MyApplicationService.java similarity index 73% rename from src/main/java/org/jetbrains/plugins/template/MyApplicationService.java rename to src/main/java/org/jetbrains/plugins/template/services/MyApplicationService.java index ecee233..9c6bc08 100644 --- a/src/main/java/org/jetbrains/plugins/template/MyApplicationService.java +++ b/src/main/java/org/jetbrains/plugins/template/services/MyApplicationService.java @@ -1,4 +1,4 @@ -package org.jetbrains.plugins.template; +package org.jetbrains.plugins.template.services; public class MyApplicationService { public MyApplicationService() { diff --git a/src/main/java/org/jetbrains/plugins/template/services/MyProjectService.java b/src/main/java/org/jetbrains/plugins/template/services/MyProjectService.java new file mode 100644 index 0000000..4068d22 --- /dev/null +++ b/src/main/java/org/jetbrains/plugins/template/services/MyProjectService.java @@ -0,0 +1,11 @@ +package org.jetbrains.plugins.template.services; + +import com.intellij.openapi.project.Project; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.plugins.template.TemplateBundle; + +public class MyProjectService { + public MyProjectService(@NotNull Project project) { + System.out.println(TemplateBundle.message("projectService", project.getName())); + } +} diff --git a/src/main/resources/META-INF/plugin.xml b/src/main/resources/META-INF/plugin.xml index 61e5e05..e029b7a 100644 --- a/src/main/resources/META-INF/plugin.xml +++ b/src/main/resources/META-INF/plugin.xml @@ -1,17 +1,22 @@ org.jetbrains.plugins.template Template - 1.0.0 JetBrains - Demonstrates various aspects of interacting with project model - com.intellij.modules.java + com.intellij.java - - + + + + + + + diff --git a/src/main/resources/META-INF/pluginIcon.svg b/src/main/resources/META-INF/pluginIcon.svg new file mode 100644 index 0000000..6132908 --- /dev/null +++ b/src/main/resources/META-INF/pluginIcon.svg @@ -0,0 +1,58 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/messages/TemplateBundle.properties b/src/main/resources/messages/TemplateBundle.properties new file mode 100644 index 0000000..f813643 --- /dev/null +++ b/src/main/resources/messages/TemplateBundle.properties @@ -0,0 +1,2 @@ +name=Template Plugin +projectService=Project service: {0}