intellij-pants-plugin icon indicating copy to clipboard operation
intellij-pants-plugin copied to clipboard

Python code in BUILD files

Open benjyw opened this issue 10 years ago • 3 comments

3rdparty/intellij/BUILD contains a ton of Python code. Other BUILD files may too, I haven't checked.

We really want to have BUILD files that are purely declarative, that's the future of Pants. :)

benjyw avatar Dec 03 '15 23:12 benjyw

The reason of having python code is that we want to use some jars in the to-be downloaded IntelliJ dist. For example with intellij build 143.381

jar_library(
    name = 'junit-plugin',
    jars = [
        _intellij_plugin_jar(path) for path in _find_all_jars(
            os.path.join(os.environ['INTELLIJ_HOME'], 'plugins', 'junit', 'lib')
        )
    ]
)

It is trying to look into .cache/intellij/IC-143.381/idea-dist/plugins/junit/lib/, and it is just for one version of the intellij. The build file is ideal to be purely declarative, but we may need a work around for this first, and please kindly suggest if there is a better way to do so.

wisechengyi avatar Jan 05 '16 01:01 wisechengyi

We could invent some kind of interpolation for common things like substituting environment variables into BUILD files.

However, using the environment variable like this with pants seems at odds with the goal of creating a hermetic build. I'm not sure this is a practice we want to officially sanction, just like using python code in the BUILD file.

On Mon, Jan 4, 2016 at 8:58 PM Yi Cheng [email protected] wrote:

The reason of having python code is that we want to use some jars in the to-be downloaded IntelliJ dist. For example with intellij build 143.381

jar_library( name = 'junit-plugin', jars = [ _intellij_plugin_jar(path) for path in _find_all_jars( os.path.join(os.environ['INTELLIJ_HOME'], 'plugins', 'junit', 'lib') ) ] )

It is trying to look into .cache/intellij/IC-143.381/idea-dist/plugins/junit/lib/, and it is just for one version of the intellij. The build file is ideal to be purely declarative, but we may need a work around for this first, and please kindly suggest if there is a better way to do so.

— Reply to this email directly or view it on GitHub https://github.com/pantsbuild/intellij-pants-plugin/issues/79#issuecomment-168869626 .

ericzundel avatar Jan 05 '16 19:01 ericzundel

Yeah, we really want to eventually ban python code from BUILD files entirely. Even now we strongly discourage it. And this use-case seems dodgy anyway, as @ericzundel mentions.

Maybe create a custom subsystem for this? Then you can set the intellij version in an option, and fall back to autodetection.

benjyw avatar Jan 05 '16 23:01 benjyw