Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider using profiles to simplify manual configuration for Maven builds #265

Open
olafurpg opened this issue Jul 15, 2021 · 0 comments
Open

Comments

@olafurpg
Copy link
Member

The following configuration can be added to pom.xml to configure lsif-java

 <profile>
          <id>lsif-java</id>
          <dependencies>
            <dependency>
              <groupId>com.sourcegraph</groupId>
              <artifactId>semanticdb-javac</artifactId>
              <version>0.5.6</version>
              <scope>provided</scope>
            </dependency>
          </dependencies>
          <build>
            <plugins>
              <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                  <compilerArgs>
                    <arg>-Xplugin:semanticdb -sourceroot:${session.executionRootDirectory} -targetroot:${session.executionRootDirectory}/target/semanticdb-targetroot</arg>
                  </compilerArgs>
                </configuration>
              </plugin>
            </plugins>
          </build>
        </profile>
      </profiles>
    </project>

The command mvn -Plsif-java -DskipTests clean verify will then produce SemanticDB files. The benefit of this approach is that it's possible to commit this change to pom.xml. The lsif-java dependency is only added when the command-line flag -Plsif-java is enabled.

The downside of this approach:

  • the semanticdb-javac dependency version is hardcoded and needs to be kept up-to-date
  • it doesn't seem possible to add profiles via settings.xml, which would make it possible for lsif-java index to automatically use profiles instead of the custom javac executable approach
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants