Maven-Bazel Migration Plugin

Used to generate a Bazel-compatible listing of all dependencies transitively. Provides a listing of "maven_jar()" directives for the WORKSPACE file, and on request, the relevant "@references" for the BUILD files.

License

License

Categories

Categories

Maven Build Tools
GroupId

GroupId

hu.skawa
ArtifactId

ArtifactId

migrator-maven-plugin
Last Version

Last Version

1.1.1
Release Date

Release Date

Type

Type

maven-plugin
Description

Description

Maven-Bazel Migration Plugin
Used to generate a Bazel-compatible listing of all dependencies transitively. Provides a listing of "maven_jar()" directives for the WORKSPACE file, and on request, the relevant "@references" for the BUILD files.
Project URL

Project URL

https://zmeggyesi.github.io/migrator-maven-plugin/
Source Code Management

Source Code Management

https://github.com/zmeggyesi/migrator-maven-plugin

Download migrator-maven-plugin

How to add to project

<plugin>
    <groupId>hu.skawa</groupId>
    <artifactId>migrator-maven-plugin</artifactId>
    <version>1.1.1</version>
</plugin>

Dependencies

compile (4)

Group / Artifact Type Version
org.apache.maven : maven-plugin-api jar 2.0
org.codehaus.plexus : plexus-utils jar 3.0.8
org.apache.maven : maven-core jar 3.3.9
com.google.guava : guava jar 20.0

provided (1)

Group / Artifact Type Version
org.apache.maven.plugin-tools : maven-plugin-annotations jar 3.2

test (1)

Group / Artifact Type Version
junit : junit jar 4.8.2

Project Modules

There are no modules declared in this project.

migrator-maven-plugin

Used to generate a Bazel-compatible listing of all dependencies transitively. Provides a listing of maven_jar() directives for the WORKSPACE file (optionally with SHA1 hashes and source servers), and on request, the relevant @references for the BUILD files. Can also export the servers used in the project, in case a dependency was not downloaded from Central (Bazel defaults to Central if no server is defined for an artifact).

Preparation

Clone the repo and run mvn install to install the plugin in your local repo before running.

If you're looking to build a specific version, first you'll need to check out the appropriate tag/commit, and change the version number in the POM plugin declaration!

Injecting

<plugin>
	<groupId>hu.skawa</groupId>
	<artifactId>migrator-maven-plugin</artifactId>
	<version>1.1.1</version>
</plugin>

Parameters

  • Global
    • outputFilePrefix[String]: Determines the prefix of the output files. If set, console output is suppressed and directed to the selected files.
  • Dependency Export
    • outputDirectives[Boolean:true|false]: Instructs the Migrator to output the WORKSPACE directives into a file named ${outputFilePrefix}-${projectName}-directives
    • outputReferences[Boolean:true|false]: Instructs the Migrator to output the BUILD directives into a file named ${outputFilePrefix}-${projectName}-references. Defaults to false.
    • addHashes[Boolean:true|false]: Instructs the Migrator to add SHA1 hashes of each artifact to the WORKSPACE directives. Defaults to false.
    • addServers[Boolean:true|false]: Instructs the Migrator to add the last server where the artifact was downloaded from. Uses only the JAR server, not the POM server, as Bazel only seems to care where the JAR can be downloaded from.

Goals

  • dependencies: Export the project dependencies into WORKSPACE- and (optionally) BUILD-style declarations. Due to the availability of Maven resolution, all dependencies are exported, including transitive ones.
  • servers: Export only the servers defined for the project into maven_server() directives. This includes servers declared in the project POM, as well as servers declared in your personal/global settings.xml files.
    The export assumes that your personal/global settings are in their default places, since Bazel assumes that as well. Therefore, the settings files are not referenced.

Use

Run the plugin by executing mvn hu.skawa:migrator-maven-plugin:${GOAL}, optionally adding the above parameters.

If you have a modular project, the build will invoke the reactor, and the plugin is executed for each project in turn. This will result in multiple output files, each prefixed by your chosen prefix and the project name.

Known issues

  • The plugin relies on the presence of the Aether _remote.repositories file beside the artifacts to determine the latest server it was resolved from. If not found, a warning is emitted and the server name will be empty.

Versions

Version
1.1.1