@@ -15,6 +15,8 @@ import System.FilePath ((</>), splitDirectories)
1515import System.Directory
1616import qualified System.FilePath.Posix as Px
1717import System.Process
18+import qualified Data.Text as T
19+import qualified Data.Text.IO as TIO
1820
1921
2022-- After Idris is built, we need to check and install the prelude and other libs
@@ -40,6 +42,8 @@ cleanJavaLib verbosity
4042 when dirty $ mvn verbosity [ "-f", "java/pom.xml", "clean" ]
4143 pomExists <- doesFileExist ("java" </> "pom.xml")
4244 when pomExists $ removeFile ("java" </> "pom.xml")
45+ execPomExists <- doesFileExist ("java" </> "executable_pom.xml")
46+ when pomExists $ removeFile ("java" </> "executable_pom.xml")
4347
4448installStdLib pkg local verbosity copy
4549 = do let dirs = L.absoluteInstallDirs pkg local copy
@@ -64,7 +68,18 @@ installStdLib pkg local verbosity copy
6468 , "IDRIS=" ++ icmd
6569 ]
6670
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
78+ , "-Dpackaging=jar"
79+ , "-DgeneratePom=True"
80+ ]
81+ let dir = datadir $ L.absoluteInstallDirs pkg local copy
82+ copyFile ("java" </> "executable_pom.xml") (dir </> "executable_pom.xml")
6883
6984-- This is a hack. I don't know how to tell cabal that a data file needs
7085-- installing but shouldn't be in the distribution. And it won't make the
@@ -94,7 +109,7 @@ checkStdLib local verbosity
94109 , "IDRIS=" ++ icmd
95110 ]
96111
97−checkJavaLib verbosity = mvn verbosity [ "-f", "java/pom.xml", "package" ]
112+checkJavaLib verbosity = mvn verbosity [ "-f", "java" </> "pom.xml", "package" ]
98113
99114noJavaFlag flags =
100115 case lookup (FlagName "nojava") (S.configConfigurationsFlags flags) of
@@ -102,12 +117,14 @@ noJavaFlag flags =
102117 Just False -> False
103118 Nothing -> False
104119
105−preparePom version
106− = do pomTemplate <- readFile ("java" </> "pom_template.xml")
107− writeFile ("java" </> "pom.xml") (unlines . map insertVersion $ lines pomTemplate)
120+preparePoms version
121+ = do pomTemplate <- TIO.readFile ("java" </> "pom_template.xml")
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)
108125 where
109− insertVersion " <version></version>" = " <version>" ++ display version ++ "</version>"
110− insertVersion other = other
126+ insertVersion template =
127+ T.replace (T.pack "$RTS-VERSION$") (T.pack $ display version) template
111128
112129-- Install libraries during both copy and install
113130-- See http://hackage.haskell.org/trac/hackage/ticket/718
@@ -121,11 +138,17 @@ main = do
121138 let verb = (S.fromFlag $ S.installVerbosity flags)
122139 installStdLib pkg lbi verb
123140 NoCopyDest
124− unless (noJavaFlag $ configFlags lbi) (installJavaLib verb)
141+ unless (noJavaFlag $ configFlags lbi)
142+ (installJavaLib pkg
143+ lbi
144+ verb
145+ NoCopyDest
146+ (pkgVersion . package $ localPkgDescr lbi)
147+ )
125148 , postConf = \ _ flags _ lbi -> do
126149 removeLibIdris lbi (S.fromFlag $ S.configVerbosity flags)
127150 unless (noJavaFlag $ configFlags lbi)
128− (preparePom . pkgVersion . package $ localPkgDescr lbi)
151+ (preparePoms . pkgVersion . package $ localPkgDescr lbi)
129152 , postClean = \ _ flags _ _ -> do
130153 let verb = S.fromFlag $ S.cleanVerbosity flags
131154 cleanStdLib verb