bazelbuild / migration-tooling

Migration tools for Bazel
Apache License 2.0
45 stars 30 forks source link

[Upgrading] Errors using generate_workspace to add a new external dependency #30

Closed petroseskinder closed 7 years ago

petroseskinder commented 7 years ago

Context

Building off of the stable changes made in #29, I tried adding a dependency on maven-settings:3.5.0, so that I could use a org.apache.maven.settings.building.SettingsBuilder within one of my classes. However, I was unsuccessful in building the target with the new dependencies. I am unsure what I am doing incorrectly or forgetting to do.

Here is the error reported when I ran bazel build generate_workspace/src/main/java/com/google/devtools/build/workspace/maven:all

migration-tooling/generate_workspace/src/main/java/com/google/devtools/build/workspace/maven/BUILD:1:1: Java compilation in rule '//generate_workspace/src/main/java/com/google/devtools/build/workspace/maven:maven' failed: Worker process sent response with exit code: 1.
generate_workspace/src/main/java/com/google/devtools/build/workspace/maven/DefaultModelResolver.java:44: error: package org.apache.maven.settings.building does not exist
import org.apache.maven.settings.building.DefaultSettingsBuildingRequest;
                                         ^
generate_workspace/src/main/java/com/google/devtools/build/workspace/maven/DefaultModelResolver.java:101: error: cannot find symbol
    DefaultSettingsBuildingRequest request = new DefaultSettingsBuildingRequest();
    ^
  symbol:   class DefaultSettingsBuildingRequest
  location: class DefaultModelResolver
generate_workspace/src/main/java/com/google/devtools/build/workspace/maven/DefaultModelResolver.java:101: error: cannot find symbol
    DefaultSettingsBuildingRequest request = new DefaultSettingsBuildingRequest();
                                                 ^
  symbol:   class DefaultSettingsBuildingRequest
  location: class DefaultModelResolver
Target //generate_workspace/src/main/java/com/google/devtools/build/workspace/maven:maven failed to build
Use --verbose_failures to see the command lines of failed build steps.

Reproducing

I went the route of running the generate_workspace command to modifying the workspace.bzl file, and then depending directly on the new artifacts maven jar.

To modify the workspace.bzl file, I ran the following command:

java -jar generate_workspace_deploy.jar \
    -a=com.google.code.findbugs:jsr305:3.0.1 \
    -a=org.codehaus.plexus:plexus-utils:jar:3.0.24 \
    -a=org.codehaus.plexus:plexus-component-annotations:1.7.1 \
    -a=org.codehaus.plexus:plexus-interpolation:1.24 \
    -a=com.google.guava:guava:20.0 \
    -a=org.apache.maven:maven-artifact:3.5.0 \
    -a=org.mockito:mockito-all:1.9.5 \
    -a=junit:junit:4.4 \
    -a=com.google.truth:truth:0.30 \
    -a=org.apache.maven:maven-settings:3.5.0 #<-- new addition

I used the stable version of generate_workspace from #29 to construct the deploy jar. This resulted in the following changes to the generate_workspace.bzl file

Then, I added deps on"@org_apache_maven_maven_settings//jar", in the "//generate_workspace/src/main/java/com/google/devtools/build/workspace/maven:maven target [diff].

After which point, I simply imported org.apache.maven.settings.building.DefaultSettingsBuildingRequest in the DefaultModelResolver [diff].

@kchodorow

kchodorow commented 7 years ago

I think you need maven-settings-builder (https://mvnrepository.com/artifact/org.apache.maven/maven-settings-builder/3.5.0), not maven-settings.

petroseskinder commented 7 years ago

I think you need maven-settings-builder, not maven-settings.

😞