Package org.apache.maven.model

Examples of org.apache.maven.model.Profile


        releaseDescriptor.setCheckoutDirectory( checkoutDirectory.getAbsolutePath() );
        releaseDescriptor.setPerformGoals( "deploy site-deploy" );
        releaseDescriptor.setAdditionalArguments( "-Dmaven.test.skip=true -P prof1,2prof" );

        MavenProject project = (MavenProject) getVariableValueFromObject( mojo, "project" );
        Profile profile1 = new Profile();
        profile1.setId( "prof1" );
        Profile profile2 = new Profile();
        profile2.setId( "2prof" );
        project.setActiveProfiles( Arrays.asList( new Profile[]{profile1, profile2} ) );

        ReleaseManager mock = mock( ReleaseManager.class );
        mojo.setReleaseManager( mock );
View Full Code Here


        // rewrite Profiles
        if ( pom.getProfiles() != null )
        {
            for ( Iterator<Profile> profiles = pom.getProfiles().iterator(); profiles.hasNext(); )
            {
                Profile profile = profiles.next();

                // rewrite Dependencies
                if ( profile.getDependencies() != null && !profile.getDependencies().isEmpty() )
                {
                    for ( Iterator<Dependency> dependencies = profile.getDependencies().iterator();
                          dependencies.hasNext(); )
                    {
                        Dependency dependency = dependencies.next();

                        if ( dependency.getArtifactId() != null
                            && dependency.getArtifactId().indexOf( rootArtifactId ) >= 0 )
                        {
                            if ( dependency.getGroupId() != null )
                            {
                                dependency.setGroupId( StringUtils.replace( dependency.getGroupId(), groupId,
                                                                            "${" + Constants.GROUP_ID + "}" ) );
                            }

                            dependency.setArtifactId( StringUtils.replace( dependency.getArtifactId(), rootArtifactId,
                                                                           "${rootArtifactId}" ) );

                            if ( dependency.getVersion() != null )
                            {
                                dependency.setVersion( "${" + Constants.VERSION + "}" );
                            }
                        }
                    }
                }

                // rewrite DependencyManagement
                if ( profile.getDependencyManagement() != null
                    && profile.getDependencyManagement().getDependencies() != null
                    && !profile.getDependencyManagement().getDependencies().isEmpty() )
                {
                    for ( Iterator<Dependency> dependencies =
                              profile.getDependencyManagement().getDependencies().iterator(); dependencies.hasNext(); )
                    {
                        Dependency dependency = dependencies.next();

                        if ( dependency.getArtifactId() != null
                            && dependency.getArtifactId().indexOf( rootArtifactId ) >= 0 )
                        {
                            if ( dependency.getGroupId() != null )
                            {
                                dependency.setGroupId( StringUtils.replace( dependency.getGroupId(), groupId,
                                                                            "${" + Constants.GROUP_ID + "}" ) );
                            }

                            dependency.setArtifactId( StringUtils.replace( dependency.getArtifactId(), rootArtifactId,
                                                                           "${rootArtifactId}" ) );

                            if ( dependency.getVersion() != null )
                            {
                                dependency.setVersion( "${" + Constants.VERSION + "}" );
                            }
                        }
                    }
                }

                // rewrite Plugins
                if ( profile.getBuild() != null && profile.getBuild().getPlugins() != null
                    && !profile.getBuild().getPlugins().isEmpty() )
                {
                    for ( Iterator<Plugin> plugins = profile.getBuild().getPlugins().iterator(); plugins.hasNext(); )
                    {
                        Plugin plugin = plugins.next();

                        if ( plugin.getArtifactId() != null && plugin.getArtifactId().indexOf( rootArtifactId ) >= 0 )
                        {
                            if ( plugin.getGroupId() != null )
                            {
                                plugin.setGroupId( StringUtils.replace( plugin.getGroupId(), groupId,
                                                                        "${" + Constants.GROUP_ID + "}" ) );
                            }

                            plugin.setArtifactId(
                                StringUtils.replace( plugin.getArtifactId(), rootArtifactId, "${rootArtifactId}" ) );

                            if ( plugin.getVersion() != null )
                            {
                                plugin.setVersion( "${" + Constants.VERSION + "}" );
                            }
                        }
                    }
                }

                // rewrite PluginManagement
                if ( profile.getBuild() != null && profile.getBuild().getPluginManagement() != null
                    && profile.getBuild().getPluginManagement().getPlugins() != null
                    && !profile.getBuild().getPluginManagement().getPlugins().isEmpty() )
                {
                    for ( Iterator<Plugin> plugins = profile.getBuild().getPluginManagement().getPlugins().iterator();
                          plugins.hasNext(); )
                    {
                        Plugin plugin = plugins.next();

                        if ( plugin.getArtifactId() != null && plugin.getArtifactId().indexOf( rootArtifactId ) >= 0 )
View Full Code Here

            }

            Counter innerCount = new Counter( counter.getDepth() + 1 );
            while ( it.hasNext() )
            {
                Profile value = (Profile) it.next();
                Element el;
                if ( ( elIt != null ) && elIt.hasNext() )
                {
                    el = (Element) elIt.next();
                    if ( !elIt.hasNext() )
View Full Code Here

     *
     * @return a properly populated profile to be used for OS validation.
     */
    private Profile createProfile()
    {
        Profile profile = new Profile();
        profile.setActivation( createActivation() );
        return profile;
    }
View Full Code Here

     * @return Profile
     */
    private Profile parseProfile( String tagName, XmlPullParser parser, boolean strict )
        throws IOException, XmlPullParserException
    {
        Profile profile = new Profile();
        java.util.Set parsed = new java.util.HashSet();
        while ( parser.nextTag() == XmlPullParser.START_TAG )
        {
            if ( checkFieldWithDuplicate( parser, "id", null, parsed ) )
            {
                profile.setId( getTrimmedValue( parser.nextText() ) );
            }
            else if ( checkFieldWithDuplicate( parser, "activation", null, parsed ) )
            {
                profile.setActivation( parseActivation( "activation", parser, strict ) );
            }
            else if ( checkFieldWithDuplicate( parser, "build", null, parsed ) )
            {
                profile.setBuild( parseBuildBase( "build", parser, strict ) );
            }
            else if ( checkFieldWithDuplicate( parser, "distributionManagement", null, parsed ) )
            {
                profile.setDistributionManagement( parseDistributionManagement( "distributionManagement", parser, strict ) );
            }
            else if ( checkFieldWithDuplicate( parser, "modules", null, parsed ) )
            {
                java.util.List modules = new java.util.ArrayList/*<String>*/();
                profile.setModules( modules );
                while ( parser.nextTag() == XmlPullParser.START_TAG )
                {
                    if ( parser.getName().equals( "module" ) )
                    {
                        modules.add( getTrimmedValue( parser.nextText() ) );
                    }
                    else if ( strict )
                    {
                        throw new XmlPullParserException( "Unrecognised association: '" + parser.getName() + "'", parser, null );
                    }
                    else
                    {
                        // swallow up to end tag since this is not valid
                        while ( parser.next() != XmlPullParser.END_TAG ) {}
                    }
                }
            }
            else if ( checkFieldWithDuplicate( parser, "repositories", null, parsed ) )
            {
                java.util.List repositories = new java.util.ArrayList/*<Repository>*/();
                profile.setRepositories( repositories );
                while ( parser.nextTag() == XmlPullParser.START_TAG )
                {
                    if ( parser.getName().equals( "repository" ) )
                    {
                        repositories.add( parseRepository( "repository", parser, strict ) );
                    }
                    else if ( strict )
                    {
                        throw new XmlPullParserException( "Unrecognised association: '" + parser.getName() + "'", parser, null );
                    }
                    else
                    {
                        // swallow up to end tag since this is not valid
                        while ( parser.next() != XmlPullParser.END_TAG ) {}
                    }
                }
            }
            else if ( checkFieldWithDuplicate( parser, "pluginRepositories", null, parsed ) )
            {
                java.util.List pluginRepositories = new java.util.ArrayList/*<Repository>*/();
                profile.setPluginRepositories( pluginRepositories );
                while ( parser.nextTag() == XmlPullParser.START_TAG )
                {
                    if ( parser.getName().equals( "pluginRepository" ) )
                    {
                        pluginRepositories.add( parseRepository( "pluginRepository", parser, strict ) );
                    }
                    else if ( strict )
                    {
                        throw new XmlPullParserException( "Unrecognised association: '" + parser.getName() + "'", parser, null );
                    }
                    else
                    {
                        // swallow up to end tag since this is not valid
                        while ( parser.next() != XmlPullParser.END_TAG ) {}
                    }
                }
            }
            else if ( checkFieldWithDuplicate( parser, "dependencies", null, parsed ) )
            {
                java.util.List dependencies = new java.util.ArrayList/*<Dependency>*/();
                profile.setDependencies( dependencies );
                while ( parser.nextTag() == XmlPullParser.START_TAG )
                {
                    if ( parser.getName().equals( "dependency" ) )
                    {
                        dependencies.add( parseDependency( "dependency", parser, strict ) );
                    }
                    else if ( strict )
                    {
                        throw new XmlPullParserException( "Unrecognised association: '" + parser.getName() + "'", parser, null );
                    }
                    else
                    {
                        // swallow up to end tag since this is not valid
                        while ( parser.next() != XmlPullParser.END_TAG ) {}
                    }
                }
            }
            else if ( checkFieldWithDuplicate( parser, "reports", null, parsed ) )
            {
                profile.setReports( Xpp3DomBuilder.build( parser ) );
            }
            else if ( checkFieldWithDuplicate( parser, "reporting", null, parsed ) )
            {
                profile.setReporting( parseReporting( "reporting", parser, strict ) );
            }
            else if ( checkFieldWithDuplicate( parser, "dependencyManagement", null, parsed ) )
            {
                profile.setDependencyManagement( parseDependencyManagement( "dependencyManagement", parser, strict ) );
            }
            else if ( checkFieldWithDuplicate( parser, "properties", null, parsed ) )
            {
                while ( parser.nextTag() == XmlPullParser.START_TAG )
                {
                    String key = parser.getName();
                    String value = parser.nextText().trim();
                    profile.addProperty( key, value );
                }
            }
            else
            {
                if ( strict )
View Full Code Here

            if ( ( model.getProfiles() != null ) && ( model.getProfiles().size() > 0 ) )
            {
                serializer.startTag( NAMESPACE, "profiles" );
                for ( Iterator iter = model.getProfiles().iterator(); iter.hasNext(); )
                {
                    Profile o = (Profile) iter.next();
                    writeProfile( o, "profile", serializer );
                }
                serializer.endTag( NAMESPACE, "profiles" );
            }
            if ( model.getDistributionManagement() != null )
View Full Code Here

                elIt = null;
            }
            Counter innerCount = new Counter( counter.getDepth() + 1 );
            while ( it.hasNext() )
            {
                Profile value = (Profile) it.next();
                Element el;
                if ( elIt != null && elIt.hasNext() )
                {
                    el = (Element) elIt.next();
                    if ( !elIt.hasNext() )
View Full Code Here

    */
    public void addProfile( Profile profile )
    {
        String profileId = profile.getId();

        Profile existing = (Profile) profilesById.get( profileId );
        if ( existing != null )
        {
            logger.warn( "Overriding profile: \'" + profileId + "\' (source: " + existing.getSource()
                + ") with new instance from source: " + profile.getSource() );
        }

        profilesById.put( profile.getId(), profile );

View Full Code Here

     */
    public void addProfiles( List profiles )
    {
        for ( Object profile1 : profiles )
        {
            Profile profile = (Profile) profile1;

            addProfile( profile );
        }
    }
View Full Code Here

    {
    }

    public static Profile convertFromProfileXmlProfile( org.apache.maven.profiles.Profile profileXmlProfile )
    {
        Profile profile = new Profile();

        profile.setId( profileXmlProfile.getId() );

        profile.setSource( "profiles.xml" );

        org.apache.maven.profiles.Activation profileActivation = profileXmlProfile.getActivation();

        if ( profileActivation != null )
        {
            Activation activation = new Activation();

            activation.setActiveByDefault( profileActivation.isActiveByDefault() );

            activation.setJdk( profileActivation.getJdk() );

            org.apache.maven.profiles.ActivationProperty profileProp = profileActivation.getProperty();

            if ( profileProp != null )
            {
                ActivationProperty prop = new ActivationProperty();

                prop.setName( profileProp.getName() );
                prop.setValue( profileProp.getValue() );

                activation.setProperty( prop );
            }

           
            ActivationOS profileOs = profileActivation.getOs();
           
            if ( profileOs != null )
            {
                org.apache.maven.model.ActivationOS os = new org.apache.maven.model.ActivationOS();

                os.setArch( profileOs.getArch() );
                os.setFamily( profileOs.getFamily() );
                os.setName( profileOs.getName() );
                os.setVersion( profileOs.getVersion() );

                activation.setOs( os );
            }
           
            org.apache.maven.profiles.ActivationFile profileFile = profileActivation.getFile();

            if ( profileFile != null )
            {
                ActivationFile file = new ActivationFile();

                file.setExists( profileFile.getExists() );
                file.setMissing( profileFile.getMissing() );

                activation.setFile( file );
            }

            profile.setActivation( activation );
        }

        profile.setProperties( profileXmlProfile.getProperties() );

        List repos = profileXmlProfile.getRepositories();
        if ( repos != null )
        {
            for ( Object repo : repos )
            {
                profile.addRepository( convertFromProfileXmlRepository( (org.apache.maven.profiles.Repository) repo ) );
            }
        }

        List pluginRepos = profileXmlProfile.getPluginRepositories();
        if ( pluginRepos != null )
        {
            for ( Object pluginRepo : pluginRepos )
            {
                profile.addPluginRepository(
                    convertFromProfileXmlRepository( (org.apache.maven.profiles.Repository) pluginRepo ) );
            }
        }

        return profile;
View Full Code Here

TOP

Related Classes of org.apache.maven.model.Profile

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.