Search in sources :

Example 11 with ArtifactOrigin

use of org.apache.ivy.core.cache.ArtifactOrigin in project ant-ivy by apache.

the class PomModuleDescriptorBuilder method addMainArtifact.

public void addMainArtifact(String artifactId, String packaging) {
    String ext;
    /*
         * TODO: we should make packaging to ext mapping configurable, since it's not possible to
         * cover all cases.
         */
    if ("pom".equals(packaging)) {
        // no artifact defined! Add the default artifact if it exist.
        DependencyResolver resolver = parserSettings.getResolver(mrid);
        if (resolver != null) {
            DefaultArtifact artifact = new DefaultArtifact(mrid, new Date(), artifactId, "jar", "jar");
            ArtifactOrigin artifactOrigin = resolver.locate(artifact);
            if (!ArtifactOrigin.isUnknown(artifactOrigin)) {
                mainArtifact = artifact;
                ivyModuleDescriptor.addArtifact("master", mainArtifact);
            }
        }
        return;
    } else if (JAR_PACKAGINGS.contains(packaging)) {
        ext = "jar";
    } else if ("pear".equals(packaging)) {
        ext = "phar";
    } else {
        ext = packaging;
    }
    mainArtifact = new DefaultArtifact(mrid, new Date(), artifactId, packaging, ext);
    ivyModuleDescriptor.addArtifact("master", mainArtifact);
}
Also used : ArtifactOrigin(org.apache.ivy.core.cache.ArtifactOrigin) DefaultArtifact(org.apache.ivy.core.module.descriptor.DefaultArtifact) Date(java.util.Date) DependencyResolver(org.apache.ivy.plugins.resolver.DependencyResolver)

Aggregations

ArtifactOrigin (org.apache.ivy.core.cache.ArtifactOrigin)11 ArtifactDownloadReport (org.apache.ivy.core.report.ArtifactDownloadReport)6 File (java.io.File)5 Artifact (org.apache.ivy.core.module.descriptor.Artifact)4 DefaultArtifact (org.apache.ivy.core.module.descriptor.DefaultArtifact)3 ResolvedResource (org.apache.ivy.plugins.resolver.util.ResolvedResource)3 JarFile (java.util.jar.JarFile)2 ConfigurationResolveReport (org.apache.ivy.core.report.ConfigurationResolveReport)2 MetadataArtifactDownloadReport (org.apache.ivy.core.report.MetadataArtifactDownloadReport)2 ResolveReport (org.apache.ivy.core.report.ResolveReport)2 DependencyResolver (org.apache.ivy.plugins.resolver.DependencyResolver)2 Test (org.junit.Test)2 IOException (java.io.IOException)1 URI (java.net.URI)1 URISyntaxException (java.net.URISyntaxException)1 ParseException (java.text.ParseException)1 Date (java.util.Date)1 CacheResourceOptions (org.apache.ivy.core.cache.CacheResourceOptions)1 DefaultRepositoryCacheManager (org.apache.ivy.core.cache.DefaultRepositoryCacheManager)1 DownloadListener (org.apache.ivy.core.cache.DownloadListener)1