Fork me on GitHub
#clojure
<
2015-10-24
>
mo-love06:10:37

does anyone know a good article on how to import and work with java abstract classes?

andrewboltachev10:10:44

Hi. How to add own library(ies) to my project? I.e. to have own repo or something?

jaen10:10:24

You have to have a jar with your library somewhere in your classpath. If you don't share the project with other people the simplest solution is to put the jar into your local maven repo with boot build-jar or lein install and then reference that from your project file. If you have to share the project with someone you would probably want to use clojars - tutorial is under https://github.com/ato/clojars-web/wiki/Tutorial. If you can't be arsed to do it properly, because you're just experimenting or don't feel like having to build and install the jar then maybe you could just copy & paste your library sources under the project's source folder and share it that way (though if your library requires something special in your project file you'd have to manually change it for your project).

jaen10:10:52

At least I think those are three basic ways you could deal with it

andrewboltachev10:10:14

btw, does it mean that name (on Clojars) must be unique?

jaen10:10:30

Of your account/group or the jar?

jaen10:10:36

It would be a yes for first, no for second

jaen10:10:52

As long as you have different groups, artifacts name can repeat I think

andrewboltachev10:10:58

names are composite

andrewboltachev10:10:04

foo.bar.buz.mylib

jaen10:10:47

Actually foo.bar.buz/mylib to be pedantic. And then mylib must be unique for all foo.bar.buzes. I think so, at least.

andrewboltachev10:10:25

and if... I have project P1 that depends on lib L1

andrewboltachev10:10:43

and I'm contantly making changes on P1 and L1 too?

jaen10:10:58

Then I'd just shove them into one source folder and call it a day

jaen10:10:13

And move out L1 out to a separate project only after it has stabilised a bit

jaen10:10:26

And you want to share it with something else

andrewboltachev10:10:38

I'd have few projects. Well, I have libraries already written

andrewboltachev10:10:12

though, having some of them open source is good idea

jaen10:10:28

If you're really making the changes frequently

andrewboltachev10:10:30

yes, I used to copy-paste files from project to project

jaen10:10:40

Then it'll probably be a pain to have to install the library over and over

jaen10:10:01

Maye use git subtree to share the code isntead of the copy paste?

jaen10:10:15

You'd skip on having to install the jar, yet you will have to sync code only once

jaen10:10:23

Or submodule. Subtree is also a thing.

jaen10:10:30

And some prefer it over submodule

jaen10:10:39

Either would work

jaen10:10:13

That's the easiest way I think, if you really keep changing the library often

jaen10:10:36

If not, then you could probably think about making it an entirely separate project, with it's own project file

andrewboltachev10:10:07

for a couple I'd do separate

jaen10:10:09

And use boot build-jar or lein install to put it in your local Maven repo

jaen10:10:30

And you could just at some point push it into clojars when you decide you want to share it

andrewboltachev10:10:09

thanks for great and exhaustive help, jaen !

jaen10:10:25

Sure, no problem

colin.yates11:10:04

@andrewboltachev: Also checkout leiningen checkouts for this use-case

andrewboltachev11:10:24

thanks colin.yates !

jaen11:10:35

@colin.yates: what's exactly the boon of using checkouts? I mean, I used them, but they did seem to require installing the jar anyway, so I'm not 100% sure what is gained.

colin.yates11:10:45

AIUI you need to declare it in project.clj and install it first but then the library's source path takes precedence. I also think the dependencies of that dependant lib are taken into account as well

jaen11:10:15

Oh, so it saves you subsequent installs then if I understand correctly?

jaen11:10:41

I had impression it didn't work that way and I had to reinstall, though more possibly I was just doing something wrong.

colin.yates11:10:02

last time I used it, you had to do it only the first time.

colin.yates11:10:37

is there an elegant solution to using Components and generating lein ring uberwar which requires the handlers to be a var (so cannot be components)?

colin.yates11:10:50

ideas: - have the system globally accessible like a global service-locator - yuck

colin.yates12:10:32

idea 2- have the components create the handlers and then alter var root with those handlers and call that as the :ring :init fn

colin.yates12:10:37

idea 3 - ask here simple_smile

redbeardymcgee13:10:59

@clem: I'm not aware of any existing template, so to speak, but you would typically write that as a task to spit out a project skeleton

arohner19:10:22

@colin.yates: I use option #2, it works pretty well

arohner19:10:55

(alter-var-root #'system (fn [_] (com/start (new-system options))))
(alter-var-root #'ring-handler (constantly (-> system :app :app)))

arohner19:10:30

:ring {:init rasterize.main/-main
:handler rasterize.system/ring-handler

asolovyov21:10:35

any ideas what's going on here?

user> (require 'riemann.client)
CompilerException java.lang.Exception: namespace 'riemann.codec' not found, compiling:(riemann/client.clj:1:1) 

asolovyov21:10:59

that's riemann-clojure-client 0.4.1, both files are included in jar (just looked), not sure what to do..

thheller21:10:36

@asolovyov: check lein deps :tree, might be a conflict somewhere

thheller21:10:12

try (io/resource "riemann/client.clj") if it actually is from 0.4.1

asolovyov21:10:54

@thheller: weird:

user> (io/resource "riemann/client.clj")
#object[java.net.URL 0x4026843d "jar:file:/Users/piranha/.m2/repository/riemann-clojure-client/riemann-clojure-client/0.4.1/riemann-clojure-client-0.4.1.jar!/riemann/client.clj"]
user> (io/resource "riemann/codec.clj")
#object[java.net.URL 0x49ce821a "jar:file:/Users/piranha/.m2/repository/riemann-clojure-client/riemann-clojure-client/0.4.1/riemann-clojure-client-0.4.1.jar!/riemann/codec.clj"]
user> (require 'riemann.client)
CompilerException java.lang.Exception: namespace 'riemann.codec' not found, compiling:(riemann/client.clj:1:1) 

asolovyov21:10:41

I can (require 'riemann.codec), but after that cider does no completion...

asolovyov21:10:42

it seems old protobuf is required by closure-compiler

asolovyov21:10:45

maybe that's the problem