@@ -2,23 +2,18 @@ package org.modelix.metamodel.gradle
2
2
3
3
import org.gradle.api.DefaultTask
4
4
import org.gradle.api.file.DirectoryProperty
5
- import org.gradle.api.file.RegularFileProperty
6
5
import org.gradle.api.model.ObjectFactory
7
6
import org.gradle.api.provider.ListProperty
8
7
import org.gradle.api.provider.Property
9
8
import org.gradle.api.tasks.Input
10
9
import org.gradle.api.tasks.InputDirectory
11
- import org.gradle.api.tasks.InputFile
12
- import org.gradle.api.tasks.InputFiles
13
10
import org.gradle.api.tasks.Optional
14
11
import org.gradle.api.tasks.OutputDirectory
15
12
import org.gradle.api.tasks.TaskAction
16
13
import org.modelix.metamodel.generator.LanguageData
17
14
import org.modelix.metamodel.generator.LanguageSet
18
15
import org.modelix.metamodel.generator.MetaModelGenerator
19
16
import org.modelix.metamodel.generator.TypescriptMMGenerator
20
- import java.io.File
21
- import java.util.*
22
17
import javax.inject.Inject
23
18
24
19
abstract class GenerateMetaModelSources @Inject constructor(of : ObjectFactory ) : DefaultTask() {
@@ -49,13 +44,14 @@ abstract class GenerateMetaModelSources @Inject constructor(of: ObjectFactory) :
49
44
val previousLanguageCount = languages.getLanguages().size
50
45
51
46
val includedNamespaces = this .includedNamespaces.get().map { it.trimEnd(' .' ) }
52
- val includedLanguages = this .includedLanguages.get() + includedNamespaces
47
+ val includedLanguages = this .includedLanguages.get()
48
+ val includedLanguagesAndNS = this .includedLanguages.get() + includedNamespaces
53
49
val namespacePrefixes = includedNamespaces.map { it + " ." }
54
50
val includedConcepts = this .includedConcepts.get()
55
51
56
52
languages = languages.filter {
57
53
languages.getLanguages().filter { lang ->
58
- includedLanguages .contains(lang.name)
54
+ includedLanguagesAndNS .contains(lang.name)
59
55
|| namespacePrefixes.any { lang.name.startsWith(it) }
60
56
}.forEach { lang ->
61
57
lang.getConceptsInLanguage().forEach { concept ->
@@ -64,6 +60,14 @@ abstract class GenerateMetaModelSources @Inject constructor(of: ObjectFactory) :
64
60
}
65
61
includedConcepts.forEach { includeConcept(it) }
66
62
}
63
+
64
+ val missingLanguages = includedLanguages - languages.getLanguages().map { it.name }.toSet()
65
+ val missingConcepts = includedConcepts - languages.getLanguages().flatMap { it.getConceptsInLanguage() }.map { it.fqName }.toSet()
66
+
67
+ if (missingLanguages.isNotEmpty() || missingConcepts.isNotEmpty()) {
68
+ throw RuntimeException (" The following languages or concepts were not found: " + (missingLanguages + missingConcepts))
69
+ }
70
+
67
71
println (" ${languages.getLanguages().size} of $previousLanguageCount languages included" )
68
72
69
73
val kotlinOutputDir = this .kotlinOutputDir.orNull?.asFile
0 commit comments