depstar

Discussion around https://github.com/seancorfield/depstar
2021-03-04T17:00:18.065800Z

How would I specify the javac options for aot compilation with depstar?

2021-03-04T17:02:39.066900Z

I am trying to set the target language level of the output.

seancorfield 2021-03-04T17:28:38.067700Z

@markbastian Not quite sure what you're asking here: javac is used for compiling Java source code, not Clojure.

2021-03-04T17:30:46.068300Z

Doesโ€™t the aot option defer to javac?

seancorfield 2021-03-04T17:31:28.068700Z

AOT is Clojure compilation, not Java compilation.

seancorfield 2021-03-04T17:31:42.069200Z

javac is for compiling Java.

2021-03-04T17:32:04.069700Z

Ah, got it.

seancorfield 2021-03-04T17:32:39.071Z

If you have Java sources, you have to run javac yourself to compile them to .class files that can be included on the classpath if needed.

2021-03-04T17:33:44.072300Z

My issue was I had a jar I was trying to deploy to google app engine. It support jvm11 and I am currently using jdk15 locally. I wasnโ€™t sure what bytecode level was being generated and wanted to make sure it was ok. But the clojure compiler I am assuming uses jdk8, right?

mpenet 2021-03-04T17:40:19.073200Z

clojure itself is compiled into java8 compatible bytecode

mpenet 2021-03-04T17:40:25.073400Z

java8+ that is

mpenet 2021-03-04T17:40:45.073600Z

so yeah

seancorfield 2021-03-04T17:47:37.076300Z

AOT compilation in depstar shells out and runs Clojure itself via java -cp ... clojure.main -e "(compile,'the-ns)" effectively. You can specify :jvm-opts to depstar and it will pass those to the java command, which was added as a way to set JVM properties that the Clojure compiler respects. See https://clojure.org/reference/compilation#_compiler_options

seancorfield 2021-03-04T17:48:49.076800Z

The :jvm-opts exec arg was added in depstar 2.0.187 so it's fairly new.

mike_ananev 2021-03-04T20:03:23.078800Z

@markbastian You can try my app template based on depstar for aot compilation and compiling java sources. It is still under development but already works. There you can set the target level of compilation. https://github.com/redstarssystems/rssysapp

๐Ÿ‘ 1
mike_ananev 2021-03-04T20:07:02.079500Z

to download the template use this command: clojure -X:clj-new :template rssysapp :name myname/myapp01 :snapshot true

seancorfield 2021-03-04T20:17:59.080300Z

(assuming you have :clj-new as an alias -- the clj-new README would lead folks to :new instead, as would my dot-clojure repo)

๐Ÿ‘ 1
2021-03-04T21:39:05.084600Z

depstar-newbie question: I want to provide project-specific aliases for the creation of a jar and uberjar. For each, I want to specify the artifact-id, group-id, and version. Is there some way to define those values once in my deps.edn file, and in the :exec-args of my jar/ubersjar aliias the value of the key :group-id would be a reference to where I defined this elsewhere in this deps.edn file?

seancorfield 2021-03-04T21:43:33.085700Z

@dcj I'm not quite understanding what you're asking...

seancorfield 2021-03-04T21:43:56.086200Z

An alias can specify :exec-args and when you use that alias, those arguments will be used.

seancorfield 2021-03-04T21:46:03.088400Z

(! 798)-> clojure -Sdeps '{:aliases {:a {:exec-args {:a 1}} :b {:exec-args {:b 2}} :c {:exec-args {:a 3 :c 3}}}}' -X:a clojure.core/println
{:a 1}
(! 799)-> clojure -Sdeps '{:aliases {:a {:exec-args {:a 1}} :b {:exec-args {:b 2}} :c {:exec-args {:a 3 :c 3}}}}' -X:a:b clojure.core/println
{:a 1, :b 2}
(! 800)-> clojure -Sdeps '{:aliases {:a {:exec-args {:a 1}} :b {:exec-args {:b 2}} :c {:exec-args {:a 3 :c 3}}}}' -X:a:b:c clojure.core/println
{:a 3, :b 2, :c 3}
(! 801)-> clojure -Sdeps '{:aliases {:a {:exec-args {:a 1}} :b {:exec-args {:b 2}} :c {:exec-args {:a 3 :c 3}}}}' -X:c:a clojure.core/println
{:a 1, :c 3}

seancorfield 2021-03-04T21:46:19.088900Z

They merge in alias order.

2021-03-04T21:48:22.091Z

:uberjar {:replace-deps {com.github.seancorfield/depstar {:mvn/version "2.0.193"}}
            :exec-fn hf.depstar/uberjar
            :exec-args {:jar "MyProject.jar"
                        :group-id "org.example"}}
and assume I have a siimilar alias for :jar, which also specifies a :group-id Specifying the same group-id twice is not DRY. I'm asking is there a way to define a "variable" in deps. edn, and then later when providing a "value" for some key, I can reference the variable?

seancorfield 2021-03-04T21:54:53.092100Z

You'd need an alias for :group-id or whatever you wanted to call it that had {:exec-args {:group-id "org.example"}} and then you'd specify that alias as well as :uberjar when building the JAR

seancorfield 2021-03-04T21:56:17.093200Z

If the entire :exec-args piece would be duplicated (not just :group-id) then you could put the whole :exec-args under an alias and under :uberjar you could say :exec-args :common-args (or whatever you called that new alias).

seancorfield 2021-03-04T21:57:15.094200Z

But allowing depstar to treat a keyword argument value as a lookup against other aliases in the project basis would definitely be possible as an enhancement...

seancorfield 2021-03-04T21:59:14.095800Z

The only wrinkle there is that depstar uses at least some of its :exec-args to determine how to build the project basis, so it couldn't support some lookups (for exec args that control how to build the basis) because they could only happen after the args had been used.

seancorfield 2021-03-04T21:59:20.096Z

Does that make sense @dcj?

2021-03-04T22:00:12.096200Z

๐Ÿ‘

seancorfield 2021-03-04T22:02:14.097700Z

I'm not sure how well documented that aspect of deps.edn is. I think Alex has mentioned it on his Inside Clojure blog. I don't know if it's explained in the deps/CLI reference on http://clojure.org

2021-03-04T22:04:46.101500Z

@seancorfield Thank you! I am not sure enhancing depstar to do :keyword val lookup is a great idea, kinda feel like that should be a deps.edn thing, and am not going to bother to propose that. I will try your suggestion to alias the entire exec-args map...

2021-03-04T22:07:05.103100Z

I spent some time attempting to search for exactly this before asking here, and obviously did not find that....

seancorfield 2021-03-04T22:11:19.103300Z

It somewhat cryptically says "Aliases give a name to a data structure that can be used either by the Clojure tool itself or other consumers of deps.edn. They are defined in the :aliases section of the config file." but doesn't give an example as far as I can see.

seancorfield 2021-03-04T22:14:23.105900Z

Thinking about it, it probably ought to resolve such keywords using the runtime basis of depstar itself since it's about controlling operation of the tool rather than computing the project basis that is used to build the JAR file.

seancorfield 2021-03-04T22:14:49.106500Z

I'll create a GitHub issue and give it some thought. I might ask Alex for his input too.

2021-03-04T22:17:43.109700Z

ok, thanks! what if another tool wants to know the version, for example? seems like this โ€œideaโ€ is broader than depstar....

seancorfield 2021-03-04T22:18:24.109900Z

https://github.com/seancorfield/depstar/issues/71

seancorfield 2021-03-04T22:19:39.111200Z

It would be nice if this was baked into the CLI itself but I don't think there's a guaranteed generic way to do it that wouldn't step on the toes of some existing tooling. But each individual tool is free to do whatever it wants with aliases.

seancorfield 2021-03-04T23:33:53.111900Z

@dcj I went ahead and implemented that so you can try it out via :git/url if you want.

2021-03-04T23:35:28.113100Z

:git/url ?

seancorfield 2021-03-04T23:36:24.113900Z

com.github.seancorfield/depstar {:git/url "<https://github.com/seancorfield/depstar>" :sha "a8cf78c9e09e3504e64fc77bcb133a7ada39a68f"} as your dependency.

seancorfield 2021-03-04T23:36:36.114200Z

Instead of com.github.seancorfield/depstar {:mvn/version "2.0.193"}

2021-03-04T23:36:44.114400Z

OIC ๐Ÿ™‚

2021-03-04T23:37:17.115100Z

looking at your diffs now

seancorfield 2021-03-04T23:37:33.115500Z

Sorry, I assumed everyone using the CLI and deps.edn knew about dependencies via :git/url or :local/root

seancorfield 2021-03-04T23:39:53.117500Z

I just updated the example in the README to use :git/url so it actually works (even though it's not released yet).

2021-03-04T23:40:01.117600Z

Thank you for doing this! This will be nice.

seancorfield 2021-03-04T23:42:27.119100Z

You can go ahead and use it right now ๐Ÿ™‚

2021-03-04T23:42:52.119500Z

Yes, I'll try it out soon, worst case, tomorrow.

1