cbf6f69c8abffa9d8ef3d9ee8d8e0d883fae79b0
[sdc.git] /
1 /*
2  * Copyright © 2018 European Support Limited
3  *
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
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16
17 package org.openecomp.sdc.onboarding;
18
19 import static org.openecomp.sdc.onboarding.Constants.FORK_COUNT;
20 import static org.openecomp.sdc.onboarding.Constants.JACOCO_SKIP;
21 import static org.openecomp.sdc.onboarding.Constants.UNICORN;
22
23 import org.apache.maven.plugin.AbstractMojo;
24 import org.apache.maven.plugin.MojoExecutionException;
25 import org.apache.maven.plugin.MojoFailureException;
26 import org.apache.maven.plugins.annotations.LifecyclePhase;
27 import org.apache.maven.plugins.annotations.Mojo;
28 import org.apache.maven.plugins.annotations.Parameter;
29 import org.apache.maven.plugins.annotations.ResolutionScope;
30 import org.apache.maven.project.MavenProject;
31
32 @Mojo(name = "init-helper", threadSafe = true, defaultPhase = LifecyclePhase.PRE_CLEAN,
33         requiresDependencyResolution = ResolutionScope.NONE)
34 public class InitializationHelperMojo extends AbstractMojo {
35
36     @Parameter(defaultValue = "${project}", readonly = true)
37     private MavenProject project;
38
39     public void execute() throws MojoExecutionException, MojoFailureException {
40
41         if (System.getProperties().containsKey(JACOCO_SKIP) && Boolean.FALSE.equals(Boolean.valueOf(
42                 System.getProperties().getProperty(JACOCO_SKIP)))) {
43             project.getProperties().setProperty(FORK_COUNT, "1");
44         } else {
45             project.getProperties().setProperty(FORK_COUNT, "0");
46         }
47
48         if (System.getProperties().containsKey(UNICORN)) {
49             project.getProperties().setProperty("classes", "classes/**/*.class");
50             project.getProperties().setProperty("testClasses", "test-classes/**/*.class");
51             project.getProperties().setProperty("mavenStatus", "maven-status/**");
52             project.getProperties().setProperty("pmd", "pmd/**");
53             project.getProperties().setProperty("customGeneratedSources", "generated-sources/custom/**");
54
55         }
56
57     }
58
59 }