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

Implement drop-in CLI #37

Merged
merged 1 commit into from
Oct 3, 2023
Merged

Implement drop-in CLI #37

merged 1 commit into from
Oct 3, 2023

Conversation

eed3si9n
Copy link
Owner

@eed3si9n eed3si9n commented Oct 3, 2023

Problem
We currently only provide shadeDirectory function as the entry point, but it's convenient to have a drop-in replacement entry point at least for process command.

Solution
This implements process and CLI entry point.
Unzipping code is mostly copied from sbt's IO module.

Note

I am wiping out the timestamp to 2010, in part to deal with cursed JAR files that have 1980-00-00 in the date.

$ unzip -l example/byte-buddy-agent.jar
Archive:  example/byte-buddy-agent.jar
  Length      Date    Time    Name
---------  ---------- -----   ----
        0  00-00-1980 04:08   META-INF/
      988  00-00-1980 04:08   META-INF/MANIFEST.MF

$ unzip -l /var/folders/cx/b301f0rs6d5cq6qnsl3mq2vc0000gn/T/test312139308153536234.jar
Archive:  /var/folders/cx/b301f0rs6d5cq6qnsl3mq2vc0000gn/T/test312139308153536234.jar
  Length      Date    Time    Name
---------  ---------- -----   ----
        0  01-01-2010 00:00   META-INF/
        0  01-01-2010 00:00   META-INF/maven/

class Main {
def help(): Unit = Main.printHelp()

def process(rulesFile: Path, inJar: Path, outJar: Path): Unit = {
Copy link
Owner Author

Choose a reason for hiding this comment

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

This is the new entry point, which is used via reflection implemented in MainUtil.runMain.

**Problem**
We currently only provide `shadeDirectory` function as the entry point,
but it's convenient to have a drop-in replacement entry point
at least for `process` command.

**Solution**
This implements `process` and CLI entry point.
// The zip 'setTime' methods try to convert from the given time to the local time based
// on java.util.TimeZone.getDefault(). When explicitly specifying the timestamp, we assume
// this already has been done if desired, so we need to 'convert back' here:
val localTime = time - java.util.TimeZone.getDefault().getOffset(time)
Copy link
Owner Author

Choose a reason for hiding this comment

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

This is the timezone workaround /cc @johnynek

@eed3si9n eed3si9n merged commit b34e3d3 into develop Oct 3, 2023
6 checks passed
@eed3si9n eed3si9n deleted the wip/cli branch October 3, 2023 20:44
@lefou
Copy link

lefou commented Dec 8, 2023

This PR introduced a source/binary incompatibility due to the removal of:

Shader.bytecodeShader(rules: Seq[ShadeRule], verbose: Boolean)

There is now a new method:

Shader.bytecodeShader(rules: Seq[ShadeRule], verbose: Boolean, skipManifest: Boolean)

What it the correct migration from the old to the new one?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants