<commit_before>/**
 * Copyright 2010 OpenEngSB Division, Vienna University of Technology
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.openengsb.openengsbplugin.base;

import java.util.ArrayList;
import java.util.List;
import java.util.Properties;

import org.apache.maven.plugin.MojoExecutionException;
import org.openengsb.openengsbplugin.tools.MavenExecutor;

public abstract class ReleaseMojo extends ConfiguredMojo {

    /**
     * The SCM URL to checkout from. If omitted, the one from the
     * release.properties file is used, followed by the URL from the current
     * POM.
     * 
     * @parameter expression="${connectionUrl}"
     * 
     * @required
     */
    protected String connectionUrl;

    public ReleaseMojo() {
        configPath = "releaseMojo/releaseCommonConfig.xml";
        configProfileXpath = "/rcc:releaseCommonConfig/rcc:profile";
    }

    protected abstract String getReleaseProfile();

    @Override
    protected void configureCoCMojo() throws MojoExecutionException {
        List<String> activatedProfiles = new ArrayList<String>();
        activatedProfiles.add(cocProfile);
        activatedProfiles.add(getReleaseProfile());

        List<String> phaseOneGoals = new ArrayList<String>();
        phaseOneGoals.add("release:prepare");

        Properties phaseOneUserProps = new Properties();
        phaseOneUserProps.put("maven.test.skip", "true");

        MavenExecutor phaseOneExecutor = getNewMavenExecutor(this);
        phaseOneExecutor.addGoals(phaseOneGoals);
        phaseOneExecutor.addUserProperties(phaseOneUserProps);
        phaseOneExecutor.addActivatedProfiles(activatedProfiles);

        phaseOneExecutor.setRecursive(true);

        addMavenExecutor(phaseOneExecutor);

        List<String> phaseTwoGoals = new ArrayList<String>();
        phaseTwoGoals.add("release:perform");

        Properties phaseTwoUserProps = new Properties();
        phaseTwoUserProps.put("maven.test.skip", "true");
        phaseTwoUserProps.put("connectionUrl", connectionUrl);

        MavenExecutor phaseTwoExecutor = getNewMavenExecutor(this);
        phaseTwoExecutor.addGoals(phaseTwoGoals);
        phaseTwoExecutor.addUserProperties(phaseTwoUserProps);
        phaseTwoExecutor.addActivatedProfiles(activatedProfiles);

        phaseTwoExecutor.setRecursive(true);

        addMavenExecutor(phaseTwoExecutor);
    }

    @Override
    protected final void validateIfExecutionIsAllowed() throws MojoExecutionException {
        throwErrorIfProjectIsNotExecutedInRootDirectory();
    }

}<commit_msg>set pom restore mode to "CLEAN" for release mojos as the wrapped mojo updates versions in the root pom<commit_after>/**
 * Copyright 2010 OpenEngSB Division, Vienna University of Technology
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.openengsb.openengsbplugin.base;

import java.util.ArrayList;
import java.util.List;
import java.util.Properties;

import org.apache.maven.plugin.MojoExecutionException;
import org.openengsb.openengsbplugin.tools.MavenExecutor;

public abstract class ReleaseMojo extends ConfiguredMojo {

    /**
     * The SCM URL to checkout from. If omitted, the one from the
     * release.properties file is used, followed by the URL from the current
     * POM.
     * 
     * @parameter expression="${connectionUrl}"
     * 
     * @required
     */
    protected String connectionUrl;

    public ReleaseMojo() {
        configPath = "releaseMojo/releaseCommonConfig.xml";
        configProfileXpath = "/rcc:releaseCommonConfig/rcc:profile";
    }

    protected abstract String getReleaseProfile();

    @Override
    protected void configureCoCMojo() throws MojoExecutionException {
        List<String> activatedProfiles = new ArrayList<String>();
        activatedProfiles.add(cocProfile);
        activatedProfiles.add(getReleaseProfile());

        List<String> phaseOneGoals = new ArrayList<String>();
        phaseOneGoals.add("release:prepare");

        Properties phaseOneUserProps = new Properties();
        phaseOneUserProps.put("maven.test.skip", "true");

        MavenExecutor phaseOneExecutor = getNewMavenExecutor(this);
        phaseOneExecutor.addGoals(phaseOneGoals);
        phaseOneExecutor.addUserProperties(phaseOneUserProps);
        phaseOneExecutor.addActivatedProfiles(activatedProfiles);

        phaseOneExecutor.setRecursive(true);

        addMavenExecutor(phaseOneExecutor);

        List<String> phaseTwoGoals = new ArrayList<String>();
        phaseTwoGoals.add("release:perform");

        Properties phaseTwoUserProps = new Properties();
        phaseTwoUserProps.put("maven.test.skip", "true");
        phaseTwoUserProps.put("connectionUrl", connectionUrl);

        MavenExecutor phaseTwoExecutor = getNewMavenExecutor(this);
        phaseTwoExecutor.addGoals(phaseTwoGoals);
        phaseTwoExecutor.addUserProperties(phaseTwoUserProps);
        phaseTwoExecutor.addActivatedProfiles(activatedProfiles);

        phaseTwoExecutor.setRecursive(true);

        addMavenExecutor(phaseTwoExecutor);
        
        setPomRestoreMode(PomRestoreMode.CLEAN);
    }

    @Override
    protected final void validateIfExecutionIsAllowed() throws MojoExecutionException {
        throwErrorIfProjectIsNotExecutedInRootDirectory();
    }

}
{'fraction_non_alphanumeric': 0.08408694272568618, 'fraction_numerical': 0.0025384737426622245, 'mean_word_length': 3.775757575757576, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3140072', 'n_tokens_mistral': 1670, 'n_tokens_neox': 1610, 'n_words': 429}