aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/program/aedifex/pom.lux
blob: 102728e1e937cf20ee6da44eaa9242725a5dd0c8 (plain)
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
(.module:
  [lux #*
   [control
    [pipe (#+ case>)]]
   [data
    ["." maybe ("#@." functor)]
    [format
     ["_" xml (#+ XML)]]
    [collection
     ["." list ("#@." monoid functor)]]]]
  [//
   ["/" project]])

## https://maven.apache.org/pom.html

(def: #export file
  "pom.xml")

(def: #export extension
  ".pom")

(def: version
  XML
  (#_.Node ["" "modelVersion"] _.attrs
           (list (#_.Text "4.0.0"))))

(def: (property tag value)
  (-> Text Text XML)
  (#_.Node ["" tag]
           _.attrs
           (list (#_.Text value))))

(def: (artifact value)
  (-> /.Artifact (List XML))
  (list (..property "groupId" (get@ #/.group value))
        (..property "artifactId" (get@ #/.name value))
        (..property "version" (get@ #/.version value))))

(def: distribution
  (-> /.Distribution XML)
  (|>> (case> #/.Repo "repo"
              #/.Manual "manual")
       (..property "distribution")))

(def: (license [name url distribution])
  (-> /.License XML)
  (|> (list (..property "name" name)
            (..property "url" url)
            (..distribution distribution))
      (#_.Node ["" "license"] _.attrs)))

(def: repository
  (-> /.Repository XML)
  (|>> (..property "url")
       list
       (#_.Node ["" "repository"] _.attrs)))

(def: (dependency [artifact type])
  (-> /.Dependency XML)
  (#_.Node ["" "dependency"]
           _.attrs
           (list@compose (..artifact artifact)
                         (list (..property "type" type)))))

(def: scm
  (-> /.SCM XML)
  (|>> (..property "url")
       list
       (#_.Node ["" "scm"] _.attrs)))

(def: (organization [name url])
  (-> /.Organization XML)
  (|> (list (..property "name" name)
            (..property "url" url))
      (#_.Node ["" "organization"] _.attrs)))

(def: (developer-organization [name url])
  (-> /.Organization (List XML))
  (list (..property "organization" name)
        (..property "organizationUrl" url)))

(def: (developer' [name email organization])
  (-> /.Developer (List XML))
  (list& (..property "name" name)
         (..property "email" email)
         (|> organization (maybe@map ..developer-organization) (maybe.default (list)))))

(template [<name> <type> <tag>]
  [(def: <name>
     (-> <type> XML)
     (|>> ..developer' (#_.Node ["" <tag>] _.attrs)))]

  [developer /.Developer "developer"]
  [contributor /.Contributor "contributor"]
  )

(def: (group tag)
  (-> Text (-> (List XML) XML))
  (|>> (#_.Node ["" tag] _.attrs)))

(def: (info value)
  (-> /.Info (List XML))
  ($_ list@compose
      (|> value (get@ #/.url) (maybe@map (..property "url")) maybe.to-list)
      (|> value (get@ #/.description) (maybe@map (..property "description")) maybe.to-list)
      (|> value (get@ #/.licenses) (list@map ..license) (..group "licenses") list)
      (|> value (get@ #/.scm) (maybe@map ..scm) maybe.to-list)
      (|> value (get@ #/.organization) (maybe@map ..organization) maybe.to-list)
      (|> value (get@ #/.developers) (list@map ..developer) (..group "developers") list)
      (|> value (get@ #/.contributors) (list@map ..contributor) (..group "contributors") list)
      ))

(def: #export (project value)
  (-> /.Project XML)
  (#_.Node ["" "project"] _.attrs
           ($_ list@compose
               (list ..version)
               (..artifact (get@ #/.identity value))
               (|> value (get@ #/.repositories) (list@map ..repository) (..group "repositories") list)
               (|> value (get@ #/.dependencies) (list@map ..dependency) (..group "dependencies") list)
               )))