From d3cfd0b1720ce03a806e78e5354cc543cd87d388 Mon Sep 17 00:00:00 2001 From: Cousjava Date: Thu, 22 Jun 2017 10:59:52 +0100 Subject: [PATCH 1/2] PAYARA-1618 outputuberjar packages up applications deployed to rootdir --- .../payara/micro/impl/UberJarCreator.java | 27 ++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/appserver/extras/payara-micro/payara-micro-core/src/main/java/fish/payara/micro/impl/UberJarCreator.java b/appserver/extras/payara-micro/payara-micro-core/src/main/java/fish/payara/micro/impl/UberJarCreator.java index d69564bcde0..a94590bceb6 100644 --- a/appserver/extras/payara-micro/payara-micro-core/src/main/java/fish/payara/micro/impl/UberJarCreator.java +++ b/appserver/extras/payara-micro/payara-micro-core/src/main/java/fish/payara/micro/impl/UberJarCreator.java @@ -1,7 +1,7 @@ /* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * - * Copyright (c) 2016 Payara Foundation and/or its affiliates. All rights reserved. + * Copyright (c) 2016-2017 Payara Foundation and/or its affiliates. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common Development @@ -40,6 +40,7 @@ package fish.payara.micro.impl; import com.google.common.io.Files; +import java.io.BufferedInputStream; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; @@ -58,6 +59,8 @@ import java.util.jar.JarOutputStream; import java.util.logging.Level; import java.util.logging.Logger; +import java.util.zip.CRC32; +import java.util.zip.CheckedInputStream; /** * @@ -338,6 +341,28 @@ public void buildUberJar() { } } + + File applicationsDir = new File(domainDir, "applications"); + if (applicationsDir.exists()){ + for (File app : fillFiles(applicationsDir)){ + String path = app.getPath(); + if (path.endsWith(".war") || path.endsWith(".jar") || path.endsWith(".rar")){ + JarEntry appEntry = new JarEntry("MICRO-INF/deploy/" + app.getName()); + appEntry.setMethod(JarEntry.STORED); + appEntry.setSize(app.length()); + CheckedInputStream check = new CheckedInputStream(new FileInputStream(app), new CRC32()); + BufferedInputStream in = new BufferedInputStream(check); + while (in.read(new byte[300]) != -1){ + //read in file completly + } + appEntry.setCrc(check.getChecksum().getValue()); + jos.putNextEntry(appEntry); + Files.copy(app, jos); + jos.flush(); + jos.closeEntry(); + } + } + } } LOGGER.info("Built Uber Jar " + outputFile.getAbsolutePath() + " in " + (System.currentTimeMillis() - start) + " (ms)"); From 9154b8e98bc2c5f3273729a02a6923a3589eea3b Mon Sep 17 00:00:00 2001 From: Cousjava Date: Fri, 23 Jun 2017 13:47:58 +0100 Subject: [PATCH 2/2] Requested changes --- .../src/main/java/fish/payara/micro/impl/UberJarCreator.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/appserver/extras/payara-micro/payara-micro-core/src/main/java/fish/payara/micro/impl/UberJarCreator.java b/appserver/extras/payara-micro/payara-micro-core/src/main/java/fish/payara/micro/impl/UberJarCreator.java index a94590bceb6..e0e7760eba9 100644 --- a/appserver/extras/payara-micro/payara-micro-core/src/main/java/fish/payara/micro/impl/UberJarCreator.java +++ b/appserver/extras/payara-micro/payara-micro-core/src/main/java/fish/payara/micro/impl/UberJarCreator.java @@ -346,9 +346,8 @@ public void buildUberJar() { if (applicationsDir.exists()){ for (File app : fillFiles(applicationsDir)){ String path = app.getPath(); - if (path.endsWith(".war") || path.endsWith(".jar") || path.endsWith(".rar")){ + if (path.endsWith(".war") || path.endsWith(".jar") || path.endsWith(".rar") || path.endsWith(".ear")){ JarEntry appEntry = new JarEntry("MICRO-INF/deploy/" + app.getName()); - appEntry.setMethod(JarEntry.STORED); appEntry.setSize(app.length()); CheckedInputStream check = new CheckedInputStream(new FileInputStream(app), new CRC32()); BufferedInputStream in = new BufferedInputStream(check);