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

Maven plugin for dumping dependencies (cross-repo navigation) #735

Merged
merged 20 commits into from
Aug 9, 2024

Conversation

antonsviridov-src
Copy link
Contributor

@antonsviridov-src antonsviridov-src commented Aug 7, 2024

GRAPH-796

This PR adds a maven plugin that can be used to produce dependencies.txt file necessary for cross-repo navigation on Sourcegraph.

It can be used in a standalone invocation:

$ mvn com.sourcegraph:maven-plugin:<VERSION>:sourcegraphDependencies

Or added directly to maven build and run with sourcegraph:sourcegraphDependencies

  <plugin>
      <groupId>com.sourcegraph</groupId>
      <artifactId>maven-plugin</artifactId>
      <version>${scip-java.version}</version>
      <executions>
          <execution>
              <goals>
                  <goal>sourcegraphDependencies</goal>
              </goals>
          </execution>
      </executions>
  </plugin>

Test plan

  • New maven project is added, and a new CI workflow that indexes it using the plugin

Provided,
"org.apache.maven" % "maven-project" % "2.2.1"
),
Compile / resourceGenerators +=
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maven has a special packaging mode for plugins, which seems to be nothing more than a post-processing step that introspects the plugin's pom.xml + all the Mojo files, then writes the special plugin.xml file.

https://maven.apache.org/guides/plugin/guide-java-plugin-development.html

Setting up a Maven build just for that seems to be counterproductive, so we just write the plugin.xml by hand using a template. It's obviously not great, but at this point I don't see a better solution, and we don't expect this plugin to change very frequently.

plugin.xml will be force-kept in sync by tests, because Maven derives a lot of information from it, so if it's broken - things won't work.

For local development this allows you to do mavenPlugin/publishM2 and use that in maven builds.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense. I love sbt

@antonsviridov-src antonsviridov-src changed the title WIP Maven plugin for dumping dependencies (cross-repo navigation) Maven plugin for dumping dependencies (cross-repo navigation) Aug 7, 2024
Copy link
Member

@olafurpg olafurpg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍🏻 Very nice to finally have a Maven plugin. After using Gradle more, I've become fonder of Maven for Java projects (although sbt is still the best JVM build tool, haven't tried Mill much)

Provided,
"org.apache.maven" % "maven-project" % "2.2.1"
),
Compile / resourceGenerators +=
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense. I love sbt

if (artifact.getFile() != null) {
builder.append(
String.format(
"%s\t%s\t%s\t%s\n",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TSV ftw!

@antonsviridov-src antonsviridov-src marked this pull request as ready for review August 8, 2024 15:03
@antonsviridov-src antonsviridov-src merged commit 4a6906a into main Aug 9, 2024
16 checks passed
@antonsviridov-src antonsviridov-src deleted the maven-plugin branch August 9, 2024 07:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants