@@ -15,6 +15,8 @@ import System.FilePath ((</>), splitDirectories)
15import System.Directory
15import System.Directory
16import qualified System.FilePath.Posix as Px
16import qualified System.FilePath.Posix as Px
17import System.Process
17import System.Process
18+import qualified Data.Text as T
19+import qualified Data.Text.IO as TIO
20-- After Idris is built, we need to check and install the prelude and other libs
22-- After Idris is built, we need to check and install the prelude and other libs
@@ -40,6 +42,8 @@ cleanJavaLib verbosity
40 when dirty $ mvn verbosity [ "-f", "java/pom.xml", "clean" ]
42 when dirty $ mvn verbosity [ "-f", "java/pom.xml", "clean" ]
41 pomExists <- doesFileExist ("java" </> "pom.xml")
43 pomExists <- doesFileExist ("java" </> "pom.xml")
42 when pomExists $ removeFile ("java" </> "pom.xml")
44 when pomExists $ removeFile ("java" </> "pom.xml")
45+ execPomExists <- doesFileExist ("java" </> "executable_pom.xml")
46+ when pomExists $ removeFile ("java" </> "executable_pom.xml")
44installStdLib pkg local verbosity copy
48installStdLib pkg local verbosity copy
45 = do let dirs = L.absoluteInstallDirs pkg local copy
49 = do let dirs = L.absoluteInstallDirs pkg local copy
@@ -64,7 +68,18 @@ installStdLib pkg local verbosity copy
64 , "IDRIS=" ++ icmd
68 , "IDRIS=" ++ icmd
67−installJavaLib verbosity = mvn verbosity [ "-f", "java/pom.xml", "install" ]
71+installJavaLib pkg local verbosity copy version = do
72+ let rtsFile = "idris-" ++ display version ++ ".jar"
73+ mvn verbosity [ "install:install-file"
74+ , "-Dfile=" ++ ("java" </> "target" </> rtsFile)
75+ , "-DgroupId=org.idris-lang"
76+ , "-DartifactId=idris"
77+ , "-Dversion=" ++ display version
79+ , "-DgeneratePom=True"
81+ let dir = datadir $ L.absoluteInstallDirs pkg local copy
82+ copyFile ("java" </> "executable_pom.xml") (dir </> "executable_pom.xml")
69-- This is a hack. I don't know how to tell cabal that a data file needs
84-- This is a hack. I don't know how to tell cabal that a data file needs
70-- installing but shouldn't be in the distribution. And it won't make the
85-- installing but shouldn't be in the distribution. And it won't make the
@@ -94,7 +109,7 @@ checkStdLib local verbosity
94 , "IDRIS=" ++ icmd
109 , "IDRIS=" ++ icmd
97−checkJavaLib verbosity = mvn verbosity [ "-f", "java/pom.xml", "package" ]
112+checkJavaLib verbosity = mvn verbosity [ "-f", "java" </> "pom.xml", "package" ]
99noJavaFlag flags =
114noJavaFlag flags =
100 case lookup (FlagName "nojava") (S.configConfigurationsFlags flags) of
115 case lookup (FlagName "nojava") (S.configConfigurationsFlags flags) of
@@ -102,12 +117,14 @@ noJavaFlag flags =
102 Just False -> False
117 Just False -> False
103 Nothing -> False
118 Nothing -> False
105−preparePom version
120+preparePoms version
106− = do pomTemplate <- readFile ("java" </> "pom_template.xml")
121+ = do pomTemplate <- TIO.readFile ("java" </> "pom_template.xml")
107− writeFile ("java" </> "pom.xml") (unlines . map insertVersion $ lines pomTemplate)
122+ TIO.writeFile ("java" </> "pom.xml") (insertVersion pomTemplate)
123+ execPomTemplate <- TIO.readFile ("java" </> "executable_pom_template.xml")
124+ TIO.writeFile ("java" </> "executable_pom.xml") (insertVersion execPomTemplate)
109− insertVersion " <version></version>" = " <version>" ++ display version ++ "</version>"
126+ insertVersion template =
110− insertVersion other = other
127+ T.replace (T.pack "$RTS-VERSION$") (T.pack $ display version) template
112-- Install libraries during both copy and install
129-- Install libraries during both copy and install
113-- See http://hackage.haskell.org/trac/hackage/ticket/718
130-- See http://hackage.haskell.org/trac/hackage/ticket/718
@@ -121,11 +138,17 @@ main = do
121 let verb = (S.fromFlag $ S.installVerbosity flags)
138 let verb = (S.fromFlag $ S.installVerbosity flags)
122 installStdLib pkg lbi verb
139 installStdLib pkg lbi verb
123 NoCopyDest
140 NoCopyDest
124− unless (noJavaFlag $ configFlags lbi) (installJavaLib verb)
141+ unless (noJavaFlag $ configFlags lbi)
146+ (pkgVersion . package $ localPkgDescr lbi)
125 , postConf = \ _ flags _ lbi -> do
148 , postConf = \ _ flags _ lbi -> do
126 removeLibIdris lbi (S.fromFlag $ S.configVerbosity flags)
149 removeLibIdris lbi (S.fromFlag $ S.configVerbosity flags)
127 unless (noJavaFlag $ configFlags lbi)
150 unless (noJavaFlag $ configFlags lbi)
128− (preparePom . pkgVersion . package $ localPkgDescr lbi)
151+ (preparePoms . pkgVersion . package $ localPkgDescr lbi)
129 , postClean = \ _ flags _ _ -> do
152 , postClean = \ _ flags _ _ -> do
130 let verb = S.fromFlag $ S.cleanVerbosity flags
153 let verb = S.fromFlag $ S.cleanVerbosity flags
131 cleanStdLib verb
154 cleanStdLib verb