-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.xq
39 lines (34 loc) · 1.36 KB
/
build.xq
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
(: create o/ps
: xar package and xqdoc
:)
declare namespace pkg="http://expath.org/ns/pkg";
import module namespace build = "quodatum.utils.build" at "buildx.xqm";
declare variable $src:=resolve-uri("src/main/");
declare variable $dest:=resolve-uri("dist/");
(:~
: the package definition as a pkg:package
:)
declare variable $package as element(pkg:package) :=doc(resolve-uri("expath-pkg.xml",$src))/pkg:package;
declare variable $content:=resolve-uri("content/",$src);
declare variable $dest-doc:=resolve-uri("doc/",$dest);
let $files:=build:files($src)
let $name:= build:xar($package)
(: save xqdoc :)
return (build:transform(
$package/pkg:xquery/pkg:file,
function($path){inspect:xqdoc(fn:resolve-uri( $path,$content))},
function($path,$data){ file:write(
resolve-uri(fn:trace($path) || ".xml",$dest-doc),
$data)
}
),
(: write xar :)
build:merge(
$files,
function($path){file:read-binary(fn:resolve-uri($path,$src))},
function($paths,$data){file:write-binary(
resolve-uri($name,$dest),
archive:create($paths,$data))}
),
build:publish($package,fn:resolve-uri("package.xml"))
)