Search in sources :

Example 1 with DownloadException

use of org.apache.maven.archetype.downloader.DownloadException in project maven-archetype by apache.

the class DefaultArchetypeArtifactManager method getArchetypeFile.

public File getArchetypeFile(final String groupId, final String artifactId, final String version, ArtifactRepository archetypeRepository, final ArtifactRepository localRepository, final List<ArtifactRepository> repositories, ProjectBuildingRequest buildingRequest) throws UnknownArchetype {
    try {
        File archetype = getArchetype(groupId, artifactId, version);
        if (archetype == null) {
            archetype = downloader.download(groupId, artifactId, version, archetypeRepository, localRepository, repositories, buildingRequest);
            setArchetype(groupId, artifactId, version, archetype);
        }
        return archetype;
    } catch (DownloadNotFoundException ex) {
        throw new UnknownArchetype(ex);
    } catch (DownloadException ex) {
        throw new UnknownArchetype(ex);
    }
}
Also used : DownloadNotFoundException(org.apache.maven.archetype.downloader.DownloadNotFoundException) DownloadException(org.apache.maven.archetype.downloader.DownloadException) UnknownArchetype(org.apache.maven.archetype.exception.UnknownArchetype) ZipFile(java.util.zip.ZipFile) File(java.io.File)

Example 2 with DownloadException

use of org.apache.maven.archetype.downloader.DownloadException in project maven-archetype by apache.

the class DefaultArchetypeArtifactManager method exists.

public boolean exists(String archetypeGroupId, String archetypeArtifactId, String archetypeVersion, ArtifactRepository archetypeRepository, ArtifactRepository localRepository, List<ArtifactRepository> remoteRepositories, ProjectBuildingRequest buildingRequest) {
    try {
        File archetype = getArchetype(archetypeGroupId, archetypeArtifactId, archetypeVersion);
        if (archetype == null) {
            archetype = downloader.download(archetypeGroupId, archetypeArtifactId, archetypeVersion, archetypeRepository, localRepository, remoteRepositories, buildingRequest);
            setArchetype(archetypeGroupId, archetypeArtifactId, archetypeVersion, archetype);
        }
        return archetype.exists();
    } catch (DownloadException e) {
        getLogger().debug("Archetype " + archetypeGroupId + ":" + archetypeArtifactId + ":" + archetypeVersion + " doesn't exist", e);
        return false;
    } catch (DownloadNotFoundException e) {
        getLogger().debug("Archetype " + archetypeGroupId + ":" + archetypeArtifactId + ":" + archetypeVersion + " doesn't exist", e);
        return false;
    }
}
Also used : DownloadNotFoundException(org.apache.maven.archetype.downloader.DownloadNotFoundException) DownloadException(org.apache.maven.archetype.downloader.DownloadException) ZipFile(java.util.zip.ZipFile) File(java.io.File)

Aggregations

File (java.io.File)2 ZipFile (java.util.zip.ZipFile)2 DownloadException (org.apache.maven.archetype.downloader.DownloadException)2 DownloadNotFoundException (org.apache.maven.archetype.downloader.DownloadNotFoundException)2 UnknownArchetype (org.apache.maven.archetype.exception.UnknownArchetype)1