guix: ant-build-system: Add main-class support.
* guix/build-system/ant.scm: New #:main-class argument * guix/build/ant-build-system.scm: Generate a manifest file with additional properties. * doc/guix.texi (Build Systems): Document it.
This commit is contained in:
parent
4d6801b735
commit
8df1faa047
|
@ -3479,6 +3479,10 @@ build file @file{build.xml} with tasks to build the specified jar
|
||||||
archive. In this case the parameter @code{#:source-dir} can be used to
|
archive. In this case the parameter @code{#:source-dir} can be used to
|
||||||
specify the source sub-directory, defaulting to ``src''.
|
specify the source sub-directory, defaulting to ``src''.
|
||||||
|
|
||||||
|
The @code{#:main-class} parameter can be used with the minimal ant
|
||||||
|
buildfile to specify the main class of the resulting jar. This makes the
|
||||||
|
jar file executable.
|
||||||
|
|
||||||
The parameter @code{#:build-target} can be used to specify the Ant task
|
The parameter @code{#:build-target} can be used to specify the Ant task
|
||||||
that should be run during the @code{build} phase. By default the
|
that should be run during the @code{build} phase. By default the
|
||||||
``jar'' task will be run.
|
``jar'' task will be run.
|
||||||
|
|
|
@ -99,6 +99,7 @@
|
||||||
(make-flags ''())
|
(make-flags ''())
|
||||||
(build-target "jar")
|
(build-target "jar")
|
||||||
(jar-name #f)
|
(jar-name #f)
|
||||||
|
(main-class #f)
|
||||||
(source-dir "src")
|
(source-dir "src")
|
||||||
(test-dir "src/test")
|
(test-dir "src/test")
|
||||||
(phases '(@ (guix build ant-build-system)
|
(phases '(@ (guix build ant-build-system)
|
||||||
|
@ -130,6 +131,7 @@
|
||||||
#:test-target ,test-target
|
#:test-target ,test-target
|
||||||
#:build-target ,build-target
|
#:build-target ,build-target
|
||||||
#:jar-name ,jar-name
|
#:jar-name ,jar-name
|
||||||
|
#:main-class ,main-class
|
||||||
#:source-dir ,source-dir
|
#:source-dir ,source-dir
|
||||||
#:test-dir ,test-dir
|
#:test-dir ,test-dir
|
||||||
#:phases ,phases
|
#:phases ,phases
|
||||||
|
|
|
@ -36,7 +36,7 @@
|
||||||
;; Code:
|
;; Code:
|
||||||
|
|
||||||
(define* (default-build.xml jar-name prefix #:optional
|
(define* (default-build.xml jar-name prefix #:optional
|
||||||
(source-dir ".") (test-dir "./test"))
|
(source-dir ".") (test-dir "./test") (main-class #f))
|
||||||
"Create a simple build.xml with standard targets for Ant."
|
"Create a simple build.xml with standard targets for Ant."
|
||||||
(call-with-output-file "build.xml"
|
(call-with-output-file "build.xml"
|
||||||
(lambda (port)
|
(lambda (port)
|
||||||
|
@ -44,6 +44,10 @@
|
||||||
`(project (@ (basedir "."))
|
`(project (@ (basedir "."))
|
||||||
(property (@ (name "classes.dir")
|
(property (@ (name "classes.dir")
|
||||||
(value "${basedir}/build/classes")))
|
(value "${basedir}/build/classes")))
|
||||||
|
(property (@ (name "manifest.dir")
|
||||||
|
(value "${basedir}/build/manifest")))
|
||||||
|
(property (@ (name "manifest.file")
|
||||||
|
(value "${manifest.dir}/MANIFEST.MF")))
|
||||||
(property (@ (name "jar.dir")
|
(property (@ (name "jar.dir")
|
||||||
(value "${basedir}/build/jar")))
|
(value "${basedir}/build/jar")))
|
||||||
(property (@ (name "dist.dir")
|
(property (@ (name "dist.dir")
|
||||||
|
@ -60,6 +64,17 @@
|
||||||
(path (@ (id "classpath"))
|
(path (@ (id "classpath"))
|
||||||
(pathelement (@ (location "${env.CLASSPATH}"))))
|
(pathelement (@ (location "${env.CLASSPATH}"))))
|
||||||
|
|
||||||
|
(target (@ (name "manifest"))
|
||||||
|
(mkdir (@ (dir "${manifest.dir}")))
|
||||||
|
(echo (@ (file "${manifest.file}")
|
||||||
|
(message ,(string-append
|
||||||
|
(if main-class
|
||||||
|
(string-append
|
||||||
|
"Main-Class: " main-class
|
||||||
|
"${line.separator}")
|
||||||
|
"")
|
||||||
|
"")))))
|
||||||
|
|
||||||
(target (@ (name "compile"))
|
(target (@ (name "compile"))
|
||||||
(mkdir (@ (dir "${classes.dir}")))
|
(mkdir (@ (dir "${classes.dir}")))
|
||||||
(javac (@ (includeantruntime "false")
|
(javac (@ (includeantruntime "false")
|
||||||
|
@ -97,10 +112,11 @@
|
||||||
(include (@ (name "**/*Test.java" )))))))
|
(include (@ (name "**/*Test.java" )))))))
|
||||||
|
|
||||||
(target (@ (name "jar")
|
(target (@ (name "jar")
|
||||||
(depends "compile"))
|
(depends "compile, manifest"))
|
||||||
(mkdir (@ (dir "${jar.dir}")))
|
(mkdir (@ (dir "${jar.dir}")))
|
||||||
(exec (@ (executable "jar"))
|
(exec (@ (executable "jar"))
|
||||||
(arg (@ (line ,(string-append "-cf ${jar.dir}/" jar-name
|
(arg (@ (line ,(string-append "-cmf ${manifest.file} "
|
||||||
|
"${jar.dir}/" jar-name
|
||||||
" -C ${classes.dir} ."))))))
|
" -C ${classes.dir} ."))))))
|
||||||
|
|
||||||
(target (@ (name "install"))
|
(target (@ (name "install"))
|
||||||
|
@ -133,12 +149,13 @@ to the default GNU unpack strategy."
|
||||||
|
|
||||||
(define* (configure #:key inputs outputs (jar-name #f)
|
(define* (configure #:key inputs outputs (jar-name #f)
|
||||||
(source-dir "src")
|
(source-dir "src")
|
||||||
(test-dir "src/test") #:allow-other-keys)
|
(test-dir "src/test")
|
||||||
|
(main-class #f) #:allow-other-keys)
|
||||||
(when jar-name
|
(when jar-name
|
||||||
(default-build.xml jar-name
|
(default-build.xml jar-name
|
||||||
(string-append (assoc-ref outputs "out")
|
(string-append (assoc-ref outputs "out")
|
||||||
"/share/java")
|
"/share/java")
|
||||||
source-dir test-dir))
|
source-dir test-dir main-class))
|
||||||
(setenv "JAVA_HOME" (assoc-ref inputs "jdk"))
|
(setenv "JAVA_HOME" (assoc-ref inputs "jdk"))
|
||||||
(setenv "CLASSPATH" (generate-classpath inputs)))
|
(setenv "CLASSPATH" (generate-classpath inputs)))
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue