From 759ac5f42c6aff901dbeede4fbf1a1d2e08cad0f Mon Sep 17 00:00:00 2001 From: Thomas Lenz Date: Wed, 4 Dec 2019 19:43:32 +0100 Subject: common EGIZ code-style refactoring --- .../java/artifacts/MavenArtifactInstaller.java | 109 ++++++++++++--------- 1 file changed, 60 insertions(+), 49 deletions(-) (limited to 'eaaf_modules/eaaf_module_moa-sig/src/test/java') diff --git a/eaaf_modules/eaaf_module_moa-sig/src/test/java/artifacts/MavenArtifactInstaller.java b/eaaf_modules/eaaf_module_moa-sig/src/test/java/artifacts/MavenArtifactInstaller.java index 7b9e2748..11c84ec0 100644 --- a/eaaf_modules/eaaf_module_moa-sig/src/test/java/artifacts/MavenArtifactInstaller.java +++ b/eaaf_modules/eaaf_module_moa-sig/src/test/java/artifacts/MavenArtifactInstaller.java @@ -6,54 +6,65 @@ import java.text.MessageFormat; public class MavenArtifactInstaller { - public static final String MVN_INSTALL_PATH = "F:\\local_work\\program\\apache-maven-3.5.2-bin\\bin\\"; - public static final String CONFIG = "/settings.xml"; - public static final String REPO_SCAN_PATH = "/repository/iaik/prod"; - - public static final String GROUP = "iaik.prod"; - public static final String PACKAGE = "jar"; - public static final String COMMAND_TEMPLATE = "{6}mvn.cmd install:install-file -s {0} -DgroupId={1} -DartifactId={2} -Dversion={3} -Dpackaging={4} -Dfile={5}"; - - public static void main(String[] args) { - String currentLocation = new java.io.File( "." ).toURI().toString(); - currentLocation = currentLocation.substring("file:/".length(), currentLocation.length() - 2); - final String settingLocation = currentLocation + CONFIG; - final File settingsFile = new File(settingLocation); - if (!settingsFile.exists()) { - System.out.println("Maven settings does not exist"); - System.exit(-1); - - } - - final String pathToScan = currentLocation + REPO_SCAN_PATH; - - final File toScan = new File(pathToScan); - - int counter=0; - for (final File dir : toScan.listFiles()) { - final String artifactName = dir.getName(); - for (final File version : dir.listFiles()) { - final String libVersion = version.getName(); - final String jarPath = version.getAbsolutePath() + "/" + artifactName + "-" + libVersion + ".jar"; - final File jar = new File(jarPath ); - if (jar.exists()) { - final String mvnCommand = MessageFormat.format(COMMAND_TEMPLATE, settingsFile.getAbsoluteFile(), GROUP, artifactName, libVersion, PACKAGE, jar.getAbsolutePath(), MVN_INSTALL_PATH); - System.out.println("Execute: " + mvnCommand); - try { - Runtime.getRuntime().exec(mvnCommand); - counter++; - } catch (final IOException e) { - e.printStackTrace(); - - } - - } else - System.out.print("Can NOT find jar with path: " + jarPath); - - } - - } - System.out.println("Install #" + counter + " maven artifacts"); - } + public static final String MVN_INSTALL_PATH = + "F:\\local_work\\program\\apache-maven-3.5.2-bin\\bin\\"; + public static final String CONFIG = "/settings.xml"; + public static final String REPO_SCAN_PATH = "/repository/iaik/prod"; + + public static final String GROUP = "iaik.prod"; + public static final String PACKAGE = "jar"; + public static final String COMMAND_TEMPLATE = + "{6}mvn.cmd install:install-file -s {0} -DgroupId={1} -DartifactId={2} -Dversion={3} -Dpackaging={4} -Dfile={5}"; + + /** + * Only for test-deployment of maven artifacts. + * + * @param args System parameters + */ + public static void main(final String[] args) { + String currentLocation = new java.io.File(".").toURI().toString(); + currentLocation = currentLocation.substring("file:/".length(), currentLocation.length() - 2); + final String settingLocation = currentLocation + CONFIG; + final File settingsFile = new File(settingLocation); + if (!settingsFile.exists()) { + System.out.println("Maven settings does not exist"); + System.exit(-1); + + } + + final String pathToScan = currentLocation + REPO_SCAN_PATH; + + final File toScan = new File(pathToScan); + + int counter = 0; + for (final File dir : toScan.listFiles()) { + final String artifactName = dir.getName(); + for (final File version : dir.listFiles()) { + final String libVersion = version.getName(); + final String jarPath = + version.getAbsolutePath() + "/" + artifactName + "-" + libVersion + ".jar"; + final File jar = new File(jarPath); + if (jar.exists()) { + final String mvnCommand = + MessageFormat.format(COMMAND_TEMPLATE, settingsFile.getAbsoluteFile(), GROUP, + artifactName, libVersion, PACKAGE, jar.getAbsolutePath(), MVN_INSTALL_PATH); + System.out.println("Execute: " + mvnCommand); + try { + Runtime.getRuntime().exec(mvnCommand); + counter++; + } catch (final IOException e) { + e.printStackTrace(); + + } + + } else { + System.out.print("Can NOT find jar with path: " + jarPath); + } + + } + + } + System.out.println("Install #" + counter + " maven artifacts"); + } } -- cgit v1.2.3