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.SKIP_TEST_RUN;
20 import static org.openecomp.sdc.onboarding.Constants.UNICORN;
22 import org.apache.maven.plugin.AbstractMojo;
23 import org.apache.maven.plugin.MojoExecutionException;
24 import org.apache.maven.plugin.MojoFailureException;
25 import org.apache.maven.plugins.annotations.LifecyclePhase;
26 import org.apache.maven.plugins.annotations.Mojo;
27 import org.apache.maven.plugins.annotations.Parameter;
28 import org.apache.maven.plugins.annotations.ResolutionScope;
29 import org.apache.maven.project.MavenProject;
31 @Mojo(name = "post-test-run-helper", threadSafe = true, defaultPhase = LifecyclePhase.TEST,
32 requiresDependencyResolution = ResolutionScope.NONE)
33 public class PostTestRunHelperMojo extends AbstractMojo {
36 private BuildState buildState;
37 @Parameter(defaultValue = "${project.artifact.groupId}:${project.artifact.artifactId}")
38 private String moduleCoordinates;
39 @Parameter(defaultValue = "${project}", readonly = true)
40 private MavenProject project;
42 private String excludePackaging;
45 public void execute() throws MojoExecutionException, MojoFailureException {
46 if (!System.getProperties().containsKey(UNICORN)) {
49 if (project.getPackaging().equals(excludePackaging)) {
52 buildState.saveResourceBuildData(moduleCoordinates);
53 if (project.getProperties().containsKey(SKIP_TEST_RUN) && !Boolean.valueOf(
54 project.getProperties().getProperty(SKIP_TEST_RUN))) {
55 if (!System.getProperties().containsKey("skipTests")) {
56 buildState.addResourceBuildTime(moduleCoordinates, System.currentTimeMillis());