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

Scrooge maven plugin is overly restrictive #229

Open
fzakaria opened this issue Mar 25, 2016 · 0 comments
Open

Scrooge maven plugin is overly restrictive #229

fzakaria opened this issue Mar 25, 2016 · 0 comments

Comments

@fzakaria
Copy link

I believe the maven plugin for scrooge is too restrictive, especially for cases where not all thrift model dependencies have the idl classifier

Here is the relevant code from AbstractMavenScroogeMojo

    for (Artifact artifact : deps) {
      // This artifact has an idl classifier.
      if (isIdlCalssifier(artifact, classifier)) {
        thriftDependencies.add(artifact);
      } else {
        if (isDepOfIdlArtifact(artifact, depsMap)) {
          // Fetch idl artifact for dependency of an idl artifact.
          try {
            Artifact idlArtifact = MavenScroogeCompilerUtil.getIdlArtifact(
              artifact,
              artifactFactory,
              artifactResolver,
              localRepository,
              remoteArtifactRepositories,
              classifier);
            thriftDependencies.add(idlArtifact);
          } catch (MojoExecutionException e) {
            /* Do nothing as this artifact is not an idl artifact
             binary jars may have dependency on thrift lib etc.
             */
            getLog().debug("Could not fetch idl jar for " + artifact);
          }
        }
      }
    }
    return thriftDependencies;
  }

Specifically consider the use-case where someone has a Maven artfiact ThriftDemoModel with the classifier idl.
This artifact depends on finatra-thrift_2.11 accordingly so that it can make use of finatra-thrift/finatra_thrift_exceptions.thrift

The code above will hit the MavenScroogeCompilerUtil however it will attempt to use the classifier idl and in this particular case, finatra-thrift is not published with any classifier.

The solution to have the classifier as empty or null won't work either because it doesn't allow mixing & matching of dependencies that may /may not use the classifier.

Solution

A better solution would be once the code has determined isIdlCalssifier, it should get all transitive dependencies and simply add them to thriftDependencies

Additional bug

There is an additional bug with the current solution. When performing isDepOfIdlArtifact it uses the getDependencyTrail method. The problem is, if a dependency of an IDL package AND the current root module, the dependencyTrail will be the shortest path and not even include the IDL dependency.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants