From c832d9df94935c97f527615e06c8e3cce958a8fc Mon Sep 17 00:00:00 2001 From: Borja Lorente Date: Thu, 2 Jan 2020 02:47:16 +0000 Subject: [PATCH] Create libraries for non python target when import dep as jar (#465) The follow-up change to https://github.com/pantsbuild/pants/pull/8812. ### Problem Since we will now be relying on libraries as a mechanism to express dependencies between targets, we need to process the libraries field for jvm executables as well. ### Solution Relax the filter in `PantsLibrariesExtension` to process any scala target (not just JarLibraries). ### Result: In combination with the pants PR above, the following UX is achieved: https://github.com/pantsbuild/pants/pull/8812#issuecomment-566515749 --- .../intellij/pants/service/project/PantsResolver.java | 5 ++++- .../project/resolver/PantsLibrariesExtension.java | 10 ++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/com/twitter/intellij/pants/service/project/PantsResolver.java b/src/com/twitter/intellij/pants/service/project/PantsResolver.java index 42d87aaac..367808cfd 100644 --- a/src/com/twitter/intellij/pants/service/project/PantsResolver.java +++ b/src/com/twitter/intellij/pants/service/project/PantsResolver.java @@ -36,8 +36,11 @@ public class PantsResolver { /** * Bump this version if project resolve changes. It will prompt user to refresh. * E.g. more modules are created or their relationship changes. + * + * 16: with 'import dep as jar', allow all target types (except Python targets) to depend on libraries directly. + * Previously only JarLibrary targets can depend on libraries. */ - public static final int VERSION = 15; + public static final int VERSION = 16; protected static final Logger LOG = Logger.getInstance(PantsResolver.class); protected final PantsCompileOptionsExecutor myExecutor; diff --git a/src/com/twitter/intellij/pants/service/project/resolver/PantsLibrariesExtension.java b/src/com/twitter/intellij/pants/service/project/resolver/PantsLibrariesExtension.java index abebb006f..9bd8b483e 100644 --- a/src/com/twitter/intellij/pants/service/project/resolver/PantsLibrariesExtension.java +++ b/src/com/twitter/intellij/pants/service/project/resolver/PantsLibrariesExtension.java @@ -13,11 +13,11 @@ import com.intellij.openapi.externalSystem.model.project.ProjectData; import com.intellij.openapi.util.io.FileUtil; import com.twitter.intellij.pants.service.PantsCompileOptionsExecutor; -import com.twitter.intellij.pants.service.project.model.graph.BuildGraph; import com.twitter.intellij.pants.service.project.PantsResolverExtension; import com.twitter.intellij.pants.service.project.model.LibraryInfo; import com.twitter.intellij.pants.service.project.model.ProjectInfo; import com.twitter.intellij.pants.service.project.model.TargetInfo; +import com.twitter.intellij.pants.service.project.model.graph.BuildGraph; import com.twitter.intellij.pants.util.PantsConstants; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -37,7 +37,13 @@ public void resolve( ) { for (Map.Entry entry : projectInfo.getSortedTargets()) { final TargetInfo targetInfo = entry.getValue(); - if (!targetInfo.isJarLibrary()) { + + if (executor.getOptions().isImportSourceDepsAsJars()) { + if (targetInfo.isPythonTarget()) { + continue; + } + } + else if (!targetInfo.isJarLibrary()) { continue; }