Search in sources :

Example 1 with UnknownArchetype

use of org.apache.maven.archetype.exception.UnknownArchetype 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 UnknownArchetype

use of org.apache.maven.archetype.exception.UnknownArchetype in project maven-archetype by apache.

the class DefaultArchetypeArtifactManager method isOldArchetype.

public boolean isOldArchetype(File archetypeFile) {
    ZipFile zipFile = null;
    try {
        getLogger().debug("checking old archetype status on " + archetypeFile);
        zipFile = getArchetypeZipFile(archetypeFile);
        return isOldArchetype(zipFile);
    } catch (IOException e) {
        getLogger().debug(e.toString());
        return false;
    } catch (UnknownArchetype e) {
        getLogger().debug(e.toString());
        return false;
    } finally {
        if (zipFile != null) {
            closeZipFile(zipFile);
        }
    }
}
Also used : ZipFile(java.util.zip.ZipFile) UnknownArchetype(org.apache.maven.archetype.exception.UnknownArchetype) IOException(java.io.IOException)

Example 3 with UnknownArchetype

use of org.apache.maven.archetype.exception.UnknownArchetype in project maven-archetype by apache.

the class DefaultArchetypeArtifactManager method getArchetypeJarLoader.

public ClassLoader getArchetypeJarLoader(File archetypeFile) throws UnknownArchetype {
    try {
        URL[] urls = new URL[1];
        urls[0] = archetypeFile.toURI().toURL();
        return new URLClassLoader(urls);
    } catch (MalformedURLException e) {
        throw new UnknownArchetype(e);
    }
}
Also used : MalformedURLException(java.net.MalformedURLException) URLClassLoader(java.net.URLClassLoader) UnknownArchetype(org.apache.maven.archetype.exception.UnknownArchetype) URL(java.net.URL)

Example 4 with UnknownArchetype

use of org.apache.maven.archetype.exception.UnknownArchetype in project maven-archetype by apache.

the class DefaultArchetypeArtifactManager method isFileSetArchetype.

public boolean isFileSetArchetype(File archetypeFile) {
    ZipFile zipFile = null;
    try {
        getLogger().debug("checking fileset archetype status on " + archetypeFile);
        zipFile = getArchetypeZipFile(archetypeFile);
        return isFileSetArchetype(zipFile);
    } catch (IOException e) {
        getLogger().debug(e.toString());
        return false;
    } catch (UnknownArchetype e) {
        getLogger().debug(e.toString());
        return false;
    } finally {
        if (zipFile != null) {
            closeZipFile(zipFile);
        }
    }
}
Also used : ZipFile(java.util.zip.ZipFile) UnknownArchetype(org.apache.maven.archetype.exception.UnknownArchetype) IOException(java.io.IOException)

Example 5 with UnknownArchetype

use of org.apache.maven.archetype.exception.UnknownArchetype in project maven-archetype by apache.

the class DefaultArchetypeArtifactManager method getPostGenerationScript.

public String getPostGenerationScript(File archetypeFile) throws UnknownArchetype {
    ZipFile zipFile = null;
    try {
        zipFile = getArchetypeZipFile(archetypeFile);
        Reader reader = getDescriptorReader(zipFile, Constants.ARCHETYPE_POST_GENERATION_SCRIPT);
        return reader == null ? null : IOUtils.toString(reader);
    } catch (IOException e) {
        throw new UnknownArchetype(e);
    } finally {
        closeZipFile(zipFile);
    }
}
Also used : ZipFile(java.util.zip.ZipFile) UnknownArchetype(org.apache.maven.archetype.exception.UnknownArchetype) ArchetypeDescriptorXpp3Reader(org.apache.maven.archetype.metadata.io.xpp3.ArchetypeDescriptorXpp3Reader) Reader(java.io.Reader) IOException(java.io.IOException)

Aggregations

UnknownArchetype (org.apache.maven.archetype.exception.UnknownArchetype)12 IOException (java.io.IOException)5 Archetype (org.apache.maven.archetype.catalog.Archetype)5 File (java.io.File)4 ZipFile (java.util.zip.ZipFile)4 ArchetypeDefinition (org.apache.maven.archetype.ui.ArchetypeDefinition)3 ArtifactRepository (org.apache.maven.artifact.repository.ArtifactRepository)3 ArrayList (java.util.ArrayList)2 Properties (java.util.Properties)2 ArchetypeGenerationRequest (org.apache.maven.archetype.ArchetypeGenerationRequest)2 ArchetypeNotDefined (org.apache.maven.archetype.exception.ArchetypeNotDefined)2 MavenArtifactRepository (org.apache.maven.artifact.repository.MavenArtifactRepository)2 MockControl (org.easymock.MockControl)2 IPortletFramework (com.liferay.ide.project.core.IPortletFramework)1 NewLiferayProfile (com.liferay.ide.project.core.model.NewLiferayProfile)1 PluginType (com.liferay.ide.project.core.model.PluginType)1 ProjectName (com.liferay.ide.project.core.model.ProjectName)1 Reader (java.io.Reader)1 MalformedURLException (java.net.MalformedURLException)1 URL (java.net.URL)1