@@ -109,24 +109,42 @@ object SourcegraphPlugin extends AutoPlugin {
109109 inConfig(Test )(configSettings)
110110 ).flatten
111111
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+
112121 def configSettings : Seq [Def .Setting [_]] = List (
113122 sourcegraphUpload := sourcegraphUpload.value,
114- sourcegraphSemanticdbDirectories := {
115- if (! semanticdbEnabled.value) {
116- streams.value.log.warn(
117- s " ${name.value}: " +
118- s " Skipping LSIF upload because semanticdbEnabled.value is false. " +
119- " To fix this problem, set the semanticdbEnabled setting to true."
120- )
121- Nil
122- } else {
123- val _ = fullClasspath.value
124- val dir =
125- semanticdbTargetRoot.value / " META-INF" / " semanticdb"
126- if (dir.isDirectory()) List (dir)
127- else Nil
123+ sourcegraphSemanticdbDirectories := Def
124+ .taskDyn[List [File ]] {
125+ val javacTargetroot = semanticdbJavacTargetroot.value
126+ if (! semanticdbEnabled.value && javacTargetroot.isEmpty) {
127+ Def .task {
128+ streams.value.log.warn(
129+ s " ${name.value}: " +
130+ s " Skipping LSIF upload because SemanticDB is not enabled " +
131+ " To fix this problem for Scala project, add the setting `semanticdbEnabled := true`."
132+ )
133+ Nil
134+ }
135+ } else {
136+ Def .task {
137+ val _ = fullClasspath.value
138+ List (
139+ javacTargetroot,
140+ Option (semanticdbTargetRoot.value)
141+ ).flatten
142+ .map(f => f / " META-INF" / " semanticdb" )
143+ .filter(_.isDirectory())
144+ }
145+ }
128146 }
129- }
147+ .value
130148 )
131149
132150 private val anyProjectFilter : ScopeFilter = ScopeFilter (
0 commit comments