[java-identity-provider] 02/11: IDP-1499 New V4 Installer: Add an InstallerSupport class

Rod Widdowson rdw at steadingsoftware.com
Fri Oct 11 11:08:25 EDT 2019


This is an automated email from the git hooks/post-receive script.

rdw pushed a commit to branch master
in repository java-identity-provider.

View the commit online:
http://git.shibboleth.net/view/?p=java-identity-provider.git;a=commit;h=38f57fd2d15434c7a7d0915361b9d281a9a91117

commit 38f57fd2d15434c7a7d0915361b9d281a9a91117
Author: Rod Widdowson <rdw at steadingsoftware.com>
AuthorDate: Sun Oct 6 11:12:12 2019 +0100

    IDP-1499 New V4 Installer: Add an InstallerSupport class
    
    https://issues.shibboleth.net/jira/browse/IDP-1499
---
 .../shibboleth/idp/installer/impl/BuildWar.java    | 29 ++---------
 .../idp/installer/impl/InstallerSupport.java       | 56 ++++++++++++++++++++++
 2 files changed, 59 insertions(+), 26 deletions(-)

diff --git a/idp-installer/src/main/java/net/shibboleth/idp/installer/impl/BuildWar.java b/idp-installer/src/main/java/net/shibboleth/idp/installer/impl/BuildWar.java
index f46a6f8..d3b5842 100644
--- a/idp-installer/src/main/java/net/shibboleth/idp/installer/impl/BuildWar.java
+++ b/idp-installer/src/main/java/net/shibboleth/idp/installer/impl/BuildWar.java
@@ -18,14 +18,11 @@
 package net.shibboleth.idp.installer.impl;
 
 import java.io.IOException;
-import java.nio.file.Files;
 import java.nio.file.Path;
 
-import org.apache.tools.ant.Project;
 import org.apache.tools.ant.BuildException;
 import org.apache.tools.ant.taskdefs.Copy;
 import org.apache.tools.ant.taskdefs.Jar;
-import org.apache.tools.ant.types.FileSet;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -44,9 +41,6 @@ public final class BuildWar {
     /** Log. */
     public static final Logger LOG = LoggerFactory.getLogger(BuildWar.class);
     
-    /** And psuedo project as parent. */
-    private static final Project ANT_PROJECT = new Project();
-
     /** private Constructor. */
     private BuildWar() {}
 
@@ -71,7 +65,7 @@ public final class BuildWar {
             LOG.warn("Deleting {} failed", webAppTmp.toAbsolutePath(), e);
         }
         final Path distWebApp =  target.resolve("dist").resolve("webapp");
-        final Copy initial = getCopyTask(distWebApp, webAppTmp);
+        final Copy initial = InstallerSupport.getCopyTask(distWebApp, webAppTmp);
         initial.setPreserveLastModified(true);
         initial.setFailOnError(true);
         initial.setVerbose(LOG.isDebugEnabled());
@@ -79,7 +73,7 @@ public final class BuildWar {
         initial.execute();
         
         final Path editWebApp = target.resolve("edit-webapp"); 
-        final Copy overlay = getCopyTask(editWebApp, webAppTmp);
+        final Copy overlay = InstallerSupport.getCopyTask(editWebApp, webAppTmp);
         overlay.setOverwrite(true);
         overlay.setPreserveLastModified(true);
         overlay.setFailOnError(true);
@@ -91,7 +85,7 @@ public final class BuildWar {
         final Jar jarTask = new Jar();
         jarTask.setDestFile(warFile.toFile());
         jarTask.setBasedir(webAppTmp.toFile());
-        jarTask.setProject(ANT_PROJECT);
+        jarTask.setProject(InstallerSupport.ANT_PROJECT);
         LOG.info("Creating war file {}", warFile);
         jarTask.execute();
         try {
@@ -101,23 +95,6 @@ public final class BuildWar {
         }
     }
     
-    /** Copy files.  We use ant rather than {@link Files#copy(Path, Path, java.nio.file.CopyOption...)}
-     * because the latter has issues with the Windows ReadOnly Attribute, and the former is tried
-     * and tested technology.
-     * @param from where to copy from
-     * @param to where to copy to
-     * @return a partially populated {@link Copy} task 
-     */
-    private static Copy getCopyTask(final Path from, final Path to) {
-        final Copy result = new Copy();
-        result.setTodir(to.toFile());
-        final FileSet fromSet = new FileSet();
-        fromSet.setDir(from.toFile());
-        result.addFileset(fromSet);
-        result.setProject(ANT_PROJECT);
-        return result;
-    }
-
     /** Program entry to build war. Calls {@link #buildWar(InstallerProperties)}.
      * @param args input
      */
diff --git a/idp-installer/src/main/java/net/shibboleth/idp/installer/impl/InstallerSupport.java b/idp-installer/src/main/java/net/shibboleth/idp/installer/impl/InstallerSupport.java
new file mode 100644
index 0000000..6edfd8e
--- /dev/null
+++ b/idp-installer/src/main/java/net/shibboleth/idp/installer/impl/InstallerSupport.java
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the University Corporation for Advanced Internet Development,
+ * Inc. (UCAID) under one or more contributor license agreements.  See the
+ * NOTICE file distributed with this work for additional information regarding
+ * copyright ownership. The UCAID licenses this file to You 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 an "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 net.shibboleth.idp.installer.impl;
+
+import java.nio.file.Files;
+import java.nio.file.Path;
+
+import org.apache.tools.ant.Project;
+import org.apache.tools.ant.taskdefs.Copy;
+import org.apache.tools.ant.types.FileSet;
+
+/** General common names and helper functions for the installer. */
+public final class InstallerSupport {
+
+    /** The name of the file and the property with the current V4 installation value.*/
+    public static final String VERSION_NAME = "idp.installed.version";
+    
+    /** A psuedo ant-project as parent. */
+    public static final Project ANT_PROJECT = new Project();
+
+    /** Private Constructor. */
+    private InstallerSupport() {}
+    
+    /** Copy files.  We use ant rather than {@link Files#copy(Path, Path, java.nio.file.CopyOption...)}
+     * because the latter has issues with the Windows ReadOnly Attribute, and the former is tried
+     * and tested technology.
+     * @param from where to copy from
+     * @param to where to copy to
+     * @return a partially populated {@link Copy} task 
+     */
+    protected static Copy getCopyTask(final Path from, final Path to) {
+        final Copy result = new Copy();
+        result.setTodir(to.toFile());
+        final FileSet fromSet = new FileSet();
+        fromSet.setDir(from.toFile());
+        result.addFileset(fromSet);
+        result.setProject(ANT_PROJECT);
+        return result;
+    }
+
+}

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the commits mailing list