aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/program/aedifex/pom.lux
blob: 9370620f5f6834d80f53096ba137521099de188d (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
122
123
124
125
126
127
128
129
(.module:
  [lux #*
   [control
    [pipe (#+ case>)]
    ["." try (#+ Try)]
    ["." exception]]
   [data
    ["." maybe ("#@." functor)]
    [format
     ["_" xml (#+ XML)]]
    [collection
     ["." list ("#@." monoid functor)]
     ["." set]]]]
  ["." // #_
   ["/" profile]
   ["#." artifact (#+ Artifact)]
   ["#." dependency (#+ Repository Dependency)]])

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

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

(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@ #//artifact.group value))
        (..property "artifactId" (get@ #//artifact.name value))
        (..property "version" (get@ #//artifact.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 value)
  (-> Dependency XML)
  (#_.Node ["" "dependency"]
           _.attrs
           (list@compose (..artifact (get@ #//dependency.artifact value))
                         (list (..property "type" (get@ #//dependency.type value))))))

(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)
  (-> /.Profile (Try XML))
  (case (get@ #/.identity value)
    (#.Some identity)
    (#try.Success
     (#_.Node ["" "project"] _.attrs
              ($_ list@compose
                  (list ..version)
                  (..artifact identity)
                  (|> value (get@ #/.repositories) set.to-list (list@map ..repository) (..group "repositories") list)
                  (|> value (get@ #/.dependencies) set.to-list (list@map ..dependency) (..group "dependencies") list)
                  )))

    _
    (exception.throw /.no-identity [])))