Skip to content

Commit 09e0ab7

Browse files
committed
Fix build and tests
1 parent b2cf9e3 commit 09e0ab7

File tree

6 files changed

+24
-16
lines changed

6 files changed

+24
-16
lines changed

gradle/wrapper/gradle-wrapper.jar

-379 Bytes
Binary file not shown.

gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
33
zipStoreBase=GRADLE_USER_HOME
44
zipStorePath=wrapper/dists
5-
distributionUrl=https\://services.gradle.org/distributions/gradle-4.2-bin.zip
5+
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-bin.zip

src/test/kotlin/com/demonwav/mcdev/framework/ProjectBuilder.kt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
package com.demonwav.mcdev.framework
1212

1313
import com.intellij.openapi.application.runWriteAction
14+
import com.intellij.openapi.project.rootManager
1415
import com.intellij.openapi.roots.ModuleRootModificationUtil
1516
import com.intellij.openapi.vfs.VfsUtil
1617
import com.intellij.openapi.vfs.VirtualFile
@@ -84,10 +85,10 @@ class ProjectBuilder(fixture: JavaCodeInsightTestFixture) {
8485
runWriteAction {
8586
VfsUtil.markDirtyAndRefresh(false, true, true, root)
8687
// Make sure to always add the module content root
87-
ModuleRootModificationUtil.updateModel(fixture.module) { model ->
88-
model.contentEntries.firstOrNull { it.file == project.baseDir } ?:
89-
model.addContentEntry(project.baseDir)
88+
if (fixture.module.rootManager.contentEntries.none { it.file == project.baseDir }) {
89+
ModuleRootModificationUtil.addContentRoot(fixture.module, project.baseDir)
9090
}
91+
9192
builder()
9293
}
9394
}

src/test/kotlin/com/demonwav/mcdev/framework/ProjectBuilderTest.kt

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,24 +10,25 @@
1010

1111
package com.demonwav.mcdev.framework
1212

13+
import com.intellij.openapi.project.rootManager
1314
import com.intellij.openapi.roots.ModuleRootModificationUtil
15+
import com.intellij.openapi.vfs.VfsUtil
1416
import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase
1517

1618
abstract class ProjectBuilderTest : LightCodeInsightFixtureTestCase() {
1719

1820
protected fun buildProject(builder: ProjectBuilder.() -> Unit) = ProjectBuilder(myFixture).build(builder)
1921

2022
fun ProjectBuilder.src(block: ProjectBuilder.() -> Unit) {
21-
dir("src", block)
22-
ModuleRootModificationUtil.updateModel(myFixture.module) { model ->
23-
val contentEntry = model.contentEntries.firstOrNull { it.file == project.baseDir } ?:
24-
model.addContentEntry(project.baseDir)
25-
26-
val srcFolder = project.baseDir.findChild("src")!!
27-
if (!contentEntry.sourceFolderFiles.contains(srcFolder)) {
28-
contentEntry.addSourceFolder(srcFolder, false)
23+
val srcFolder = VfsUtil.createDirectoryIfMissing(project.baseDir, "src")
24+
val entry = myFixture.module.rootManager.contentEntries.first { it.file == project.baseDir }
25+
if (!entry.sourceFolderFiles.contains(srcFolder)) {
26+
ModuleRootModificationUtil.updateModel(myFixture.module) { model ->
27+
model.contentEntries.first { it.file == project.baseDir }.addSourceFolder(srcFolder, false)
2928
}
3029
}
30+
31+
dir("src", block)
3132
}
3233

3334
override fun tearDown() {

src/test/kotlin/com/demonwav/mcdev/framework/TestUtil.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ val mockJdk by lazy {
2828
}
2929

3030
private fun findLibraryPath(name: String) = FileUtil.toSystemIndependentName(System.getProperty("testLibs.$name")!!)
31-
private fun findLibrary(name: String) = StandardFileSystems.jar().findFileByPath(findLibraryPath(name) + JarFileSystem.JAR_SEPARATOR)
31+
private fun findLibrary(name: String) = StandardFileSystems.jar().refreshAndFindFileByPath(findLibraryPath(name) + JarFileSystem.JAR_SEPARATOR)
3232

3333
fun createLibrary(project: Project, name: String): Library {
3434
val table = LibraryTablesRegistrar.getInstance().getLibraryTable(project)

src/test/kotlin/com/demonwav/mcdev/platform/mixin/BaseMixinTest.kt

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,17 @@ abstract class BaseMixinTest : BaseMinecraftTest(PlatformType.MIXIN) {
2525
override fun setUp() {
2626
super.setUp()
2727

28+
runWriteTask {
29+
library = createLibrary(project, "mixin")
30+
}
31+
2832
ModuleRootModificationUtil.updateModel(myModule) { model ->
29-
runWriteTask {
30-
library = createLibrary(project, "mixin")
31-
}
3233
model.addLibraryEntry(library ?: throw IllegalStateException("Library not created"))
34+
val orderEntries = model.orderEntries
35+
val last = orderEntries.last()
36+
System.arraycopy(orderEntries, 0, orderEntries, 1, orderEntries.size - 1)
37+
orderEntries[0] = last
38+
model.rearrangeOrderEntries(orderEntries)
3339
}
3440
}
3541

0 commit comments

Comments
 (0)