Fork me on GitHub
#java
<
2020-07-10
>
ewen08:07:22

@jjttjj Looks like this is working for me, I can see the parameter names when I compile with :javac-options ["-parameters"] and I don't see them without -parameters

jjttjj14:07:22

Thanks! yeah I had figuired it out and thought I deleted my message here but it looks like it didn't work. I think it was an issue with a previously cached jar being used

jjttjj15:07:15

@U066KJ18E So now I have the javac part working but I'm having issues with building a jar. I basically have a directory of class files and want to put those in a jar. I'm on windows and I have a feeling it relates to that, and specifically path separator differences I can build a working jar with the jar at the command line. Here is the jar file listing output of using badigeon vs the command line:

Badigeon generated jar:

(jar/jar mvn-id {:mvn/version mvn-version}
  {:out-path "my.jar"
   :paths    [(str class-dir)]
   :deps     {}})

-rw-rw-rw-        91  11-Jul-2020  11:11:30  meta-inf/manifest.mf
  -rw-rw-rw-       220  11-Jul-2020  10:12:46  META-INF/badigeon/com.interactivebrokers/tws-api/deps.edn
  -rw-rw-rw-      1048  11-Jul-2020  11:11:30  META-INF/maven/com.interactivebrokers/tws-api/pom.xml
  -rw-rw-rw-      1059  11-Jul-2020  11:11:28  com\ib\client\Bar.class
  -rw-rw-rw-       754  11-Jul-2020  11:11:28  com\ib\client\BitMask.class
  -rw-rw-rw-       955  11-Jul-2020  11:11:28  com\ib\client\Builder$ByteBuffer.class
  -rw-rw-rw-      6446  11-Jul-2020  11:11:28  com\ib\client\Builder.class

............
  
-rw-rw-rw-      1373  11-Jul-2020  11:11:30  com\ib\controller\Profile$Type.class
  -rw-rw-rw-      1809  11-Jul-2020  11:11:30  com\ib\controller\Profile.class
  -rw-rw-rw-      8100  11-Jul-2020  11:11:30  com\ib\controller\ScanCode.class
  -rw-rw-rw-       599  11-Jul-2020  11:11:30  com\ib\controller\TradeId.class
  -rw-rw-rw-       127  11-Jul-2020  11:11:30  META-INF/maven/com.interactivebrokers/tws-api/pom.properties
- ----------  --------  -----------  --------  ----------------------------------------------------------------
                542012                         172 files



Commandline generated jar:


M Filemode      Length  Date         Time      File
- ----------  --------  -----------  --------  ----------------------------------------------------------------
  drwxrwxrwx         0  11-Jul-2020  11:02:08  meta-inf/
  -rw-rw-rw-        66  11-Jul-2020  11:02:08  meta-inf/manifest.mf
  drwxrwxrwx         0  11-Jul-2020  11:02:02  com/
  drwxrwxrwx         0  11-Jul-2020  11:02:02  com/ib/
  drwxrwxrwx         0  11-Jul-2020  11:02:02  com/ib/client/
  -rw-rw-rw-      1059  11-Jul-2020  11:02:02  com/ib/client/Bar.class
  -rw-rw-rw-       754  11-Jul-2020  11:02:02  com/ib/client/BitMask.class
  -rw-rw-rw-       955  11-Jul-2020  11:02:02  com/ib/client/Builder$ByteBuffer.class
  -rw-rw-rw-      6446  11-Jul-2020  11:02:02  com/ib/client/Builder.class

...............
                  
  -rw-rw-rw-      1373  11-Jul-2020  11:02:02  com/ib/controller/Profile$Type.class
  -rw-rw-rw-      1809  11-Jul-2020  11:02:02  com/ib/controller/Profile.class
  -rw-rw-rw-      8100  11-Jul-2020  11:02:02  com/ib/controller/ScanCode.class
  -rw-rw-rw-       599  11-Jul-2020  11:02:02  com/ib/controller/TradeId.class
- ----------  --------  -----------  --------  ----------------------------------------------------------------
                540592                         175 files

jjttjj15:07:08

It seems like Badigeon omits the empty directory listings? fwiw this is a java project with no deps, I just need to put all the class files in jar

jjttjj15:07:35

(I can open an actual issue later, I'm realizing that probably would have been better)

ewen13:07:43

Yes, the empty directory might be missing. I will try to make the output closer to the javac one, although I don't think that it makes a difference. The path separators seems different, I will try to run it on windows

jjttjj17:07:30

(disregard my previous deleted message if it shows up for you) Ok I think changing this line: https://github.com/EwenG/badigeon/blob/54436429d324c17c916e4922fcd2b62b6a514ab7/src/badigeon/jar.clj#L118 to this:

(put-jar-entry! jar-out f (str/replace relative-path "\\" "/"))
to replace backslashes with slashes seems to fix things on windows. There might be a better way to do this.

ewen08:07:28

Yes it makes sense, replacing the path separator is something that is done in a few places already, but it looks like everything was not covered :)

ewen09:07:44

I made a new release to fix the path separator on windows

jjttjj11:07:41

Tested, works now, thanks!

jjttjj11:07:08

One other thing, sorry to keep bugging you: Currently usage of the jar stuff seems dependent on a deps.edn file in the project root where badigeon is used. Due to this line: https://github.com/EwenG/badigeon/blob/7eb120a132e7a443e492df16393e9821da221368/src/badigeon/jar.clj#L204 What I'm trying to do is write a little script that can be run in isolation with a clj command that will download a zip of java source files, compile them and maven install them locally. So I'm using it as a general "do stuff with java source" library, unrelated to a clojure/tools.deps project. Is this valid for your intended uses of badigeon? If so would you consider making the existence of the deps.edn file optional, or somehow parameterizing it?

ewen12:07:22

The deps map is already a parameter of others badigeon api like "uberjar". The fact that the jar api is not consistent is unfortunate and the reason is simply that it was written earlier. So I guess defaulting to an empty map when deps.edn is not there would be ok

jjttjj12:07:13

Yeah I do use the :deps option, it just looks like the jar function assumes the deps file exists anyway (and is merged with the passed in :deps.

ewen08:07:31

I pushed a change on master to make it optional

jjttjj03:07:50

Awesome, thank you so much!