Package org.apache.maven.model

Examples of org.apache.maven.model.Profile


    extends PlexusTestCase
{
   
    public void testShouldActivateDefaultProfile() throws ProfileActivationException
    {
        Profile notActivated = new Profile();
        notActivated.setId("notActivated");
       
        Activation nonActivation = new Activation();
       
        nonActivation.setJdk("19.2");
       
        notActivated.setActivation( nonActivation );
       
        Profile defaultActivated = new Profile();
        defaultActivated.setId("defaultActivated");
       
        Activation defaultActivation = new Activation();
       
        defaultActivation.setActiveByDefault(true);
       
        defaultActivated.setActivation( defaultActivation );
       
        ProfileManager profileManager = new DefaultProfileManager(getContainer());
       
        profileManager.addProfile(notActivated);
        profileManager.addProfile(defaultActivated);
View Full Code Here


        assertEquals("defaultActivated", ((Profile)active.get(0)).getId());
    }

    public void testShouldNotActivateDefaultProfile() throws ProfileActivationException
    {
        Profile syspropActivated = new Profile();
        syspropActivated.setId("syspropActivated");
       
        Activation syspropActivation = new Activation();
       
        ActivationProperty syspropProperty = new ActivationProperty();
        syspropProperty.setName("java.version");
       
        syspropActivation.setProperty(syspropProperty);
       
        syspropActivated.setActivation( syspropActivation );
       
        Profile defaultActivated = new Profile();
        defaultActivated.setId("defaultActivated");
       
        Activation defaultActivation = new Activation();
       
        defaultActivation.setActiveByDefault(true);
       
        defaultActivated.setActivation( defaultActivation );
       
        ProfileManager profileManager = new DefaultProfileManager(getContainer());
       
        profileManager.addProfile(syspropActivated);
        profileManager.addProfile(defaultActivated);
View Full Code Here

        assertEquals("syspropActivated", ((Profile)active.get(0)).getId());
    }

    public void testShouldNotActivateReversalOfPresentSystemProperty() throws ProfileActivationException
    {
        Profile syspropActivated = new Profile();
        syspropActivated.setId("syspropActivated");
       
        Activation syspropActivation = new Activation();
       
        ActivationProperty syspropProperty = new ActivationProperty();
        syspropProperty.setName("!java.version");
       
        syspropActivation.setProperty(syspropProperty);
       
        syspropActivated.setActivation( syspropActivation );
       
        ProfileManager profileManager = new DefaultProfileManager(getContainer());
       
        profileManager.addProfile(syspropActivated);
       
View Full Code Here

        assertEquals( 0, active.size() );
    }

    public void testShouldOverrideAndActivateInactiveProfile() throws ProfileActivationException
    {
        Profile syspropActivated = new Profile();
        syspropActivated.setId("syspropActivated");
       
        Activation syspropActivation = new Activation();
       
        ActivationProperty syspropProperty = new ActivationProperty();
        syspropProperty.setName("!java.version");
       
        syspropActivation.setProperty(syspropProperty);
       
        syspropActivated.setActivation( syspropActivation );
       
        ProfileManager profileManager = new DefaultProfileManager(getContainer());
       
        profileManager.addProfile(syspropActivated);
       
View Full Code Here

        assertEquals( "syspropActivated", ((Profile)active.get(0)).getId());
    }

    public void testShouldOverrideAndDeactivateActiveProfile() throws ProfileActivationException
    {
        Profile syspropActivated = new Profile();
        syspropActivated.setId("syspropActivated");
       
        Activation syspropActivation = new Activation();
       
        ActivationProperty syspropProperty = new ActivationProperty();
        syspropProperty.setName("java.version");
       
        syspropActivation.setProperty(syspropProperty);
       
        syspropActivated.setActivation( syspropActivation );
       
        ProfileManager profileManager = new DefaultProfileManager(getContainer());
       
        profileManager.addProfile(syspropActivated);
       
View Full Code Here

        assertEquals( 0, active.size() );
    }

   public void testOsActivationProfile() throws ProfileActivationException
    {
        Profile osActivated = new Profile();
        osActivated.setId("os-profile");

        Activation osActivation = new Activation();

        ActivationOS activationOS = new ActivationOS();

        activationOS.setName("!dddd");

        osActivation.setOs(activationOS);

        osActivated.setActivation(osActivation);

        ProfileManager profileManager = new DefaultProfileManager(getContainer());

        profileManager.addProfile(osActivated);
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() );
            }
           
            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 );
        }
        else
        {
            profile.setActivation( new AlwaysOnActivation() );
        }

        profile.setProperties( profileXmlProfile.getProperties() );

        List repos = profileXmlProfile.getRepositories();
        if ( repos != null )
        {
            for ( Iterator it = repos.iterator(); it.hasNext(); )
            {
                profile
                    .addRepository(
                        convertFromProfileXmlRepository( (org.apache.maven.profiles.Repository) it.next() ) );
            }
        }

        List pluginRepos = profileXmlProfile.getPluginRepositories();
        if ( pluginRepos != null )
        {
            for ( Iterator it = pluginRepos.iterator(); it.hasNext(); )
            {
                profile.addPluginRepository( convertFromProfileXmlRepository( (org.apache.maven.profiles.Repository) it
                    .next() ) );
            }
        }

        return profile;
View Full Code Here

        List newProfiles = new ArrayList( profiles.size() );

        for ( Iterator it = profiles.iterator(); it.hasNext(); )
        {
            Profile profile = (Profile) it.next();

            Profile newProfile = new Profile();

            newProfile.setId( profile.getId() );

            newProfile.setActivation( cloneProfileActivation( profile.getActivation() ) );

            newProfile.setBuild( cloneProfileBuild( profile.getBuild() ) );

            newProfile.setDependencies( cloneProfileDependencies( profile.getDependencies() ) );

            DependencyManagement dm = profile.getDependencyManagement();

            if ( dm != null )
            {
                DependencyManagement newDM = new DependencyManagement();

                newDM.setDependencies( cloneProfileDependencies( dm.getDependencies() ) );

                newProfile.setDependencyManagement( newDM );
            }

            newProfile.setDistributionManagement( cloneProfileDistributionManagement( profile
                .getDistributionManagement() ) );

            List modules = profile.getModules();

            if ( modules != null && !modules.isEmpty() )
            {
                newProfile.setModules( new ArrayList( modules ) );
            }

            newProfile.setPluginRepositories( cloneProfileRepositories( profile.getPluginRepositories() ) );

            Properties props = profile.getProperties();

            if ( props != null )
            {
                Properties newProps = new Properties();
                newProps.putAll( props );

                newProfile.setProperties( newProps );
            }

            newProfile.setReporting( cloneProfileReporting( profile.getReporting() ) );

            newProfile.setReports( profile.getReports() );

            newProfile.setRepositories( cloneProfileRepositories( profile.getRepositories() ) );

            newProfile.setSource( profile.getSource() );

            newProfiles.add( newProfile );
        }

        return newProfiles;
View Full Code Here

            throw new ProjectBuildingException( projectId, "Failed to calculate active external profiles.", e );
        }

        for ( Iterator i = activeExternalProfiles.iterator(); i.hasNext(); )
        {
            Profile externalProfile = (Profile) i.next();

            for ( Iterator repoIterator = externalProfile.getRepositories().iterator(); repoIterator.hasNext(); )
            {
                Repository mavenRepo = (Repository) repoIterator.next();

                ArtifactRepository artifactRepo = null;
                try
View Full Code Here

                throw new ProjectBuildingException( projectId, e.getMessage(), e );
            }

            for ( Iterator it = activeProfiles.iterator(); it.hasNext(); )
            {
                Profile profile = (Profile) it.next();

                profileInjector.inject( profile, model );
            }
        }
        else
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.