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

pants intransitive dependencies #311

Open
viktortnk opened this issue Aug 22, 2017 · 6 comments
Open

pants intransitive dependencies #311

viktortnk opened this issue Aug 22, 2017 · 6 comments

Comments

@viktortnk
Copy link

viktortnk commented Aug 22, 2017

jar_library(
    name='finatra-jackson',
    jars=[
        scala_jar('com.twitter', 'finatra-jackson', '2.12.0', intransitive=True)
    ])

Even though I specify dependency as intransitive, plugin still brings all if it's modules in scope

screenshot 2017-08-22 16 48 04

@baroquebobcat
Copy link
Contributor

Hm. This might be an issue on the pants side. Does running ./pants export on the target also collect all of these jars?

@viktortnk
Copy link
Author

@baroquebobcat Nope, ./pants export only shows finatra-jackson, without it's dependencies

@wisechengyi
Copy link
Collaborator

@viktortnk I tried with your build file. It does seem to be intransitive. Do you think that it could be leaked from somewhere else, i.e. the extra jars belong to some other deps?

$ ./pants export 3rdparty/jvm/com/twitter:finatra-jackson
{
    "preferred_jvm_distributions": {
        "java7": {
            "non_strict": "/Library/Java/JavaVirtualMachines/TwitterJDK/Contents/Home"
        },
        "java6": {
            "non_strict": "/Library/Java/JavaVirtualMachines/TwitterJDK/Contents/Home"
        },
        "java8": {
            "strict": "/Library/Java/JavaVirtualMachines/TwitterJDK/Contents/Home",
            "non_strict": "/Library/Java/JavaVirtualMachines/TwitterJDK/Contents/Home"
        }
    },
    "libraries": {
        "com.twitter:finatra-jackson_2.11:2.12.0": {
            "default": "/Users/yic/.ivy2/pants/com.twitter/finatra-jackson_2.11/jars/finatra-jackson_2.11-2.12.0.jar"
        }
    },
    "version": "1.0.9",
    "targets": {
        "3rdparty/jvm/com/twitter:finatra-jackson": {
            "pants_target_type": "jar_library",
            "is_target_root": true,
            "globs": {
                "globs": []
            },
            "targets": [],
            "roots": [],
            "is_code_gen": false,
            "is_synthetic": false,
            "target_type": "SOURCE",
            "id": "3rdparty.jvm.com.twitter.finatra-jackson",
            "libraries": [
                "com.twitter:finatra-jackson_2.11:2.12.0"
            ],
            "scope": "default",
            "transitive": true
        }
    },
    "jvm_platforms": {
        "platforms": {
            "java7": {
                "source_level": "1.7",
                "args": [],
                "target_level": "1.7"
            },
            "java6": {
                "source_level": "1.6",
                "args": [],
                "target_level": "1.6"
            },
            "java8": {
                "source_level": "1.8",
                "args": [],
                "target_level": "1.8"
            }
        },
        "default_platform": "java8"
    }
}

@viktortnk
Copy link
Author

@wisechengyi Other modules in project depend on finatra-http which has finatra-jackson as dependency. So you think it comes from there? I didn't expect it to work that way.

@wisechengyi
Copy link
Collaborator

You could do the same export command to check for that

@viktortnk
Copy link
Author

viktortnk commented Aug 23, 2017

Hm, I'll try to explain my case

Let's consider 3 pants modules:
api - has case classes as REST api protocol definition + validation annotations from finatra
core [depends on api] - implements business logic
controller [depends on api and core] - finatra http layer

I want keep api module very light on dependencies, but use annotations coming from finatra-jackson

So I define separate target for it in Pants:
jar_library(
name='finatra-jackson',
jars=[
scala_jar('com.twitter', 'finatra-jackson', '2.12.0', intransitive=True)
])

and make build of api module have just this piece:

scala_library(
dependencies=[
'3rdparty:finatra-jackson',
]
)

obviously I use finatra-http target on a controller module, as it works with http layer, but it is not in any dependencies of api and core

So it looks like Pants bringing all dependecies of finatra-jackson in scope for compilation, although it is defined as intransitive:

So in api module I'm allowed to do this:

import com.twitter.finagle.Http
import com.twitter.finatra.validation._

case class OAuthPayloadData(@NotEmpty code: String, @NotEmpty redirectUri: String)

object A {

  val c = Http.client.newService("google.com")
}

(validation package is part of finatra-jackson, but finagle.Http is definitely not)

For above code snipped, neither IDEA, nor Pants compilation complaining (tried also rebuild after ./pants clean-all).
Is it expected behaviour?

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

No branches or pull requests

3 participants