Java Code Examples for org.apache.ivy.core.module.id.ModuleRevisionId#getName()

The following examples show how to use org.apache.ivy.core.module.id.ModuleRevisionId#getName() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DefaultConfigurationsToArtifactsConverter.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public Artifact createIvyArtifact(PublishArtifact publishArtifact, ModuleRevisionId moduleRevisionId) {
    Map<String, String> extraAttributes = new HashMap<String, String>();
    if (GUtil.isTrue(publishArtifact.getClassifier())) {
        extraAttributes.put(Dependency.CLASSIFIER, publishArtifact.getClassifier());
    }
    String name = publishArtifact.getName();
    if (!GUtil.isTrue(name)) {
        name = moduleRevisionId.getName();
    }
    return new DefaultArtifact(
            moduleRevisionId,
            publishArtifact.getDate(),
            name,
            publishArtifact.getType(),
            publishArtifact.getExtension(),
            extraAttributes);
}
 
Example 2
Source File: DefaultConfigurationsToArtifactsConverter.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public Artifact createIvyArtifact(PublishArtifact publishArtifact, ModuleRevisionId moduleRevisionId) {
    Map<String, String> extraAttributes = new HashMap<String, String>();
    if (GUtil.isTrue(publishArtifact.getClassifier())) {
        extraAttributes.put(Dependency.CLASSIFIER, publishArtifact.getClassifier());
    }
    String name = publishArtifact.getName();
    if (!GUtil.isTrue(name)) {
        name = moduleRevisionId.getName();
    }
    return new DefaultArtifact(
            moduleRevisionId,
            publishArtifact.getDate(),
            name,
            publishArtifact.getType(),
            publishArtifact.getExtension(),
            extraAttributes);
}
 
Example 3
Source File: IvyTranslations.java    From jeka with Apache License 2.0 6 votes vote down vote up
static void populateModuleDescriptorWithPublication(DefaultModuleDescriptor descriptor,
        JkMavenPublication publication, Instant publishDate) {
    JkArtifactLocator artifactLocator = publication.getArtifactLocator();
    final ModuleRevisionId moduleRevisionId = descriptor.getModuleRevisionId();
    final String ivyArtifactName = moduleRevisionId.getName();
    final Artifact mavenMainArtifact = toPublishedMavenArtifact(artifactLocator.getMainArtifactPath(),
            ivyArtifactName, null, moduleRevisionId, publishDate);
    final String mainConf = "default";
    populateDescriptorWithMavenArtifact(descriptor, mainConf, mavenMainArtifact);
    for (final JkArtifactId artifactId  : artifactLocator.getArtifactIds()) {
        if (artifactId.equals(artifactLocator.getMainArtifactId())) {
            continue;
        }
        final Path file = artifactLocator.getArtifactPath(artifactId);
        final String classifier = artifactId.getName();
        final Artifact mavenArtifact = toPublishedMavenArtifact(file, ivyArtifactName, classifier,
                descriptor.getModuleRevisionId(), publishDate);
        populateDescriptorWithMavenArtifact(descriptor, classifier, mavenArtifact);
    }
}
 
Example 4
Source File: PomModuleDescriptorWriter.java    From ant-ivy with Apache License 2.0 5 votes vote down vote up
private static void setModuleVariables(ModuleDescriptor md, IvyVariableContainer variables,
        PomWriterOptions options) {
    ModuleRevisionId mrid = md.getModuleRevisionId();
    variables.setVariable("ivy.pom.groupId", mrid.getOrganisation(), true);

    String artifactId = options.getArtifactName();
    if (artifactId == null) {
        artifactId = mrid.getName();
    }

    String packaging = options.getArtifactPackaging();
    if (packaging == null) {
        // find artifact to determine the packaging
        Artifact artifact = findArtifact(md, artifactId);
        if (artifact == null) {
            // no suitable artifact found, default to 'pom'
            packaging = "pom";
        } else {
            packaging = artifact.getType();
        }
    }

    variables.setVariable("ivy.pom.artifactId", artifactId, true);
    variables.setVariable("ivy.pom.packaging", packaging, true);
    if (mrid.getRevision() != null) {
        variables.setVariable("ivy.pom.version", mrid.getRevision(), true);
    }
    if (options.getDescription() != null) {
        variables.setVariable("ivy.pom.description", options.getDescription(), true);
    } else if (!isNullOrEmpty(md.getDescription())) {
        variables.setVariable("ivy.pom.description", md.getDescription(), true);
    }
    if (md.getHomePage() != null) {
        variables.setVariable("ivy.pom.url", md.getHomePage(), true);
    }
}
 
Example 5
Source File: LatestConflictManagerTest.java    From ant-ivy with Apache License 2.0 5 votes vote down vote up
/**
 * Test case for IVY-407 (with transitivity). There are 5 modules A, B, C, D and E.
 * <ol>
 * <li>publish C-1.0.0, C-1.0.1 and C-1.0.2</li>
 * <li>B needs C-1.0.0 : retrieve ok and publish B-1.0.0</li>
 * <li>A needs B-1.0.0 and C-1.0.2 : retrieve ok and publish A-1.0.0</li>
 * <li>D needs C-1.0.1 : retrieve ok and publish D-1.0.0</li>
 * <li>E needs D-1.0.0 and A-1.0.0 (D before A in ivy file) :
 * retrieve failed to get C-1.0.2 from A (get apparently C-1.0.1 from D)</li>
 * </ol>
 *
 * @throws Exception if something goes wrong
 * @see <a href="https://issues.apache.org/jira/browse/IVY-407">IVY-407</a>
 */
@Test
public void testLatestTimeTransitivity() throws Exception {
    ivy = new Ivy();
    ivy.configure(LatestConflictManagerTest.class
            .getResource("ivysettings-latest-time-transitivity.xml"));
    ivy.getSettings().setVariable("ivy.log.conflict.resolution", "true", true);

    // set timestamps, because svn is not preserving this information,
    // and the latest time strategy is relying on it
    long time = System.currentTimeMillis() - 10000;
    new File("test/repositories/IVY-407/MyCompany/C/ivy-1.0.0.xml").setLastModified(time);
    new File("test/repositories/IVY-407/MyCompany/C/ivy-1.0.1.xml")
            .setLastModified(time + 2000);
    new File("test/repositories/IVY-407/MyCompany/C/ivy-1.0.2.xml")
            .setLastModified(time + 4000);

    ResolveReport report = ivy.resolve(
        LatestConflictManagerTest.class.getResource("ivy-latest-time-transitivity.xml"),
        getResolveOptions());
    ConfigurationResolveReport defaultReport = report.getConfigurationReport("default");
    for (ModuleRevisionId mrid : defaultReport.getModuleRevisionIds()) {
        switch (mrid.getName()) {
            case "A":
                assertEquals("A revision should be 1.0.0", "1.0.0", mrid.getRevision());
                break;
            case "B":
                // by transitivity
                assertEquals("B revision should be 1.0.0", "1.0.0", mrid.getRevision());
                break;
            case "C":
                assertEquals("C revision should be 1.0.2", "1.0.2", mrid.getRevision());
                break;
            case "D":
                assertEquals("D revision should be 1.0.0", "1.0.0", mrid.getRevision());
                break;
        }
    }
}
 
Example 6
Source File: AbstractOSGiResolver.java    From ant-ivy with Apache License 2.0 5 votes vote down vote up
public ResolvedResource findIvyFileRef(DependencyDescriptor dd, ResolveData data) {
    ModuleRevisionId mrid = dd.getDependencyRevisionId();

    String osgiType = mrid.getOrganisation();
    if (osgiType == null) {
        throw new RuntimeException("Unsupported OSGi module Id: " + mrid.getModuleId());
    }
    String id = mrid.getName();
    Collection<ModuleDescriptor> mds = ModuleDescriptorWrapper.unwrap(getRepoDescriptor()
            .findModules(osgiType, id));
    if (mds == null || mds.isEmpty()) {
        Message.verbose("\t " + id + " not found.");
        return null;
    }

    ResolvedResource[] ret;
    if (BundleInfo.BUNDLE_TYPE.equals(osgiType)) {
        ret = findBundle(dd, data, mds);
    } else {
        ret = findCapability(dd, data, mds);
    }

    ResolvedResource found = findResource(ret, getDefaultRMDParser(dd.getDependencyId()), mrid,
        data.getDate());
    if (found == null) {
        Message.debug("\t" + getName() + ": no resource found for " + mrid);
    }
    return found;
}
 
Example 7
Source File: IvyDeliver.java    From ant-ivy with Apache License 2.0 5 votes vote down vote up
public void deliverDependency(ModuleRevisionId depMrid, String version, String status,
        String depStatus) {
    if (isNullOrEmpty(deliverTarget)) {
        return;
    }
    // call deliver target if any
    CallTarget ct = (CallTarget) getProject().createTask("antcall");
    ct.setOwningTarget(getOwningTarget());
    ct.init();
    ct.setTarget(deliverTarget);
    ct.setInheritAll(true);
    ct.setInheritRefs(true);
    Property param = ct.createParam();
    param.setName("dependency.name");
    param.setValue(depMrid.getName());
    param = ct.createParam();
    param.setName("dependency.published.status");
    param.setValue(status);
    param = ct.createParam();
    param.setName("dependency.published.version");
    param.setValue(version);
    param = ct.createParam();
    param.setName("dependency.version");
    param.setValue(depMrid.getRevision());
    param = ct.createParam();
    param.setName("dependency.status");
    param.setValue(depStatus == null ? "null" : depStatus);

    ct.perform();

    String deliveredProperty = depMrid.getName() + "." + depMrid.getRevision()
            + ".delivered";
    getProject().setProperty(deliveredProperty, "true");
    appendDeliveryList(deliveredProperty + " = true");

    getProject().setProperty("recursive." + depMrid.getName() + ".delivered", "true");
    appendDeliveryList("recursive." + depMrid.getName() + ".delivered" + " = true");
}
 
Example 8
Source File: IvyTranslations.java    From jeka with Apache License 2.0 5 votes vote down vote up
static Artifact toPublishedArtifact(JkIvyPublication.JkPublicationArtifact artifact,
        ModuleRevisionId moduleId, Instant date) {
    final String artifactName = JkUtilsString.isBlank(artifact.name) ? moduleId.getName()
            : artifact.name;
    final String extension = JkUtilsObject.firstNonNull(artifact.extension, "");
    final String type = JkUtilsObject.firstNonNull(artifact.type, extension);
    return new DefaultArtifact(moduleId, new Date(date.toEpochMilli()), artifactName, type, extension);
}
 
Example 9
Source File: IvyPublisherForMaven.java    From jeka with Apache License 2.0 5 votes vote down vote up
private Path makePom(ModuleDescriptor moduleDescriptor, JkMavenPublication publication) {
    final ModuleRevisionId ivyModuleRevisionId = moduleDescriptor.getModuleRevisionId();
    final String artifactName = ivyModuleRevisionId.getName();
    final Path pomXml;
    if (this.descriptorOutputDir != null) {
        pomXml = Paths.get(targetDir()).resolve("published-pom-" + ivyModuleRevisionId.getOrganisation()
        + "-" + artifactName + "-" + ivyModuleRevisionId.getRevision() + ".xml");
    } else {
        pomXml = JkUtilsPath.createTempFile("published-pom-", ".xml");
    }
    final String packaging = JkUtilsString.substringAfterLast(publication.getArtifactLocator()
            .getMainArtifactPath().getFileName().toString(), ".");
    final PomWriterOptions pomWriterOptions = new PomWriterOptions();
    pomWriterOptions.setMapping(new ScopeMapping());
    pomWriterOptions.setArtifactPackaging(packaging);
    Path fileToDelete = null;
    if (publication.getPomMetadata() != null) {
        final Path template = JkPomTemplateGenerator.generateTemplate(publication.getPomMetadata());
        pomWriterOptions.setTemplate(template.toFile());
        fileToDelete = template;
    }
    try {
        PomModuleDescriptorWriter.write(moduleDescriptor, pomXml.toFile(), pomWriterOptions);
        if (fileToDelete != null) {
            Files.deleteIfExists(fileToDelete);
        }
        return pomXml;
    } catch (final IOException e) {
        throw JkUtilsThrowable.unchecked(e);
    }
}
 
Example 10
Source File: PackagerCacheEntry.java    From ant-ivy with Apache License 2.0 4 votes vote down vote up
private static File getSubdir(File rootDir, ModuleRevisionId mr) {
    return new File(rootDir, mr.getOrganisation() + File.separatorChar + mr.getName()
            + File.separatorChar + mr.getRevision());
}
 
Example 11
Source File: DefaultModuleVersionIdentifier.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public static ModuleVersionIdentifier newId(ModuleRevisionId moduleRevisionId) {
    return new DefaultModuleVersionIdentifier(moduleRevisionId.getOrganisation(), moduleRevisionId.getName(), moduleRevisionId.getRevision());
}
 
Example 12
Source File: DefaultArtifact.java    From ant-ivy with Apache License 2.0 4 votes vote down vote up
public static Artifact newPomArtifact(ModuleRevisionId mrid, Date pubDate) {
    return new DefaultArtifact(mrid, pubDate, mrid.getName(), "pom", "pom", true);
}
 
Example 13
Source File: ResolveEngine.java    From ant-ivy with Apache License 2.0 4 votes vote down vote up
private String getDependenciesFetchedKey(IvyNode node, String conf) {
    ModuleRevisionId moduleRevisionId = node.getResolvedId();
    return moduleRevisionId.getOrganisation() + "|" + moduleRevisionId.getName() + "|"
            + moduleRevisionId.getRevision() + "|" + conf;
}
 
Example 14
Source File: IvyDeliver.java    From ant-ivy with Apache License 2.0 4 votes vote down vote up
public String resolve(ModuleDescriptor published, String publishedStatus,
        ModuleRevisionId depMrid, String depStatus) {
    if (StatusManager.getCurrent().isIntegration(publishedStatus)) {
        // published status is integration one, nothing to ask
        return super.resolve(published, publishedStatus, depMrid, depStatus);
    }

    // we are publishing a delivery (a non integration module)

    if (!StatusManager.getCurrent().isIntegration(depStatus)) {
        // dependency is already a delivery, nothing to ask
        return super.resolve(published, publishedStatus, depMrid, depStatus);
    }

    // the dependency is not a delivery

    String statusProperty = depMrid.getName() + "." + depMrid.getRevision() + ".status";
    String versionProperty = depMrid.getName() + "." + depMrid.getRevision() + ".version";
    String deliveredProperty = depMrid.getName() + "." + depMrid.getRevision()
            + ".delivered";

    String version = getProject().getProperty(versionProperty);
    String status = getProject().getProperty(statusProperty);
    String delivered = getProject().getProperty(deliveredProperty);
    Message.debug("found version = " + version + " status=" + status + " delivered="
            + delivered);
    if (version != null && status != null) {
        if ("true".equals(delivered)) {
            // delivery has already been done : just return the value
            return version;
        } else {
            deliverDependency(depMrid, version, status, depStatus);
            loadDeliveryList();
            return version;
        }
    }

    /**
     * By setting these properties: recursive.delivery.status and
     * recursive.delivery.version, then if the specific status/version is not found, then we
     * will use the status/version set in these global properties. This will apply to all
     * artifacts in the system. This patch is meant to be used for recursive deliveries so
     * that all deliveries will use the global status/version unless a more specific one is
     * set.
     */
    String globalStatusProperty = "recursive.delivery.status";
    String globalVersionProperty = "recursive.delivery.version";
    version = getProject().getProperty(globalVersionProperty);
    status = getProject().getProperty(globalStatusProperty);
    if (version != null && status != null) {
        // found global delivery properties
        delivered = getProject().getProperty(
            "recursive." + depMrid.getName() + ".delivered");
        Message.debug("found global version = " + version + " and global status=" + status
                + " - delivered = " + delivered);
        if ("true".equals(delivered)) {
            // delivery has already been done : just return the value
            return version;
        } else {
            getProject().setProperty(statusProperty, status);
            deliverDependency(depMrid, version, status, depStatus);
            loadDeliveryList();
            return version;
        }
    }

    // we must ask the user what version and status he want to have
    // for the dependency
    Input input = (Input) getProject().createTask("input");
    input.setOwningTarget(getOwningTarget());
    input.init();

    // ask status
    input.setMessage(depMrid.getName() + " " + depMrid.getRevision()
            + ": please enter a status: ");
    input.setValidargs(StatusManager.getCurrent().getDeliveryStatusListString());
    input.setAddproperty(statusProperty);
    input.perform();
    status = getProject().getProperty(statusProperty);
    appendDeliveryList(statusProperty + " = " + status);

    // ask version
    input.setMessage(depMrid.getName() + " " + depMrid.getRevision()
            + ": please enter a version: ");
    input.setValidargs(null);
    input.setAddproperty(versionProperty);
    input.perform();

    version = getProject().getProperty(versionProperty);
    appendDeliveryList(versionProperty + " = " + version);
    deliverDependency(depMrid, version, status, depStatus);

    loadDeliveryList();

    return version;
}
 
Example 15
Source File: DefaultDependencyMetaData.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public DefaultDependencyMetaData(DependencyDescriptor dependencyDescriptor) {
    this.dependencyDescriptor = dependencyDescriptor;
    ModuleRevisionId dependencyRevisionId = dependencyDescriptor.getDependencyRevisionId();
    requested = new DefaultModuleVersionSelector(dependencyRevisionId.getOrganisation(), dependencyRevisionId.getName(), dependencyRevisionId.getRevision());
}
 
Example 16
Source File: DefaultModuleVersionIdentifier.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public static ModuleVersionIdentifier newId(ModuleRevisionId moduleRevisionId) {
    return new DefaultModuleVersionIdentifier(moduleRevisionId.getOrganisation(), moduleRevisionId.getName(), moduleRevisionId.getRevision());
}
 
Example 17
Source File: DefaultDependencyMetaData.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public DefaultDependencyMetaData(DependencyDescriptor dependencyDescriptor) {
    this.dependencyDescriptor = dependencyDescriptor;
    ModuleRevisionId dependencyRevisionId = dependencyDescriptor.getDependencyRevisionId();
    requested = new DefaultModuleVersionSelector(dependencyRevisionId.getOrganisation(), dependencyRevisionId.getName(), dependencyRevisionId.getRevision());
}
 
Example 18
Source File: DefaultDependencyMetaData.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public DefaultDependencyMetaData(DependencyDescriptor dependencyDescriptor) {
    this.dependencyDescriptor = dependencyDescriptor;
    ModuleRevisionId dependencyRevisionId = dependencyDescriptor.getDependencyRevisionId();
    requested = new DefaultModuleVersionSelector(dependencyRevisionId.getOrganisation(), dependencyRevisionId.getName(), dependencyRevisionId.getRevision());
}
 
Example 19
Source File: DefaultModuleVersionIdentifier.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public static ModuleVersionIdentifier newId(ModuleRevisionId moduleRevisionId) {
    return new DefaultModuleVersionIdentifier(moduleRevisionId.getOrganisation(), moduleRevisionId.getName(), moduleRevisionId.getRevision());
}
 
Example 20
Source File: DefaultDependencyMetaData.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public DefaultDependencyMetaData(DependencyDescriptor dependencyDescriptor) {
    this.dependencyDescriptor = dependencyDescriptor;
    ModuleRevisionId dependencyRevisionId = dependencyDescriptor.getDependencyRevisionId();
    requested = new DefaultModuleVersionSelector(dependencyRevisionId.getOrganisation(), dependencyRevisionId.getName(), dependencyRevisionId.getRevision());
}