generated from JetBrains/intellij-platform-plugin-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ddee296
commit a74cd16
Showing
8 changed files
with
41 additions
and
100 deletions.
There are no files selected for viewing
32 changes: 25 additions & 7 deletions
32
src/main/kotlin/cn/xor7/xiaohei/leavesknife/activities/ProjectStartupActivity.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 |
---|---|---|
@@ -1,21 +1,39 @@ | ||
package cn.xor7.xiaohei.leavesknife.activities | ||
|
||
import cn.xor7.xiaohei.leavesknife.services.LEAVESKNIFE_CONFIG_FILE | ||
import cn.xor7.xiaohei.leavesknife.services.leavesknifeConfigService | ||
import com.intellij.openapi.project.Project | ||
import com.intellij.openapi.project.guessProjectDir | ||
import com.intellij.openapi.startup.ProjectActivity | ||
import org.gradle.tooling.GradleConnector | ||
import org.gradle.tooling.model.idea.IdeaProject | ||
import java.io.File | ||
import java.nio.file.Files | ||
import java.nio.file.Paths | ||
|
||
class ProjectStartupActivity : ProjectActivity { | ||
override suspend fun execute(project: Project) { | ||
val projectDir = project.basePath ?: return | ||
GradleConnector.newConnector() | ||
.forProjectDirectory(File(projectDir)) | ||
.connect().use { connection -> | ||
val ideaProject: IdeaProject = connection.getModel(IdeaProject::class.java) | ||
project.leavesknifeConfigService.enablePlugin = | ||
ideaProject.modules.any { it.name == "paper-api-generator" } | ||
project.guessProjectDir()?.let { | ||
if (Files.exists( | ||
Paths.get( | ||
it.path, | ||
LEAVESKNIFE_CONFIG_FILE | ||
) | ||
) | ||
) { | ||
project.leavesknifeConfigService.enablePlugin = true | ||
return@let | ||
} | ||
GradleConnector.newConnector() | ||
.forProjectDirectory(File(it.path)) | ||
.connect().use { connection -> | ||
val ideaProject: IdeaProject = connection.getModel(IdeaProject::class.java) | ||
if (ideaProject.modules.any { it.name == "paper-api-generator" }) { | ||
// project.leavesknifeConfigService.enablePlugin = true | ||
// TODO: 提示用户是否启用插件 | ||
return@let | ||
} | ||
} | ||
} | ||
} | ||
} |
12 changes: 0 additions & 12 deletions
12
src/main/kotlin/cn/xor7/xiaohei/leavesknife/listeners/MyApplicationActivationListener.kt
This file was deleted.
Oops, something went wrong.
18 changes: 0 additions & 18 deletions
18
src/main/kotlin/cn/xor7/xiaohei/leavesknife/services/GradleProjectResolver.kt
This file was deleted.
Oops, something went wrong.
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
26 changes: 12 additions & 14 deletions
26
src/main/kotlin/cn/xor7/xiaohei/leavesknife/services/ProjectConfigService.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
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
39 changes: 0 additions & 39 deletions
39
src/test/kotlin/cn/xor7/xiaohei/leavesknife/MyPluginTest.kt
This file was deleted.
Oops, something went wrong.