summaryrefslogtreecommitdiffstats
path: root/openecomp-be/tools/compile-helper-plugin/src/main/java/org
diff options
context:
space:
mode:
authorvempo <vitaliy.emporopulo@amdocs.com>2018-11-06 18:41:14 +0200
committerOren Kleks <orenkle@amdocs.com>2018-11-07 07:17:04 +0000
commita706d714e2d0f308abe6fea01f091a1c5a1fe5ee (patch)
tree9b9725eecceb33f5a0350bb4e60d633810a5beb3 /openecomp-be/tools/compile-helper-plugin/src/main/java/org
parentfbb90d54a0630768c71b4b62dd5f88235f1c7537 (diff)
Removed compile-helper-plugin
Change-Id: I4d10879ac3195e25b8a2c97776c59241a25338a8 Issue-ID: SDC-1861 Signed-off-by: vempo <vitaliy.emporopulo@amdocs.com>
Diffstat (limited to 'openecomp-be/tools/compile-helper-plugin/src/main/java/org')
-rw-r--r--openecomp-be/tools/compile-helper-plugin/src/main/java/org/openecomp/sdc/onboarding/BuildHelper.java242
-rw-r--r--openecomp-be/tools/compile-helper-plugin/src/main/java/org/openecomp/sdc/onboarding/BuildState.java316
-rw-r--r--openecomp-be/tools/compile-helper-plugin/src/main/java/org/openecomp/sdc/onboarding/Constants.java75
-rw-r--r--openecomp-be/tools/compile-helper-plugin/src/main/java/org/openecomp/sdc/onboarding/InitializationHelperMojo.java70
-rw-r--r--openecomp-be/tools/compile-helper-plugin/src/main/java/org/openecomp/sdc/onboarding/PostCompileHelperMojo.java97
-rw-r--r--openecomp-be/tools/compile-helper-plugin/src/main/java/org/openecomp/sdc/onboarding/PostSourceGeneratorMojo.java61
-rw-r--r--openecomp-be/tools/compile-helper-plugin/src/main/java/org/openecomp/sdc/onboarding/PostTestRunHelperMojo.java62
-rw-r--r--openecomp-be/tools/compile-helper-plugin/src/main/java/org/openecomp/sdc/onboarding/PreCompileHelperMojo.java470
-rw-r--r--openecomp-be/tools/compile-helper-plugin/src/main/java/org/openecomp/sdc/onboarding/PreTestCompileHelperMojo.java88
9 files changed, 0 insertions, 1481 deletions
diff --git a/openecomp-be/tools/compile-helper-plugin/src/main/java/org/openecomp/sdc/onboarding/BuildHelper.java b/openecomp-be/tools/compile-helper-plugin/src/main/java/org/openecomp/sdc/onboarding/BuildHelper.java
deleted file mode 100644
index 8d1941169e..0000000000
--- a/openecomp-be/tools/compile-helper-plugin/src/main/java/org/openecomp/sdc/onboarding/BuildHelper.java
+++ /dev/null
@@ -1,242 +0,0 @@
-/*
- * Copyright © 2018 European Support Limited
- *
- * 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 a "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.openecomp.sdc.onboarding;
-
-import static org.openecomp.sdc.onboarding.Constants.CHECKSUM;
-import static org.openecomp.sdc.onboarding.Constants.COLON;
-import static org.openecomp.sdc.onboarding.Constants.DOT;
-import static org.openecomp.sdc.onboarding.Constants.JAR;
-import static org.openecomp.sdc.onboarding.Constants.JAVA_EXT;
-import static org.openecomp.sdc.onboarding.Constants.SHA1;
-import static org.openecomp.sdc.onboarding.Constants.UNICORN;
-
-import java.io.ByteArrayInputStream;
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.ObjectInputStream;
-import java.io.UncheckedIOException;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.nio.charset.StandardCharsets;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.security.MessageDigest;
-import java.security.NoSuchAlgorithmException;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Optional;
-import java.util.concurrent.ForkJoinPool;
-import java.util.concurrent.RecursiveTask;
-import java.util.jar.JarEntry;
-import java.util.jar.JarInputStream;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-import java.util.stream.Stream;
-import org.apache.maven.plugin.MojoFailureException;
-import org.apache.maven.project.MavenProject;
-
-class BuildHelper {
-
-
- private static final Map<String, String> STORE = new HashMap<>();
- private static final Logger LOG = Logger.getAnonymousLogger();
-
- private BuildHelper() {
- // do not remove.
- }
-
- static String getSnapshotSignature(File snapshotFile, String moduleCoordinate, String version) {
- String key = moduleCoordinate + ":" + version;
- String signature = STORE.get(key);
- if (signature != null) {
- return signature;
- }
- try {
- signature = new String(fetchSnapshotSignature(snapshotFile, version));
- if (version.equals(signature)) {
- signature = getSha1For(snapshotFile, Paths.get(snapshotFile.getParentFile().getAbsolutePath(),
- moduleCoordinate.substring(moduleCoordinate.indexOf(':') + 1) + "-" + version + DOT + JAR + DOT
- + SHA1).toFile());
- }
- STORE.put(key, signature);
- return signature;
- } catch (IOException | NoSuchAlgorithmException e) {
- LOG.log(Level.FINE, e.getMessage(), e);
- return version;
- }
-
- }
-
- private static String getSha1For(File file, File signatureFile) throws IOException, NoSuchAlgorithmException {
- if (signatureFile.exists()) {
- return new String(Files.readAllBytes(signatureFile.toPath()));
- }
- return getSourceChecksum(Files.readAllBytes(file.toPath()), SHA1);
- }
-
- static long getChecksum(File file, String fileType) {
- try {
- return readSources(file, fileType).hashCode();
- } catch (IOException e) {
- throw new UncheckedIOException(e);
- }
- }
-
- static String getSourceChecksum(String data, String hashType) throws NoSuchAlgorithmException {
- return getSourceChecksum(data.getBytes(), hashType);
- }
-
- static String getSourceChecksum(byte[] data, String hashType) throws NoSuchAlgorithmException {
- MessageDigest md = MessageDigest.getInstance(hashType);
- md.update(data);
- byte[] hashBytes = md.digest();
-
- StringBuilder buffer = new StringBuilder();
- for (byte hashByte : hashBytes) {
- buffer.append(Integer.toString((hashByte & 0xff) + 0x100, 16).substring(1));
- }
- return buffer.toString();
- }
-
-
- private static Map<String, List<String>> readSources(File file, String fileType) throws IOException {
- Map<String, List<String>> source = new HashMap<>();
-
- if (!file.exists()) {
- return source;
- }
-
- try (Stream<Path> pathStream = Files.walk(Paths.get(file.getAbsolutePath()))) {
- File[] selectedFiles = pathStream.filter(
- JAVA_EXT.equals(fileType) ? BuildHelper::isRegularJavaFile : Files::isRegularFile)
- .map(Path::toFile).toArray(File[]::new);
- source.putAll(ForkJoinPool.commonPool()
- .invoke(new FileReadTask(selectedFiles, file.getAbsolutePath())));
- return source;
- }
- }
-
- private static boolean isRegularJavaFile(Path path) {
- File file = path.toFile();
- return file.isFile() && file.getName().endsWith(JAVA_EXT);
- }
-
- private static class FileReadTask extends RecursiveTask<Map<String, List<String>>> {
-
- private final Map<String, List<String>> store = new HashMap<>();
- final File[] files;
- final String pathPrefix;
- private static final int MAX_FILES = 10;
-
- FileReadTask(File[] files, String pathPrefix) {
- this.files = files;
- this.pathPrefix = pathPrefix;
- }
-
- private static List<String> getData(File file) throws IOException {
- List<String> coll = Files.readAllLines(file.toPath(), StandardCharsets.ISO_8859_1);
- if (file.getAbsolutePath().contains(File.separator + "generated-sources" + File.separator)) {
- coll.removeIf(s -> s == null || s.trim().startsWith("/") || s.trim().startsWith("*"));
- }
- return coll;
- }
-
-
- @Override
- protected Map<String, List<String>> compute() {
- if (files.length > MAX_FILES) {
- FileReadTask task1 = new FileReadTask(Arrays.copyOfRange(files, 0, files.length / 2), pathPrefix);
- FileReadTask task2 =
- new FileReadTask(Arrays.copyOfRange(files, files.length / 2, files.length), pathPrefix);
- task1.fork();
- task2.fork();
- store.putAll(task1.join());
- store.putAll(task2.join());
- } else {
- for (File toRead : files) {
- try {
- store.put(toRead.getAbsolutePath().substring(pathPrefix.length())
- .replace(File.separatorChar, '.'), getData(toRead));
- } catch (IOException e) {
- throw new UncheckedIOException(e);
- }
- }
- }
-
- return store;
- }
- }
-
- static Optional<String> getArtifactPathInLocalRepo(String repoPath, MavenProject project, byte[] sourceChecksum)
- throws MojoFailureException {
- STORE.put(project.getGroupId() + COLON + project.getArtifactId() + COLON + project.getVersion(),
- new String(sourceChecksum));
- URI uri;
- try {
- uri = new URI(repoPath + (project.getGroupId().replace('.', '/')) + '/' + project.getArtifactId() + '/'
- + project.getVersion());
- } catch (URISyntaxException e) {
- throw new MojoFailureException(e.getMessage(), e);
- }
- File f = new File(uri);
- File[] list = f.listFiles(t -> t.getName().equals(project.getArtifactId() + "-" + project.getVersion() + "."
- + project.getPackaging()));
- if (list != null && list.length > 0) {
- try {
- if (Arrays.equals(sourceChecksum, fetchSnapshotSignature(list[0], project.getVersion()))) {
- return Optional.of(list[0].getAbsolutePath());
- }
- } catch (IOException e) {
- throw new UncheckedIOException(e);
- }
- }
- return Optional.empty();
- }
-
- private static byte[] fetchSnapshotSignature(File file, String version) throws IOException {
-
- byte[] data = Files.readAllBytes(file.toPath());
- try (ByteArrayInputStream byteInputStream = new ByteArrayInputStream(data);
- JarInputStream jarInputStream = new JarInputStream(byteInputStream)) {
-
- JarEntry entry;
- while ((entry = jarInputStream.getNextJarEntry()) != null) {
- if (entry.getName().endsWith(UNICORN + DOT + CHECKSUM)) {
- byte[] sigStore = new byte[1024];
- return new String(sigStore, 0, jarInputStream.read(sigStore, 0, 1024)).getBytes();
- }
- }
- }
- return version.getBytes();
- }
-
- static <T> Optional<T> readState(String fileName, Class<T> clazz) {
-
- try (InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream(fileName);
- ObjectInputStream ois = new ObjectInputStream(is)) {
- return Optional.of(clazz.cast(ois.readObject()));
- } catch (Exception e) {
- LOG.log(Level.FINE, e.getMessage(), e);
- return Optional.empty();
- }
- }
-
-}
diff --git a/openecomp-be/tools/compile-helper-plugin/src/main/java/org/openecomp/sdc/onboarding/BuildState.java b/openecomp-be/tools/compile-helper-plugin/src/main/java/org/openecomp/sdc/onboarding/BuildState.java
deleted file mode 100644
index 89adf203b5..0000000000
--- a/openecomp-be/tools/compile-helper-plugin/src/main/java/org/openecomp/sdc/onboarding/BuildState.java
+++ /dev/null
@@ -1,316 +0,0 @@
-/*
- * Copyright © 2018 European Support Limited
- *
- * 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 a "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.openecomp.sdc.onboarding;
-
-import static org.openecomp.sdc.onboarding.BuildHelper.readState;
-import static org.openecomp.sdc.onboarding.Constants.ANSI_COLOR_RESET;
-import static org.openecomp.sdc.onboarding.Constants.ANSI_YELLOW;
-import static org.openecomp.sdc.onboarding.Constants.FULL_BUILD_DATA;
-import static org.openecomp.sdc.onboarding.Constants.FULL_RESOURCE_BUILD_DATA;
-import static org.openecomp.sdc.onboarding.Constants.JAR;
-import static org.openecomp.sdc.onboarding.Constants.RESOURCES_CHANGED;
-import static org.openecomp.sdc.onboarding.Constants.SKIP_MAIN_SOURCE_COMPILE;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.nio.file.Paths;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Optional;
-import java.util.Set;
-import java.util.function.Function;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-import org.apache.maven.artifact.Artifact;
-import org.apache.maven.project.MavenProject;
-
-public class BuildState {
-
- private static final String SHUTDOWN_TIME = "shutdownTime";
- private static final String VERSION = "version";
-
- private static HashMap<String, Map> compileDataStore = new HashMap<>();
- private static final Map<String, Object> MODULE_BUILD_DATA = new HashMap<>();
- private static final Map<String, Object> RESOURCE_BUILD_DATA = new HashMap<>();
- private static final Map<String, Artifact> ARTIFACTS = new HashMap<>();
- private static final Set<String> EXECUTE_TESTS_IF_DEPENDS_ON_STORE = new HashSet<>();
- private static final Set<String> PMD_EXECUTED_IN_RUN = new HashSet<>();
- private static File stateFileLocation =
- new File(Paths.get(System.getProperties().getProperty("java.io.tmpdir")).toFile(), "compileState.dat");
-
- private static File compileStateFile;
- private static final Logger LOG = Logger.getAnonymousLogger();
- private MavenProject project;
- private String compileStateFilePath;
-
- static {
- initializeStore();
- Optional<HashMap> masterStore = readState("compile.dat", HashMap.class);
- //noinspection unchecked
- compileDataStore = (HashMap) masterStore.orElseGet(() -> compileDataStore);
- String version = String.class.cast(compileDataStore.get(VERSION));
- if (version != null) {
- stateFileLocation = new File(Paths.get(System.getProperties().getProperty("java.io.tmpdir")).toFile(),
- "compileState.dat-" + version);
- }
- if (stateFileLocation.exists()) {
- HashMap dat = loadState(stateFileLocation);
- if (swapStates(compileDataStore, dat)) {
- compileDataStore = dat;
- }
- }
- }
-
-
- void init() {
- ARTIFACTS.clear();
- for (Artifact artifact : project.getArtifacts()) {
- if (artifact.isSnapshot() && JAR.equals(artifact.getType())) {
- ARTIFACTS.put(artifact.getGroupId() + ":" + artifact.getArtifactId(), artifact);
- }
- }
- if (compileStateFile == null) {
- setCompileStateFile(
- getCompileStateFile(compileStateFilePath.substring(0, compileStateFilePath.indexOf('/')), project));
- }
- }
-
- private static void setCompileStateFile(File file) {
- compileStateFile = file;
- }
-
- static void initializeStore() {
- compileDataStore.put(Constants.FULL_BUILD_DATA, new HashMap<>());
- compileDataStore.put(Constants.FULL_RESOURCE_BUILD_DATA, new HashMap<>());
- compileDataStore.put(Constants.MODULE_BUILD_DATA, new HashMap<>());
- compileDataStore.put(Constants.RESOURCE_BUILD_DATA, new HashMap<>());
- }
-
-
- static void recordPMDRun(String moduleCoordinates) {
- PMD_EXECUTED_IN_RUN.add(moduleCoordinates);
- }
-
- static boolean isPMDRun(String moduleCoordinates) {
- return PMD_EXECUTED_IN_RUN.contains(moduleCoordinates);
- }
-
- private void writeCompileState() throws IOException {
- writeState(compileStateFile, compileDataStore);
- }
-
- private void writeState(File file, HashMap store) throws IOException {
- try (FileOutputStream fos = new FileOutputStream(file); ObjectOutputStream oos = new ObjectOutputStream(fos)) {
- oos.writeObject(store);
- }
- }
-
-
- private File getCompileStateFile(String moduleCoordinate, MavenProject mavenProject) {
- return getStateFile(moduleCoordinate, mavenProject, compileStateFilePath);
- }
-
-
- private File getStateFile(String moduleCoordinate, MavenProject mavenProject, String filePath) {
- return new File(getTopParentProject(moduleCoordinate, mavenProject).getBasedir(),
- filePath.substring(filePath.indexOf('/') + 1));
- }
-
- MavenProject getTopParentProject(String moduleCoordinate, MavenProject mavenProject) {
- if (getModuleCoordinate(mavenProject).equals(moduleCoordinate) || mavenProject.getParent() == null) {
- return mavenProject;
- } else {
- return getTopParentProject(moduleCoordinate, mavenProject.getParent());
- }
- }
-
- private String getModuleCoordinate(MavenProject project) {
- return project.getGroupId() + ":" + project.getArtifactId();
- }
-
- void addModuleBuildTime(String moduleCoordinates, Long buildTime) {
- Map fullBuildData = compileDataStore.get(FULL_BUILD_DATA);
- @SuppressWarnings("unchecked") Long lastTime = (Long) fullBuildData.put(moduleCoordinates, buildTime);
- try {
- if (lastTime == null || !lastTime.equals(buildTime)) {
- boolean skipMainCompile = project.getProperties().containsKey(SKIP_MAIN_SOURCE_COMPILE);
- if (!skipMainCompile) {
- writeCompileState();
- }
- }
- } catch (IOException e) {
- LOG.log(Level.FINE, e.getMessage(), e);
- }
- }
-
- void addResourceBuildTime(String moduleCoordinates, Long buildTime) {
- Map fullResourceBuildData = compileDataStore.get(FULL_RESOURCE_BUILD_DATA);
- if (project.getProperties().containsKey(RESOURCES_CHANGED)
- || fullResourceBuildData.get(moduleCoordinates) == null) {
- try {
- //noinspection unchecked
- fullResourceBuildData.put(moduleCoordinates, buildTime);
- writeCompileState();
- } catch (IOException e) {
- LOG.log(Level.FINE, e.getMessage(), e);
- }
- }
- }
-
- void addModuleBuildData(String moduleCoordinates, Map moduleBuildDependencies) {
- MODULE_BUILD_DATA.put(moduleCoordinates, moduleBuildDependencies);
- }
-
- HashMap readModuleBuildData() {
- return (HashMap) compileDataStore.get(Constants.MODULE_BUILD_DATA).get(getModuleCoordinate(project));
- }
-
- void saveModuleBuildData(String moduleCoordinate) {
- if (MODULE_BUILD_DATA.get(moduleCoordinate) != null) {
- Map buildData = compileDataStore.get(Constants.MODULE_BUILD_DATA);
- //noinspection unchecked
- buildData.put(moduleCoordinate, MODULE_BUILD_DATA.get(moduleCoordinate));
- }
- saveCompileData();
- }
-
- void saveResourceBuildData(String moduleCoordinate) {
- if (RESOURCE_BUILD_DATA.get(moduleCoordinate) != null) {
- Map buildData = compileDataStore.get(Constants.RESOURCE_BUILD_DATA);
- //noinspection unchecked
- buildData.put(moduleCoordinate, RESOURCE_BUILD_DATA.get(moduleCoordinate));
- }
- saveCompileData();
- }
-
- void saveCompileData() {
- saveBuildData(compileStateFile, compileDataStore);
- }
-
- void markTestsMandatoryModule(String moduleCoordinates) {
- EXECUTE_TESTS_IF_DEPENDS_ON_STORE.add(moduleCoordinates);
- }
-
- private void saveBuildData(File file, Object dataToSave) {
- file.getParentFile().mkdirs();
- if (dataToSave != null) {
- try (FileOutputStream fos = new FileOutputStream(file);
- ObjectOutputStream ois = new ObjectOutputStream(fos)) {
- ois.writeObject(dataToSave);
- } catch (IOException e) {
- LOG.log(Level.FINE, e.getMessage(), e);
- }
- }
- }
-
- HashMap readResourceBuildData() {
- return (HashMap) compileDataStore.get(Constants.RESOURCE_BUILD_DATA).get(getModuleCoordinate(project));
- }
-
-
- void addResourceBuildData(String moduleCoordinates, Map currentModuleResourceBuildData) {
- RESOURCE_BUILD_DATA.put(moduleCoordinates, currentModuleResourceBuildData);
- }
-
- Long getBuildTime(String moduleCoordinates) {
- Long buildTime = (Long) compileDataStore.get(FULL_BUILD_DATA).get(moduleCoordinates);
- return buildTime == null ? 0 : buildTime;
- }
-
- Long getResourceBuildTime(String moduleCoordinates) {
- Long resourceBuildTime = (Long) compileDataStore.get(FULL_RESOURCE_BUILD_DATA).get(moduleCoordinates);
- return resourceBuildTime == null ? 0 : resourceBuildTime;
- }
-
- boolean isCompileMust(String moduleCoordinates, Collection<String> dependencies) {
- for (String d : dependencies) {
- if (ARTIFACTS.containsKey(d) && JAR.equals(ARTIFACTS.get(d).getType())) {
- boolean versionEqual = ARTIFACTS.get(d).getVersion().equals(project.getVersion());
- if (versionEqual && getBuildTime(d) == 0) {
- LOG.warning(ANSI_YELLOW + "[WARNING:]" + "You have module[" + d
- + "] not locally compiled even once, please compile your project once daily "
- + "from root to have reliable build results."
- + ANSI_COLOR_RESET);
- return true;
- }
- }
- }
- return isMust(this::getBuildTime, moduleCoordinates, dependencies);
- }
-
- boolean isTestExecutionMandatory() {
- for (String d : ARTIFACTS.keySet()) {
- if (EXECUTE_TESTS_IF_DEPENDS_ON_STORE.contains(d)) {
- return true;
- }
- }
- return false;
- }
-
- boolean isTestMust(String moduleCoordinates) {
- return getBuildTime(moduleCoordinates) > getResourceBuildTime(moduleCoordinates) || isMust(
- this::getResourceBuildTime, moduleCoordinates, ARTIFACTS.keySet());
- }
-
- private boolean isMust(Function<String, Long> function, String moduleCoordinates, Collection<String> dependencies) {
- Long time = function.apply(moduleCoordinates);
- if (time == null || time == 0) {
- return true;
- }
- for (String module : dependencies) {
- Long buildTime = function.apply(module);
- if (buildTime >= time) {
- return true;
- }
- }
- return false;
- }
-
- private static HashMap loadState(File file) {
- try (InputStream is = new FileInputStream(file); ObjectInputStream ois = new ObjectInputStream(is)) {
- return (HashMap) ois.readObject();
- } catch (Exception e) {
- LOG.log(Level.FINE, e.getMessage(), e);
- return new HashMap<>();
- }
- }
-
- private static boolean swapStates(HashMap repo, HashMap last) {
- long repoTime = repo.get(SHUTDOWN_TIME) == null ? 0 : (Long) repo.get(SHUTDOWN_TIME);
- long lastTime = last.get(SHUTDOWN_TIME) == null ? 0 : (Long) last.get(SHUTDOWN_TIME);
- String repoVersion = repo.get(VERSION) == null ? "" : (String) repo.get(VERSION);
- String lastVersion = last.get(VERSION) == null ? "" : (String) last.get(VERSION);
- long repoBuildNumber = repoTime % 1000;
- long lastBuildNumber = lastTime % 1000;
- if (repoBuildNumber != lastBuildNumber) {
- return false;
- }
- if (!repoVersion.equals(lastVersion)) {
- return false;
- }
- return repoTime < lastTime;
- }
-
-
-}
diff --git a/openecomp-be/tools/compile-helper-plugin/src/main/java/org/openecomp/sdc/onboarding/Constants.java b/openecomp-be/tools/compile-helper-plugin/src/main/java/org/openecomp/sdc/onboarding/Constants.java
deleted file mode 100644
index c6603a7497..0000000000
--- a/openecomp-be/tools/compile-helper-plugin/src/main/java/org/openecomp/sdc/onboarding/Constants.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Copyright © 2018 European Support Limited
- *
- * 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 a "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.openecomp.sdc.onboarding;
-
-public class Constants {
-
-
- public static final String UNICORN = "unicorn";
- public static final String EMPTY_STRING = "";
- public static final String JACOCO_SKIP = "jacoco.skip";
- public static final String JACOCO_BUILD = Boolean.toString(
- System.getProperties().containsKey(JACOCO_SKIP) && Boolean.FALSE.equals(Boolean.valueOf(
- System.getProperties().getProperty(JACOCO_SKIP))));
- public static final String JACOCO = Boolean.valueOf(JACOCO_BUILD) ? UNICORN : EMPTY_STRING;
- public static final String PREFIX = System.getProperties().contains(UNICORN) ? EMPTY_STRING : UNICORN;
- public static final String FORK_COUNT = "fork.count";
- public static final String FORK_MODE = "fork.mode";
- public static final String SKIP_PMD = "skipPMD";
- public static final String JAVA_EXT = ".java";
- public static final String ANY_EXT = "*";
- public static final String SKIP_TEST_RUN = PREFIX + JACOCO + "skipTestRun";
- public static final String SKIP_TESTS = "skipTests";
- public static final String MAIN = "main";
- public static final String TEST = "test";
- public static final String RESOURCES_CHANGED = "resourcesChanged";
- public static final String ANSI_YELLOW = "\u001B[43m";
- public static final String ANSI_COLOR_RESET = "\u001B[0m";
- public static final String SKIP_MAIN_SOURCE_COMPILE = PREFIX + JACOCO + "skipMainSourceCompile";
- public static final String SKIP_TEST_SOURCE_COMPILE = PREFIX + JACOCO + "skipTestSourceCompile";
- public static final String MAIN_CHECKSUM = "mainChecksum";
- public static final String CHECKSUM = "checksum";
- public static final String TEST_CHECKSUM = "testChecksum";
- public static final String RESOURCE_CHECKSUM = "resourceChecksum";
- public static final String TEST_RESOURCE_CHECKSUM = "testResourceChecksum";
- public static final String MAIN_SOURCE_CHECKSUM = "mainSourceChecksum";
- public static final String TEST_SOURCE_CHECKSUM = "testSourceChecksum";
- public static final String GENERATED_SOURCE_CHECKSUM = "generatedSourceChecksum";
- public static final String EMPTY_JAR = "emptyJAR";
- public static final String JAR = "jar";
- public static final String SHA1 = "sha1";
- public static final String COLON = ":";
- public static final String DOT = ".";
- public static final String FULL_BUILD_DATA = "fullBuildData";
- public static final String FULL_RESOURCE_BUILD_DATA = "fullResourceBuildData";
- public static final String MODULE_BUILD_DATA = "moduleBuildData";
- public static final String RESOURCE_BUILD_DATA = "resourceBuildData";
- public static final String RESOURCE_ONLY = "resourceOnly";
- public static final String TEST_RESOURCE_ONLY = "testResourceOnly";
- public static final String INSTRUMENT_WITH_TEST_ONLY = "instrumentWithTestOnly";
- public static final String RESOURCE_WITH_TEST_ONLY = "resourceWithTestOnly";
- public static final String INSTRUMENT_ONLY = "instrumentOnly";
- public static final String TEST_ONLY = "testOnly";
- public static final String SKIP_RESOURCE_COLLECTION = PREFIX + JACOCO + "skipResourceCollection";
- public static final String SKIP_INSTALL = PREFIX + JACOCO + "skipInstall";
-
-
- private Constants() {
- }
-
-
-}
diff --git a/openecomp-be/tools/compile-helper-plugin/src/main/java/org/openecomp/sdc/onboarding/InitializationHelperMojo.java b/openecomp-be/tools/compile-helper-plugin/src/main/java/org/openecomp/sdc/onboarding/InitializationHelperMojo.java
deleted file mode 100644
index 2bc22dce49..0000000000
--- a/openecomp-be/tools/compile-helper-plugin/src/main/java/org/openecomp/sdc/onboarding/InitializationHelperMojo.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Copyright © 2018 European Support Limited
- *
- * 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 a "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.openecomp.sdc.onboarding;
-
-import org.apache.maven.plugin.AbstractMojo;
-import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.plugin.MojoFailureException;
-import org.apache.maven.plugins.annotations.LifecyclePhase;
-import org.apache.maven.plugins.annotations.Mojo;
-import org.apache.maven.plugins.annotations.Parameter;
-import org.apache.maven.plugins.annotations.ResolutionScope;
-import org.apache.maven.project.MavenProject;
-
-import static org.openecomp.sdc.onboarding.Constants.*;
-
-@Mojo(name = "init-helper", threadSafe = true, defaultPhase = LifecyclePhase.GENERATE_RESOURCES,
- requiresDependencyResolution = ResolutionScope.TEST)
-public class InitializationHelperMojo extends AbstractMojo {
-
- @Parameter(defaultValue = "${project}", readonly = true)
- private MavenProject project;
- @Parameter
- private BuildState buildState;
- @Parameter
- private String excludePackaging;
-
- @Override
- public void execute() throws MojoExecutionException, MojoFailureException {
- if (PREFIX == UNICORN || JACOCO == UNICORN) {
- System.getProperties().setProperty(UNICORN, Boolean.TRUE.toString());
- }
- if (project.getPackaging().equals(excludePackaging)) {
- return;
- }
- if (Boolean.valueOf(JACOCO_BUILD)) {
- project.getProperties().setProperty(FORK_COUNT, "1");
- project.getProperties().setProperty(FORK_MODE, "once");
- } else {
- project.getProperties().setProperty(FORK_COUNT, "0");
- project.getProperties().setProperty(FORK_MODE, "never");
- }
-
- project.getProperties().setProperty(SKIP_PMD, Boolean.TRUE.toString());
-
- if (System.getProperties().containsKey(UNICORN)) {
- buildState.init();
- } else {
- project.getProperties().setProperty("skipMainSourceCompile", Boolean.FALSE.toString());
- project.getProperties().setProperty("skipTestSourceCompile", Boolean.FALSE.toString());
- }
-
-
- }
-
-
-}
diff --git a/openecomp-be/tools/compile-helper-plugin/src/main/java/org/openecomp/sdc/onboarding/PostCompileHelperMojo.java b/openecomp-be/tools/compile-helper-plugin/src/main/java/org/openecomp/sdc/onboarding/PostCompileHelperMojo.java
deleted file mode 100644
index a00e900b9a..0000000000
--- a/openecomp-be/tools/compile-helper-plugin/src/main/java/org/openecomp/sdc/onboarding/PostCompileHelperMojo.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * Copyright © 2018 European Support Limited
- *
- * 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 a "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.openecomp.sdc.onboarding;
-
-import org.apache.maven.plugin.AbstractMojo;
-import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.plugins.annotations.LifecyclePhase;
-import org.apache.maven.plugins.annotations.Mojo;
-import org.apache.maven.plugins.annotations.Parameter;
-import org.apache.maven.plugins.annotations.ResolutionScope;
-import org.apache.maven.project.MavenProject;
-
-import java.io.File;
-
-import static org.openecomp.sdc.onboarding.Constants.*;
-
-@Mojo(name = "post-compile-helper", threadSafe = true, defaultPhase = LifecyclePhase.TEST_COMPILE,
- requiresDependencyResolution = ResolutionScope.TEST)
-public class PostCompileHelperMojo extends AbstractMojo {
-
- @Parameter(defaultValue = "${project}", readonly = true)
- private MavenProject project;
- @Parameter(defaultValue = "${project.artifact.groupId}:${project.artifact.artifactId}")
- private String moduleCoordinates;
- @Parameter
- private String excludePackaging;
- @Parameter
- private BuildState buildState;
- @Parameter
- private File mainResourceLocation;
- @Parameter
- private File testResourceLocation;
-
-
- public void execute() throws MojoExecutionException {
- if (!System.getProperties().containsKey(UNICORN)) {
- return;
- }
- if (project.getPackaging().equals(excludePackaging)) {
- return;
- }
- if (project.getProperties().containsKey(TEST_ONLY)) {
- project.getProperties().setProperty(SKIP_MAIN_SOURCE_COMPILE, Boolean.TRUE.toString());
- project.getProperties().remove(TEST_ONLY);
- }
- postProcessInstrumentedModules();
-
- if (project.getProperties().containsKey(RESOURCE_WITH_TEST_ONLY)) {
- project.getProperties().setProperty(SKIP_MAIN_SOURCE_COMPILE, Boolean.TRUE.toString());
- project.getProperties().remove(RESOURCE_WITH_TEST_ONLY);
- }
- if (project.getProperties().containsKey(RESOURCE_ONLY)) {
- project.getProperties().setProperty(SKIP_MAIN_SOURCE_COMPILE, Boolean.TRUE.toString());
- project.getProperties().setProperty(SKIP_TEST_SOURCE_COMPILE, Boolean.TRUE.toString());
- project.getProperties().remove(RESOURCE_ONLY);
- }
- if (project.getProperties().containsKey(TEST_RESOURCE_ONLY)) {
- project.getProperties().setProperty(SKIP_MAIN_SOURCE_COMPILE, Boolean.TRUE.toString());
- project.getProperties().setProperty(SKIP_TEST_SOURCE_COMPILE, Boolean.TRUE.toString());
- project.getProperties().remove(TEST_RESOURCE_ONLY);
- }
- if (!project.getProperties().containsKey(SKIP_MAIN_SOURCE_COMPILE)) {
- buildState.addModuleBuildTime(moduleCoordinates, System.currentTimeMillis());
- project.getProperties().setProperty(SKIP_PMD, Boolean.FALSE.toString());
- }
- if (!project.getProperties().containsKey(SKIP_TEST_SOURCE_COMPILE)) {
- project.getProperties().setProperty(SKIP_PMD, Boolean.FALSE.toString());
- }
- buildState.saveModuleBuildData(moduleCoordinates);
- }
-
- private void postProcessInstrumentedModules() {
- if (project.getProperties().containsKey(INSTRUMENT_ONLY)) {
- project.getProperties().setProperty(SKIP_MAIN_SOURCE_COMPILE, Boolean.TRUE.toString());
- project.getProperties().setProperty(SKIP_TEST_SOURCE_COMPILE, Boolean.TRUE.toString());
- project.getProperties().remove(INSTRUMENT_ONLY);
- }
- if (project.getProperties().containsKey(INSTRUMENT_WITH_TEST_ONLY)) {
- project.getProperties().setProperty(SKIP_MAIN_SOURCE_COMPILE, Boolean.TRUE.toString());
- project.getProperties().remove(INSTRUMENT_WITH_TEST_ONLY);
- }
- }
-}
diff --git a/openecomp-be/tools/compile-helper-plugin/src/main/java/org/openecomp/sdc/onboarding/PostSourceGeneratorMojo.java b/openecomp-be/tools/compile-helper-plugin/src/main/java/org/openecomp/sdc/onboarding/PostSourceGeneratorMojo.java
deleted file mode 100644
index 2aa6cc5df7..0000000000
--- a/openecomp-be/tools/compile-helper-plugin/src/main/java/org/openecomp/sdc/onboarding/PostSourceGeneratorMojo.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Copyright © 2018 European Support Limited
- *
- * 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 a "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.openecomp.sdc.onboarding;
-
-import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.plugin.MojoFailureException;
-import org.apache.maven.plugins.annotations.LifecyclePhase;
-import org.apache.maven.plugins.annotations.Mojo;
-import org.apache.maven.plugins.annotations.ResolutionScope;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.UncheckedIOException;
-import java.nio.file.Files;
-import java.nio.file.Paths;
-import java.util.List;
-import java.util.stream.Collectors;
-
-
-@Mojo(name = "post-source-generator-helper", threadSafe = true, defaultPhase = LifecyclePhase.GENERATE_RESOURCES,
- requiresDependencyResolution = ResolutionScope.TEST)
-public class PostSourceGeneratorMojo extends PreCompileHelperMojo {
-
- public void execute() throws MojoExecutionException, MojoFailureException {
- if (isCodeGenerator()) {
- super.execute();
- }
- }
-
- // @Override
- void deleteAllClasses(File file) {
- if (!file.exists()) {
- return;
- }
- try {
- List<File> list =
- Files.walk(Paths.get(file.getAbsolutePath())).filter(Files::isRegularFile).map(p -> p.toFile())
- .collect(Collectors.toList());
- for (File f : list) {
- f.delete();
- }
- } catch (IOException e) {
- throw new UncheckedIOException(e);
- }
-
- }
-}
diff --git a/openecomp-be/tools/compile-helper-plugin/src/main/java/org/openecomp/sdc/onboarding/PostTestRunHelperMojo.java b/openecomp-be/tools/compile-helper-plugin/src/main/java/org/openecomp/sdc/onboarding/PostTestRunHelperMojo.java
deleted file mode 100644
index 1291266e21..0000000000
--- a/openecomp-be/tools/compile-helper-plugin/src/main/java/org/openecomp/sdc/onboarding/PostTestRunHelperMojo.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Copyright © 2018 European Support Limited
- *
- * 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 a "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.openecomp.sdc.onboarding;
-
-import org.apache.maven.plugin.AbstractMojo;
-import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.plugin.MojoFailureException;
-import org.apache.maven.plugins.annotations.LifecyclePhase;
-import org.apache.maven.plugins.annotations.Mojo;
-import org.apache.maven.plugins.annotations.Parameter;
-import org.apache.maven.plugins.annotations.ResolutionScope;
-import org.apache.maven.project.MavenProject;
-
-import static org.openecomp.sdc.onboarding.Constants.*;
-
-@Mojo(name = "post-test-run-helper", threadSafe = true, defaultPhase = LifecyclePhase.TEST,
- requiresDependencyResolution = ResolutionScope.NONE)
-public class PostTestRunHelperMojo extends AbstractMojo {
-
- @Parameter
- private BuildState buildState;
- @Parameter(defaultValue = "${project.artifact.groupId}:${project.artifact.artifactId}")
- private String moduleCoordinates;
- @Parameter(defaultValue = "${project}", readonly = true)
- private MavenProject project;
- @Parameter
- private String excludePackaging;
-
-
- public void execute() throws MojoExecutionException, MojoFailureException {
- if (!System.getProperties().containsKey(UNICORN)) {
- return;
- }
- if (project.getPackaging().equals(excludePackaging)) {
- return;
- }
-
- if (project.getProperties().containsKey(SKIP_TEST_RUN) && !Boolean.valueOf(
- project.getProperties().getProperty(SKIP_TEST_RUN))) {
- if (!System.getProperties().containsKey(SKIP_TESTS)) {
- buildState.saveResourceBuildData(moduleCoordinates);
- buildState.addResourceBuildTime(moduleCoordinates, System.currentTimeMillis());
-
- }
- }
-
- }
-}
diff --git a/openecomp-be/tools/compile-helper-plugin/src/main/java/org/openecomp/sdc/onboarding/PreCompileHelperMojo.java b/openecomp-be/tools/compile-helper-plugin/src/main/java/org/openecomp/sdc/onboarding/PreCompileHelperMojo.java
deleted file mode 100644
index 29503b9f48..0000000000
--- a/openecomp-be/tools/compile-helper-plugin/src/main/java/org/openecomp/sdc/onboarding/PreCompileHelperMojo.java
+++ /dev/null
@@ -1,470 +0,0 @@
-/*
- * Copyright © 2018 European Support Limited
- *
- * 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 a "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.openecomp.sdc.onboarding;
-
-import static org.openecomp.sdc.onboarding.BuildHelper.getArtifactPathInLocalRepo;
-import static org.openecomp.sdc.onboarding.BuildHelper.getChecksum;
-import static org.openecomp.sdc.onboarding.BuildHelper.getSnapshotSignature;
-import static org.openecomp.sdc.onboarding.BuildHelper.getSourceChecksum;
-import static org.openecomp.sdc.onboarding.BuildHelper.readState;
-import static org.openecomp.sdc.onboarding.Constants.ANY_EXT;
-import static org.openecomp.sdc.onboarding.Constants.CHECKSUM;
-import static org.openecomp.sdc.onboarding.Constants.COLON;
-import static org.openecomp.sdc.onboarding.Constants.DOT;
-import static org.openecomp.sdc.onboarding.Constants.EMPTY_JAR;
-import static org.openecomp.sdc.onboarding.Constants.GENERATED_SOURCE_CHECKSUM;
-import static org.openecomp.sdc.onboarding.Constants.INSTRUMENT_ONLY;
-import static org.openecomp.sdc.onboarding.Constants.INSTRUMENT_WITH_TEST_ONLY;
-import static org.openecomp.sdc.onboarding.Constants.JAR;
-import static org.openecomp.sdc.onboarding.Constants.JAVA_EXT;
-import static org.openecomp.sdc.onboarding.Constants.MAIN;
-import static org.openecomp.sdc.onboarding.Constants.MAIN_CHECKSUM;
-import static org.openecomp.sdc.onboarding.Constants.MAIN_SOURCE_CHECKSUM;
-import static org.openecomp.sdc.onboarding.Constants.PREFIX;
-import static org.openecomp.sdc.onboarding.Constants.RESOURCES_CHANGED;
-import static org.openecomp.sdc.onboarding.Constants.RESOURCE_CHECKSUM;
-import static org.openecomp.sdc.onboarding.Constants.RESOURCE_ONLY;
-import static org.openecomp.sdc.onboarding.Constants.RESOURCE_WITH_TEST_ONLY;
-import static org.openecomp.sdc.onboarding.Constants.SHA1;
-import static org.openecomp.sdc.onboarding.Constants.SKIP_INSTALL;
-import static org.openecomp.sdc.onboarding.Constants.SKIP_MAIN_SOURCE_COMPILE;
-import static org.openecomp.sdc.onboarding.Constants.SKIP_PMD;
-import static org.openecomp.sdc.onboarding.Constants.SKIP_RESOURCE_COLLECTION;
-import static org.openecomp.sdc.onboarding.Constants.SKIP_TEST_RUN;
-import static org.openecomp.sdc.onboarding.Constants.SKIP_TEST_SOURCE_COMPILE;
-import static org.openecomp.sdc.onboarding.Constants.TEST;
-import static org.openecomp.sdc.onboarding.Constants.TEST_CHECKSUM;
-import static org.openecomp.sdc.onboarding.Constants.TEST_ONLY;
-import static org.openecomp.sdc.onboarding.Constants.TEST_RESOURCE_CHECKSUM;
-import static org.openecomp.sdc.onboarding.Constants.TEST_RESOURCE_ONLY;
-import static org.openecomp.sdc.onboarding.Constants.TEST_SOURCE_CHECKSUM;
-import static org.openecomp.sdc.onboarding.Constants.UNICORN;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.UncheckedIOException;
-import java.nio.file.Files;
-import java.nio.file.Paths;
-import java.nio.file.StandardOpenOption;
-import java.security.NoSuchAlgorithmException;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Optional;
-import java.util.Set;
-
-import org.apache.maven.artifact.Artifact;
-import org.apache.maven.execution.MavenSession;
-import org.apache.maven.model.Plugin;
-import org.apache.maven.model.PluginExecution;
-import org.apache.maven.plugin.AbstractMojo;
-import org.apache.maven.plugin.InvalidPluginDescriptorException;
-import org.apache.maven.plugin.MavenPluginManager;
-import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.plugin.MojoFailureException;
-import org.apache.maven.plugin.MojoNotFoundException;
-import org.apache.maven.plugin.PluginDescriptorParsingException;
-import org.apache.maven.plugin.PluginResolutionException;
-import org.apache.maven.plugin.descriptor.MojoDescriptor;
-import org.apache.maven.plugins.annotations.Component;
-import org.apache.maven.plugins.annotations.LifecyclePhase;
-import org.apache.maven.plugins.annotations.Mojo;
-import org.apache.maven.plugins.annotations.Parameter;
-import org.apache.maven.plugins.annotations.ResolutionScope;
-import org.apache.maven.project.MavenProject;
-
-
-@Mojo(name = "pre-compile-helper", threadSafe = true, defaultPhase = LifecyclePhase.GENERATE_RESOURCES,
- requiresDependencyResolution = ResolutionScope.TEST)
-public class PreCompileHelperMojo extends AbstractMojo {
-
- @Parameter(defaultValue = "${project}")
- private MavenProject project;
- @Parameter(defaultValue = "${project.artifact.groupId}:${project.artifact.artifactId}")
- private String moduleCoordinates;
- @Parameter(defaultValue = "${session}")
- private MavenSession session;
- @Parameter
- private String excludePackaging;
- @Parameter
- private List<String> excludeDependencies;
- @Parameter
- private BuildState buildState;
- @Parameter
- private File mainSourceLocation;
- @Parameter
- private File testSourceLocation;
- @Parameter
- private File generatedSourceLocation;
- @Component
- private MavenPluginManager pluginManager;
- @Parameter
- private File mainResourceLocation;
- @Parameter
- private File testResourceLocation;
- private Map<String, Object> resourceBuildData;
-
- private static Map<String, String> checksumMap;
- private long mainChecksum = 0;
- private long testChecksum = 0;
- private long resourceChecksum = 0;
- private long testResourceChecksum = 0;
- Optional<String> artifactPath;
-
- static {
- checksumMap = readCurrentPMDState("pmd.dat");
- }
-
- public void execute() throws MojoExecutionException, MojoFailureException {
-
-
- if (project.getPackaging().equals(excludePackaging)) {
- return;
- }
- init();
- processPMDCheck();
- project.getProperties().setProperty(EMPTY_JAR, "");
- if (!System.getProperties().containsKey(UNICORN)) {
- return;
- }
- resourceChecksum = getChecksum(mainResourceLocation, ANY_EXT);
- testResourceChecksum = getChecksum(testResourceLocation, ANY_EXT);
- project.getProperties().setProperty(RESOURCE_CHECKSUM, String.valueOf(resourceChecksum));
- project.getProperties().setProperty(TEST_RESOURCE_CHECKSUM, String.valueOf(testResourceChecksum));
- byte[] sourceChecksum = calculateChecksum(mainChecksum, resourceChecksum).getBytes();
- artifactPath = getArtifactPathInLocalRepo(session.getLocalRepository().getUrl(), project, sourceChecksum);
-
- boolean isFirstBuild = buildState.getBuildTime(moduleCoordinates) == 0 || !artifactPath.isPresent();
-
- Map<String, Object> moduleBuildData = getCurrentModuleBuildData();
- Map<String, Object> lastTimeModuleBuildData = buildState.readModuleBuildData();
- resourceBuildData = getCurrentResourceBuildData();
- Map<String, Object> lastTimeResourceBuildData = buildState.readResourceBuildData();
- generateSyncAlert(lastTimeResourceBuildData != null && (
- !resourceBuildData.get(MAIN).equals(lastTimeResourceBuildData.get(MAIN)) || !resourceBuildData.get(TEST)
- .equals(lastTimeResourceBuildData
- .get(TEST)
- .toString())));
- boolean buildDataSameWithPreviousBuild =
- isBuildDataSameWithPreviousBuild(lastTimeModuleBuildData, moduleBuildData);
- boolean resourceMainBuildDataSameWithPreviousBuild =
- isResourceMainBuildDataSameWithPreviousBuild(lastTimeResourceBuildData);
-
- boolean mainToBeCompiled = isCompileNeeded(HashMap.class.cast(moduleBuildData.get(MAIN)).keySet(), isFirstBuild,
- buildDataSameWithPreviousBuild);
-
- boolean resourceDataSame = resourceBuildData.equals(lastTimeResourceBuildData);
-
- boolean testToBeCompiled =
- lastTimeModuleBuildData == null || !moduleBuildData.get(TEST).equals(lastTimeModuleBuildData.get(TEST));
- final boolean instrumented = isCurrentModuleInstrumented();
- setMainBuildAttribute(mainToBeCompiled, testToBeCompiled);
- generateSignature(sourceChecksum);
- setTestBuild(resourceDataSame, resourceMainBuildDataSameWithPreviousBuild, testToBeCompiled, mainToBeCompiled);
- setInstrumentedBuild(testToBeCompiled, mainToBeCompiled, instrumented);
-
- if (!moduleBuildData.equals(lastTimeModuleBuildData) || isFirstBuild) {
- buildState.addModuleBuildData(moduleCoordinates, moduleBuildData);
- }
- setResourceBuild(resourceMainBuildDataSameWithPreviousBuild, mainToBeCompiled, testToBeCompiled);
- setJarFlags(mainToBeCompiled, instrumented, !resourceMainBuildDataSameWithPreviousBuild);
- setInstallFlags(mainToBeCompiled, instrumented, project.getPackaging(),
- !resourceMainBuildDataSameWithPreviousBuild);
-
- setArtifactPath(mainToBeCompiled, instrumented, JAR.equals(project.getPackaging()),
- resourceMainBuildDataSameWithPreviousBuild);
- }
-
- private void generateSignature(byte[] sourceChecksum) {
- try {
- Paths.get(project.getBuild().getOutputDirectory()).toFile().mkdirs();
- Files.write(Paths.get(project.getBuild().getOutputDirectory(), UNICORN + DOT + CHECKSUM), sourceChecksum,
- StandardOpenOption.CREATE);
- } catch (IOException e) {
- throw new UncheckedIOException(e);
- }
- }
-
- private String calculateChecksum(long mainChecksum, long resourceChecksum) throws MojoExecutionException {
- try {
- return getSourceChecksum(mainChecksum + COLON + resourceChecksum, SHA1);
- } catch (NoSuchAlgorithmException e) {
- throw new MojoExecutionException(e.getMessage(), e);
- }
- }
-
- private boolean isResourceMainBuildDataSameWithPreviousBuild(Map<String, Object> lastTimeResourceBuildData) {
- return lastTimeResourceBuildData != null && (lastTimeResourceBuildData.get(MAIN) != null && resourceBuildData
- .get(MAIN)
- .equals(lastTimeResourceBuildData
- .get(MAIN)));
- }
-
- private boolean isBuildDataSameWithPreviousBuild(Map<String, Object> lastTimeModuleBuildData,
- Map<String, Object> moduleBuildData) {
- return lastTimeModuleBuildData != null && (lastTimeModuleBuildData.get(MAIN) != null && moduleBuildData
- .get(MAIN)
- .equals(lastTimeModuleBuildData
- .get(MAIN)));
- }
-
- private void setInstrumentedBuild(boolean testToBeCompiled, boolean mainToBeCompiled, boolean instrumented) {
- if (!testToBeCompiled && !mainToBeCompiled && instrumented) {
- project.getProperties().setProperty(INSTRUMENT_ONLY, Boolean.TRUE.toString());
- project.getProperties().remove(SKIP_MAIN_SOURCE_COMPILE);
- project.getProperties().remove(SKIP_TEST_SOURCE_COMPILE);
- }
- if (testToBeCompiled && !mainToBeCompiled && instrumented) {
- project.getProperties().setProperty(INSTRUMENT_WITH_TEST_ONLY, Boolean.TRUE.toString());
- project.getProperties().remove(SKIP_MAIN_SOURCE_COMPILE);
- }
- if (instrumented) {
- buildState.markTestsMandatoryModule(moduleCoordinates);
- project.getProperties().setProperty(SKIP_TEST_RUN, Boolean.FALSE.toString());
- }
- }
-
- private void setArtifactPath(boolean mainToBeCompiled, boolean instrumented, boolean isJar,
- boolean resourceDataSame) {
- if (!mainToBeCompiled && !instrumented && isJar && resourceDataSame) {
- project.getProperties().setProperty("artifactPathToCopy", artifactPath.orElse(null));
- }
- }
-
- private void setResourceBuild(boolean resourceMainBuildDataSameWithPreviousBuild, boolean mainToBeCompiled,
- boolean testToBeCompiled) {
- if (resourceMainBuildDataSameWithPreviousBuild) {
- project.getProperties().setProperty(SKIP_RESOURCE_COLLECTION, Boolean.TRUE.toString());
- } else {
- project.getProperties().setProperty(RESOURCES_CHANGED, Boolean.TRUE.toString());
- }
- if (!resourceMainBuildDataSameWithPreviousBuild && !mainToBeCompiled) {
- project.getProperties().remove(SKIP_MAIN_SOURCE_COMPILE);
- if (!testToBeCompiled) {
- project.getProperties().remove(SKIP_TEST_SOURCE_COMPILE);
- project.getProperties().setProperty(RESOURCE_ONLY, Boolean.TRUE.toString());
- } else {
- project.getProperties().setProperty(RESOURCE_WITH_TEST_ONLY, Boolean.TRUE.toString());
- }
- }
- }
-
- private void setTestBuild(boolean resourceDataSame, boolean resourceMainBuildDataSameWithPreviousBuild,
- boolean testToBeCompiled, boolean mainToBeCompiled) {
- if (!resourceDataSame) {
- buildState.addResourceBuildData(moduleCoordinates, resourceBuildData);
- project.getProperties().setProperty(SKIP_TEST_RUN, Boolean.FALSE.toString());
- if (resourceMainBuildDataSameWithPreviousBuild && !testToBeCompiled && !mainToBeCompiled) {
- project.getProperties().setProperty(TEST_RESOURCE_ONLY, Boolean.TRUE.toString());
- project.getProperties().remove(SKIP_MAIN_SOURCE_COMPILE);
- project.getProperties().remove(SKIP_TEST_SOURCE_COMPILE);
- }
- }
- }
-
- private void setMainBuildAttribute(boolean mainToBeCompiled, boolean testToBeCompiled) {
- if (!mainToBeCompiled) {
- project.getProperties().setProperty(SKIP_MAIN_SOURCE_COMPILE, Boolean.TRUE.toString());
- }
- if (testToBeCompiled && !mainToBeCompiled) {
- project.getProperties().setProperty(TEST_ONLY, Boolean.TRUE.toString());
- project.getProperties().remove(SKIP_MAIN_SOURCE_COMPILE);
- }
-
- if (mainToBeCompiled || testToBeCompiled) {
- project.getProperties().setProperty(SKIP_TEST_RUN, Boolean.FALSE.toString());
- } else {
- project.getProperties().setProperty(SKIP_TEST_SOURCE_COMPILE, Boolean.TRUE.toString());
- }
- }
-
- private void setJarFlags(boolean compile, boolean instrumented, boolean resourceChanged) {
- if (compile || instrumented || resourceChanged || PREFIX == UNICORN) {
- project.getProperties().setProperty(EMPTY_JAR, "");
- } else {
- project.getProperties().setProperty(EMPTY_JAR, "**/*");
- project.getProperties().setProperty("mvnDsc", "false");
- }
- }
-
- private void setInstallFlags(boolean compile, boolean instrumented, String packaging, boolean resourceChanged) {
- if (!compile && !instrumented && !resourceChanged && JAR.equals(packaging)) {
- project.getProperties().setProperty(SKIP_INSTALL, Boolean.TRUE.toString());
- }
- }
-
- private boolean isCompileNeeded(Collection<String> dependencyCoordinates, boolean isFirstBuild,
- boolean buildDataSame) {
- return isFirstBuild || !buildDataSame || buildState.isCompileMust(moduleCoordinates, dependencyCoordinates);
- }
-
- private boolean isCurrentModuleInstrumented() {
- try {
- return scanModuleFor(LifecyclePhase.PROCESS_CLASSES.id(), LifecyclePhase.PROCESS_TEST_CLASSES.id(),
- LifecyclePhase.COMPILE.id(), LifecyclePhase.TEST_COMPILE.id());
- } catch (Exception e) {
- getLog().debug(e);
- return true;
- }
- }
-
- boolean isCodeGenerator() {
- try {
- return scanModuleFor(LifecyclePhase.GENERATE_RESOURCES.id(), LifecyclePhase.GENERATE_SOURCES.id(),
- LifecyclePhase.GENERATE_TEST_RESOURCES.id(), LifecyclePhase.GENERATE_TEST_SOURCES.id());
- } catch (Exception e) {
- getLog().debug(e);
- return true;
- }
- }
-
- private Map<String, Object> getCurrentModuleBuildData() throws MojoExecutionException {
- Map<String, Object> moduleBuildData = new HashMap<>();
- moduleBuildData.put(MAIN, new HashMap<String, String>());
- moduleBuildData.put(TEST, new HashMap<String, String>());
- HashMap.class.cast(moduleBuildData.get(MAIN))
- .put(MAIN_SOURCE_CHECKSUM, project.getProperties().getProperty(MAIN_CHECKSUM));
- HashMap.class.cast(moduleBuildData.get(TEST))
- .put(TEST_SOURCE_CHECKSUM, project.getProperties().getProperty(TEST_CHECKSUM));
- if (isCodeGenerator()) {
- HashMap.class.cast(moduleBuildData.get(MAIN))
- .put(GENERATED_SOURCE_CHECKSUM, getChecksum(generatedSourceLocation, JAVA_EXT));
- }
- if (project.getArtifacts() == null || project.getArtifacts().isEmpty()) {
- return moduleBuildData;
- }
- for (Artifact dependency : project.getArtifacts()) {
- if (JAR.equals(dependency.getType())) {
- String version = dependency.isSnapshot() || dependency.getFile().getName().contains("SNAPSHOT") ?
- getSnapshotSignature(dependency.getFile(),
- dependency.getGroupId() + COLON + dependency.getArtifactId(),
- dependency.getVersion()) : dependency.getVersion();
- if (excludeDependencies.contains(dependency.getScope())) {
- HashMap.class.cast(moduleBuildData.get(TEST))
- .put(dependency.getGroupId() + COLON + dependency.getArtifactId(), version);
- continue;
- }
- HashMap.class.cast(moduleBuildData.get(MAIN))
- .put(dependency.getGroupId() + COLON + dependency.getArtifactId(), version);
- }
- }
- return moduleBuildData;
- }
-
- private static Map<String, String> readCurrentPMDState(String fileName) {
- Optional<HashMap> val = readState(fileName, HashMap.class);
- return val.orElseGet(HashMap::new);
- }
-
- private boolean isPMDMandatory(Set<Artifact> dependencies) {
- for (Artifact artifact : dependencies) {
- if (BuildState.isPMDRun(artifact.getGroupId() + COLON + artifact.getArtifactId())) {
- return true;
- }
- }
- return false;
- }
-
- private boolean scanModuleFor(String... types)
- throws InvalidPluginDescriptorException, PluginResolutionException, MojoNotFoundException,
- PluginDescriptorParsingException {
- for (Plugin plugin : project.getBuildPlugins()) {
- if (!("org.apache.maven.plugins".equals(plugin.getGroupId()) && plugin.getArtifactId().startsWith("maven"))
- && !plugin.getGroupId().startsWith("org.openecomp.sdc")) {
- boolean success = scanPlugin(plugin, types);
- if (success) {
- return true;
- }
- }
- }
- return false;
- }
-
- private boolean scanPlugin(Plugin plugin, String... types)
- throws InvalidPluginDescriptorException, PluginDescriptorParsingException, MojoNotFoundException,
- PluginResolutionException {
- for (PluginExecution pluginExecution : plugin.getExecutions()) {
- if (pluginExecution.getPhase() != null) {
- boolean phaseAvailable = Arrays.asList(types).contains(pluginExecution.getPhase());
- if (phaseAvailable) {
- return true;
- }
- }
- for (String goal : pluginExecution.getGoals()) {
- MojoDescriptor md = pluginManager.getMojoDescriptor(plugin, goal, project.getRemotePluginRepositories(),
- session.getRepositorySession());
- if (Arrays.asList(types).contains(md.getPhase())) {
- return true;
- }
- }
- }
- return false;
- }
-
- private Map<String, Object> getCurrentResourceBuildData() {
- HashMap<String, Object> resourceBuildStateData = new HashMap<>();
- resourceBuildStateData.put(MAIN, project.getProperties().getProperty(RESOURCE_CHECKSUM));
- resourceBuildStateData.put(TEST, project.getProperties().getProperty(TEST_RESOURCE_CHECKSUM));
- resourceBuildStateData.put("dependency", getDependencies().hashCode());
- return resourceBuildStateData;
- }
-
- private Map<String, String> getDependencies() {
- Map<String, String> dependencies = new HashMap<>();
- for (Artifact d : project.getArtifacts()) {
- dependencies.put(d.getGroupId() + COLON + d.getArtifactId(), d.getVersion());
- }
- return dependencies;
- }
-
- private void init() {
- if (mainSourceLocation == null) {
- mainSourceLocation = Paths.get(project.getBuild().getSourceDirectory()).toFile();
- }
- if (testSourceLocation == null) {
- testSourceLocation = Paths.get(project.getBuild().getTestSourceDirectory()).toFile();
- }
- if (mainResourceLocation == null) {
- mainResourceLocation = Paths.get(project.getBuild().getResources().get(0).getDirectory()).toFile();
- }
- if (testResourceLocation == null) {
- testResourceLocation = Paths.get(project.getBuild().getTestResources().get(0).getDirectory()).toFile();
- }
- }
-
- private void processPMDCheck() {
- mainChecksum = getChecksum(mainSourceLocation, JAVA_EXT);
- testChecksum = getChecksum(testSourceLocation, JAVA_EXT);
- project.getProperties().setProperty(MAIN_CHECKSUM, String.valueOf(mainChecksum));
- project.getProperties().setProperty(TEST_CHECKSUM, String.valueOf(testChecksum));
- String checksum = mainChecksum + COLON + testChecksum;
- if (!checksum.equals(checksumMap.get(moduleCoordinates)) || isPMDMandatory(project.getArtifacts())) {
- project.getProperties().setProperty(SKIP_PMD, Boolean.FALSE.toString());
- BuildState.recordPMDRun(moduleCoordinates);
- generateSyncAlert(!checksum.equals(checksumMap.get(moduleCoordinates)));
- }
- }
-
- private void generateSyncAlert(boolean required) {
- if (required) {
- getLog().warn(
- "\u001B[33m\u001B[1m UNICORN Alert!!! Source code in version control system for this module is different than your local one. \u001B[0m");
- }
- }
-}
diff --git a/openecomp-be/tools/compile-helper-plugin/src/main/java/org/openecomp/sdc/onboarding/PreTestCompileHelperMojo.java b/openecomp-be/tools/compile-helper-plugin/src/main/java/org/openecomp/sdc/onboarding/PreTestCompileHelperMojo.java
deleted file mode 100644
index 8ca623c9a1..0000000000
--- a/openecomp-be/tools/compile-helper-plugin/src/main/java/org/openecomp/sdc/onboarding/PreTestCompileHelperMojo.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * Copyright © 2018 European Support Limited
- *
- * 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 a "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.openecomp.sdc.onboarding;
-
-import org.apache.maven.model.Plugin;
-import org.apache.maven.plugin.AbstractMojo;
-import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.plugin.MojoFailureException;
-import org.apache.maven.plugins.annotations.LifecyclePhase;
-import org.apache.maven.plugins.annotations.Mojo;
-import org.apache.maven.plugins.annotations.Parameter;
-import org.apache.maven.plugins.annotations.ResolutionScope;
-import org.apache.maven.project.MavenProject;
-import org.codehaus.plexus.util.xml.Xpp3Dom;
-
-import java.util.List;
-
-import static org.openecomp.sdc.onboarding.Constants.*;
-
-@Mojo(name = "pre-test-compile-helper", threadSafe = true, defaultPhase = LifecyclePhase.PROCESS_TEST_CLASSES,
- requiresDependencyResolution = ResolutionScope.TEST)
-public class PreTestCompileHelperMojo extends AbstractMojo {
-
- @Parameter
- private BuildState buildState;
- @Parameter(defaultValue = "${project}", readonly = true)
- private MavenProject project;
- @Parameter(defaultValue = "${project.artifact.groupId}:${project.artifact.artifactId}")
- private String moduleCoordinates;
- @Parameter(defaultValue = "${project.buildPlugins}", readonly = true)
- private List<Plugin> plugins;
- @Parameter
- private String excludePackaging;
-
-
- public void execute() throws MojoExecutionException, MojoFailureException {
- if (!System.getProperties().containsKey(UNICORN)) {
- return;
- }
- if (project.getPackaging().equals(excludePackaging)) {
- return;
- }
- if (buildState.isTestExecutionMandatory()) {
- project.getProperties().setProperty(SKIP_TEST_RUN, Boolean.FALSE.toString());
- }
- boolean isTestMust = buildState.isTestMust(moduleCoordinates);
- if (isTestMust) {
- project.getProperties().setProperty(RESOURCES_CHANGED, Boolean.TRUE.toString());
- if (!project.getProperties().containsKey(SKIP_TEST_RUN)) {
- project.getProperties().setProperty(SKIP_TEST_RUN, Boolean.FALSE.toString());
- }
- }
- if (!project.getProperties().containsKey(SKIP_TEST_RUN) || isTestSkippedExplicitly()) {
- project.getProperties().setProperty(SKIP_TEST_RUN, Boolean.TRUE.toString());
- }
- if (System.getProperties().containsKey(JACOCO_SKIP) && Boolean.FALSE.equals(Boolean.valueOf(
- System.getProperties().getProperty(JACOCO_SKIP)))) {
- project.getProperties().setProperty(SKIP_TEST_RUN, Boolean.FALSE.toString());
- }
- }
-
-
- private boolean isTestSkippedExplicitly() {
- for (Plugin p : plugins) {
- if ("org.apache.maven.plugins:maven-surefire-plugin".equals(p.getKey())) {
- Xpp3Dom dom = Xpp3Dom.class.cast(p.getConfiguration());
- if (dom.getChild(SKIP_TESTS) != null) {
- return Boolean.TRUE.equals(Boolean.valueOf(dom.getValue()));
- }
- }
- }
- return false;
- }
-}