コード例 #1
0
 public void testSourceFilesAreCorrectlyMarkedAsSourceOrGenerated() throws Exception {
   scratch.file(
       "com/google/example/BUILD",
       "genrule(",
       "   name = 'gen',",
       "   outs = ['gen.java'],",
       "   cmd = '',",
       ")",
       "java_library(",
       "    name = 'lib',",
       "    srcs = ['Test.java', ':gen'],",
       ")");
   Map<String, RuleIdeInfo> ruleIdeInfos = buildRuleIdeInfo("//com/google/example:lib");
   RuleIdeInfo ruleIdeInfo = getRuleInfoAndVerifyLabel("//com/google/example:lib", ruleIdeInfos);
   assertThat(ruleIdeInfo.getJavaRuleIdeInfo().getSourcesList())
       .containsExactly(
           ArtifactLocation.newBuilder()
               .setRootPath(targetConfig.getGenfilesDirectory().getPath().getPathString())
               .setRelativePath("com/google/example/gen.java")
               .setIsSource(false)
               .build(),
           ArtifactLocation.newBuilder()
               .setRootPath(directories.getWorkspace().getPathString())
               .setRelativePath("com/google/example/Test.java")
               .setIsSource(true)
               .build());
 }
コード例 #2
0
 @Override
 public String apply(Artifact artifact) {
   ArtifactLocation location = makeArtifactLocation(artifact);
   return Joiner.on(",")
       .join(
           location.getRootExecutionPathFragment(),
           location.getRelativePath(),
           location.getRootPath());
 }
コード例 #3
0
 private static ArtifactLocation makeArtifactLocation(SourceDirectory resourceDir) {
   return ArtifactLocation.newBuilder()
       .setRootPath(resourceDir.getRootPath().toString())
       .setRootExecutionPathFragment(resourceDir.getRootExecutionPathFragment().toString())
       .setRelativePath(resourceDir.getRelativePath().toString())
       .setIsSource(resourceDir.isSource())
       .build();
 }
コード例 #4
0
 private static ArtifactLocation makeArtifactLocation(Root root, PathFragment relativePath) {
   return ArtifactLocation.newBuilder()
       .setRootPath(root.getPath().toString())
       .setRootExecutionPathFragment(root.getExecPath().toString())
       .setRelativePath(relativePath.toString())
       .setIsSource(root.isSourceRoot())
       .build();
 }