2 * Copyright © 2018 European Support Limited
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on a "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package org.openecomp.sdc.onboarding;
19 import static org.openecomp.sdc.onboarding.Constants.FORK_COUNT;
20 import static org.openecomp.sdc.onboarding.Constants.FORK_MODE;
21 import static org.openecomp.sdc.onboarding.Constants.JACOCO;
22 import static org.openecomp.sdc.onboarding.Constants.JACOCO_BUILD;
23 import static org.openecomp.sdc.onboarding.Constants.PREFIX;
24 import static org.openecomp.sdc.onboarding.Constants.SKIP_PMD;
25 import static org.openecomp.sdc.onboarding.Constants.UNICORN;
27 import org.apache.maven.plugin.AbstractMojo;
28 import org.apache.maven.plugin.MojoExecutionException;
29 import org.apache.maven.plugin.MojoFailureException;
30 import org.apache.maven.plugins.annotations.LifecyclePhase;
31 import org.apache.maven.plugins.annotations.Mojo;
32 import org.apache.maven.plugins.annotations.Parameter;
33 import org.apache.maven.plugins.annotations.ResolutionScope;
34 import org.apache.maven.project.MavenProject;
36 @Mojo(name = "init-helper", threadSafe = true, defaultPhase = LifecyclePhase.GENERATE_RESOURCES,
37 requiresDependencyResolution = ResolutionScope.TEST)
38 public class InitializationHelperMojo extends AbstractMojo {
40 @Parameter(defaultValue = "${project}", readonly = true)
41 private MavenProject project;
43 private BuildState buildState;
45 private String excludePackaging;
48 public void execute() throws MojoExecutionException, MojoFailureException {
49 if (PREFIX == UNICORN || JACOCO == UNICORN) {
50 System.getProperties().setProperty(UNICORN, Boolean.TRUE.toString());
52 if (project.getPackaging().equals(excludePackaging)) {
55 if (Boolean.valueOf(JACOCO_BUILD)) {
56 project.getProperties().setProperty(FORK_COUNT, "1");
57 project.getProperties().setProperty(FORK_MODE, "once");
59 project.getProperties().setProperty(FORK_COUNT, "0");
60 project.getProperties().setProperty(FORK_MODE, "never");
63 project.getProperties().setProperty(SKIP_PMD, Boolean.TRUE.toString());
65 if (System.getProperties().containsKey(UNICORN)) {
68 project.getProperties().setProperty("skipMainSourceCompile", Boolean.FALSE.toString());
69 project.getProperties().setProperty("skipTestSourceCompile", Boolean.FALSE.toString());