Java Code Examples for org.apache.maven.model.Profile#setId()

The following examples show how to use org.apache.maven.model.Profile#setId() . 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: 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 2
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 3
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 4
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 5
Source File: QuarkusServer.java    From microprofile-starter with Apache License 2.0 4 votes vote down vote up
@Override
public void adaptMavenModel(Model pomFile, JessieModel model, boolean mainProject) {
    String quarkusVersion = "";
    switch (model.getSpecification().getMicroProfileVersion()) {

        case NONE:
            break;
        case MP32:
            quarkusVersion = "1.3.4.Final";
            break;
        case MP30:
            break;
        case MP22:
            break;
        case MP21:
            break;
        case MP20:
            break;
        case MP14:
            break;
        case MP13:
            break;
        case MP12:
            break;
        default:
    }
    pomFile.addProperty("version.quarkus", quarkusVersion);
    List<MicroprofileSpec> microprofileSpecs = model.getParameter(JessieModel.Parameter.MICROPROFILESPECS);

    Profile nativeProfile = pomFile.getProfiles().get(0).clone();
    nativeProfile.setId("native");
    nativeProfile.getActivation().setActiveByDefault(false);
    nativeProfile.getBuild().getPlugins().get(0).getExecutions().get(0).setGoals(Collections.singletonList("native-image"));

    Xpp3Dom configuration = new Xpp3Dom("configuration");

    Xpp3Dom enableHttpUrlHandler = new Xpp3Dom("enableHttpUrlHandler");
    enableHttpUrlHandler.setValue("true");
    configuration.addChild(enableHttpUrlHandler);

    if (microprofileSpecs.contains(MicroprofileSpec.JWT_AUTH) && mainProject) {
        Xpp3Dom additionalBuildArgsLog = new Xpp3Dom("additionalBuildArgs");
        additionalBuildArgsLog.setValue("-H:Log=registerResource:");
        configuration.addChild(additionalBuildArgsLog);

        Xpp3Dom additionalBuildArgsResources = new Xpp3Dom("additionalBuildArgs");
        additionalBuildArgsResources.setValue("-H:IncludeResources=privateKey.pem");
        configuration.addChild(additionalBuildArgsResources);
    }

    nativeProfile.getBuild().getPlugins().get(0).setConfiguration(configuration);

    pomFile.addProfile(nativeProfile);

    // We add Rest by default as all our examples use it anyway.
    mavenHelper.addDependency(pomFile, "io.quarkus", "quarkus-resteasy", "${version.quarkus}");

    //if (microprofileSpecs.contains(MicroprofileSpec.CONFIG)) {
    // Config is present by default.
    //}
    if (microprofileSpecs.contains(MicroprofileSpec.FAULT_TOLERANCE) && mainProject) {
        mavenHelper.addDependency(pomFile, "io.quarkus", "quarkus-smallrye-fault-tolerance", "${version.quarkus}");
    }
    if (microprofileSpecs.contains(MicroprofileSpec.JWT_AUTH)) {
        mavenHelper.addDependency(pomFile, "io.quarkus", "quarkus-smallrye-jwt", "${version.quarkus}");
    }
    if (microprofileSpecs.contains(MicroprofileSpec.METRICS) && mainProject) {
        mavenHelper.addDependency(pomFile, "io.quarkus", "quarkus-smallrye-metrics", "${version.quarkus}");
    }
    if (microprofileSpecs.contains(MicroprofileSpec.HEALTH_CHECKS) && mainProject) {
        mavenHelper.addDependency(pomFile, "io.quarkus", "quarkus-smallrye-health", "${version.quarkus}");
    }
    if (microprofileSpecs.contains(MicroprofileSpec.OPEN_API) && mainProject) {
        mavenHelper.addDependency(pomFile, "io.quarkus", "quarkus-smallrye-openapi", "${version.quarkus}");
    }
    if (microprofileSpecs.contains(MicroprofileSpec.OPEN_TRACING)) {
        mavenHelper.addDependency(pomFile, "io.quarkus", "quarkus-smallrye-opentracing", "${version.quarkus}");
    }
    if ((microprofileSpecs.contains(MicroprofileSpec.REST_CLIENT) || microprofileSpecs.contains(MicroprofileSpec.JWT_AUTH)) && mainProject) {
        mavenHelper.addDependency(pomFile, "io.quarkus", "quarkus-rest-client", "${version.quarkus}");
    }
}