Skip to content

No target roots found in build graph #544

@slvrtrn

Description

@slvrtrn

Hello. I am trying to contribute to this plugin https://github.com/scalapb/scalapb-pants and make it a little bit more IDEA friendly. Right now, it is not possible to import it in the IDEA 2020.1.3 with Pants plugin 1.15.1

If I comment out all the Scala BUILD definitions (leaving only the Python ones cause I want all the syntax highlighting there to redefine custom targets definitions for V1 & V2), I am getting the following error

No target roots found in build graph. Please make sure Pants export version >= 1.0.9

Output of ./pants export :: provides some Python targets though

▶ ./pants export ::
{
    "version": "1.1.0",
    "targets": {
        "//:scalapb_pants_plugin": {
            "targets": [
                "src/python:plugin"
            ],
            "libraries": [],
            "roots": [],
            "id": ".scalapb_pants_plugin",
            "target_type": "SOURCE",
            "is_code_gen": false,
            "is_synthetic": false,
            "pants_target_type": "target",
            "globs": {
                "globs": []
            },
            "transitive": true,
            "scope": "default",
            "is_target_root": true
        },
        "src/python:plugin": {
            "targets": [
                "3rdparty/python:pantsbuild.pants"
            ],
            "libraries": [],
            "roots": [
                {
                    "source_root": "/Users/serge/work/scalapb-pants/src/python/scalapb/pants/targets",
                    "package_prefix": "scalapb.pants.targets"
                },
                {
                    "source_root": "/Users/serge/work/scalapb-pants/src/python/scalapb/pants/tasks",
                    "package_prefix": "scalapb.pants.tasks"
                },
                {
                    "source_root": "/Users/serge/work/scalapb-pants/src/python/scalapb/pants",
                    "package_prefix": "scalapb.pants"
                }
            ],
            "id": "src.python.plugin",
            "target_type": "SOURCE",
            "is_code_gen": false,
            "is_synthetic": false,
            "pants_target_type": "python_library",
            "globs": {
                "globs": [
                    "src/python/./scalapb/pants/**/*.py"
                ]
            },
            "transitive": true,
            "scope": "default",
            "is_target_root": true,
            "python_interpreter": "CPython-3.7.3"
        }
// etc... 3rdparty modules and everything else

pants.toml that I am using now looks like

[GLOBAL]
v1 = true
v2 = false
pants_version = "1.29.0"
print_exception_stacktrace = true
enable_pantsd = false

pythonpath = ['%(buildroot)s/src/python']

backend_packages.add = [
    'pants.backend.python',
    'scalapb.pants',
]
backend_packages.remove = [
    'pants.backend.python.lint.isort',
]

[python-setup]
interpreter_constraints = [
    'CPython>=3.7',
]

[source]
root_patterns = [
    '%(buildroot)s/src/python',
    '%(buildroot)s/examples',
]

[scala]
version = 2.12

[jvm-platform]
default_platform = "java11"
platforms = """
{
  'java11': {'source': '11', 'target': '11', 'args': [] },
}
"""

if I uncomment Scala BUILD definitions back, I am getting this

FAILURE: Modulizable targets must not contain any synthetic target, but in this case the following synthetic targets depend on other non-synthetic modules:
{ScalaLibrary(.pants.d/gen/scalapb-gen/9c44cc2743fa/examples.simple.dep_proto/current:examples.simple.dep_proto), ScalaLibrary(.pants.d/gen/scalapb-gen/9c44cc2743fa/examples.simple.simple_proto/current:examples.simple.simple_proto), ScalaLibrary(.pants.d/gen/scalapb-gen/9c44cc2743fa/examples.client.client_proto/current:examples.client.client_proto), ScalaLibrary(.pants.d/gen/scalapb-gen/9c44cc2743fa/examples.grpc.service_proto/current:examples.grpc.service_proto)}
One approach that may help is to reduce the scope of the import to further avoid synthetic targets.

everything is working fine from the console though (I am unable to compile and run the example project using ./pants run examples/simple:main command)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions