Search in sources :

Example 1 with ArchetypeGenerateCommand

use of org.kie.workbench.common.screens.archetype.mgmt.backend.maven.ArchetypeGenerateCommand in project kie-wb-common by kiegroup.

the class ArchetypeServiceImpl method add.

@Override
public void add(final GAV archetypeGav, final GAV templateGav) {
    checkNotNull("archetypeGav", archetypeGav);
    checkNotNull("templateGav", templateGav);
    appendTemplateSuffix(templateGav);
    checkArchetypeAlreadyAdded(templateGav);
    final Path workingDirectoryPath = createTempDirectory(templateGav.getArtifactId());
    final File workingDirectory = new File(workingDirectoryPath.toString());
    final FileSystemLock physicalLock = createLock(workingDirectory);
    try {
        physicalLock.lock();
        executeMaven(new ArchetypeGenerateCommand(workingDirectoryPath.toString(), archetypeGav, templateGav));
        checkModuleValid(workingDirectoryPath.resolve(templateGav.getArtifactId()));
        finishAddExternalArchetype(templateGav, workingDirectory);
    } catch (GitAPIException | MavenEmbedderException e) {
        LOGGER.error(String.format("Failed to add the archetype %s", templateGav), e);
    } finally {
        physicalLock.unlock();
    }
}
Also used : Path(org.uberfire.java.nio.file.Path) GitAPIException(org.eclipse.jgit.api.errors.GitAPIException) FileSystemLock(org.uberfire.java.nio.fs.jgit.FileSystemLock) MavenEmbedderException(org.appformer.maven.integration.embedder.MavenEmbedderException) ArchetypeGenerateCommand(org.kie.workbench.common.screens.archetype.mgmt.backend.maven.ArchetypeGenerateCommand) File(java.io.File)

Aggregations

File (java.io.File)1 MavenEmbedderException (org.appformer.maven.integration.embedder.MavenEmbedderException)1 GitAPIException (org.eclipse.jgit.api.errors.GitAPIException)1 ArchetypeGenerateCommand (org.kie.workbench.common.screens.archetype.mgmt.backend.maven.ArchetypeGenerateCommand)1 Path (org.uberfire.java.nio.file.Path)1 FileSystemLock (org.uberfire.java.nio.fs.jgit.FileSystemLock)1