Skip to content

Commit

Permalink
Change to only allow a single output type
Browse files Browse the repository at this point in the history
  • Loading branch information
stuartwdouglas committed Oct 23, 2019
1 parent 7e35142 commit cbc70cb
Show file tree
Hide file tree
Showing 23 changed files with 212 additions and 311 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
import java.util.List;

import io.quarkus.deployment.pkg.builditem.ArtifactResultBuildItem;
import io.quarkus.deployment.pkg.builditem.JarBuildItem;
import io.quarkus.deployment.pkg.builditem.NativeImageBuildItem;
import io.quarkus.deployment.pkg.builditem.ThinJarBuildItem;
import io.quarkus.deployment.pkg.builditem.UberJarBuildItem;

/**
* Represents an outcome of {@link AugmentTask}
Expand All @@ -15,15 +14,13 @@
public class AugmentOutcome {

private final List<ArtifactResultBuildItem> packageOutput;
private final ThinJarBuildItem thinJar;
private final UberJarBuildItem uberJar;
private final JarBuildItem jar;
private final NativeImageBuildItem nativeImage;

public AugmentOutcome(List<ArtifactResultBuildItem> packageOutput, ThinJarBuildItem thinJar, UberJarBuildItem uberJar,
public AugmentOutcome(List<ArtifactResultBuildItem> packageOutput, JarBuildItem thinJar,
NativeImageBuildItem nativeImage) {
this.packageOutput = packageOutput;
this.thinJar = thinJar;
this.uberJar = uberJar;
this.jar = thinJar;
this.nativeImage = nativeImage;
}

Expand All @@ -34,12 +31,8 @@ public List<ArtifactResultBuildItem> getPackageOutput() {
return packageOutput;
}

public ThinJarBuildItem getThinJar() {
return thinJar;
}

public UberJarBuildItem getUberJar() {
return uberJar;
public JarBuildItem getJar() {
return jar;
}

public NativeImageBuildItem getNativeImage() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,8 @@
import io.quarkus.deployment.builditem.BytecodeTransformerBuildItem;
import io.quarkus.deployment.builditem.MainClassBuildItem;
import io.quarkus.deployment.pkg.builditem.ArtifactResultBuildItem;
import io.quarkus.deployment.pkg.builditem.JarBuildItem;
import io.quarkus.deployment.pkg.builditem.NativeImageBuildItem;
import io.quarkus.deployment.pkg.builditem.ThinJarBuildItem;
import io.quarkus.deployment.pkg.builditem.UberJarBuildItem;
import io.smallrye.config.PropertiesConfigSource;
import io.smallrye.config.SmallRyeConfigProviderResolver;

Expand Down Expand Up @@ -184,7 +183,7 @@ public AugmentOutcome run(CurateOutcome appState, CuratedApplicationCreator ctx)
Thread.currentThread().setContextClassLoader(old);
}
return new AugmentOutcome(result.consumeMulti(ArtifactResultBuildItem.class),
result.consumeOptional(ThinJarBuildItem.class), result.consumeOptional(UberJarBuildItem.class),
result.consumeOptional(JarBuildItem.class),
result.consumeOptional(NativeImageBuildItem.class));

} catch (Exception e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ protected void testCreator(CuratedApplicationCreator creator) throws Exception {
final AugmentOutcome outcome = creator
.runTask(AugmentTask.builder().build());

final Path libDir = outcome.getThinJar().getLibraryDir();
final Path libDir = outcome.getJar().getLibraryDir();
assertTrue(Files.isDirectory(libDir));
final Set<String> actualLib = new HashSet<>();
try (Stream<Path> stream = Files.list(libDir)) {
Expand All @@ -49,7 +49,7 @@ protected void testCreator(CuratedApplicationCreator creator) throws Exception {
}
}

final Path runnerJar = outcome.getThinJar().getPath();
final Path runnerJar = outcome.getJar().getPath();
assertTrue(Files.exists(runnerJar));
try (JarFile jar = new JarFile(runnerJar.toFile())) {
final Attributes mainAttrs = jar.getManifest().getMainAttributes();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public class NativeConfig {
/**
* If the HTTP url handler should be enabled, allowing you to do URL.openConnection() for HTTP URLs
*/
@ConfigItem(defaultValue = "false")
@ConfigItem(defaultValue = "true")
public boolean enableHttpUrlHandler;

/**
Expand Down Expand Up @@ -130,14 +130,22 @@ public class NativeConfig {
@ConfigItem
public Optional<String> nativeImageXmx;

/**
* If this build should be done using a container runtime. If this is set docker will be used by default,
* unless container-runtime is also set.
*/
@ConfigItem(defaultValue = "false")
public boolean containerBuild;

/**
* The docker image to use to do the image build
*/
@ConfigItem(defaultValue = "quay.io/quarkus/ubi-quarkus-native-image:19.2.0")
public String builderImage;

/**
* The container runtime (e.g. docker) that is used to do an image based build
* The container runtime (e.g. docker) that is used to do an image based build. If this is set then
* a container build is always done.
*/
@ConfigItem
public String containerRuntime = "";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,22 @@
@ConfigRoot
public class PackageConfig {

public static final String THIN_JAR = "thin-jar";
public static final String UBER_JAR = "uber-jar";
public static final String JAR = "jar";
public static final String NATIVE = "native";

/**
* A list of requested output types. Even if some types are not explicitly requested as output
* they may still be built if they are needed.
* The requested output type.
*
* The default build in types are thin-jar, uber-jar and native
* The default built in types are jar and native
*/
@ConfigItem(defaultValue = THIN_JAR)
public List<String> types;
@ConfigItem(defaultValue = JAR)
public String type;

/**
* If the java runner should be packed as an uberjar
*/
@ConfigItem(defaultValue = "false")
public boolean uberJar;

/**
* The entry point of the application. In most cases this should not be modified.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,30 @@

import io.quarkus.builder.item.SimpleBuildItem;

public final class UberJarBuildItem extends SimpleBuildItem {
public final class JarBuildItem extends SimpleBuildItem {

private final Path path;
private final Path originalArtifact;
private final Path libraryDir;

public UberJarBuildItem(Path path, Path originalArtifact) {
public JarBuildItem(Path path, Path originalArtifact, Path libraryDir) {
this.path = path;
this.originalArtifact = originalArtifact;
this.libraryDir = libraryDir;
}

public boolean isUberJar() {
return libraryDir == null;
}

public Path getPath() {
return path;
}

public Path getLibraryDir() {
return libraryDir;
}

public Path getOriginalArtifact() {
return originalArtifact;
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package io.quarkus.deployment.pkg.builditem;

import io.quarkus.builder.item.MultiBuildItem;

/**
* marker build item that extensions can use to force uber jar creation
*/
public final class UberJarRequiredBuildItem extends MultiBuildItem {
}
Loading

0 comments on commit cbc70cb

Please sign in to comment.