Skip to content

Commit

Permalink
[idea] feat: generate gradle-wrapper.properties and src/test directory (
Browse files Browse the repository at this point in the history
#2622)

feat: generate gradle-wrapper.properties and src/test directory
  • Loading branch information
Samarium150 authored Apr 15, 2023
1 parent 30b3472 commit f28a1a0
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.1-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!--
~ Copyright 2019-2023 Mamoe Technologies and contributors.
~
~ 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
~ Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
~
~ https://github.com/mamoe/mirai/blob/dev/LICENSE
-->

<html>
<body>
<p>This is a built-in file template used to create a new gradle-wrapper.properties for Mirai Console Plugin projects.</p>
</body>
</html>
3 changes: 2 additions & 1 deletion mirai-console/tools/intellij-plugin/src/assets/Assets.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2019-2022 Mamoe Technologies and contributors.
* Copyright 2019-2023 Mamoe Technologies and contributors.
*
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
Expand All @@ -26,6 +26,7 @@ object FT { // file template
const val SettingsGradleKts = "Plugin settings.gradle.kts"
const val SettingsGradle = "Plugin settings.gradle"

const val GradleWrapperProperties = "Gradle gradle-wrapper.properties"
const val GradleProperties = "Gradle gradle.properties"

const val PluginMainKt = "Plugin main class Kotlin.kt"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2019-2022 Mamoe Technologies and contributors.
* Copyright 2019-2023 Mamoe Technologies and contributors.
*
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
Expand All @@ -23,6 +23,7 @@ class FileTemplateRegistrar : com.intellij.ide.fileTemplates.FileTemplateGroupDe
addTemplate(FileTemplateDescriptor(FT.PluginMainJava))
addTemplate(FileTemplateDescriptor(FT.PluginMainService))

addTemplate(FileTemplateDescriptor(FT.GradleWrapperProperties))
addTemplate(FileTemplateDescriptor(FT.GradleProperties))

addTemplate(FileTemplateDescriptor(FT.SettingsGradleKts))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2019-2022 Mamoe Technologies and contributors.
* Copyright 2019-2023 Mamoe Technologies and contributors.
*
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
Expand Down Expand Up @@ -108,6 +108,10 @@ class MiraiModuleBuilder : StarterModuleBuilder() {
val model = starterContext.getUserData(MIRAI_PROJECT_MODEL_KEY)!!

val standardAssetsProvider = StandardAssetsProvider()
assets.add(GeneratorTemplateFile(
standardAssetsProvider.gradleWrapperPropertiesLocation,
ftManager.getCodeTemplate(FT.GradleWrapperProperties)
))
assets.addAll(standardAssetsProvider.getGradlewAssets())

model.buildSystemType.createBuildSystem(model)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2019-2022 Mamoe Technologies and contributors.
* Copyright 2019-2023 Mamoe Technologies and contributors.
*
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
Expand Down Expand Up @@ -39,6 +39,9 @@ sealed class GradleProjectCreator(
collect(GeneratorEmptyDirectory("src/main/${model.languageType.sourceSetDirName}"))
collect(GeneratorEmptyDirectory("src/main/resources"))

collect(GeneratorEmptyDirectory("src/test/${model.languageType.sourceSetDirName}"))
collect(GeneratorEmptyDirectory("src/test/resources"))

collect(GeneratorTemplateFile(model.languageType.pluginMainClassFile(this)))

collect(GeneratorTemplateFile(".gitignore", getTemplate(FT.Gitignore)))
Expand Down

0 comments on commit f28a1a0

Please sign in to comment.