Package org.apache.maven.repository

Examples of org.apache.maven.repository.Artifact


            throw new RuntimeException("No target directory supplied");
        }
        ServiceDocument serviceDocument = ServiceDocument.Factory.newInstance();
        ServiceType serviceType = serviceDocument.addNewService();
        for (Iterator iterator = artifacts.iterator(); iterator.hasNext();) {
            Artifact artifact = (Artifact) iterator.next();
            Dependency dependency = artifact.getDependency();
            if ("true".equals(dependency.getProperty(DEPENDENCY_PROPERTY))) {
                String groupId = dependency.getGroupId();
                String artifactId = dependency.getArtifactId();
                String type = dependency.getType();
                org.apache.geronimo.deployment.xbeans.ArtifactType dependencyType = serviceType.addNewDependency();
View Full Code Here


    public void setArtifacts(List artifacts) {
        this.artifacts = artifacts;
        TreeMap tree = new TreeMap();
        for (Iterator iterator = artifacts.iterator(); iterator.hasNext();) {
            Artifact artifact = (Artifact) iterator.next();
            Dependency dependency = artifact.getDependency();
            if (dependency.getProperty(PACKAGING_CONFIG_PROPERTY) != null) {
                String orderString = dependency.getProperty(PACKAGING_CONFIG_PROPERTY);
                try {
                    Integer order = Integer.decode(orderString);
                    String artifactString = dependency.getGroupId() + "/" + dependency.getArtifactId() + "/" + dependency.getVersion() + "/" + dependency.getType();
View Full Code Here

    private Object getPackageBuilder() throws ClassNotFoundException, IllegalAccessException, InstantiationException, MalformedURLException {
        if (classLoader == null) {
            String repo = context.getMavenRepoLocal();
            List urls = new ArrayList();
            for (Iterator iterator = pluginArtifacts.iterator(); iterator.hasNext();) {
                Artifact artifact = (Artifact) iterator.next();
                Dependency dependency = artifact.getDependency();
                if ("true".equals(dependency.getProperty(PACKAGING_CLASSPATH_PROPERTY))) {
                    String urlString = artifact.getUrlPath();
                    URL url = new File(repo + urlString).toURL();
                    urls.add(url);
                }
            }

            boolean found = false;
            for (Iterator iterator = artifacts.iterator(); iterator.hasNext();) {
                Artifact artifact = (Artifact) iterator.next();
                Dependency dependency = artifact.getDependency();
                if ("geronimo".equals(dependency.getGroupId())
                && "geronimo-packaging-plugin".equals(dependency.getArtifactId())
                && "plugin".equals(dependency.getType())) {
                    String urlString = artifact.getUrlPath();
                    URL url = new File(repo + urlString).toURL();
                    urls.add(url);
                    found = true;
                }
            }
View Full Code Here

    }

    private LinkedHashSet toDependencies() {
        LinkedHashSet dependencies = new LinkedHashSet();
        for (Iterator iterator = artifacts.iterator(); iterator.hasNext();) {
            Artifact artifact = (Artifact) iterator.next();
            Dependency dependency = artifact.getDependency();
            org.apache.geronimo.kernel.repository.Dependency geronimoDependency = toGeronimoDependency(dependency);
            if (geronimoDependency != null) {
                dependencies.add(geronimoDependency);
            }
        }
View Full Code Here

        for ( Iterator i = project.getDependencies().iterator(); i.hasNext(); )
        {
            Dependency d = (Dependency) i.next();
            String mavenJarProperty = project.getContext()
                .getMavenJarOverride( Project.standardToLegacyId( d.getId() ) );
            Artifact artifact = DefaultArtifactFactory.createArtifact( d );

            if ( mavenJarOverride && StringUtils.isNotEmpty( mavenJarProperty ) )
            {
                // The jar override option has been set and we have a property
                // for the this dependency so override the path with the user
                // specified value.
                if ( Character.isDigit( mavenJarProperty.charAt( 0 ) ) || "SNAPSHOT".equals( mavenJarProperty ) )
                {
                    // User is requesting a specific version of a dependency
                    // be used.
                    d.setVersion( mavenJarProperty );
                    artifact.setPath( project.getContext().getMavenRepoLocal() + artifact.generatePath() );
                    artifact.setOverrideType( Artifact.OVERRIDE_VERSION );
                }
                else
                {
                    // User is requesting a specific path to a dependency
                    // be used.
                    artifact.setPath( new File( mavenJarProperty ).getAbsolutePath() );
                    artifact.setOverrideType( Artifact.OVERRIDE_PATH );
                }
            }
            else
            {
                artifact.setPath( project.getContext().getMavenRepoLocal() + artifact.generatePath() );
            }

            projectArtifacts.add( artifact );
        }
View Full Code Here

    {
        StringBuffer classpath = new StringBuffer();

        for ( Iterator i = project.getArtifacts().iterator(); i.hasNext(); )
        {
            Artifact artifact = (Artifact) i.next();
            Dependency d = artifact.getDependency();

            // Only add jar or ejb (MAVEN-512) dependencies to the classpath
            if ( d.isAddedToClasspath() )
            {
                classpath.append( artifact.getPath() ).append( cps );
            }
            project.setDependencyPath( d.getKey(), artifact.getPath() );
        }

        return classpath.toString();
    }
View Full Code Here

        LOGGER.debug( "Processing dependencies for project " + project.getName() + "; classloader " + projectClassLoader );

        // add the dependencies to the classpath
        for ( Iterator i = project.getArtifacts().iterator(); i.hasNext(); )
        {
            Artifact artifact = (Artifact) i.next();
            Dependency dependency = artifact.getDependency();
            if ( dependency.isPlugin() )
            {
                // TODO: is this the best place to call this?
                installPlugin( artifact.getFile(), project );
            }

            // get correct classloader
            String dependencyClassLoader = dependency.getProperty( "classloader" );

            // add to classloader
            if ( artifact.exists() )
            {
                // Only add compile type dependencies to classloader
                // what about ejbs etc
                if ( dependency.isAddedToClasspath() )
                {
                    if ( dependencyClassLoader != null )
                    {
                        LOGGER.debug( "DEPRECATION: " + dependency.getId() + " in project " + project.getId()
                            + " forces the classloader '" + dependencyClassLoader + "'" );
                        LOGGER.debug( "             This behaviour is deprecated. Please refer to the FAQ" );
                        ForeheadClassLoader loader = Forehead.getInstance().getClassLoader( dependencyClassLoader );
                        if ( loader == null )
                        {
                            LOGGER.warn( "classloader '" + dependencyClassLoader
                                + "' not found. Adding dependencies to the project classloader instead" );
                            loader = projectClassLoader;
                        }
                        else
                        {
                            LOGGER.debug( "poking dependency " + artifact.getFile() + " into classloader "
                                + dependencyClassLoader );
                        }
                        loader.addURL( artifact.getFile().toURL() );
                    }
                    else
                    {
                        LOGGER.debug( "adding dependency " + artifact.getFile() + " into project classloader" );
                        projectClassLoader.addURL( artifact.getFile().toURL() );
                    }
                }
                else
                {
                    LOGGER.debug( "Non classpath dependency: '" + artifact.getFile() + "' not added to classpath" );
                }
            }
            else
            {
                LOGGER.info( "Artifact '" + artifact.getFile() + "' not found to add to classpath" );
            }
        }
        // Explicity set the classloader used to find resources. As we just
        // poked all the dependencies into the classloader.
        project.getContext().setClassLoader( projectClassLoader );
View Full Code Here

        clearFailedDependencies();

        for ( Iterator i = getProject().getArtifacts().iterator(); i.hasNext(); )
        {
            Artifact artifact = (Artifact) i.next();

            String path = artifact.getUrlPath();
            if ( resolvedArtifacts.contains( path ) )
            {
                if ( LOGGER.isDebugEnabled() )
                    LOGGER.debug( "(previously resolved: " + path + ")" );
                continue;
            }
            resolvedArtifacts.add( path );

            // The artifact plain doesn't exist so chalk it up as a failed dependency.
            if ( !artifact.exists() )
            {
                if ( LOGGER.isDebugEnabled() )
                    LOGGER.debug( "Artifact [" + path + "] not found in local repository" );
                failedDependencies.add( artifact );
            }
            else if ( artifact.isSnapshot() && !Artifact.OVERRIDE_PATH.equals( artifact.getOverrideType() ) )
            {
                // The artifact exists but we need to take into account the user
                // being online and whether the artifact is a snapshot. If the user
                // is online then snapshots are added to the list of failed dependencies
                // so that a newer version can be retrieved if one exists. We make
                // an exception when the user is working offline and let them
                // take their chances with a strong warning that they could possibly
                // be using an out-of-date artifact. We don't want to cripple users
                // when working offline.
                if ( online )
                {
                    failedDependencies.add( artifact );
                }
                else
                {
                    LOGGER.warn( getMessage( "offline.snapshot.warning", artifact.getName() ) );
                }
            }
        }

        // If we have any failed dependencies then we will attempt to download
View Full Code Here

        message.append( "\n" );

        for ( Iterator i = failedDependencies.iterator(); i.hasNext(); )
        {
            Artifact artifact = (Artifact) i.next();
            message.append( "- " + artifact.getDescription() );

            String overrideType = artifact.getOverrideType();
            if ( overrideType != Artifact.OVERRIDE_NONE )
            {
                if ( Artifact.OVERRIDE_VERSION.equals( overrideType ) )
                {
                    message.append( "; version override doesn't exist: " + artifact.getDependency().getVersion() );
                }
                else if ( Artifact.OVERRIDE_PATH.equals( overrideType ) )
                {
                    message.append( "; path override doesn't exist: " + artifact.getPath() );
                }
            }

            String url = artifact.getDependency().getUrl();
            if ( StringUtils.isNotEmpty( url ) )
            {
                // FIXME: internationalize
                message.append( " (" ).append( "try downloading from " ).append( url ).append( ")" );
            }
View Full Code Here

        if ( failedDependencies.size() > 0 )
        {
            LOGGER.info( getMessage( "satisfy.project.message", getProject().getName() ) );
        }

        Artifact artifact;
        Iterator i = failedDependencies.iterator();
        while ( i.hasNext() )
        {
            artifact = (Artifact) i.next();

            // before we try to download a missing dependency we have to verify
            // that the dependency is not of the type Artifact.OVERRIDE_PATH,
            // in which case it can not be downloaded. Just skip this iteration.
            // Since the dependency won't get removed from the failedDependencies list
            // an error message will be created.
            String overrideType = artifact.getOverrideType();
            if ( Artifact.OVERRIDE_PATH.equals( overrideType ) )
            {
                continue;
            }

            // The directory structure for the project this dependency belongs to
            // may not exists so attempt to create the project directory structure
            // before attempting to download the dependency.
            File directory = artifact.getFile().getParentFile();

            if ( !directory.exists() )
            {
                directory.mkdirs();
            }

            if ( getRemoteArtifact( artifact ) )
            {
                // The dependency has been successfully downloaded so lets remove
                // it from the failed dependency list.
                i.remove();
            }
            else
            {
                if ( artifact.exists() )
                {
                    // The snapshot jar locally exists and not in remote repository
                    //LOGGER.info( getMessage( "not.existing.artifact.in.repo", artifact.getUrlPath() ) );
                    i.remove();
                }
View Full Code Here

TOP

Related Classes of org.apache.maven.repository.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.