@@ -40,6 +40,10 @@ object SourcegraphPlugin extends AutoPlugin {
40
40
taskKey[File ](
41
41
" The --root argument to the 'src lsif upload' command. By default, uses root directory of this build."
42
42
)
43
+ val sourcegraphJavacTargetroot : TaskKey [Option [File ]] =
44
+ taskKey[Option [File ]](
45
+ " The directories where the semanticdb-javac compiler plugin emits SemanticDB files."
46
+ )
43
47
44
48
val Sourcegraph : Configuration =
45
49
config(" sourcegraph" )
@@ -109,26 +113,34 @@ object SourcegraphPlugin extends AutoPlugin {
109
113
inConfig(Test )(configSettings)
110
114
).flatten
111
115
112
- private lazy val semanticdbJavacTargetroot = Def .task[Option [File ]] {
113
- (for {
114
- option <- javacOptions.value
115
- if option.startsWith(" -Xplugin:semanticdb-javac" )
116
- pluginOption <- option.split(" \\ s+" )
117
- if pluginOption.startsWith(" -targetroot:" )
118
- } yield new File (pluginOption.stripPrefix(" -targetroot:" ))).lastOption
119
- }
120
-
121
116
def configSettings : Seq [Def .Setting [_]] = List (
122
117
sourcegraphUpload := sourcegraphUpload.value,
118
+ sourcegraphJavacTargetroot := {
119
+ (for {
120
+ option <- javacOptions.value
121
+ if option.startsWith(" -Xplugin:semanticdb-javac" )
122
+ pluginOption <- option.split(" \\ s+" )
123
+ if pluginOption.startsWith(" -targetroot:" )
124
+ } yield new File (pluginOption.stripPrefix(" -targetroot:" ))).lastOption
125
+ },
123
126
sourcegraphSemanticdbDirectories := {
124
- val javacTargetroot = semanticdbJavacTargetroot.value
125
- val _ = fullClasspath.value
126
- List (
127
- javacTargetroot,
128
- Option (semanticdbTargetRoot.value)
129
- ).flatten
130
- .map(f => f / " META-INF" / " semanticdb" )
131
- .filter(_.isDirectory())
127
+ if (! semanticdbEnabled.value) {
128
+ streams.value.log.warn(
129
+ s " ${name.value}: " +
130
+ s " Skipping LSIF upload because semanticdbEnabled.value is false. " +
131
+ " To fix this problem, set the semanticdbEnabled setting to true."
132
+ )
133
+ Nil
134
+ } else {
135
+ val javacTargetroot = sourcegraphJavacTargetroot.value
136
+ val _ = fullClasspath.value
137
+ List (
138
+ javacTargetroot,
139
+ Option (semanticdbTargetRoot.value)
140
+ ).flatten
141
+ .map(f => f / " META-INF" / " semanticdb" )
142
+ .filter(_.isDirectory())
143
+ }
132
144
}
133
145
)
134
146
0 commit comments