|
120 | 120 | (is (.exists prop-out)) |
121 | 121 | (is (submap? {"groupId" "test", "artifactId" "p2", "version" "1.2.3"} props))))) |
122 | 122 |
|
| 123 | +(deftest test-ignore-existing-pom |
| 124 | + ;; verify existing scm info is preserved if src-pom is supplied: |
| 125 | + (with-test-dir "test-data/p4" |
| 126 | + (api/set-project-root! (.getAbsolutePath *test-dir*)) |
| 127 | + (api/delete {:path "target"}) |
| 128 | + (api/write-pom {:lib 'test/p4 |
| 129 | + :version "1.2.3" |
| 130 | + :class-dir "target/classes" |
| 131 | + :src-dirs ["src"] |
| 132 | + :src-pom "pom.xml" |
| 133 | + :resource-dirs ["resources"] |
| 134 | + :basis (api/create-basis nil)}) |
| 135 | + (let [pom-dir (jio/file (project-path "target/classes/META-INF/maven/test/p4")) |
| 136 | + pom-out (jio/file pom-dir "pom.xml") |
| 137 | + pom (read-xml pom-out) |
| 138 | + prop-out (jio/file pom-dir "pom.properties") |
| 139 | + props (read-props prop-out)] |
| 140 | + ;; check xml out |
| 141 | + (is (.exists pom-out)) |
| 142 | + (are [path val] (= val (xml-path-val pom path)) |
| 143 | + [::pom/packaging] ["jar"] |
| 144 | + [::pom/groupId] ["test"] |
| 145 | + [::pom/artifactId] ["p4"] |
| 146 | + [::pom/version] ["1.2.3"] |
| 147 | + [::pom/name] ["p4"] |
| 148 | + [::pom/build ::pom/sourceDirectory] ["src"] |
| 149 | + [::pom/build ::pom/resources ::pom/resource ::pom/directory] ["resources"] |
| 150 | + [::pom/scm ::pom/tag] ["HEAD"] |
| 151 | + [::pom/scm ::pom/url] ["git@github.com:clojure/tools.build.git"]) |
| 152 | + (is (= 2 (count (xml-path-val pom [::pom/dependencies])))) |
| 153 | + (is (= 1 (count (xml-path-val pom [::pom/repositories])))) |
| 154 | + ;; check properties out |
| 155 | + (is (.exists prop-out)) |
| 156 | + (is (submap? {"groupId" "test", "artifactId" "p4", "version" "1.2.3"} props)))) |
| 157 | + ;; verify no scm info is present if src-pom is :none: |
| 158 | + (with-test-dir "test-data/p4" |
| 159 | + (api/set-project-root! (.getAbsolutePath *test-dir*)) |
| 160 | + (api/delete {:path "target"}) |
| 161 | + (api/write-pom {:lib 'test/p4 |
| 162 | + :version "1.2.3" |
| 163 | + :class-dir "target/classes" |
| 164 | + :src-dirs ["src"] |
| 165 | + :src-pom :none |
| 166 | + :resource-dirs ["resources"] |
| 167 | + :basis (api/create-basis nil)}) |
| 168 | + (let [pom-dir (jio/file (project-path "target/classes/META-INF/maven/test/p4")) |
| 169 | + pom-out (jio/file pom-dir "pom.xml") |
| 170 | + pom (read-xml pom-out) |
| 171 | + prop-out (jio/file pom-dir "pom.properties") |
| 172 | + props (read-props prop-out)] |
| 173 | + ;; check xml out |
| 174 | + (is (.exists pom-out)) |
| 175 | + (are [path val] (= val (xml-path-val pom path)) |
| 176 | + [::pom/packaging] ["jar"] |
| 177 | + [::pom/groupId] ["test"] |
| 178 | + [::pom/artifactId] ["p4"] |
| 179 | + [::pom/version] ["1.2.3"] |
| 180 | + [::pom/name] ["p4"] |
| 181 | + [::pom/build ::pom/sourceDirectory] ["src"] |
| 182 | + [::pom/build ::pom/resources ::pom/resource ::pom/directory] ["resources"] |
| 183 | + [::pom/scm ::pom/tag] nil |
| 184 | + [::pom/scm ::pom/url] nil) |
| 185 | + (is (= 2 (count (xml-path-val pom [::pom/dependencies])))) |
| 186 | + (is (= 1 (count (xml-path-val pom [::pom/repositories])))) |
| 187 | + ;; check properties out |
| 188 | + (is (.exists prop-out)) |
| 189 | + (is (submap? {"groupId" "test", "artifactId" "p4", "version" "1.2.3"} props))))) |
| 190 | + |
123 | 191 | ;; check that optional deps are marked optional |
124 | 192 | (deftest test-optional |
125 | 193 | (with-test-dir "test-data/p3" |
|
0 commit comments