GraxCode / threadtear

Multifunctional java deobfuscation tool suite
GNU General Public License v3.0
889 stars 121 forks source link

Licenses aren't included in fat jar. #27

Closed weisJ closed 4 years ago

weisJ commented 4 years ago

Currently the fatJar task simply copies the content of each dependency into the jar. This results in files that have the same name to be overwritten. Because most licenses are located at (and called) META-INF/LICENSE only one of those will survive (which isn't event deterministic.

I see two possible solutions here.

  1. Switch to a plugin which handles the creation of the fat jar e.g. shadow and configure it to copy the contents of the META-INF folder of each jar to META-INF/<dependency-name>.

  2. Switch from java-library to theapplicationplugin. Theapplication` plugin creates a distribution zip which contains all jar files and a startup script.

    plugins {
       id 'application'
    }
    
    application {
       mainClassName = 'me.nov.threadtear.Threadtear'
       applicationName = 'Threadtear'
    }

    The resulting zip has the following structure.

    Threadtear-2.7.0/
    ├── bin/    // This is also the working directory for the application.
    │   ├── Threadtear
    │   └── Threadtear.bat
    └── lib/
         ├── ...
         └── all dependencies
GraxCode commented 4 years ago

Actually, gradle puts all of the license files inside the jar file without any problems, as duplicate zip entries are allowed (not in java though). But you are right, it would be nice to know from which library they come from. I really don't like the idea of making threadtear an application as in my opinion a standalone .jar file is much more compact than a folder with bin, lib, etc.

weisJ commented 4 years ago

Actually, gradle puts all of the license files inside the jar file without any problems, as duplicate zip entries are allowed (not in java though).

I don’t see this reflected in the resulting fat jar. There are still licenses that are missing.

GraxCode commented 4 years ago

Screenshot_24 (using WinRAR) What tool are you using?

weisJ commented 4 years ago

I was using the archive view in IntelliJ, which apparently doesn’t show duplicate files. I still think it would be nice to remove the ambiguity between the licenses. One shouldn’t be forced to use a certain program to view them.

GraxCode commented 4 years ago

Of course, that's what i also think. Will probably use shadow to handle that.

weisJ commented 4 years ago

With #26 I have implemented merging of unique licenses with the same name into one file. I think for now this is the best one can do with the shadow plugin, as neither the relocators nor the transformers get information about the original dependency a file comes from.

GraxCode commented 4 years ago

Should this be closed?

weisJ commented 4 years ago

Can be closed. If the shadow plugin ever gets updated to include dependency information for files the current approach can be improved.