5 ms·
how do you do conditionals or loops in maven?
by pswenson 11y ago
how do you do conditionals or loops in maven?
- lmm 11y agoYou don't. If you need to run custom code in the build you have to encapsulate that as a plugin (which will be a first-class maven module in its own right, which naturally nudges you to writing unit tests, having a proper release process with semver and so on for your build step). But mostly you keep your build simple and declarative and you put any business logic in the actual code. It's wonderful.
- jacques_chester 11y ago> how do you do conditionals or loops in maven? What you're asking for is Turing-complete XML. History has shown that this is usually a mistake.
- dashoffset 11y agoOr maybe he's asking for a non-XML Turing-complete configuration.
- nirvdrum 11y agoYou can use the maven polyglot plugin [1] to write your POM in something other than XML. It's fairly new, but it's there. We use it in JRuby to write our POMs in Ruby. As an example of a loop: https://github.com/jruby/jruby/blob/8e29ae1302e7aa989b8808f7edf7228a27d29f1a/core/pom.rb#L263-L277 https://github.com/jruby/jruby/blob/8e29ae1302e7aa989b8808f7... [1] -- https://github.com/takari/polyglot-maven https://github.com/takari/polyglot-maven
- iso-8859-1 11y agoWhy can't I use Java with Polyglot?
- nirvdrum 11y agoI don't know much about the development of the project, simply that it exists and is usable. I'd file an issue with the project and see what comes of it.