org.apache.maven.model.Activation Java Examples

The following examples show how to use org.apache.maven.model.Activation. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: LocationAwareMavenXpp3Writer.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private void writeActivation(Activation activation, String tagName, XmlSerializer serializer)
        throws java.io.IOException {
    serializer.startTag(NAMESPACE, tagName);
    flush(serializer);
    StringBuffer b = b(serializer);
    int start = b.length();
    if (activation.isActiveByDefault() != false) {
        writeValue(serializer, "activeByDefault", String.valueOf(activation.isActiveByDefault()), activation);
    }
    if (activation.getJdk() != null) {
        writeValue(serializer, "jdk", activation.getJdk(), activation);
    }
    if (activation.getOs() != null) {
        writeActivationOS(activation.getOs(), "os", serializer);
    }
    if (activation.getProperty() != null) {
        writeActivationProperty(activation.getProperty(), "property", serializer);
    }
    if (activation.getFile() != null) {
        writeActivationFile(activation.getFile(), "file", serializer);
    }
    serializer.endTag(NAMESPACE, tagName).flush();
    logLocation(activation, "", start, b.length());
}
 
Example #2
Source File: DependencyAddedInProfileTest.java    From quarkus with Apache License 2.0 5 votes vote down vote up
@Override
protected TsArtifact modelApp() {

    final TsQuarkusExt extA_100 = new TsQuarkusExt("ext-a", "1.0.0");
    addToExpectedLib(extA_100.getRuntime());

    final TsQuarkusExt extB_100 = new TsQuarkusExt("ext-b", "1.0.0");
    install(extB_100);
    final TsArtifact extB_100_rt = extB_100.getRuntime();
    addToExpectedLib(extB_100_rt);

    final TsArtifact appJar = TsArtifact.jar("app")
            .addDependency(extA_100);

    final Profile profile = new Profile();
    profile.setId("extra");
    Activation activation = new Activation();
    ActivationProperty ap = new ActivationProperty();
    ap.setName("extra");
    activation.setProperty(ap);
    profile.setActivation(activation);
    final Dependency dep = new Dependency();
    dep.setGroupId(extB_100_rt.getGroupId());
    dep.setArtifactId(extB_100_rt.getArtifactId());
    dep.setVersion(extB_100_rt.getVersion());
    profile.addDependency(dep);
    appJar.addProfile(profile);

    createWorkspace();

    setSystemProperty("extra", "extra");

    return appJar;
}
 
Example #3
Source File: MicroprofileServersAddon.java    From microprofile-starter with Apache License 2.0 5 votes vote down vote up
@Override
public void adaptMavenModel(Model pomFile, JessieModel model, boolean mainProject) {

    String serverName = options.get("server").getSingleValue();
    // From MP 3.2 on with Helidon, one of the Maven deps changed
    // So I created a new profile with correct naming.  The solution with the MP version in the profile name is not really useful in this case
    // since it will be for several MP releases.
    if ("helidon".equals(serverName) && model.getSpecification().getMicroProfileVersion().ordinal() <= MicroProfileVersion.MP32.ordinal()) {
        serverName = "helidon2";
    }
    String profileName = serverName + "-" + model.getSpecification().getMicroProfileVersion().getCode();

    Profile profile = findProfile(profileName);
    if (profile == null) {
        profile = findProfile(serverName);
    }

    if (profile == null) {
        throw new JessieUnexpectedException("Profile not found " + profileName);
    }

    Profile selectedProfile = profile.clone();
    selectedProfile.setId(serverName);
    Activation activeByDefault = new Activation();
    activeByDefault.setActiveByDefault(true);
    selectedProfile.setActivation(activeByDefault);
    pomFile.getProfiles().add(selectedProfile);

    if (microprofileSpecs.contains(MicroprofileSpec.JWT_AUTH) && mainProject) {
        mavenHelper.addDependency(pomFile, "io.vertx", "vertx-auth-jwt", VERTX_JWT_VERSION);
    }

    if (model.hasMainAndSecondaryProject()) {
        if (mainProject) {
            pomFile.setArtifactId(model.getMaven().getArtifactId() + "-" + JessieModel.MAIN_INDICATOR);
        } else {
            pomFile.setArtifactId(model.getMaven().getArtifactId() + "-" + JessieModel.SECONDARY_INDICATOR);
        }
    }
}
 
Example #4
Source File: FlattenMojo.java    From flatten-maven-plugin with Apache License 2.0 5 votes vote down vote up
/**
 * @param activation is the {@link Activation} of a {@link Profile}.
 * @return <code>true</code> if the given {@link Activation} is build-time driven, <code>false</code> otherwise (if
 *         it is triggered by OS or JDK).
 */
protected static boolean isBuildTimeDriven( Activation activation )
{

    if ( activation == null )
    {
        return true;
    }
    if ( StringUtils.isEmpty( activation.getJdk() ) && activation.getOs() == null )
    {
        return true;
    }
    return false;
}
 
Example #5
Source File: CreateMavenBundlePom.java    From tesb-studio-se with Apache License 2.0 5 votes vote down vote up
/**
 * skip depoly phase in publich to cloud in parent pom, enable in nexus.
 */
private Profile addProfileForCloud() {
    Profile deployCloudProfile = new Profile();
    deployCloudProfile.setId("deploy-cloud");
    Activation deployCloudActivation = new Activation();
    ActivationProperty activationProperty = new ActivationProperty();
    activationProperty.setName("!altDeploymentRepository");
    deployCloudActivation.setProperty(activationProperty);
    deployCloudProfile.setActivation(deployCloudActivation);
    deployCloudProfile.setBuild(new Build());
    deployCloudProfile.getBuild().addPlugin(addSkipDeployFeatureMavenPlugin());
    return deployCloudProfile;
}
 
Example #6
Source File: CreateMavenDataServicePom.java    From tesb-studio-se with Apache License 2.0 5 votes vote down vote up
/**
 * DOC skip depoly phase in publich to cloud in parent pom, enable in nexus.
 */
private Profile addProfileForCloud() {
    Profile deployCloudProfile = new Profile();
    deployCloudProfile.setId("deploy-cloud");
    Activation deployCloudActivation = new Activation();
    ActivationProperty activationProperty = new ActivationProperty();
    activationProperty.setName("!altDeploymentRepository");
    deployCloudActivation.setProperty(activationProperty);
    deployCloudProfile.setActivation(deployCloudActivation);
    deployCloudProfile.setBuild(new Build());
    deployCloudProfile.getBuild().addPlugin(addSkipDeployFeatureMavenPlugin());
    return deployCloudProfile;
}
 
Example #7
Source File: Project.java    From pom-manipulation-ext with Apache License 2.0 4 votes vote down vote up
public void updateProfiles (List<Profile> remoteProfiles)
{
    final List<Profile> profiles = model.getProfiles();

    if ( !remoteProfiles.isEmpty() )
    {
        for ( Profile profile : remoteProfiles )
        {
            final Iterator<Profile> i = profiles.iterator();
            while ( i.hasNext() )
            {
                final Profile p = i.next();

                if ( profile.getId().equals( p.getId() ) )
                {
                    logger.debug( "Removing local profile {} ", p );
                    i.remove();
                    // Don't break out of the loop so we can check for active profiles
                }

                // If we have injected profiles and one of the current profiles is using
                // activeByDefault it will get mistakenly deactivated due to the semantics
                // of activeByDefault. Therefore replace the activation.
                if ( p.getActivation() != null && p.getActivation().isActiveByDefault() )
                {
                    logger.warn( "Profile {} is activeByDefault", p );

                    final Activation replacement = new Activation();
                    final ActivationProperty replacementProp = new ActivationProperty();
                    replacementProp.setName( "!disableProfileActivation" );
                    replacement.setProperty( replacementProp );

                    p.setActivation( replacement );
                }
            }

            logger.debug( "Adding profile {}", profile );
            profiles.add( profile );
        }
    }
}