> You'd do something like this:
>
> my_pom = file(_(:target, 'pom.xm'l)) do |f|
> # generate pom.xml
> end
>
> package(:jar).pom.from my_pom
>
> alex
Thanks, Alex, for the hint.
This partially works.
For Java sub projects this does the expected.
I actually added the following helper method on the outermost level of my
buildfile:
def create_pom(pkg, deps)
file(_(:target, "pom.xml")) do |file|
File.open(file.to_s, 'w') do |f|
xml = Builder::XmlMarkup.new(:target=>f, :indent=>2)
xml.instruct!
xml.project do
xml.modelVersion "4.0.0"
xml.groupId pkg.group
xml.artifactId pkg.id
xml.version pkg.version
xml.dependencies do
deps.each do |artifact|
xml.dependency artifact do
xml.groupId artifact.group
xml.artifactId artifact.id
xml.version artifact.version
end
end
end
end
end
end
end
In the definition of a Java-based sub project I can then do:
package(:jar).pom.from create_pom(package(:jar), compile.dependencies)
and the generated pom.xml is correctly being used.
However, from a Scala-based sub project the same does not work.
Firstly, the temporary pom.xml in the target sub directory is only created if
it doesn't exist yet. For some reason in the Java-based sub project this is not
the case.
Secondly, the compile.dependencies array for Scala projects contains just a
list of Strings (namely the file systems paths to the artifacts rather than
actual artifact objects responding to "group", "id", etc.)
Why is this the case?
Also: Do I really have to take the ugly way of generating a temporary pom.xml
on the file system rather than using the XML builder to generate a string which
can then be used as the pom content? For some reason
"package(:jar).pom.content('...pom content...')" does not seem to work as
expected....
(Of course closing issue BUILDR-486 would be even better... :)
Thanks for any further help on this!
Cheers,
Mathias
---
[email protected]
http://www.parboiled.org