2
2
// SPDX-License-Identifier: Apache-2.0
3
3
4
4
// Engine tests are split out due to otherwise quirky project dependency issues with module tests extending engine tests
5
-
6
5
plugins {
7
- id " java-library"
8
- id " org.jetbrains.gradle.plugin.idea-ext"
9
- id " terasology-common"
6
+ id( " java-library" )
7
+ id( " org.jetbrains.gradle.plugin.idea-ext" )
8
+ id( " terasology-common" )
10
9
}
11
10
12
11
// Grab all the common stuff like plugins to use, artifact repositories, code analysis config
13
- apply from : " $rootDir /config/gradle/publish.gradle"
14
-
15
- import groovy.json.JsonSlurper
12
+ apply (from = " $rootDir /config/gradle/publish.gradle" )
16
13
17
- ext {
18
- // Read environment variables, including variables passed by jenkins continuous integration server
19
- env = System . getenv()
20
- }
14
+ // Read environment variables, including variables passed by jenkins continuous integration server
15
+ val env = System .getenv()
21
16
22
17
// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
23
18
// Java Section //
24
19
// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
25
20
26
21
// Read the internal version out of the engine-tests module.txt
27
- def moduleFile = file(' src/main/resources/org/terasology/unittest/module.txt' )
28
-
29
- if (! moduleFile. exists()) {
30
- println " Failed to find module.txt for engine-tests"
31
- throw new GradleException (" Failed to find module.txt for engine-tests" )
32
- }
22
+ val moduleFile = layout.projectDirectory.file(" src/main/resources/org/terasology/unittest/module.txt" ).asFile
33
23
34
- println " Scanning for version in module.txt for engine-tests"
35
- def slurper = new JsonSlurper ()
36
- def moduleConfig = slurper. parseText(moduleFile. text)
24
+ println (" Scanning for version in module.txt for engine-tests" )
25
+ val moduleConfig = groovy.json.JsonSlurper ().parseText(moduleFile.readText()) as Map <String , String >
37
26
38
27
// Gradle uses the magic version variable when creating the jar name (unless explicitly set differently)
39
- version = moduleConfig. version
28
+ version = moduleConfig[ " version" ] !!
40
29
41
30
// Jenkins-Artifactory integration catches on to this as part of the Maven-type descriptor
42
- group = ' org.terasology.engine'
31
+ group = " org.terasology.engine"
43
32
44
- println " Version for $project . name loaded as $version for group $group "
33
+ println ( " Version for $project .name loaded as $version for group $group " )
45
34
46
- sourceSets {
35
+ configure< SourceSetContainer > {
47
36
// Adjust output path (changed with the Gradle 6 upgrade, this puts it back)
48
- main. java. destinationDirectory = new File ( " $b uildDir / classes" )
49
- test. java. destinationDirectory = new File ( " $b uildDir / testClasses" )
37
+ main { java.destinationDirectory.set(layout.buildDirectory.dir( " classes" )) }
38
+ test { java.destinationDirectory.set(layout.buildDirectory.dir( " testClasses" )) }
50
39
}
51
40
52
41
// Primary dependencies definition
53
42
dependencies {
54
43
// Dependency on the engine itself
55
- implementation project(' :engine' )
44
+ implementation( project(" :engine" ) )
56
45
57
46
// Dependency not provided for modules, but required for module-tests
58
- implementation group : ' com.google.code.gson' , name : ' gson' , version : ' 2.8.6'
59
- implementation group : ' org.codehaus.plexus' , name : ' plexus-utils' , version : ' 3.0.16'
60
- implementation group : ' com.google.protobuf' , name : ' protobuf-java' , version : ' 3.16.1'
61
- implementation " org.terasology:reflections:0.9.12-MB"
47
+ implementation( " com.google.code.gson: gson: 2.8.6" )
48
+ implementation( " org.codehaus.plexus: plexus-utils: 3.0.16" )
49
+ implementation( " com.google.protobuf: protobuf-java: 3.16.1" )
50
+ implementation( " org.terasology:reflections:0.9.12-MB" )
62
51
63
52
implementation(" org.terasology.joml-ext:joml-test:0.1.0" )
64
53
@@ -77,7 +66,7 @@ dependencies {
77
66
api(" com.google.truth:truth:1.1.3" ) {
78
67
because(" we provide some helper classes" )
79
68
}
80
- implementation(' org.mockito:mockito-core:5.6.0' ) {
69
+ implementation(" org.mockito:mockito-core:5.6.0" ) {
81
70
because(" classes like HeadlessEnvironment use mocks" )
82
71
}
83
72
constraints {
@@ -90,47 +79,44 @@ dependencies {
90
79
}
91
80
92
81
// TODO: Remove it when gestalt will can to handle ProtectionDomain without classes (Resources)
93
- task copyResourcesToClasses ( type : Copy ) {
94
- from tasks . named (" processResources" )
95
- into sourceSets. main. output. classesDirs. first()
82
+ tasks.register< Copy >( " copyResourcesToClasses " ) {
83
+ from(" processResources" )
84
+ into( sourceSets[ " main" ] .output.classesDirs.first() )
96
85
}
97
86
98
- tasks. named(" compileJava" ){
99
- dependsOn(copyResourcesToClasses)
87
+ tasks.named(" compileJava" ) {
88
+ dependsOn(" copyResourcesToClasses" )
100
89
}
101
90
102
- jar { // Workaround about previous copy to classes. idk why engine-tests:jar called before :engine ...
103
- duplicatesStrategy = " EXCLUDE"
91
+ tasks.withType<Jar > {
92
+ // Workaround about previous copy to classes. idk why engine-tests:jar called before :engine ...
93
+ duplicatesStrategy = DuplicatesStrategy .EXCLUDE
104
94
}
105
95
106
- test {
107
- dependsOn rootProject. extractNatives
108
-
109
- description(" Runs all tests (slow)" )
110
-
96
+ tasks.named<Test >(" test" ) {
97
+ dependsOn(tasks.getByPath(" :extractNatives" ))
98
+ description = " Runs all tests (slow)"
99
+ useJUnitPlatform ()
111
100
systemProperty(" junit.jupiter.execution.timeout.default" , " 4m" )
112
101
}
113
102
114
- task unitTest (type : Test ) {
115
- dependsOn rootProject. extractNatives
116
-
117
- group " Verification"
118
- description(" Runs unit tests (fast)" )
119
-
103
+ tasks.register<Test >(" unitTest" ) {
104
+ dependsOn(tasks.getByPath(" :extractNatives" ))
105
+ group = " Verification"
106
+ description = " Runs unit tests (fast)"
120
107
useJUnitPlatform {
121
- excludeTags " MteTest" , " TteTest"
108
+ excludeTags = setOf ( " MteTest" , " TteTest" )
122
109
}
123
110
systemProperty(" junit.jupiter.execution.timeout.default" , " 1m" )
124
111
}
125
112
126
- task integrationTest (type : Test ) {
127
- dependsOn rootProject. extractNatives
128
-
129
- group " Verification"
130
- description(" Runs integration tests (slow) tagged with 'MteTest' or 'TteTest'" )
113
+ tasks.register<Test >(" integrationTest" ) {
114
+ dependsOn(tasks.getByPath(" :extractNatives" ))
115
+ group = " Verification"
116
+ description = " Runs integration tests (slow) tagged with 'MteTest' or 'TteTest'"
131
117
132
118
useJUnitPlatform {
133
- includeTags " MteTest" , " TteTest"
119
+ includeTags = setOf ( " MteTest" , " TteTest" )
134
120
}
135
121
systemProperty(" junit.jupiter.execution.timeout.default" , " 5m" )
136
122
}
@@ -139,8 +125,8 @@ idea {
139
125
module {
140
126
// Change around the output a bit
141
127
inheritOutputDirs = false
142
- outputDir = file(' build/classes' )
143
- testOutputDir = file(' build/testClasses' )
144
- downloadSources = true
128
+ outputDir = file(" build/classes" )
129
+ testOutputDir = file(" build/testClasses" )
130
+ isDownloadSources = true
145
131
}
146
132
}
0 commit comments