[java-identity-provider] 06/13: IDP-1808 Option in plugin.sh to postpone rebuilding the .war file
Rod Widdowson
rdw at steadingsoftware.com
Sun Jun 6 11:40:46 UTC 2021
This is an automated email from the git hooks/post-receive script.
rdw pushed a commit to branch main
in repository java-identity-provider.
View the commit online:
http://git.shibboleth.net/view/?p=java-identity-provider.git;a=commit;h=5d6be3934314201f2dcb00fdd86b0a1e111b1efb
commit 5d6be3934314201f2dcb00fdd86b0a1e111b1efb
Author: Rod Widdowson <rdw at steadingsoftware.com>
AuthorDate: Fri Apr 30 13:39:59 2021 +0100
IDP-1808 Option in plugin.sh to postpone rebuilding the .war file
https://issues.shibboleth.net/jira/browse/IDP-1808
Control is via --noRebuild
---
.../idp/installer/plugin/impl/PluginInstaller.java | 54 ++++++++++++++++------
.../plugin/impl/PluginInstallerArguments.java | 12 +++++
.../installer/plugin/impl/PluginInstallerCLI.java | 1 +
.../idp/installer/plugin/impl/PluginCLITest.java | 3 ++
4 files changed, 55 insertions(+), 15 deletions(-)
diff --git a/idp-installer/src/main/java/net/shibboleth/idp/installer/plugin/impl/PluginInstaller.java b/idp-installer/src/main/java/net/shibboleth/idp/installer/plugin/impl/PluginInstaller.java
index 596e8a6cb..98c5f7c41 100644
--- a/idp-installer/src/main/java/net/shibboleth/idp/installer/plugin/impl/PluginInstaller.java
+++ b/idp-installer/src/main/java/net/shibboleth/idp/installer/plugin/impl/PluginInstaller.java
@@ -159,9 +159,12 @@ public final class PluginInstaller extends AbstractInitializableComponent implem
/** The "plugin under construction" classpath loader. AutoClosed. */
private URLClassLoader installingPluginLoader;
- /** The securiotyParams for the module context. */
+ /** The securityParams for the module context. */
private HttpClientSecurityParameters securityParams;
+ /** Do we rebuild? */
+ private boolean rebuildWar = true;
+
/** Set IdP Home.
* @param home Where we are working from
*/
@@ -213,6 +216,20 @@ public final class PluginInstaller extends AbstractInitializableComponent implem
securityParams = params;
}
+ /** Set whether we rebuild the war.
+ * @param what - whether we will or not
+ */
+ public void setRebuildWar(final boolean what) {
+ rebuildWar = what;
+ }
+
+ /** Do we rebuild the war?
+ * @return true if we are going to.
+ */
+ public boolean isRebuildWar() {
+ return rebuildWar;
+ }
+
/** Install the plugin from the provided URL. Involves downloading
* the file and then doing a {@link #installPlugin(Path, String, boolean)}.
* @param baseURL where we get the files from
@@ -282,14 +299,17 @@ public final class PluginInstaller extends AbstractInitializableComponent implem
rollBack.completed();
}
- final BuildWar builder = new BuildWar(idpHome);
- try {
- builder.initialize();
- } catch (final ComponentInitializationException e) {
- throw new BuildException(e);
+ if (isRebuildWar()) {
+ final BuildWar builder = new BuildWar(idpHome);
+ try {
+ builder.initialize();
+ } catch (final ComponentInitializationException e) {
+ throw new BuildException(e);
+ }
+ builder.execute();
+ } else {
+ LOG.info("WAR file not rebuilt.");
}
- builder.execute();
-
emitModuleChanges();
}
@@ -332,14 +352,18 @@ public final class PluginInstaller extends AbstractInitializableComponent implem
}
}
- final BuildWar builder = new BuildWar(idpHome);
- try {
- builder.initialize();
- } catch (final ComponentInitializationException e) {
- throw new BuildException(e);
+ if (isRebuildWar()) {
+ final BuildWar builder = new BuildWar(idpHome);
+ try {
+ builder.initialize();
+ } catch (final ComponentInitializationException e) {
+ throw new BuildException(e);
+ }
+ builder.execute();
+ LOG.info("Removed resources for {} from the WAR file.", pluginId);
+ } else {
+ LOG.info("Removed resources for {}. WAR file not rebuilt.", pluginId);
}
- builder.execute();
- LOG.info("Removed resources for {} from the war", pluginId);
}
pluginsContents.resolve(pluginId).toFile().deleteOnExit();
emitModuleChanges();
diff --git a/idp-installer/src/main/java/net/shibboleth/idp/installer/plugin/impl/PluginInstallerArguments.java b/idp-installer/src/main/java/net/shibboleth/idp/installer/plugin/impl/PluginInstallerArguments.java
index 421604334..3389f9b94 100644
--- a/idp-installer/src/main/java/net/shibboleth/idp/installer/plugin/impl/PluginInstallerArguments.java
+++ b/idp-installer/src/main/java/net/shibboleth/idp/installer/plugin/impl/PluginInstallerArguments.java
@@ -96,6 +96,10 @@ public class PluginInstallerArguments extends AbstractIdPHomeAwareCommandLineArg
@Parameter(names= {"--updateURL"})
@Nullable private String updateURL;
+ /** Override version check. */
+ @Parameter(names= {"--noRebuild", "--no-rebuild"})
+ @Nullable private boolean noRebuild;
+
/** The {@link #forceUpdateVersion} as a {@link PluginVersion}. */
@Nullable private PluginVersion updateVersion;
@@ -238,6 +242,13 @@ public class PluginInstallerArguments extends AbstractIdPHomeAwareCommandLineArg
return operation;
}
+ /** Do we rebuild the war?
+ * @return whether we do or not
+ */
+ public boolean isRebuild() {
+ return !noRebuild;
+ }
+
/** {@inheritDoc} */
// Checkstyle: CyclomaticComplexity OFF
public void validate() throws IllegalArgumentException {
@@ -348,6 +359,7 @@ public class PluginInstallerArguments extends AbstractIdPHomeAwareCommandLineArg
out.println(String.format(" %-22s %s", "-i, --input <what>", "Install (file name or web address)"));
out.println(String.format(" %-22s %s", "--noCheck", "Do not check the version"));
out.println(String.format(" %-22s %s", "-u, --update <PluginId>", "update"));
+ out.println(String.format(" %-22s %s", "--noRebuild", "do NOT rebuild war"));
out.println(String.format(" %-22s %s", "-fu, --force-update <version>",
"force version to update to (requires -u)"));
out.println(String.format(" %-22s %s", "-r, --remove, --uninstall <PluginId>",
diff --git a/idp-installer/src/main/java/net/shibboleth/idp/installer/plugin/impl/PluginInstallerCLI.java b/idp-installer/src/main/java/net/shibboleth/idp/installer/plugin/impl/PluginInstallerCLI.java
index 46bdbda0b..c1f6e6f8f 100644
--- a/idp-installer/src/main/java/net/shibboleth/idp/installer/plugin/impl/PluginInstallerCLI.java
+++ b/idp-installer/src/main/java/net/shibboleth/idp/installer/plugin/impl/PluginInstallerCLI.java
@@ -202,6 +202,7 @@ public final class PluginInstallerCLI extends AbstractIdPHomeAwareCommandLine<Pl
}
inst.setModuleContextSecurityParams(getHttpClientSecurityParameters());
inst.setUpdateOverrideURLs(updateURLs);
+ inst.setRebuildWar(args.isRebuild());
inst.initialize();
installer = inst;
}
diff --git a/idp-installer/src/test/java/net/shibboleth/idp/installer/plugin/impl/PluginCLITest.java b/idp-installer/src/test/java/net/shibboleth/idp/installer/plugin/impl/PluginCLITest.java
index 55099ee82..3692a57e2 100644
--- a/idp-installer/src/test/java/net/shibboleth/idp/installer/plugin/impl/PluginCLITest.java
+++ b/idp-installer/src/test/java/net/shibboleth/idp/installer/plugin/impl/PluginCLITest.java
@@ -84,6 +84,7 @@ public class PluginCLITest extends BasePluginTest {
assertEquals(PluginInstallerCLI.runMain(new String[] {
"-i", PLUGIN_DISTRO,
"--noCheck",
+ "--noRebuild"
}),
AbstractCommandLine.RC_OK);
}
@@ -93,6 +94,7 @@ public class PluginCLITest extends BasePluginTest {
assertEquals(PluginInstallerCLI.runMain(new String[] {
"-u", PLUGIN_ID,
"--noCheck",
+ "--noRebuild"
}),
AbstractCommandLine.RC_OK);
}
@@ -117,6 +119,7 @@ public class PluginCLITest extends BasePluginTest {
public void testUninstall() {
assertEquals(PluginInstallerCLI.runMain(new String[] {
"-r", PLUGIN_ID,
+ "--noRebuild"
}),
AbstractCommandLine.RC_OK);
}
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list