Skip to content

Commit 2de3308

Browse files
committed
Merge branch '2021.1' into 2021.2
2 parents 5914830 + 09c148a commit 2de3308

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+1406
-526
lines changed

build.gradle.kts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ plugins {
2020
groovy
2121
idea
2222
id("org.jetbrains.intellij") version "1.0"
23-
id("org.cadixdev.licenser") version "0.6.0"
23+
id("org.cadixdev.licenser") version "0.6.1"
2424
id("org.jlleitschuh.gradle.ktlint") version "10.0.0"
2525
}
2626

@@ -58,7 +58,7 @@ val gradleToolingExtensionJar = tasks.register<Jar>(gradleToolingExtensionSource
5858

5959
repositories {
6060
mavenCentral()
61-
maven("https://wav.jfrog.io/artifactory/mcdev/")
61+
maven("https://repo.denwav.dev/repository/maven-public/")
6262
maven("https://repo.spongepowered.org/maven")
6363
maven("https://jetbrains.bintray.com/intellij-third-party-dependencies")
6464
maven("https://repo.gradle.org/gradle/libs-releases-local/")
@@ -79,7 +79,7 @@ dependencies {
7979
implementation(libs.templateMakerFabric)
8080

8181
jflex(libs.jflex.lib)
82-
jflexSkeleton("${libs.jflex.skeleton.text()}:idea@skeleton")
82+
jflexSkeleton("${libs.jflex.skeleton.text()}@skeleton")
8383
grammarKit(libs.grammarKit)
8484

8585
testLibs(libs.test.mockJdk)

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ kotlin.code.style=official
1414
ideaVersion = 212.3116.43-EAP-SNAPSHOT
1515
ideaVersionName = 2021.2
1616

17-
coreVersion = 1.5.11
17+
coreVersion = 1.5.12
1818
downloadIdeaSources = true
1919

2020
pluginTomlVersion = 0.2.144.3766-211

gradle/libs.versions.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ gradleToolingExtension = "com.jetbrains.intellij.gradle:gradle-tooling-extension
1818
annotations = "org.jetbrains:annotations:20.1.0"
1919

2020
# Testing
21-
test-mockJdk = "org.jetbrains.idea:mockJDK:1.7-4d76c50"
21+
test-mockJdk = "org.jetbrains.idea:mock-jdk:1.7-4d76c50"
2222
test-mixin = "org.spongepowered:mixin:0.7-SNAPSHOT"
2323
test-spongeapi = "org.spongepowered:spongeapi:7.0.0"
2424
test-nbt = "com.demonwav.mcdev:all-types-nbt:1.0"

gradle/wrapper/gradle-wrapper.jar

333 Bytes
Binary file not shown.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-7.1-bin.zip
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists

gradlew

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ case "`uname`" in
7272
Darwin* )
7373
darwin=true
7474
;;
75-
MINGW* )
75+
MSYS* | MINGW* )
7676
msys=true
7777
;;
7878
NONSTOP* )

readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ Minecraft Development for IntelliJ
4040
</tr>
4141
</table>
4242

43-
Info and Documentation [![Current Release](https://img.shields.io/badge/release-1.5.11-orange.svg?style=flat-square)](https://plugins.jetbrains.com/plugin/8327)
43+
Info and Documentation [![Current Release](https://img.shields.io/badge/release-1.5.12-orange.svg?style=flat-square)](https://plugins.jetbrains.com/plugin/8327)
4444
----------------------
4545

4646
<a href="https://discord.gg/j6UNcfr"><img src="https://i.imgur.com/JXu9C1G.png" height="48px"></img></a>

src/main/kotlin/creator/CreatorStep.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import com.intellij.openapi.application.runReadAction
2020
import com.intellij.openapi.progress.ProgressIndicator
2121
import com.intellij.openapi.project.Project
2222
import com.intellij.openapi.vfs.VirtualFile
23+
import com.intellij.psi.PsiDocumentManager
2324
import com.intellij.psi.PsiFile
2425
import com.intellij.psi.PsiManager
2526
import com.intellij.psi.SmartPsiElementPointer
@@ -46,6 +47,7 @@ interface CreatorStep {
4647
runWriteTask {
4748
for (scheduledReformat in scheduledReformats) {
4849
val file = scheduledReformat.element ?: continue
50+
PsiDocumentManager.getInstance(file.project).getDocument(file)?.setReadOnly(false)
4951
ReformatCodeProcessor(file, false).run()
5052
}
5153
}
@@ -81,6 +83,7 @@ interface CreatorStep {
8183
fun writeText(file: Path, text: String, psiManager: PsiManager? = null) {
8284
Files.write(file, text.toByteArray(Charsets.UTF_8), CREATE, TRUNCATE_EXISTING, WRITE)
8385
psiManager?.findFile(file.virtualFileOrError)?.let {
86+
PsiDocumentManager.getInstance(psiManager.project).getDocument(it)?.setReadOnly(false)
8487
ReformatCodeProcessor(it, false).run()
8588
}
8689
}

src/main/kotlin/creator/buildsystem/gradle/gradle-steps.kt

Lines changed: 38 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -53,16 +53,22 @@ class SimpleGradleSetupStep(
5353
private val project: Project,
5454
private val rootDirectory: Path,
5555
private val buildSystem: BuildSystem,
56-
private val gradleFiles: GradleFiles<String>
56+
private val gradleFiles: GradleFiles<String>,
57+
private val kotlinScript: Boolean = false
5758
) : CreatorStep {
5859

5960
override fun runStep(indicator: ProgressIndicator) {
6061
runWriteTask {
62+
if (project.isDisposed) {
63+
return@runWriteTask
64+
}
65+
6166
buildSystem.directories =
6267
DirectorySet.create(rootDirectory)
6368
val (buildGradle, gradleProp, settingsGradle) = setupGradleFiles(
6469
rootDirectory,
65-
gradleFiles
70+
gradleFiles,
71+
kotlinScript
6672
)
6773

6874
val psiManager = PsiManager.getInstance(project)
@@ -93,13 +99,18 @@ class GradleSetupStep(
9399
private val project: Project,
94100
private val rootDirectory: Path,
95101
private val buildSystem: BuildSystem,
96-
private val gradleFiles: GradleFiles<String>
102+
private val gradleFiles: GradleFiles<String>,
103+
private val kotlinScript: Boolean = false
97104
) : CreatorStep {
98105
override fun runStep(indicator: ProgressIndicator) {
99-
val (_, gradleProp, settingsGradle) = setupGradleFiles(rootDirectory, gradleFiles)
106+
val (_, gradleProp, settingsGradle) = setupGradleFiles(rootDirectory, gradleFiles, kotlinScript)
100107

101108
runWriteTask {
102-
val buildGradlePsi = addBuildGradleDependencies(project, buildSystem, gradleFiles.buildGradle)
109+
if (project.isDisposed) {
110+
return@runWriteTask
111+
}
112+
113+
val buildGradlePsi = addBuildGradleDependencies(project, buildSystem, gradleFiles.buildGradle, kotlinScript)
103114
val psiManager = PsiManager.getInstance(project)
104115
psiManager.findDirectory(rootDirectory.virtualFileOrError)?.let { dir ->
105116
dir.findFile(buildGradlePsi.name)?.delete()
@@ -123,11 +134,11 @@ data class GradleFiles<out T>(
123134
val settingsGradle: T?
124135
)
125136

126-
fun setupGradleFiles(dir: Path, givenFiles: GradleFiles<String>): GradleFiles<Path> {
137+
fun setupGradleFiles(dir: Path, givenFiles: GradleFiles<String>, kotlinScript: Boolean = false): GradleFiles<Path> {
127138
return GradleFiles(
128-
dir.resolve("build.gradle"),
139+
dir.resolve(if (kotlinScript) "build.gradle.kts" else "build.gradle"),
129140
givenFiles.gradleProperties?.let { dir.resolve("gradle.properties") },
130-
givenFiles.settingsGradle?.let { dir.resolve("settings.gradle") }
141+
givenFiles.settingsGradle?.let { dir.resolve(if (kotlinScript) "settings.gradle.kts" else "settings.gradle") },
131142
).apply {
132143
Files.deleteIfExists(buildGradle)
133144
Files.createFile(buildGradle)
@@ -136,10 +147,15 @@ fun setupGradleFiles(dir: Path, givenFiles: GradleFiles<String>): GradleFiles<Pa
136147
}
137148
}
138149

139-
fun addBuildGradleDependencies(project: Project, buildSystem: BuildSystem, text: String): PsiFile {
150+
fun addBuildGradleDependencies(
151+
project: Project,
152+
buildSystem: BuildSystem,
153+
text: String,
154+
kotlinScript: Boolean = false
155+
): PsiFile {
140156
val file = PsiFileFactory.getInstance(project).createFileFromText(GroovyLanguage, text)
141157
return file.runWriteAction {
142-
val fileName = "build.gradle"
158+
val fileName = if (kotlinScript) "build.gradle.kts" else "build.gradle"
143159
file.name = fileName
144160

145161
val groovyFile = file as GroovyFile
@@ -203,7 +219,8 @@ private fun getClosableBlockByName(element: PsiElement, name: String) =
203219
class BasicGradleFinalizerStep(
204220
private val module: Module,
205221
private val rootDirectory: Path,
206-
private val buildSystem: BuildSystem
222+
private val buildSystem: BuildSystem,
223+
private vararg val additionalRunTasks: String
207224
) : CreatorStep {
208225
private val project
209226
get() = module.project
@@ -212,7 +229,7 @@ class BasicGradleFinalizerStep(
212229
// Tell IntelliJ to import this project
213230
rootDirectory.virtualFileOrError.refresh(false, true)
214231

215-
invokeLater {
232+
invokeLater(module.disposed) {
216233
val path = rootDirectory.toAbsolutePath().toString()
217234
if (canLinkAndRefreshGradleProject(path, project, false)) {
218235
linkAndRefreshGradleProject(path, project)
@@ -222,10 +239,17 @@ class BasicGradleFinalizerStep(
222239

223240
// Set up the run config
224241
// Get the gradle external task type, this is what sets it as a gradle task
242+
addRunTaskConfiguration("build")
243+
for (tasks in additionalRunTasks) {
244+
addRunTaskConfiguration(tasks)
245+
}
246+
}
247+
248+
private fun addRunTaskConfiguration(task: String) {
225249
val gradleType = GradleExternalTaskConfigurationType.getInstance()
226250

227251
val runManager = RunManager.getInstance(project)
228-
val runConfigName = buildSystem.artifactId + " build"
252+
val runConfigName = buildSystem.artifactId + ' ' + task
229253

230254
val runConfiguration = ExternalSystemRunConfiguration(
231255
GradleConstants.SYSTEM_ID,
@@ -237,7 +261,7 @@ class BasicGradleFinalizerStep(
237261
// Set relevant gradle values
238262
runConfiguration.settings.externalProjectPath = rootDirectory.toAbsolutePath().toString()
239263
runConfiguration.settings.executionName = runConfigName
240-
runConfiguration.settings.taskNames = listOf("build")
264+
runConfiguration.settings.taskNames = listOf(task)
241265

242266
runConfiguration.isAllowRunningInParallel = false
243267

src/main/kotlin/facet/MinecraftFacet.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,10 @@ class MinecraftFacet(
6666
}
6767

6868
fun refresh() {
69+
if (module.isDisposed) {
70+
return
71+
}
72+
6973
// Don't allow parent types with child types in auto detected set
7074
val allEnabled = configuration.state.run {
7175
autoDetectTypes = PlatformType.removeParents(autoDetectTypes)

0 commit comments

Comments
 (0)