connexta / osg-eyes

1 stars 3 forks source link

Package dependency analysis features as a Clojure/Java/JavaScript library for use in static analysis or other apps #1

Open Lambeaux opened 4 years ago

Lambeaux commented 4 years ago

Summary

To get actionable results quickly, everything is going to live in a single module and the only artifact from build output will be a command line tool for working with the data. This issue concerns the next steps for making a shared, stable library available to consumers.

~Ensuring Clojure code is packaged into the artifact~

I do not think Clojure can be called by other Clojure programs or used at the REPL when it is AOT compiled. The pom would need to change so that clojure/ directories get copied into the jar as a resource, like so:

<sourceDirectory>src/test/clojure</sourceDirectory>
<resources>
  <resource>
    <directory>src/main/resources</directory>
  </resource>
  <resource>
    <directory>src/main/clojure</directory>
  </resource>
</resources>

Also the AOT settings would need to be fine tuned beyond the defaults.

Lambeaux commented 4 years ago

Turns out that the Clojure maven plugin supports adding source directories properly, so the build helper plugin was able to be removed 👍 https://github.com/talios/clojure-maven-plugin#available-goals

After some fine tuning I found the crux of an issue that was making compilation take a long time with default Clojure maven plugin settings. The idea was to leverage the Clojure :gen-class feature so that managing a main class ourselves wasn't necessary. Since our main class wraps REPLy's main class, this led to the AOT compilation of our code and all transitive dependency code. Since emitted bytecode is tied to the Clojure version, I doubt you can (or should) mix and match Clojure source and bytecode across projects & dependencies.

In light of this we're taking a hint from REPLy's main class and will just manage the Java main class ourselves without any compilation of our Clojure main. Other namespaces will be compiled and discarded to ensure the code is correct. In the future, a build option for AOT-ing the entire app including transitives would make sense if we want the slight performance boost for released artifacts. https://github.com/talios/clojure-maven-plugin#namespace-configuration

IMO it seems the only remaining task for this issue is to split out modules when appropriate.

Lambeaux commented 3 years ago

Possible duplicate of #21 - there's definitely some overlap in the relevant work.