issue: loading from jar file is not working
This commit is contained in:
parent
090f784089
commit
da9bfedfd8
4 changed files with 37 additions and 8 deletions
|
@ -24,8 +24,9 @@
|
||||||
:resource-paths ["test-resources"]
|
:resource-paths ["test-resources"]
|
||||||
:dependencies []
|
:dependencies []
|
||||||
:leiningen/reply
|
:leiningen/reply
|
||||||
{:dependencies [[org.slf4j/jcl-over-slf4j "1.8.0-beta0"]]
|
{:dependencies [[org.slf4j/jcl-over-slf4j "1.8.0-beta0"]
|
||||||
|
[dda/dummy "0.1.0-SNAPSHOT"]]
|
||||||
:exclusions [commons-logging]}}
|
:exclusions [commons-logging]}}
|
||||||
:test {:source-paths ["test"]
|
:test {:source-paths ["test"]
|
||||||
:resource-paths ["test-resources"]
|
:resource-paths ["test-resources"]
|
||||||
:dependencies []}})
|
:dependencies [[dda/dummy "0.1.0-SNAPSHOT"]]}})
|
||||||
|
|
|
@ -9,7 +9,8 @@
|
||||||
(ns cryogen-core.classpath-able-io
|
(ns cryogen-core.classpath-able-io
|
||||||
(:require [clojure.java.io :as io]
|
(:require [clojure.java.io :as io]
|
||||||
[clojure.string :as st]
|
[clojure.string :as st]
|
||||||
[schema.core :as s]))
|
[schema.core :as s])
|
||||||
|
(:import [java.nio.file FileSystems Paths Files]))
|
||||||
|
|
||||||
(def SourceType (s/enum :classpath :filesystem))
|
(def SourceType (s/enum :classpath :filesystem))
|
||||||
|
|
||||||
|
@ -73,12 +74,12 @@
|
||||||
|
|
||||||
(s/defn file-from-cp ; :- File
|
(s/defn file-from-cp ; :- File
|
||||||
[resource-path :- Path]
|
[resource-path :- Path]
|
||||||
(let [file-from-cp (io/file (io/resource resource-path))]
|
(try
|
||||||
(try
|
(let [file-from-cp (io/file (io/resource resource-path))]
|
||||||
(when (.exists file-from-cp)
|
(when (.exists file-from-cp)
|
||||||
file-from-cp)
|
file-from-cp))
|
||||||
(catch Exception e
|
(catch Exception e
|
||||||
nil))))
|
nil)))
|
||||||
|
|
||||||
(s/defn file-from-fs ; :- File
|
(s/defn file-from-fs ; :- File
|
||||||
[fs-prefix :- Prefix
|
[fs-prefix :- Prefix
|
||||||
|
|
|
@ -19,6 +19,12 @@
|
||||||
|
|
||||||
(def target "target/tmp")
|
(def target "target/tmp")
|
||||||
|
|
||||||
|
; TODO: Fix this test!
|
||||||
|
(deftest test-file-from-cp
|
||||||
|
(is
|
||||||
|
(sut/file-from-cp
|
||||||
|
"dummy")))
|
||||||
|
|
||||||
(deftest test-resource-from-cp-or-fs
|
(deftest test-resource-from-cp-or-fs
|
||||||
(is
|
(is
|
||||||
(.exists
|
(.exists
|
||||||
|
|
21
test/cryogen_core/classpath_able_io_test.repl
Normal file
21
test/cryogen_core/classpath_able_io_test.repl
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
TODO: to solve reading from jars:
|
||||||
|
1. create fs
|
||||||
|
|
||||||
|
|
||||||
|
(FileSystems/newFileSystem
|
||||||
|
(java.net.URI.
|
||||||
|
"jar:file:/home/jem/.m2/repository/dda/dummy/0.1.0-SNAPSHOT/dummy-0.1.0-SNAPSHOT.jar")
|
||||||
|
{})
|
||||||
|
|
||||||
|
|
||||||
|
2. be able to use it
|
||||||
|
|
||||||
|
(Files/exists
|
||||||
|
(.getPath
|
||||||
|
(FileSystems/getFileSystem
|
||||||
|
(java.net.URI.
|
||||||
|
"jar:file:/home/jem/.m2/repository/dda/dummy/0.1.0-SNAPSHOT/dummy-0.1.0-SNAPSHOT.jar"))
|
||||||
|
"dummy"
|
||||||
|
(into-array String '()))
|
||||||
|
(into-array java.nio.file.LinkOption {}))
|
||||||
|
|
Loading…
Reference in a new issue