Skip to content

Commit

Permalink
Create libraries for non python target when import dep as jar (#465)
Browse files Browse the repository at this point in the history
The follow-up change to pantsbuild/pants#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:
pantsbuild/pants#8812 (comment)
  • Loading branch information
blorente authored and wisechengyi committed Jan 2, 2020
1 parent 3fc07d4 commit c832d9d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -37,7 +37,13 @@ public void resolve(
) {
for (Map.Entry<String, TargetInfo> entry : projectInfo.getSortedTargets()) {
final TargetInfo targetInfo = entry.getValue();
if (!targetInfo.isJarLibrary()) {

if (executor.getOptions().isImportSourceDepsAsJars()) {
if (targetInfo.isPythonTarget()) {
continue;
}
}
else if (!targetInfo.isJarLibrary()) {
continue;
}

Expand Down

0 comments on commit c832d9d

Please sign in to comment.