Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove uberJar Maven/Gradle param & quarkus.package.uber-jar property #14987

Merged
merged 1 commit into from
Feb 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,6 @@ public class PackageConfig {
@ConfigItem(defaultValue = JAR)
public String type;

/**
* If the java runner should be packed as an uberjar
*
* This is deprecated, you should use quarkus.package.type=uber-jar instead
*/
@Deprecated
@ConfigItem(defaultValue = "false")
public boolean uberJar;

/**
* Manifest configuration of the runner jar.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,19 +181,13 @@ public JarBuildItem buildRunnerJar(CurateOutcomeBuildItem curateOutcomeBuildItem
if (appCDS.isPresent()) {
handleAppCDSSupportFileGeneration(transformedClasses, generatedClasses, appCDS.get());
}
if (!(packageConfig.type.equalsIgnoreCase(PackageConfig.JAR) ||
packageConfig.type.equalsIgnoreCase(PackageConfig.UBER_JAR))
&& packageConfig.uberJar) {
throw new RuntimeException(
"Cannot set quarkus.package.uber-jar=true and quarkus.package.type, if you want an uber-jar set quarkus.package.type=uber-jar.");
}

if (!uberJarRequired.isEmpty() && !legacyJarRequired.isEmpty()) {
throw new RuntimeException(
"Extensions with conflicting package types. One extension requires uber-jar another requires legacy format");
}

if (legacyJarRequired.isEmpty() && (!uberJarRequired.isEmpty() || packageConfig.uberJar
if (legacyJarRequired.isEmpty() && (!uberJarRequired.isEmpty()
|| packageConfig.type.equalsIgnoreCase(PackageConfig.UBER_JAR))) {
return buildUberJar(curateOutcomeBuildItem, outputTargetBuildItem, transformedClasses, applicationArchivesBuildItem,
packageConfig, applicationInfo, generatedClasses, generatedResources, closeablesBuildItem,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ public class QuarkusBuild extends QuarkusTask {

private static final String NATIVE_PROPERTY_NAMESPACE = "quarkus.native";

private boolean uberJar;

private List<String> ignoredEntries = new ArrayList<>();

public QuarkusBuild() {
Expand All @@ -49,21 +47,6 @@ public QuarkusBuild nativeArgs(Action<Map<String, ?>> action) {
return this;
}

@Input
public boolean isUberJar() {
return uberJar;
}

/**
* @param uberJar Set to true if the build task should build an uberjar
* @deprecated use {@code quarkus.package.type} instead
*/
@Option(description = "Set to true if the build task should build an uberjar", option = "uber-jar")
@Deprecated
public void setUberJar(boolean uberJar) {
this.uberJar = uberJar;
}

@Optional
@Input
public List<String> getIgnoredEntries() {
Expand Down Expand Up @@ -135,13 +118,6 @@ public void buildQuarkus() {
String joinedEntries = String.join(",", ignoredEntries);
effectiveProperties.setProperty("quarkus.package.user-configured-ignored-entries", joinedEntries);
}
boolean clear = false;
if (isUberJar() && System.getProperty("quarkus.package.uber-jar") == null) {
getLogger().lifecycle(
"The uberJar option is deprecated, and will be removed in a future version. To build an uber-jar set the config property quarkus.package.type=uber-jar. For more info see https://quarkus.io/guides/gradle-tooling#building-uber-jars");
System.setProperty("quarkus.package.uber-jar", "true");
clear = true;
}
try (CuratedApplication appCreationContext = QuarkusBootstrap.builder()
.setBaseClassLoader(getClass().getClassLoader())
.setAppModelResolver(modelResolver)
Expand All @@ -164,10 +140,6 @@ public void buildQuarkus() {

} catch (BootstrapException e) {
throw new GradleException("Failed to build a runnable JAR", e);
} finally {
if (clear) {
System.clearProperty("quarkus.package.uber-jar");
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
@Mojo(name = "build", defaultPhase = LifecyclePhase.PACKAGE, requiresDependencyResolution = ResolutionScope.COMPILE_PLUS_RUNTIME, threadSafe = true)
public class BuildMojo extends QuarkusBootstrapMojo {

public static final String QUARKUS_PACKAGE_UBER_JAR = "quarkus.package.uber-jar";
private static final String PACKAGE_TYPE_PROP = "quarkus.package.type";
private static final String NATIVE_PROFILE_NAME = "native";
private static final String NATIVE_PACKAGE_TYPE = "native";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,7 @@ public abstract class QuarkusBootstrapMojo extends AbstractMojo {
private String finalName;

/**
* @deprecated use {@code quarkus.package.type} instead
*/
@Parameter(property = "uberJar", defaultValue = "false")
@Deprecated
private boolean uberJar;

/**
* When using the uberJar option, this array specifies entries that should
* When building an uber-jar, this array specifies entries that should
* be excluded from the final jar. The entries are relative to the root of
* the file. An example of this configuration could be:
* <code><pre>
Expand Down Expand Up @@ -148,14 +141,6 @@ protected String[] ignoredEntries() {
return ignoredEntries;
}

protected boolean uberJar() {
if (uberJar) {
getLog().warn(
"The parameter uberJar is deprecated, and will be removed in a future version. To build an uber-jar set the config property quarkus.package.type=uber-jar. For more info see https://quarkus.io/guides/maven-tooling#uber-jar-maven");
}
return uberJar;
}

protected AppArtifactKey projectId() {
return projectId == null ? projectId = new AppArtifactKey(project.getGroupId(), project.getArtifactId()) : projectId;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,6 @@ protected QuarkusBootstrap bootstrapQuarkus(QuarkusBootstrapMojo mojo) throws Mo
effectiveProperties.setProperty(name, projectProperties.getProperty(name));
}
}
if (mojo.uberJar() && System.getProperty(BuildMojo.QUARKUS_PACKAGE_UBER_JAR) == null) {
effectiveProperties.setProperty(BuildMojo.QUARKUS_PACKAGE_UBER_JAR, "true");
}

effectiveProperties.putIfAbsent("quarkus.application.name", mojo.mavenProject().getArtifactId());
effectiveProperties.putIfAbsent("quarkus.application.version", mojo.mavenProject().getVersion());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public ArtifactResultBuildItem functionDeployment(OutputTargetBuildItem target,
throws BuildException, IOException {
if (!jar.isUberJar()) {
throw new BuildException("Google Cloud Function deployment need to use a uberjar, " +
"please set 'quarkus.package.uber-jar=true' inside your application.properties",
"please set 'quarkus.package.type=uber-jar' inside your application.properties",
Collections.EMPTY_LIST);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public ArtifactResultBuildItem functionDeployment(OutputTargetBuildItem target,
throws BuildException, IOException {
if (!jar.isUberJar()) {
throw new BuildException("Google Cloud Function deployment need to use a uberjar, " +
"please set 'quarkus.package.uber-jar=true' inside your application.properties",
"please set 'quarkus.package.type=uber-jar' inside your application.properties",
Collections.EMPTY_LIST);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public ArtifactResultBuildItem functionDeployment(OutputTargetBuildItem target,
throws BuildException, IOException {
if (!jar.isUberJar()) {
throw new BuildException("Google Cloud Function deployment need to use a uberjar, " +
"please set 'quarkus.package.uber-jar=true' inside your application.properties",
"please set 'quarkus.package.type=uber-jar' inside your application.properties",
Collections.EMPTY_LIST);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,23 +43,6 @@ public void testUberJarMavenPluginConfiguration()
verifyUberJar();
}

@Test
public void testPackageWorksWhenUberjarIsFalse()
throws MavenInvocationException, IOException, InterruptedException {
testDir = initProject("projects/uberjar-check", "projects/project-uberjar-false");

running = new RunningInvoker(testDir, false);
final MavenProcessInvocationResult result = running.execute(Collections.singletonList("package"),
Collections.singletonMap("QUARKUS_PACKAGE_UBER_JAR", "false"));

assertThat(result.getProcess().waitFor()).isEqualTo(0);

File runnerJar = getTargetDir().toPath().resolve("quarkus-app").resolve("quarkus-run.jar").toFile();

// make sure the jar can be read by JarInputStream
ensureManifestOfJarIsReadableByJarInputStream(runnerJar);
}

private void ensureManifestOfJarIsReadableByJarInputStream(File jar) throws IOException {
try (InputStream fileInputStream = new FileInputStream(jar)) {
try (JarInputStream stream = new JarInputStream(fileInputStream)) {
Expand Down Expand Up @@ -116,7 +99,7 @@ public void testDependencyOnPomMutableJar()
@Test
public void testPackageWorksWhenUberjarIsTrue()
throws MavenInvocationException, IOException, InterruptedException {
testDir = initProject("projects/uberjar-check", "projects/project-uberjar-true");
testDir = initProject("projects/uberjar-check");

createAndVerifyUberJar();
// ensure that subsequent package without clean also works
Expand All @@ -125,7 +108,7 @@ public void testPackageWorksWhenUberjarIsTrue()

private void createAndVerifyUberJar() throws IOException, MavenInvocationException, InterruptedException {
Properties p = new Properties();
p.setProperty("quarkus.package.uber-jar", "true");
p.setProperty("quarkus.package.type", "uber-jar");

running = new RunningInvoker(testDir, false);
final MavenProcessInvocationResult result = running.execute(Collections.singletonList("package"),
Expand Down Expand Up @@ -183,12 +166,12 @@ public void testCustomPackaging()
*/
@Test
public void testRunnerUberJarHasValidCRC() throws Exception {
testDir = initProject("projects/uberjar-check", "projects/project-uberjar-true2");
testDir = initProject("projects/uberjar-check", "projects/project-uberjar-crc");

running = new RunningInvoker(testDir, false);

Properties p = new Properties();
p.setProperty("quarkus.package.uber-jar", "true");
p.setProperty("quarkus.package.type", "uber-jar");
final MavenProcessInvocationResult result = running.execute(Collections.singletonList("package"),
Collections.emptyMap(), p);
assertThat(result.getProcess().waitFor()).isEqualTo(0);
Expand All @@ -212,7 +195,7 @@ public void testRunnerUberJarHasValidCRC() throws Exception {
*/
@Test
public void testLegacyJarHasValidCRC() throws Exception {
testDir = initProject("projects/uberjar-check", "projects/project-uberjar-false2");
testDir = initProject("projects/uberjar-check", "projects/project-legacyjar-crc");

running = new RunningInvoker(testDir, false);
final MavenProcessInvocationResult result = running.execute(Collections.singletonList("package"),
Expand All @@ -238,7 +221,7 @@ public void testLegacyJarHasValidCRC() throws Exception {
*/
@Test
public void testFastJarHasValidCRC() throws Exception {
testDir = initProject("projects/uberjar-check", "projects/project-uberjar-false2");
testDir = initProject("projects/uberjar-check", "projects/project-fastjar-crc");

running = new RunningInvoker(testDir, false);
final MavenProcessInvocationResult result = running.execute(Collections.singletonList("package"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public void testManifestEntries() throws Exception {
Assertions.assertEquals("Test Value 1", testAttributes.getValue(testKey1),
"Custom Manifest Entry for Test-Key-1 value is not correct");
Assertions.assertTrue(testAttributes.containsKey(new Attributes.Name("Test-Key-2")),
"Custom Manifest Emntry for Test-Key-2 is missing");
"Custom Manifest Entry for Test-Key-2 is missing");
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
quarkus.package.type=jar
quarkus.package.uber-jar=false
quarkus.package.manifest.manifest-sections.Test-Information.Test-Key-1=Test Value 1
quarkus.package.manifest.manifest-sections.Test-Information.Test-Key-2=Test Value 2
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
quarkus.package.type=jar
quarkus.package.uber-jar=true
quarkus.package.type=uber-jar
quarkus.package.manifest.manifest-sections.Test-Information.Test-Key-1=Test Value 1
quarkus.package.manifest.manifest-sections.Test-Information.Test-Key-2=Test Value 2
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
quarkus.package.type=jar
quarkus.package.uber-jar=false
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
quarkus.package.type=jar
quarkus.package.uber-jar=true
quarkus.package.type=uber-jar