Package org.apache.maven.artifact

Examples of org.apache.maven.artifact.Artifact


                    if(!runModeMatches(bundle, runMode)) {
                        continue;
                    }
                    final ArtifactDefinition d = new ArtifactDefinition(bundle, startLevel);
                    try {
                        final Artifact artifact = getArtifact(d);
                        bundles.add(artifact.getFile().toURI().toURL().toExternalForm());
                    } catch (Exception e) {
                        getLog().error("Unable to resolve artifact ", e);
                    }
                }
            }
View Full Code Here


     * @return the artifact, which has been resolved.
     * @throws MojoExecutionException
     */
    protected Artifact getArtifact(String groupId, String artifactId, String version, String type, String classifier)
            throws MojoExecutionException {
                Artifact artifact;
                VersionRange vr;

                try {
                    vr = VersionRange.createFromVersionSpec(version);
                } catch (InvalidVersionSpecificationException e) {
                    vr = VersionRange.createFromVersion(version);
                }

                if (StringUtils.isEmpty(classifier)) {
                    artifact = factory.createDependencyArtifact(groupId, artifactId, vr, type, null, Artifact.SCOPE_COMPILE);
                } else {
                    artifact = factory.createDependencyArtifact(groupId, artifactId, vr, type, classifier,
                            Artifact.SCOPE_COMPILE);
                }

                // This code kicks in when the version specifier is a range.
                if (vr.getRecommendedVersion() == null) {
                    try {
                        List<ArtifactVersion> availVersions = metadataSource.retrieveAvailableVersions(artifact, local, remoteRepos);
                        ArtifactVersion resolvedVersion = vr.matchVersion(availVersions);
                        artifact.setVersion(resolvedVersion.toString());
                    } catch (ArtifactMetadataRetrievalException e) {
                        throw new MojoExecutionException("Unable to find version for artifact", e);
                    }

                }
View Full Code Here

            DependencyResolutionRequiredException {
        List artifacts = project.getCompileArtifacts();
        URL[] path = new URL[artifacts.size() + 1];
        int i = 0;
        for (Iterator ai=artifacts.iterator(); ai.hasNext(); ) {
            Artifact a = (Artifact) ai.next();
            path[i++] = a.getFile().toURI().toURL();
        }
        final String targetDirectory = project.getBuild().getOutputDirectory();
        path[path.length - 1] = new File(targetDirectory).toURI().toURL();
        loader = new URLClassLoader(path, this.getClass().getClassLoader());
    }
View Full Code Here

        if (BundleListUtils.isCurrentArtifact(project, defaultBundleList)) {
            initializedBundleList = readBundleList(bundleListFile);
        } else {
            initializedBundleList = new BundleList();
            if (includeDefaultBundles) {
                Artifact defBndListArtifact = getArtifact(defaultBundleList.getGroupId(),
                        defaultBundleList.getArtifactId(), defaultBundleList.getVersion(), defaultBundleList.getType(),
                        defaultBundleList.getClassifier());
                getLog().info("Using bundle list file from " + defBndListArtifact.getFile().getAbsolutePath());
                initializedBundleList = readBundleList(defBndListArtifact.getFile());
            }

            if (bundleListFile.exists()) {
                initializedBundleList.merge(readBundleList(bundleListFile));
            }
View Full Code Here

        }
    }

    private void extractConfiguration(final Artifact artifact) throws MojoExecutionException, IOException {
        // check for configuration artifact
        Artifact cfgArtifact = null;
        try {
            cfgArtifact = getArtifact(artifact.getGroupId(),
                    artifact.getArtifactId(),
                    artifact.getVersion(),
                    AttachPartialBundleListMojo.CONFIG_TYPE,
                    AttachPartialBundleListMojo.CONFIG_CLASSIFIER);
        } catch (final MojoExecutionException ignore) {
            // we just ignore this
        }
        if ( cfgArtifact != null ) {
            getLog().info(
                    String.format("Merging settings from partial bundle list %s:%s:%s", cfgArtifact.getGroupId(),
                            cfgArtifact.getArtifactId(), cfgArtifact.getVersion()));

            // extract
            zipUnarchiver.setSourceFile(cfgArtifact.getFile());
            try {
                this.tmpOutputDir.mkdirs();
                zipUnarchiver.setDestDirectory(this.tmpOutputDir);
                zipUnarchiver.extract();
View Full Code Here

                return configDirectory;
            }

            @Override
            Artifact getArtifact(ArtifactDefinition def) throws MojoExecutionException {
                final Artifact a = Mockito.mock(Artifact.class);
                final String fakeName = new StringBuilder()
                .append("/FAKE_BUNDLE/")
                .append(def.getArtifactId())
                .append("/")
                .append(def.getStartLevel())
                .append("/")
                .append(def.getRunModes())
                .toString();
                Mockito.when(a.getFile()).thenReturn(new File(fakeName));
                return a;
            }

            @Override
            Log getLog() {
View Full Code Here

        };
        ArchiverManager archiveManager = mock(ArchiverManager.class);
        MavenProject project = mock(MavenProject.class);

        File coreFile = new File("core");
        Artifact coreResources = mock(Artifact.class);
        when(coreResources.getArtifactId()).thenReturn("jbehave-core");
        when(coreResources.getType()).thenReturn("zip");
        when(coreResources.getFile()).thenReturn(coreFile);
        File siteFile = new File("site");
        Artifact siteResources = mock(Artifact.class);
        when(siteResources.getArtifactId()).thenReturn("jbehave-site-resources");
        when(siteResources.getType()).thenReturn("zip");
        when(siteResources.getFile()).thenReturn(siteFile);

        Set<Artifact> allArtifacts = new HashSet<Artifact>();
        allArtifacts.add(coreResources);
        allArtifacts.add(siteResources);
View Full Code Here

        };
        ArchiverManager archiveManager = mock(ArchiverManager.class);
        MavenProject project = mock(MavenProject.class);

        File resourcesFile = new File("some");
        Artifact someResources = mock(Artifact.class);
        when(someResources.getArtifactId()).thenReturn("some-resources");
        when(someResources.getType()).thenReturn("jar");
        when(someResources.getFile()).thenReturn(resourcesFile);

        Set<Artifact> allArtifacts = new HashSet<Artifact>();
        allArtifacts.add(someResources);

        String buildDirectory = "target";
View Full Code Here

        };
        ArchiverManager archiveManager = mock(ArchiverManager.class);
        MavenProject project = mock(MavenProject.class);

        File coreFile = new File("core");
        Artifact coreResources = mock(Artifact.class);
        when(coreResources.getArtifactId()).thenReturn("jbehave-core");
        when(coreResources.getType()).thenReturn("zip");
        when(coreResources.getFile()).thenReturn(coreFile);
        File siteFile = new File("site");
        Artifact siteResources = mock(Artifact.class);
        when(siteResources.getArtifactId()).thenReturn("jbehave-site-resources");
        when(siteResources.getType()).thenReturn("zip");
        when(siteResources.getFile()).thenReturn(siteFile);

        Set<Artifact> allArtifacts = new HashSet<Artifact>();
        allArtifacts.add(coreResources);
        allArtifacts.add(siteResources);
View Full Code Here

    private Set<Artifact> resourceArtifacts() {
        Set<Artifact> artifacts = allArtifacts();
        CollectionUtils.filter(artifacts, new Predicate() {
            public boolean evaluate(Object object) {
                Artifact artifact = (Artifact) object;
                return allowedBy("artifactId", artifact.getArtifactId(), resourceArtifactIds)
                        && allowedBy("type", artifact.getType(), resourceTypes);
            }
        });
        return artifacts;
    }
View Full Code Here

TOP

Related Classes of org.apache.maven.artifact.Artifact

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.