Skip to content

Commit

Permalink
Fix issue with fast-jar not working using OpenShift and Docker strategy
Browse files Browse the repository at this point in the history
Fixes quarkusio#16113

(cherry picked from commit df695f3)
  • Loading branch information
geoand authored and gsmet committed Apr 3, 2021
1 parent 1a9962d commit c88134c
Showing 1 changed file with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import static io.quarkus.container.image.openshift.deployment.OpenshiftUtils.mergeConfig;
import static io.quarkus.container.util.PathsUtil.findMainSourcesRoot;
import static io.quarkus.deployment.pkg.steps.JarResultBuildStep.DEFAULT_FAST_JAR_DIRECTORY_NAME;

import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
Expand Down Expand Up @@ -252,7 +253,8 @@ public void openshiftBuildFromJar(OpenshiftConfig openshiftConfig,
//The contextRoot is where inside the tarball we will add the jars. A null value means everything will be added under '/' while "target" means everything will be added under '/target'.
//For docker kind of builds where we use instructions like: `COPY target/*.jar /deployments` it using '/target' is a requirement.
//For s2i kind of builds where jars are expected directly in the '/' we have to use null.
String contextRoot = config.buildStrategy == BuildStrategy.DOCKER ? "target" : null;
String outputDirName = out.getOutputDirectory().getFileName().toString();
String contextRoot = getContextRoot(outputDirName, packageConfig.isFastJar(), config.buildStrategy);
if (packageConfig.isFastJar()) {
createContainerImage(kubernetesClient, openshiftYml.get(), config, contextRoot, jar.getPath().getParent(),
jar.getPath().getParent());
Expand All @@ -266,6 +268,16 @@ public void openshiftBuildFromJar(OpenshiftConfig openshiftConfig,
artifactResultProducer.produce(new ArtifactResultBuildItem(null, "jar-container", Collections.emptyMap()));
}

private String getContextRoot(String outputDirName, boolean isFastJar, BuildStrategy buildStrategy) {
if (buildStrategy != BuildStrategy.DOCKER) {
return null;
}
if (!isFastJar) {
return outputDirName;
}
return outputDirName + "/" + DEFAULT_FAST_JAR_DIRECTORY_NAME;
}

@BuildStep(onlyIf = { IsNormalNotRemoteDev.class, OpenshiftBuild.class, NativeBuild.class })
public void openshiftBuildFromNative(OpenshiftConfig openshiftConfig, S2iConfig s2iConfig,
ContainerImageConfig containerImageConfig,
Expand Down

0 comments on commit c88134c

Please sign in to comment.