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

Change decompiler from quiltflower to vineflower #35610

Merged
merged 1 commit into from
Sep 20, 2023
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 @@ -248,10 +248,10 @@ public static BuiltInType fromString(String value) {
public boolean includeDependencyList;

/**
* Quiltflower Decompiler configuration
* Vineflower Decompiler configuration
*/
@ConfigItem
public QuiltFlowerConfig quiltflower;
public VineFlowerConfig vineflower;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about renaming it to something future-proof? decompiler perhaps?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's somewhat meant to be futureproof in the sense you could have support for multiple decompilers for example the config is quarkus.package.vineflower.enabled=true maybe there could be support for another one this way? quarkus.package.my-other-decompiler.enabled=true. I may be wrong though!

a bit what I could gather from the code in #25729 where both fernflower and quiltflower could coexist

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason I ask is that I never know the config to enable the compiler without looking at the docs. quarkus.package.decompiler.enabled=true is cleaner (to me at least) 😄

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a bit what I could gather from the code in #25729 where both fernflower and quiltflower could coexist

Right, and I believe this is the reason why @geoand made it that way. I'm afraid that removing the config option would make existing users a bit annoyed, so perhaps deprecating (for removal) quarkus.package.quiltflower in favor of quarkus.package.vineflower may be better in this case

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But I am still leaning towards having quarkus.package.decompiler.enabled, given I doubt anybody cares about the decompiler used in practice :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So is there a consensus here? :)

In my opinion, having both config, with the deprecated one is more or less useful as there isn't extreme adaptation to be made. On quarkus update, when looking at the migration it would be quite clear, vs deprecating, it, then doing it in some other release, not like if a behaviour changed underneath. As per quarkus.package.decompiler.enabled, I do like it, but definitely not my call! I can adapt to what you guys decide.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like to keep the decompiler name for the time being.


/**
* If set to {@code true}, it will result in the Quarkus writing the transformed application bytecode
Expand Down Expand Up @@ -302,7 +302,7 @@ public String getRunnerSuffix() {
}

@ConfigGroup
public static class QuiltFlowerConfig {
public static class VineFlowerConfig {
/**
* An advanced option that will decompile generated and transformed bytecode into the 'decompiled' directory.
* This is only taken into account when fast-jar is used.
Expand All @@ -311,13 +311,13 @@ public static class QuiltFlowerConfig {
public boolean enabled;

/**
* The version of Quiltflower to use
* The version of Vineflower to use
*/
@ConfigItem(defaultValue = "1.8.1")
@ConfigItem(defaultValue = "1.9.3")
public String version;

/**
* The directory into which to save the Quiltflower tool if it doesn't exist
* The directory into which to save the Vineflower tool if it doesn't exist
*/
@ConfigItem(defaultValue = "${user.home}/.quarkus")
public String jarDirectory;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -603,17 +603,17 @@ private JarBuildItem buildThinJar(CurateOutcomeBuildItem curateOutcomeBuildItem,
Path decompiledOutputDir = null;
boolean wasDecompiledSuccessfully = true;
Decompiler decompiler = null;
if (packageConfig.quiltflower.enabled) {
if (packageConfig.vineflower.enabled) {
decompiledOutputDir = buildDir.getParent().resolve("decompiled");
FileUtil.deleteDirectory(decompiledOutputDir);
Files.createDirectory(decompiledOutputDir);
if (packageConfig.quiltflower.enabled) {
decompiler = new Decompiler.QuiltflowerDecompiler();
Path jarDirectory = Paths.get(packageConfig.quiltflower.jarDirectory);
if (packageConfig.vineflower.enabled) {
decompiler = new Decompiler.VineflowerDecompiler();
Path jarDirectory = Paths.get(packageConfig.vineflower.jarDirectory);
if (!Files.exists(jarDirectory)) {
Files.createDirectory(jarDirectory);
}
decompiler.init(new Decompiler.Context(packageConfig.quiltflower.version, jarDirectory, decompiledOutputDir));
decompiler.init(new Decompiler.Context(packageConfig.vineflower.version, jarDirectory, decompiledOutputDir));
decompiler.downloadIfNecessary();
}
}
Expand Down Expand Up @@ -1572,15 +1572,15 @@ public Context(String versionStr, Path jarLocation, Path decompiledOutputDir) {

}

class QuiltflowerDecompiler implements Decompiler {
class VineflowerDecompiler implements Decompiler {

private Context context;
private Path decompilerJar;

@Override
public void init(Context context) {
this.context = context;
this.decompilerJar = context.jarLocation.resolve(String.format("quiltflower-%s.jar", context.versionStr));
this.decompilerJar = context.jarLocation.resolve(String.format("vineflower-%s.jar", context.versionStr));
}

@Override
Expand All @@ -1589,7 +1589,7 @@ public boolean downloadIfNecessary() {
return true;
}
String downloadURL = String.format(
"https://github.com/QuiltMC/quiltflower/releases/download/%s/quiltflower-%s.jar",
"https://repo.maven.apache.org/maven2/org/vineflower/vineflower/%s/vineflower-%s.jar",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we somehow use the Maven resolver APIs here? I fear that this may not work in environments with a firewall, but maybe it can be revisited in a future PR

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not exactly sure what that means as I have never used it. I wouldn't mind looking into it in another PR to have less risks in that one. For my comprehension, would it be about fetching the jar during build so it can be used form the MAVEN_HOME when needed? Or like currently download as needed via something like shrinkwrap/resolver (this does not seem to help with firewall though)?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would argue this is exactly similar to what it used to be. So let's not make @manofthepeace 's life harder than it needs to be.

context.versionStr, context.versionStr);
try (BufferedInputStream in = new BufferedInputStream(new URL(downloadURL).openStream());
FileOutputStream fileOutputStream = new FileOutputStream(decompilerJar.toFile())) {
Expand All @@ -1600,7 +1600,7 @@ public boolean downloadIfNecessary() {
}
return true;
} catch (IOException e) {
log.error("Unable to download Quiltflower from " + downloadURL, e);
log.error("Unable to download Vineflower from " + downloadURL, e);
return false;
}
}
Expand Down Expand Up @@ -1633,7 +1633,7 @@ public boolean decompile(Path jarToDecompile) {
}

if (exitCode != 0) {
log.errorf("Quiltflower decompiler exited with error code: %d.", exitCode);
log.errorf("Vineflower decompiler exited with error code: %d.", exitCode);
return false;
}

Expand Down
2 changes: 1 addition & 1 deletion docs/.vale/fixtures/Quarkus/Headings/testvalid.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
== Proof Key for Code Exchange
== Kogito updates
== IBM Cloud is a valid product name
== Spotify, GraphQL, and Quiltflower are proper nouns so uppercase in headings is OK.
== Spotify, GraphQL, and Vineflower are proper nouns so uppercase in headings is OK.
== Use xDS gRPC
== Use JBoss Logging for application logging
== JBoss Logging API
Expand Down
2 changes: 1 addition & 1 deletion docs/.vale/fixtures/Quarkus/Spelling/testvalid.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,6 @@ Pytorch
qeth
Quarkiverse
Quarkus
Quiltflower
Qute
Readonly
Rebalance
Expand Down Expand Up @@ -376,6 +375,7 @@ Valgrind
validator
Velero
Vert.x
Vineflower
vsix
WebAuthn
WebSocket
Expand Down
2 changes: 1 addition & 1 deletion docs/.vale/styles/Quarkus/Headings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,6 @@ exceptions:
- Qt
- Quarkiverse
- Quarkus
- Quiltflower
- Qute
- RESTEasy
- Red Hat
Expand Down Expand Up @@ -233,6 +232,7 @@ exceptions:
- Valgrind
- Velero
- Vert.x
- Vineflower
- WebAuthn
- WebSocket
- Webview
Expand Down
2 changes: 1 addition & 1 deletion docs/.vale/styles/Quarkus/Spelling.yml
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,6 @@ filters:
- QLogic
- Quarkiverse
- Quarkus
- Quiltflower
- Qute
- Realtime
- Redis
Expand Down Expand Up @@ -425,6 +424,7 @@ filters:
- Velero
- Vert.x
- vHost
- Vineflower
- VMs
- VMware
- vsix
Expand Down
2 changes: 1 addition & 1 deletion docs/src/main/asciidoc/writing-extensions.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -2246,7 +2246,7 @@ The only particular aspect of writing Quarkus extensions in Eclipse is that APT
Quarkus generates a lot of classes during the build phase and in many cases also transforms existing classes.
It is often extremely useful to see the generated bytecode and transformed classes during the development of an extension.

If you set the `quarkus.package.quiltflower.enabled` property to `true` then Quarkus will download and invoke the https://github.com/QuiltMC/quiltflower[Quiltflower decompiler] and dump the result in the `decompiled` directory of the build tool output (`target/decompiled` for Maven for example).
If you set the `quarkus.package.vineflower.enabled` property to `true` then Quarkus will download and invoke the https://github.com/Vineflower/vineflower[Vineflower decompiler] and dump the result in the `decompiled` directory of the build tool output (`target/decompiled` for Maven for example).

NOTE: This property only works during a normal production build (i.e. not for dev mode/tests) and when `fast-jar` packaging type is used (the default behavior).

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ quarkus.hibernate-orm.database.generation=drop-and-create
quarkus.hibernate-orm.statistics=true
quarkus.hibernate-orm.metrics.enabled=true

quarkus.package.quiltflower.enabled=true
quarkus.package.vineflower.enabled=true
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ mp.messaging.incoming.countries-t2-in.connector=smallrye-kafka
mp.messaging.incoming.countries-t2-in.topic=countries-t2
mp.messaging.incoming.countries-t2-in.auto.offset.reset=earliest

quarkus.package.quiltflower.enabled=true
quarkus.package.vineflower.enabled=true

test.prop=test