aboutsummaryrefslogtreecommitdiffstats
path: root/openecomp-be
diff options
context:
space:
mode:
authorvempo <vitaliy.emporopulo@amdocs.com>2018-11-05 18:41:47 +0200
committervempo <vitaliy.emporopulo@amdocs.com>2018-11-05 18:41:47 +0200
commitf069fd4e35f20456f83767ca07d8a58b50ca4b59 (patch)
tree6cb4a612b741172773503b616fc7c930852c96bd /openecomp-be
parent6a0ed133209fc349e92e1a5948ee1d8cba3d6ac2 (diff)
Removed artifact-copy plugin
Change-Id: I2993bdc46693af1b48ed886718d17b835437740e Issue-ID: SDC-1861 Signed-off-by: vempo <vitaliy.emporopulo@amdocs.com>
Diffstat (limited to 'openecomp-be')
-rw-r--r--openecomp-be/pom.xml24
-rw-r--r--openecomp-be/tools/artifact-copy-plugin/pom.xml44
-rw-r--r--openecomp-be/tools/artifact-copy-plugin/src/main/java/org/openecomp/sdc/onboarding/util/ArtifactHelper.java168
-rw-r--r--openecomp-be/tools/artifact-copy-plugin/src/main/java/org/openecomp/sdc/onboarding/util/CalibrateArtifactPlugin.java55
-rw-r--r--openecomp-be/tools/artifact-copy-plugin/src/main/java/org/openecomp/sdc/onboarding/util/InitializationHelperMojo.java200
-rw-r--r--openecomp-be/tools/build-data-installer/pom.xml42
6 files changed, 0 insertions, 533 deletions
diff --git a/openecomp-be/pom.xml b/openecomp-be/pom.xml
index 234234ef15..356b0c5670 100644
--- a/openecomp-be/pom.xml
+++ b/openecomp-be/pom.xml
@@ -61,30 +61,6 @@
</plugin>
<plugin>
<groupId>org.openecomp.sdc.onboarding</groupId>
- <artifactId>artifact-copy-plugin</artifactId>
- <version>${project.version}</version>
- <executions>
- <execution>
- <goals>
- <goal>init-artifact-helper</goal>
- <!--<goal>copy-helper</goal>-->
- <goal>calibrate-artifact-helper</goal>
- </goals>
- </execution>
- </executions>
- <configuration>
- <groupId>org.openecomp.sdc</groupId>
- <artifactId>build-data-installer</artifactId>
- <version>${project.version}</version>
- <artifactHelper>
- <project>${project}</project>
- <session>${session}</session>
- <unicornRoot>org.openecomp.sdc:sdc-onboarding/target/build-data</unicornRoot>
- </artifactHelper>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.openecomp.sdc.onboarding</groupId>
<artifactId>compile-helper-plugin</artifactId>
<version>${project.version}</version>
<executions>
diff --git a/openecomp-be/tools/artifact-copy-plugin/pom.xml b/openecomp-be/tools/artifact-copy-plugin/pom.xml
deleted file mode 100644
index 1e35ac0c39..0000000000
--- a/openecomp-be/tools/artifact-copy-plugin/pom.xml
+++ /dev/null
@@ -1,44 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <groupId>org.openecomp.sdc.onboarding</groupId>
- <artifactId>artifact-copy-plugin</artifactId>
- <packaging>maven-plugin</packaging>
- <parent>
- <artifactId>sdc-onboarding</artifactId>
- <groupId>org.openecomp.sdc</groupId>
- <version>1.3.3-SNAPSHOT</version>
- <relativePath>../../../onboarding/pom.xml</relativePath>
- </parent>
- <properties>
- <classes>classes/**/*.class</classes>
- <mavenStatus>maven-status/**</mavenStatus>
- <skipTestRun>true</skipTestRun>
- </properties>
- <dependencies>
- <dependency>
- <groupId>org.apache.maven</groupId>
- <artifactId>maven-core</artifactId>
- <version>${maven-core.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.maven.plugin-tools</groupId>
- <artifactId>maven-plugin-annotations</artifactId>
- <version>${maven-plugin-annotations.version}</version>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-plugin-plugin</artifactId>
- <version>${maven-plugin-plugin.version}</version>
- </plugin>
- </plugins>
- </build>
-
-</project> \ No newline at end of file
diff --git a/openecomp-be/tools/artifact-copy-plugin/src/main/java/org/openecomp/sdc/onboarding/util/ArtifactHelper.java b/openecomp-be/tools/artifact-copy-plugin/src/main/java/org/openecomp/sdc/onboarding/util/ArtifactHelper.java
deleted file mode 100644
index ce63a8d466..0000000000
--- a/openecomp-be/tools/artifact-copy-plugin/src/main/java/org/openecomp/sdc/onboarding/util/ArtifactHelper.java
+++ /dev/null
@@ -1,168 +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.util;
-
-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.io.OutputStream;
-import java.net.URL;
-import java.nio.file.Files;
-import java.nio.file.Paths;
-import java.nio.file.StandardCopyOption;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Scanner;
-import java.util.Set;
-
-import org.apache.maven.artifact.repository.ArtifactRepository;
-import org.apache.maven.execution.MavenSession;
-import org.apache.maven.project.MavenProject;
-
-public class ArtifactHelper {
-
- private MavenProject project;
- private MavenSession session;
- private static final Map<String, byte[]> store = new HashMap<>();
- private static final Set<String> terminalModuleCoordinates = new HashSet<>();
- private String unicornRoot = null;
- private static File unicornMetaLocation = null;
- private final File tempLocation = Paths.get(System.getProperties().getProperty("java.io.tmpdir")).toFile();
- private static int snapshotBuildNumber = 0;
- private static final String HYPHEN = "-";
-
- void init(String terminalModuleCoordinate) {
- setUnicornMetaLocation(getUnicornRootFile(unicornRoot.substring(0, unicornRoot.indexOf('/')), project));
- setTerminalModuleCoordinates(session.getProjects().get(session.getProjects().size() - 1));
- terminalModuleCoordinates.add(terminalModuleCoordinate);
- }
-
- private static void setUnicornMetaLocation(File file) {
- unicornMetaLocation = file;
- }
-
- static void setSnapshotBuildNumber(int number) {
- snapshotBuildNumber = number;
- }
-
- List<ArtifactRepository> getRepositories(boolean snapshotRepo) {
- List<ArtifactRepository> list = new ArrayList<>();
- for (ArtifactRepository artRepo : project.getRemoteArtifactRepositories()) {
- if (snapshotRepo) {
- if (artRepo.getSnapshots().isEnabled()) {
- list.add(artRepo);
- }
- } else {
- if (artRepo.getReleases().isEnabled()) {
- list.add(artRepo);
- }
- }
- }
- return list;
- }
-
- private void setTerminalModuleCoordinates(MavenProject project) {
- terminalModuleCoordinates.add(getModuleCoordinate(project));
- }
-
- private boolean isModuleTerminal(MavenProject project) {
- return terminalModuleCoordinates.contains(getModuleCoordinate(project));
- }
-
- File getUnicornMetaLocation() {
- return unicornMetaLocation;
- }
-
- String getContents(URL path) throws IOException {
- try (InputStream is = path.openStream(); Scanner scanner = new Scanner(is).useDelimiter("\\A")) {
- return scanner.hasNext() ? scanner.next() : "";
- }
- }
-
- void store(String artifactId, byte[] data) {
- store.put(artifactId, data);
- }
-
- void deleteAll(File f) {
-
- if (!f.exists() || !f.isDirectory()) {
- return;
- }
-
- File[] fileList = f.listFiles();
- if (fileList == null) {
- return;
- }
-
- for (File file : fileList) {
-
- if (file.isFile()) {
- file.delete();
- }
- }
- }
-
- String getModuleCoordinate(MavenProject project) {
- return project.getGroupId() + ":" + project.getArtifactId();
- }
-
- private File getUnicornRootFile(String moduleCoordinate, MavenProject mavenProject) {
- return getStateFile(moduleCoordinate, mavenProject, unicornRoot);
- }
-
- 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());
- }
- }
-
- void shutDown(MavenProject project) throws IOException, ClassNotFoundException {
- File file = new File(unicornMetaLocation, "compileState.dat");
- HashMap dataStore;
- if (isModuleTerminal(project) && file.exists()) {
- try (InputStream is = new FileInputStream(file); ObjectInputStream ois = new ObjectInputStream(is)) {
- dataStore = (HashMap) ois.readObject();
- //noinspection unchecked
- dataStore.put("shutdownTime", (System.currentTimeMillis() / 1000) * 1000 + snapshotBuildNumber);
- //noinspection unchecked
- dataStore.put("version", project.getVersion());
- }
- try (OutputStream os = new FileOutputStream(file); ObjectOutputStream oos = new ObjectOutputStream(os)) {
- oos.writeObject(dataStore);
- }
- Files.copy(file.toPath(),
- Paths.get(tempLocation.getAbsolutePath(), file.getName() + HYPHEN + project.getVersion()),
- StandardCopyOption.REPLACE_EXISTING);
- }
- }
-}
-
-
diff --git a/openecomp-be/tools/artifact-copy-plugin/src/main/java/org/openecomp/sdc/onboarding/util/CalibrateArtifactPlugin.java b/openecomp-be/tools/artifact-copy-plugin/src/main/java/org/openecomp/sdc/onboarding/util/CalibrateArtifactPlugin.java
deleted file mode 100644
index fa871c20c5..0000000000
--- a/openecomp-be/tools/artifact-copy-plugin/src/main/java/org/openecomp/sdc/onboarding/util/CalibrateArtifactPlugin.java
+++ /dev/null
@@ -1,55 +0,0 @@
-package org.openecomp.sdc.onboarding.util;
-
-import org.apache.maven.execution.MavenSession;
-import org.apache.maven.plugin.AbstractMojo;
-import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.plugin.MojoFailureException;
-import org.apache.maven.plugins.annotations.*;
-import org.apache.maven.project.MavenProject;
-import org.apache.maven.project.MavenProjectHelper;
-
-import java.io.File;
-import java.io.IOException;
-
-@Mojo(name = "calibrate-artifact-helper", threadSafe = true, defaultPhase = LifecyclePhase.INSTALL,
- requiresDependencyResolution = ResolutionScope.TEST)
-public class CalibrateArtifactPlugin extends AbstractMojo {
-
- private static final String ARTIFACT_COPY_PATH = "artifactPathToCopy";
-
- @Parameter(defaultValue = "${session}")
- private MavenSession session;
- @Parameter(defaultValue = "${project}", readonly = true)
- private MavenProject project;
- @Component
- private MavenProjectHelper projectHelper;
- @Parameter
- private String groupId;
- @Parameter
- private String artifactId;
- @Parameter
- private String version;
- @Parameter
- private String excludePackaging;
- @Parameter
- private ArtifactHelper artifactHelper;
-
- @Override
- public void execute() throws MojoExecutionException, MojoFailureException {
- if (project.getPackaging().equals(excludePackaging)) {
- return;
- }
- if (project.getProperties().containsKey(ARTIFACT_COPY_PATH)
- && project.getProperties().getProperty(ARTIFACT_COPY_PATH) != null) {
- File f = new File(project.getProperties().getProperty(ARTIFACT_COPY_PATH));
- if (f.exists()) {
- project.getArtifact().setFile(f);
- }
- }
- try {
- artifactHelper.shutDown(project);
- } catch (IOException | ClassNotFoundException e) {
- throw new MojoExecutionException("Unexpected Error Occured during shutdown activities", e);
- }
- }
-}
diff --git a/openecomp-be/tools/artifact-copy-plugin/src/main/java/org/openecomp/sdc/onboarding/util/InitializationHelperMojo.java b/openecomp-be/tools/artifact-copy-plugin/src/main/java/org/openecomp/sdc/onboarding/util/InitializationHelperMojo.java
deleted file mode 100644
index afe5d3e702..0000000000
--- a/openecomp-be/tools/artifact-copy-plugin/src/main/java/org/openecomp/sdc/onboarding/util/InitializationHelperMojo.java
+++ /dev/null
@@ -1,200 +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.util;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.lang.reflect.Method;
-import java.net.URL;
-import java.nio.file.Files;
-import java.nio.file.Paths;
-import java.nio.file.StandardCopyOption;
-import java.util.List;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-import org.apache.maven.artifact.repository.ArtifactRepository;
-import org.apache.maven.execution.MavenSession;
-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.apache.maven.settings.Proxy;
-
-@Mojo(name = "init-artifact-helper", threadSafe = true, defaultPhase = LifecyclePhase.PRE_CLEAN,
- requiresDependencyResolution = ResolutionScope.NONE)
-public class InitializationHelperMojo extends AbstractMojo {
-
- private static final String UNICORN_INITIALIZED = "unicorn_initialized";
- private static final String HTTP = "http";
- private static final String HTTPS = "https";
- private static final String SNAPSHOT = "SNAPSHOT";
- private static final String DOT = ".";
-
- @Parameter(defaultValue = "${session}")
- private MavenSession session;
- @Parameter(defaultValue = "${project}", readonly = true)
- private MavenProject project;
- @Parameter
- private String groupId;
- @Parameter
- private String artifactId;
- @Parameter
- private String version;
- @Parameter
- private String excludePackaging;
- @Parameter
- private ArtifactHelper artifactHelper;
-
- @Override
- public void execute() throws MojoExecutionException {
- if (System.getProperties().containsKey(UNICORN_INITIALIZED)) {
- try {
- artifactHelper.shutDown(project);
- } catch (IOException | ClassNotFoundException e) {
- throw new MojoExecutionException("Unexpected Error Occurred during shutdown activities", e);
- }
- return;
- }
- artifactHelper.init(groupId + ":" + artifactId);
- artifactHelper.deleteAll(artifactHelper.getUnicornMetaLocation());
- String resolvedVersion =
- getResolvedVersion(artifactHelper.getRepositories(version.contains(SNAPSHOT)), artifactId);
- getLog().info(resolvedVersion.equals(version) ? "Unicorn Initialization Failed!!!" :
- "Unicorn Initialization Completed Successfully!!!");
- System.getProperties().setProperty(UNICORN_INITIALIZED, Boolean.TRUE.toString());
- }
-
- private String getResolvedVersion(List<ArtifactRepository> list, String artifactId) {
- Pattern timestampPattern = Pattern.compile(".*<timestamp>(.*)</timestamp>.*");
- Pattern buildNumberPattern = Pattern.compile(".*<buildNumber>(.*)</buildNumber>.*");
-
- String timestamp = null;
- String buildNumber = null;
- for (ArtifactRepository repo : list) {
- try {
- URL url = new URL(repo.getUrl() + (groupId.replace('.', '/')) + '/' + artifactId + '/' + version
- + "/maven-metadata.xml");
- setProxy(url);
- String content = artifactHelper.getContents(url);
- Matcher m = timestampPattern.matcher(content);
- if (m.find()) {
- timestamp = m.group(1);
- }
- m = buildNumberPattern.matcher(content);
- if (m.find()) {
- buildNumber = m.group(1);
- }
-
- URL fallbackUrl =
- new URL(repo.getUrl() + (groupId.replace('.', '/')) + '/' + artifactId + '/' + version + '/');
- timestamp = verifyBuildTimestamp(buildNumber, timestamp, fallbackUrl);
- if (timestamp != null && buildNumber != null) {
- byte[] data = fetchContents(repo.getUrl(), artifactId, timestamp + "-" + buildNumber);
- artifactHelper.store(artifactId, data);
- getLog().info(artifactId + " Version to be copied is " + timestamp + "-" + buildNumber);
- ArtifactHelper.setSnapshotBuildNumber(Integer.parseInt(buildNumber) + 1);
- return timestamp + "-" + buildNumber;
- }
- } catch (IOException e) {
- getLog().debug(e);
- }
- }
- return version;
- }
-
- private String verifyBuildTimestamp(String buildNumber, String timestamp, URL fallbackUrl) throws IOException {
- if (buildNumber == null) {
- return timestamp;
- }
- String buildPage = artifactHelper.getContents(fallbackUrl);
- Pattern verifyPattern = Pattern.compile(
- ".*" + artifactId + "-" + version.replace(SNAPSHOT, "") + "(.*)" + "-" + buildNumber + ".jar</a>.*");
- Matcher m = verifyPattern.matcher(buildPage);
- if (m.find()) {
- String str = m.group(1);
- if (!str.equals(timestamp)) {
- return str;
- }
- }
- return timestamp;
- }
-
- private byte[] fetchContents(String repoUrl, String artifactId, String resolvedVersion) throws IOException {
- File location = Paths.get(project.getBuild().getDirectory(), "build-data").toFile();
- location.mkdirs();
- File file = new File(location, artifactId + "-" + (version.equals(resolvedVersion) ? version :
- version.replace(SNAPSHOT, resolvedVersion)) + DOT
- + "jar");
- URL path = new URL(repoUrl + (groupId.replace('.', '/')) + '/' + artifactId + '/' + version + '/' + artifactId
- + "-" + (version.equals(resolvedVersion) ? version :
- version.replace(SNAPSHOT, resolvedVersion)) + DOT + "jar");
- try (InputStream is = path.openStream()) {
- Files.copy(is, file.toPath(), StandardCopyOption.REPLACE_EXISTING);
- }
- byte[] data = Files.readAllBytes(file.toPath());
- try {
- addJarToClasspath(file);
- } catch (Exception e) {
- getLog().error("Error while feeding the build-data into system.", e);
- }
-
- return data;
- }
-
- private void setProxy(URL url) {
- if (url.getProtocol().equalsIgnoreCase(HTTP)) {
- setProperties("http.proxyHost", "http.proxyPort", "http.nonProxyHosts", HTTP);
- } else if (url.getProtocol().equalsIgnoreCase(HTTPS)) {
- setProperties("https.proxyHost", "https.proxyPort", "https.nonProxyHosts", HTTPS);
- }
- }
-
- private void setProperties(String proxyHostProperty, String proxyPortProperty, String nonProxyHostsProperty,
- String protocol) {
- for (Proxy proxy : session.getSettings().getProxies()) {
- if (proxy.isActive() && proxy.getProtocol().equalsIgnoreCase(protocol)) {
- if (proxy.getHost() != null && !proxy.getHost().trim().isEmpty()) {
- System.setProperty(proxyHostProperty, proxy.getHost());
- System.setProperty(proxyPortProperty, String.valueOf(proxy.getPort()));
- }
- if (proxy.getNonProxyHosts() != null && !proxy.getNonProxyHosts().trim().isEmpty()) {
- System.setProperty(nonProxyHostsProperty, proxy.getNonProxyHosts());
- }
- }
- }
- }
-
- public void addJarToClasspath(File jar) throws MojoFailureException {
- try {
- ClassLoader cl = ClassLoader.getSystemClassLoader();
- Class<?> clazz = cl.getClass();
-
- Method method = clazz.getSuperclass().getDeclaredMethod("addURL", URL.class);
-
- method.setAccessible(true);
- method.invoke(cl, jar.toURI().toURL());
- } catch (Exception e) {
- throw new MojoFailureException("Problem while loading build-data", e);
- }
- }
-
-}
diff --git a/openecomp-be/tools/build-data-installer/pom.xml b/openecomp-be/tools/build-data-installer/pom.xml
deleted file mode 100644
index f69dad6be2..0000000000
--- a/openecomp-be/tools/build-data-installer/pom.xml
+++ /dev/null
@@ -1,42 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <artifactId>build-data-installer</artifactId>
-
- <parent>
- <artifactId>sdc-onboarding</artifactId>
- <groupId>org.openecomp.sdc</groupId>
- <version>1.3.3-SNAPSHOT</version>
- <relativePath>../../../onboarding/pom.xml</relativePath>
- </parent>
- <build>
- <plugins>
- <plugin>
- <groupId>org.openecomp.sdc.onboarding</groupId>
- <artifactId>artifact-copy-plugin</artifactId>
- <version>${project.version}</version>
- <executions>
- <execution>
- <goals>
- <goal>init-artifact-helper</goal>
- <goal>calibrate-artifact-helper</goal>
- </goals>
- </execution>
- </executions>
- <configuration>
- <groupId>org.openecomp.sdc</groupId>
- <artifactId>build-data-installer</artifactId>
- <version>${project.version}</version>
- <artifactHelper>
- <project>${project}</project>
- <session>${session}</session>
- <unicornRoot>org.openecomp.sdc:sdc-onboarding/target/build-data</unicornRoot>
- </artifactHelper>
- </configuration>
- </plugin>
- </plugins>
- </build>
-</project> \ No newline at end of file