コード例 #1
0
  private ModuleDescriptor findProject(DependencyDescriptor descriptor) {
    String projectPathValue = descriptor.getAttribute(DependencyDescriptorFactory.PROJECT_PATH_KEY);
    if (projectPathValue == null) {
      return null;
    }
    Project project = gradle.getRootProject().project(projectPathValue);
    Module projectModule = ((ProjectInternal) project).getModule();
    ModuleDescriptor projectDescriptor =
        moduleDescriptorConverter.convert(
            project.getConfigurations().getAll(),
            projectModule,
            IvyContext.getContext().getIvy().getSettings());

    for (DependencyArtifactDescriptor artifactDescriptor : descriptor.getAllDependencyArtifacts()) {
      for (Artifact artifact : projectDescriptor.getAllArtifacts()) {
        if (artifact.getName().equals(artifactDescriptor.getName())
            && artifact.getExt().equals(artifactDescriptor.getExt())) {
          String path =
              artifact.getExtraAttribute(DefaultIvyDependencyPublisher.FILE_PATH_EXTRA_ATTRIBUTE);
          ReflectionUtil.invoke(
              artifactDescriptor,
              "setExtraAttribute",
              new Object[] {DefaultIvyDependencyPublisher.FILE_PATH_EXTRA_ATTRIBUTE, path});
        }
      }
    }

    return projectDescriptor;
  }
コード例 #2
0
 @Override
 protected ResolvedResource findArtifactRef(Artifact artifact, Date date) {
   String path =
       artifact.getExtraAttribute(DefaultIvyDependencyPublisher.FILE_PATH_EXTRA_ATTRIBUTE);
   if (path == null) {
     return null;
   }
   File file = new File(path);
   return new ResolvedResource(
       new FileResource(new FileRepository(), file), artifact.getId().getRevision());
 }
コード例 #3
0
 @Test
 public void init() {
   assertSame(testPom, artifactPom.getPom());
   assertEquals(expectedArtifact, artifactPom.getArtifact());
   assertEquals(expectedFile, artifactPom.getArtifactFile());
   checkPom(
       expectedArtifact.getModuleRevisionId().getOrganisation(),
       expectedArtifact.getName(),
       expectedArtifact.getType(),
       expectedArtifact.getModuleRevisionId().getRevision(),
       expectedArtifact.getExtraAttribute(DependencyManager.CLASSIFIER));
 }
コード例 #4
0
 @Test
 public void initWithCustomPomSettings() {
   testPom.setArtifactId(expectedArtifact.getName() + "X");
   testPom.setGroupId(expectedArtifact.getModuleRevisionId().getOrganisation() + "X");
   testPom.setVersion(expectedArtifact.getModuleRevisionId().getRevision() + "X");
   testPom.setPackaging(expectedArtifact.getType() + "X");
   testPom.setClassifier(expectedArtifact.getExtraAttribute(DependencyManager.CLASSIFIER) + "X");
   artifactPom = new DefaultArtifactPom(testPom, expectedArtifact, expectedFile);
   assertEquals(expectedArtifact, artifactPom.getArtifact());
   assertEquals(expectedFile, artifactPom.getArtifactFile());
   checkPom(
       testPom.getGroupId(),
       testPom.getArtifactId(),
       testPom.getPackaging(),
       testPom.getVersion(),
       testPom.getClassifier());
 }
コード例 #5
0
 @Override
 public DownloadReport download(Artifact[] artifacts, DownloadOptions options) {
   DownloadReport dr = new DownloadReport();
   for (Artifact artifact : artifacts) {
     ArtifactDownloadReport artifactDownloadReport = new ArtifactDownloadReport(artifact);
     String path =
         artifact.getExtraAttribute(DefaultIvyDependencyPublisher.FILE_PATH_EXTRA_ATTRIBUTE);
     if (path == null) {
       artifactDownloadReport.setDownloadStatus(DownloadStatus.FAILED);
     } else {
       File file = new File(path);
       artifactDownloadReport.setDownloadStatus(DownloadStatus.SUCCESSFUL);
       artifactDownloadReport.setArtifactOrigin(new ArtifactOrigin(artifact, true, getName()));
       artifactDownloadReport.setLocalFile(file);
       artifactDownloadReport.setSize(file.length());
     }
     dr.addArtifactReport(artifactDownloadReport);
   }
   return dr;
 }
コード例 #6
0
 public void resolve(Artifact artifact, BuildableArtifactResolveResult result) {
   String path =
       artifact.getExtraAttribute(
           DefaultIvyDependencyPublisher.FILE_ABSOLUTE_PATH_EXTRA_ATTRIBUTE);
   result.resolved(new File(path));
 }