Create a new artifact.

@param item  The item to create an artifact for
@return      A resolved artifact for the given item.

@throws MojoExecutionException   Failed to create artifact
487669
@Override
    protected Artifact createArtifact(final ArtifactItem item) throws MojoExecutionException {
        assert item != null;
        
        if (item.getVersion() == null) {
            throw new MojoExecutionException("Unable to find artifact without version specified: " + item.getGroupId()
                + ":" + item.getArtifactId() + ":" + item.getVersion() + " in either project dependencies or in project dependencyManagement.");
        }
        
        // if version is a range get the highest available version
        if (item.getVersion().trim().startsWith("[") || item.getVersion().trim().startsWith("(") ) {
            try {
                item.setVersion(resolveVersionRange(item.getGroupId(), item.getArtifactId(), item.getType(), item.getVersion()));
            } catch (VersionRangeResolutionException e) {
                throw new MojoExecutionException("Could not get the highest version from the range: " + item.getVersion(), e);
            }
        }
        
        return resolveArtifactItem(item);
    }
677124
public ESigItem add(ESigItem item) {
        if (!items.contains(item)) {
            items.add(item);
            fireEvent("ADD", item);
        }
        
        return item;
    }
1255183
protected InputStream initInput(final File file)
        throws MojoExecutionException {
        InputStream stream = null;
        try {
            if (file.isDirectory()) {
                throw new MojoExecutionException("File "
                    + file.getAbsolutePath()
                    + " is directory!");
            }
            if (!file.exists()) {
                throw new MojoExecutionException("File "
                    + file.getAbsolutePath()
                    + " does not exist!");
            }
            stream = new FileInputStream(file);
            //append to outfile here
        } catch (FileNotFoundException e) {
            throw new MojoExecutionException("Could not find file: "
                + file.getAbsolutePath(), e);
        }
        return stream;
    }
638390
public void execute() throws MojoExecutionException, MojoFailureException {
        try {
            final List<String> command = createCommand();
            checkWorkingDirectory();
            final int status = execute(command);
            if (failOnAnsibleError && status != 0){
                throw new MojoFailureException("Non-zero exit status returned");
            }
        } catch (IOException e) {
            throw new MojoExecutionException("Unable to run playbook", e);
        } catch (InterruptedException e) {
            throw new MojoExecutionException("Run interrupted", e);
        }
    }
1011577
public void execute() throws MojoFailureException, MojoExecutionException {
        // Validate
        validateArtifactInformation();

        Artifact artifact =
                artifactFactory.createArtifactWithClassifier( groupId, artifactId, version, packaging, classifier );

        File existingFile = getLocalRepoFile(artifact);
        if (existingFile != null && existingFile.exists()) {
            System.out.println("Using cached remapped artifact "+ existingFile.getPath()); // delete file to reinstall
            return; // success
        }

        // Remap
        File outJar = null;
        try {
            // load input jar(s), as one combined jar (for jarmods)
            List<File> files = new ArrayList<File>();
            for (String filename : inJars) {
                files.add(FileLocator.getFile(filename));
            }
            Jar inJar = Jar.init(files);

            // temporary output file
            outJar = File.createTempFile(groupId + "." + artifactId + "-" + version, "." + packaging);

            // mappings
            JarMapping mapping = new JarMapping();
            if (excludedPackages != null) {
                for (String packageName : excludedPackages) {
                    mapping.addExcludedPackage(packageName);
                }
            }
            mapping.loadMappings(srgIn, reverse, numeric, inShadeRelocation, outShadeRelocation);
            mapping.setFallbackInheritanceProvider(new JarProvider(inJar));


            // access transformers
            RemapperProcessor preprocessor = null;
            if (accessTransformers != null) {
                AccessMap accessMap = new AccessMap();

                for (String filename : accessTransformers) {
                    if (filename != null && filename.length() != 0) {
                        accessMap.loadAccessTransformer(filename);
                    }
                }

                preprocessor = new RemapperProcessor(null, null, accessMap);
            }

            // Do the remap
            JarRemapper remapper = new JarRemapper(preprocessor, mapping);
            remapper.setGenerateAPI(generateAPI);
            remapper.remapJar(inJar, outJar);
        } catch (Exception ex) {
            ex.printStackTrace();
            throw new MojoExecutionException("Error creating remapped jar at "+outJar+": " + ex.getMessage(), ex);
        }

        // Replace main artifact with this remapped artifact
        if (replaceMainArtifact) {
            getLog().info("Replacing original artifact with remapped artifact.");
            File originalArtifact = project.getArtifact().getFile();
            originalArtifact.delete();
            if (!outJar.renameTo(originalArtifact)) {
                throw new MojoExecutionException("Error replacing remapped jar at "+originalArtifact+" with "+outJar);
            }
        }

        // Attach output artifact to this project
        if (attachArtifact) {
            if (attachArtifactClassifier == null || attachArtifactClassifier.equals("")) {
                attachArtifactClassifier = null;
            }

            getLog().info("Attaching artifact " + outJar.getPath());
            projectHelper.attachArtifact(project, attachArtifactType, attachArtifactClassifier, outJar);
        }

        // Install output artifact to local repository
        if (installArtifact) {
            installArtifact(artifact, outJar);
        }
    }
526767
public void execute()
            throws MojoExecutionException {
        if (extensions == null || extensions.isEmpty()) {
            extensions = ImmutableList.of("md", "markdown");
        }

        if (instance == null) {
            instance = new PegDownProcessor(Extensions.ALL);
        }

        try {
            for (File f : getResources(extensions)) {
                process(f);
            }
        } catch (IOException e) {
            throw new MojoExecutionException("Error while processing a Markdown file", e);
        }

    }
1035131
public void execute() throws MojoExecutionException {
        
        if (jar == null || !jar.exists()) {
            if (gavExists()) { // attempt to resolve jar from GAV
                DefaultArtifactResolver resolver = new DefaultArtifactResolver();
                ArtifactResolutionResult result = resolver.resolve(new ArtifactResolutionRequest()
                    .setArtifact(new DefaultArtifact(groupId, artifactId, version, null, "jar", null, 
                        new DefaultArtifactHandler("jar")))
                );
                
                if (result.isSuccess()) {
                    jar = result.getArtifacts().iterator().next().getFile();
                } else {
                    String message = "Jar file '" + jar.getPath() + "' not specified and "
                        + "GAV coordinates could not be resolved";
                    getLog().error(message);
                    throw new MojoExecutionException(message);                    
                }
            } else {
                String message = "Jar file '" + jar.getPath() + "' does not exixt and "
                    + "GAV coordinates not specified";
                getLog().error(message);
                throw new MojoExecutionException(message);
            }
        }
        
        try {
            repositoryPath = findRepoPath(this.ceylonRepository);
            ArtifactRepositoryLayout layout = new CeylonRepoLayout();
            getLog().debug("Layout: " + layout.getClass());

            localRepository =
                new DefaultArtifactRepository(ceylonRepository, repositoryPath.toURI().toURL().toString(), layout);
            getLog().debug("Repository: " +  localRepository);
        } catch (MalformedURLException e) {
            throw new MojoExecutionException("MalformedURLException: " + e.getMessage(), e);
        }
        
        if (pomFile != null) { // explicitly specified
           processModel(readModel(pomFile));
        } else if (new File(jar.getParentFile(), "pom.xml").exists()) { // pom.xml in the same directory
            processModel(readModel(new File(jar.getParentFile(), "pom.xml"))); 
        } else {
            boolean foundPom = false;

            try {
                Pattern pomEntry = Pattern.compile("META-INF/maven/.*/pom\\.xml");

                JarFile jarFile = new JarFile(jar);

                Enumeration<JarEntry> jarEntries = jarFile.entries();

                while (jarEntries.hasMoreElements()) {
                    JarEntry entry = jarEntries.nextElement();

                    if (pomEntry.matcher(entry.getName()).matches()) {
                        getLog().debug("Using " + entry.getName() + " for groupId, artifactId, packaging and version");
                        foundPom = true;
                        InputStream pomInputStream = null;

                        try {
                            pomInputStream = jarFile.getInputStream(entry);
                            processModel(readModel(pomInputStream));
                            break;
                        } finally {
                            if (pomInputStream != null) {
                                pomInputStream.close();
                            } 
                            if (jarFile != null) {
                                jarFile.close();
                            }                            
                        }
                    }
                }

                if (!foundPom) {
                    getLog().info("pom.xml not found in " + jar.getName());
                }
            } catch (IOException e) {
                getLog().warn("This jar file was not packaged by Maven");
            }
        }
        // if packaging is set, check it
        if (packaging != null & !"jar".equals(packaging)) {
            throw new MojoExecutionException("POM packaging is not 'jar' ");
        }
        
        if (!jar.getName().endsWith(".jar")) {
            throw new MojoExecutionException("Jar File extension must be 'jar'  ");
        }
    
        if (groupId == null || "".equals(groupId)) {
            throw new MojoExecutionException("Group Id is empty  ");
        }
  
        if (artifactId == null || "".equals(artifactId)) {
            throw new MojoExecutionException("Artifact Id is empty  ");
        }
 
        if (version == null || "".equals(version)) {
            throw new MojoExecutionException("Version is empty  ");
        }
        
        installJar(jar);
    }
1032988
@SuppressWarnings("unchecked")
    private <T extends ItemInfoImpl> T getOrCreateInfo(final ConfigItem type, final Object item) {
        final Class<?> itemType = getType(item);
        final T info;
        // details holder allows to implicitly filter by type and avoid duplicate registration
        if (detailsHolder.containsKey(itemType)) {
            // no duplicate registration
            info = (T) detailsHolder.get(itemType);
        } else {
            itemsHolder.put(type, item);
            info = type.newContainer(itemType);
            detailsHolder.put(itemType, info);
        }
        return info;
    }
969709
function create(item, store) {
      var data = store.rootData.asObject();
      // New item has id
      if (item[store.idProperty]) {
        // Check item duplicated
        if (!data[item[store.idProperty]]) {
          // Create item
          data[item[store.idProperty]] = item;
        } else {
          // Item already exists
          return vcomet.error.log(
            "store",
            "Item with id " + item[store.idProperty] + " already exists"
          );
        }
      } else {
        // Add id value to item
        item[store.idProperty] = Object.keys(data).length.toString();
        // Create item
        data[item[store.idProperty]] = item;
      }
      if (item[store.idProperty]) {
        // Update store data
        store.rootData = store.data = new Result(data, store, store.data.__sorted);
        // Update store data items length
        store.size = Object.keys(store.data).length;
        // Trigger onSourceChanged event
        vcomet.triggerCallback("onSourceChanged", store);
        return item;
      } else {
        return vcomet.error.log("store", "Incorrect item format");
      }
    }
163197
public void addItem(T item) {
        mListItems.add(item);
        notifyItemInserted(mListItems.indexOf(item));
    }
242011
private Artifact getArtifactFromMavenCoordinates(final String artifact) throws MojoFailureException {

    String[] parts = StringUtils.split(artifact, ":");

    String version;
    String packaging = null;
    String classifier = null;

    switch (parts.length) {
      case 3:
        // groupId:artifactId:version
        version = parts[2];
        break;

      case 4:
        // groupId:artifactId:packaging:version
        packaging = parts[2];
        version = parts[3];
        break;

      case 5:
        // groupId:artifactId:packaging:classifier:version
        packaging = parts[2];
        classifier = parts[3];
        version = parts[4];
        break;

      default:
        throw new MojoFailureException("Invalid artifact: " + artifact);
    }

    String groupId = parts[0];
    String artifactId = parts[1];

    return createArtifact(artifactId, groupId, version, packaging, classifier);
  }
1003317
public void setItem(java.util.Collection<ImportJobResponse> item) {
        if (item == null) {
            this.item = null;
            return;
        }

        this.item = new java.util.ArrayList<ImportJobResponse>(item);
    }
1032738
Artifact createArtifact(ArtifactFactory artifactFactory) {
    if (groupId == null || artifactId == null || version == null || type == null) {
      throw new NullPointerException("signaturesArtifact is missing some properties. Required are: groupId, artifactId, version, type");
    }
    return artifactFactory.createArtifactWithClassifier(groupId, artifactId, version, type, classifier);
  }
344643
void createTotalSpecifications(final File dir, final String packageDirectory) throws MojoExecutionException {

        if (dir.equals(null)) {
            throw new MojoExecutionException("Could not read from directory " + dir.getPath());
        }
        final File[] files = dir.listFiles();
        if (files == null) {
            return;
        }
        final File[] providedContextFiles = dir.listFiles((java.io.FileFilter) FileFilterUtils.andFileFilter(FileFilterUtils.fileFileFilter(), FileFilterUtils.nameFileFilter("providedcontext.json")));
        if (providedContextFiles.length == 1) {
            final File parent = providedContextFiles[0].getParentFile();
            final File outputDir = new File(getSpecificationOutput() + File.separator + packageDirectory.substring(0,packageDirectory.lastIndexOf(File.separator)));
            outputDir.mkdirs();
            try {
                generateTotalSpecification(parent, outputDir);
            } catch (final CodeGenException e) {
                throw new MojoExecutionException("Couldn't create total specification",e);
            }
        }
        for (File entry : dir.listFiles()) {
            if (entry.isDirectory()) {
                createTotalSpecifications(entry, (packageDirectory == null) ? entry.getName() : packageDirectory + File.separator + entry.getName());
            }
        }
    }
280799
@Override
    public void execute()
            throws MojoExecutionException
    {

        boolean withExtensions = CollectionUtils.isNotEmpty( jnlpExtensions );

        if ( withExtensions )
        {
            prepareExtensions();
            findDefaultJnlpExtensionTemplateURL();
        }

        checkInput();

        getLog().debug( "using work directory " + getWorkDirectory() );
        getLog().debug( "using library directory " + getLibDirectory() );

        IOUtil ioUtil = getIoUtil();

        // ---
        // prepare layout
        // ---

        ioUtil.makeDirectoryIfNecessary( getWorkDirectory() );
        ioUtil.makeDirectoryIfNecessary( getLibDirectory() );

        try
        {
            ioUtil.copyResources( getResourcesDirectory(), getWorkDirectory() );

            artifactWithMainClass = null;

            processDependencies();

            if ( jnlp.isRequireMainClass() && artifactWithMainClass == null )
            {
                throw new MojoExecutionException(
                        "didn't find artifact with main class: " + jnlp.getMainClass() + ". Did you specify it? " );
            }

            if ( withExtensions )
            {
                processExtensionsDependencies();
            }

            // ---
            // Process native libs (FIXME)
            // ---

            processNativeLibs();

            if ( ( isPack200() || getSign() != null ) && getLog().isDebugEnabled() )
            {
                logCollection(
                        "Some dependencies may be skipped. Here's the list of the artifacts that should be signed/packed: ",
                        getModifiedJnlpArtifacts() );
            }

            // ---
            // Process collected jars
            // ---

            signOrRenameJars();

            // ---
            // Generate jnlp file
            // ---

            generateJnlpFile( getWorkDirectory() );

            // ---
            // Generate jnlp extension files
            // ---

            if ( withExtensions )
            {
                generateJnlpExtensionsFile( getWorkDirectory() );
            }

            // ---
            // Generate archive file if required
            // ---

            if ( makeArchive )
            {
                // package the zip. Note this is very simple. Look at the JarMojo which does more things.
                // we should perhaps package as a war when inside a project with war packaging ?

                ioUtil.makeDirectoryIfNecessary( archive.getParentFile() );

                ioUtil.deleteFile( archive );

                verboseLog( "Will create archive at location: " + archive );

                ioUtil.createArchive( getWorkDirectory(), archive );

                if ( attachArchive )
                {
                    // maven 2 version 2.0.1 method
                    projectHelper.attachArtifact( getProject(), "zip", archive );
                }
            }
        }
        catch ( MojoExecutionException e )
        {
            throw e;
        }
        catch ( Exception e )
        {
            throw new MojoExecutionException( "Failure to run the plugin: ", e );
        }
    }
525958
@Override
    protected MavenFormatStage createFormatStage(final Collection<MavenResolvedArtifact> filteredArtifacts)
            throws IllegalArgumentException {
        assert filteredArtifacts != null : "filtered artifacts are required";
        return new MavenFormatStageImpl(filteredArtifacts);
    }
548133
public void execute() throws MojoExecutionException, MojoFailureException {
        getLog().info("Downloading fabric8 maven artifacts to local repository: " + localRepositoryDirectory);

        File repo = init();

        // find the fabric8 artifact
        Artifact artifact = findFabric8Archetype(project);

        if (artifact != null) {
            ArchetypeCatalog catalog;
            try {
                catalog = FabricArchetypeCatalogFactory.getArchetypeCatalog(artifact);
            } catch (Exception e) {
                getLog().warn("Error downloading archetype catalog due " + e.getMessage(), e);
                return;
            }

            if (catalog != null) {
                getLog().info("Catalog contains " + catalog.getArchetypes().size() + " archetypes");

                for (Archetype a : catalog.getArchetypes()) {
                    try {
                        download(repo, a);
                    } catch (Exception e) {
                        getLog().warn("Error downloading " + a + " due " + e.getMessage(), e);
                    }
                }
            }
        }

        getLog().info("Download complete");
    }