Are Maven profiles like Ant targets?
I'm coming from the Ant world, where targets are fundamental. Need to generate the JavaDocs and a JAR? Write targets called "javadoc" and "jar" then do: ant javadoc ant jar In Maven, these particular tasks have built-in plugins, so there's no need to write a target. Instead you just invoke the plugin goal: mvn javadoc:javadoc mvn jar:jar But there are many scenarios in which no plugin is available. For instance, I use install4j to build an installer, and I use DocBook to translate XML into PDF. Accomplishing these tasks with the AntRun plugin is easy enough, but it's not clear how to actually invoke them. The Ant concept of a target does not exist in Maven. Maven does have profiles, however. I'm able to put the install4j stuff into a profile called "install4j" and the DocBook stuff into a profile called "docbook". Then I can do: mvn -Pinstall4j mvn -Pdocbook This works, but from an end-user standpoint it's a little confusing. For some things you invoke a plugin goal but for other things you invoke a profile. It's inconsistent. Also, the Build Profiles chapter of the Maven book mentions nothing about this use case. It only talks about profiles for the purpose of build portability. So... am I doing this right? Are profiles intended to play the role of Ant targets? Or is there some other mechanism for that? Trevor - To unsubscribe, e-mail: users-unsubscr...@maven.apache.org For additional commands, e-mail: users-h...@maven.apache.org
Re: Are Maven profiles like Ant targets?
On Tue, Dec 16, 2008 at 10:27 AM, Trevor Harmon wrote: > I'm coming from the Ant world, where targets are fundamental. Need to > generate the JavaDocs and a JAR? Write targets called "javadoc" and "jar" > then do: > > ant javadoc > ant jar > > In Maven, these particular tasks have built-in plugins, so there's no need > to write a target. Instead you just invoke the plugin goal: > > mvn javadoc:javadoc > mvn jar:jar > > But there are many scenarios in which no plugin is available. For instance, > I use install4j to build an installer, and I use DocBook to translate XML > into PDF. Accomplishing these tasks with the AntRun plugin is easy enough, > but it's not clear how to actually invoke them. The Ant concept of a target > does not exist in Maven. > > Maven does have profiles, however. I'm able to put the install4j stuff into > a profile called "install4j" and the DocBook stuff into a profile called > "docbook". Then I can do: > > mvn -Pinstall4j > mvn -Pdocbook > > This works, but from an end-user standpoint it's a little confusing. For > some things you invoke a plugin goal but for other things you invoke a > profile. It's inconsistent. Also, the Build Profiles chapter of the Maven > book mentions nothing about this use case. It only talks about profiles for > the purpose of build portability. > > So... am I doing this right? Are profiles intended to play the role of Ant > targets? Or is there some other mechanism for that? > I wouldn't say that profiles are analagous to Ant targets, no; you might be able to make them react that way, but that's not really the intent. The closest analog to an Ant target is a maven lifecycle phase, like "install"; there's a pre-defined lifecycle that Maven follows, and you can bind plugins of your choosing to that lifecycle. This works well in many 'build' scenarios, but it's also true that Maven is tailored around those kind of environments, and isn't as well suited for the world of "execute some arbitrary work for me" as Ant would be. That said, it's not hard to imagine using Maven to build an installer or some Docbook documentation; each of these might be a module on a larger multi-module project. - Geoffrey -- Geoffrey Wiseman http://www.geoffreywiseman.ca/
Re: Are Maven profiles like Ant targets?
On Tuesday 16 December 2008 Trevor Harmon wrote: [...] > So... am I doing this right? Are profiles intended to play the role of > Ant targets? Or is there some other mechanism for that? You are doing it wrong. Maven has no targets like ant has. Maven has lifecylces [0] which is built of phases (e.g. 'compile', package', 'install'). Plugins are attached to phases and are executed whenever a phase is executed. Profiles are used to configure plugins in different ways. Start reading the documentation at [1] and especially the books "Better builds with Maven" and "Maven - The Definitve Guide". Both are available online for free. Search this archive or google it. hth, - martin [0] http://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html [1] http://maven.apache.org/guides/index.html signature.asc Description: This is a digitally signed message part.
RE: Are Maven profiles like Ant targets?
You probably want to use a plugin. For instance you could use the DocBook plugin. http://maven-plugins.sourceforge.net/maven-sdocbook-plugin/index.html Once you have this plugin you can simply run the command: mvn sdocbook You will also want to get a better understanding of Maven's build lifecycle and undertand how lifecycles, phases and goals are related. It is more complex than ant targets but is also far more powerful. http://books.sonatype.com/maven-book/reference/lifecycle.html Ultimately, you will want to hide the fact that your particular project is using DocBook by binding these goals to a certain phase of the build lifecycle. ie: you will never have to run the "mvn sdocbook" command explicitly (although you still could if you needed to). What part of the lifecycle will be up to you but creating PDFs would likely best be sutied to the site lifecycle. Good luck. --- Todd Thiessen > -Original Message- > From: Trevor Harmon [mailto:tre...@vocaro.com] > Sent: Tuesday, December 16, 2008 10:28 AM > To: Maven Users List > Subject: Are Maven profiles like Ant targets? > > I'm coming from the Ant world, where targets are fundamental. > Need to generate the JavaDocs and a JAR? Write targets called > "javadoc" and "jar" then do: > >ant javadoc >ant jar > > In Maven, these particular tasks have built-in plugins, so > there's no need to write a target. Instead you just invoke > the plugin goal: > >mvn javadoc:javadoc >mvn jar:jar > > But there are many scenarios in which no plugin is available. > For instance, I use install4j to build an installer, and I > use DocBook to translate XML into PDF. Accomplishing these > tasks with the AntRun plugin is easy enough, but it's not > clear how to actually invoke them. > The Ant concept of a target does not exist in Maven. > > Maven does have profiles, however. I'm able to put the > install4j stuff into a profile called "install4j" and the > DocBook stuff into a profile called "docbook". Then I can do: > >mvn -Pinstall4j >mvn -Pdocbook > > This works, but from an end-user standpoint it's a little confusing. > For some things you invoke a plugin goal but for other things > you invoke a profile. It's inconsistent. Also, the Build > Profiles chapter of the Maven book mentions nothing about > this use case. It only talks about profiles for the purpose > of build portability. > > So... am I doing this right? Are profiles intended to play > the role of Ant targets? Or is there some other mechanism for that? > > Trevor > > > - > To unsubscribe, e-mail: users-unsubscr...@maven.apache.org > For additional commands, e-mail: users-h...@maven.apache.org > > - To unsubscribe, e-mail: users-unsubscr...@maven.apache.org For additional commands, e-mail: users-h...@maven.apache.org
Re: Are Maven profiles like Ant targets?
On Dec 16, 2008, at 10:43 AM, Todd Thiessen wrote: You probably want to use a plugin. For instance you could use the DocBook plugin. http://maven-plugins.sourceforge.net/maven-sdocbook-plugin/index.html The sdocbook plugin does not work with Maven 2. I also tried the more recent docbook plugin: http://mojo.codehaus.org/docbook-maven-plugin/ But it's in a very alpha stage and lacks basic features (e.g. PDF generation). That's why I'm using the AntRun plugin; it gives me access to Ant's Xslt task for transforming DocBook. You will also want to get a better understanding of Maven's build lifecycle and undertand how lifecycles, phases and goals are related. It is more complex than ant targets but is also far more powerful. http://books.sonatype.com/maven-book/reference/lifecycle.html I'm familiar with the lifecycles, but it's strange you should say they are more powerful than Ant targets because they seem less powerful, at least when using the AntRun plugin. For example, my DocBook AntRun stuff is used for generating developer documentation, so binding it to any of the default lifecycle phases doesn't make sense. The site phase of the site lifecycle is probably the best place to put it, but then it gets tossed in with everything else in that phase. There's no way to run the DocBook stuff by itself; I have to run it along with everything else in the site phase. So in that sense, lifecycles are less powerful than Ant targets because they are more coarsely grained. I don't have the same control over what gets run. If, however, I put the DocBook stuff into a separate profile then suddenly I have that control. I don't know how else to get it without profiles. Trevor - To unsubscribe, e-mail: users-unsubscr...@maven.apache.org For additional commands, e-mail: users-h...@maven.apache.org
Re: Are Maven profiles like Ant targets?
On Dec 16, 2008, at 10:42 AM, Martin Höller wrote: You are doing it wrong. Maven has no targets like ant has. Maven has lifecylces [0] which is built of phases (e.g. 'compile', package', 'install'). Plugins are attached to phases and are executed whenever a phase is executed. Well, without profiles, I don't know how to do it right. For example, I use the AntRun plugin to invoke install4j, which builds installers for my artifact. Binding this to the deploy phase probably makes the most sense, but if I do that, the deploy goal of the deploy plugin also runs. There's no way to tell Maven to just run the install4j stuff. If, however, I split off the install4j stuff into an "install4j" profile and bind it to the package phase, then I can do: mvn -Pinstall4j package And suddenly Maven does exactly what I want: It runs install4j and nothing else. Without profiles, how can I accomplish this? Trevor - To unsubscribe, e-mail: users-unsubscr...@maven.apache.org For additional commands, e-mail: users-h...@maven.apache.org
RE: Are Maven profiles like Ant targets?
They are more powerful in the sense that you can still call any goal independantly, but still have the flexibility to bind it to a phase which is part of a well defined life cycle. You get the best of both worlds this way. Perhaps the doxia plugin would work? http://maven.apache.org/doxia/book/index.html Not sure what you are doing in your profile that solves your issue though. If you give some further info on this, perhaps some of the more experieced Maven users can provide you with a pure Maven solution. If you wish to run something independently, you don't need ant or Maven for this. Run run the executable. --- Todd Thiessen > -Original Message- > From: Trevor Harmon [mailto:tre...@vocaro.com] > Sent: Tuesday, December 16, 2008 2:34 PM > To: Maven Users List > Subject: Re: Are Maven profiles like Ant targets? > > On Dec 16, 2008, at 10:43 AM, Todd Thiessen wrote: > > > You probably want to use a plugin. For instance you could use the > > DocBook plugin. > > > > > http://maven-plugins.sourceforge.net/maven-sdocbook-plugin/index.html > > The sdocbook plugin does not work with Maven 2. > > I also tried the more recent docbook plugin: > > http://mojo.codehaus.org/docbook-maven-plugin/ > > But it's in a very alpha stage and lacks basic features (e.g. > PDF generation). > > That's why I'm using the AntRun plugin; it gives me access to > Ant's Xslt task for transforming DocBook. > > > You will also want to get a better understanding of Maven's build > > lifecycle and undertand how lifecycles, phases and goals > are related. > > It is more complex than ant targets but is also far more powerful. > > > > http://books.sonatype.com/maven-book/reference/lifecycle.html > > I'm familiar with the lifecycles, but it's strange you should > say they are more powerful than Ant targets because they seem > less powerful, at least when using the AntRun plugin. For > example, my DocBook AntRun stuff is used for generating > developer documentation, so binding it to any of the default > lifecycle phases doesn't make sense. The site phase of the > site lifecycle is probably the best place to put it, but then > it gets tossed in with everything else in that phase. There's > no way to run the DocBook stuff by itself; I have to run it > along with everything else in the site phase. > > So in that sense, lifecycles are less powerful than Ant > targets because they are more coarsely grained. I don't have > the same control over what gets run. If, however, I put the > DocBook stuff into a separate profile then suddenly I have > that control. I don't know how else to get it without profiles. > > Trevor > > > - > To unsubscribe, e-mail: users-unsubscr...@maven.apache.org > For additional commands, e-mail: users-h...@maven.apache.org > > - To unsubscribe, e-mail: users-unsubscr...@maven.apache.org For additional commands, e-mail: users-h...@maven.apache.org
Re: Are Maven profiles like Ant targets?
On Dec 16, 2008, at 2:54 PM, Todd Thiessen wrote: They are more powerful in the sense that you can still call any goal independantly But if I have two tasks implemented with AntRun, there's no way to call them independently because there's only one goal: run. I guess most of my problems boil down to the limitations of the AntRun plugin. Perhaps the doxia plugin would work? http://maven.apache.org/doxia/book/index.html That plugin is fine if you want to use DocBook as a source for Doxia, but it's not designed for stand-alone documentation created using DocBook and the DocBook XSL stylesheets. The Xslt task in Ant works great for that, though. Not sure what you are doing in your profile that solves your issue though. If you give some further info on this, perhaps some of the more experieced Maven users can provide you with a pure Maven solution. Let me use a different plugin as an example. Let's say I'm developing a desktop application, and it runs in two different modes depending on the command-line options. I don't want to keep typing in the same long string of options all the time, so I pickle them into two separate Ant targets, "mode1" and "mode2". Then I can run them like this: ant mode1 ant mode2 How would I accomplish this in Maven? There's the exec plugin, but it has only one goal (exec:java). There's no way to run the application in two different ways with just that one goal. Not without profiles, that is. With profiles, I can create two profiles, "mode1" and "mode2", and define an exec plugin in each one. Then I can run them like this: mvn -Pmode1 exec:java mvn -Pmode2 exec:java So there's an example where profiles have nothing to do with build portability and are playing the same role as Ant targets. If you wish to run something independently, you don't need ant or Maven for this. Run run the executable. Isn't that like saying Ant or Maven aren't necessary for compiling Java code because you can just run the javac executable? Doesn't make sense... Trevor - To unsubscribe, e-mail: users-unsubscr...@maven.apache.org For additional commands, e-mail: users-h...@maven.apache.org
RE: Are Maven profiles like Ant targets?
--- Todd Thiessen > -Original Message- > From: Trevor Harmon [mailto:tre...@vocaro.com] > Sent: Tuesday, December 16, 2008 3:59 PM > To: Maven Users List > Subject: Re: Are Maven profiles like Ant targets? > > On Dec 16, 2008, at 2:54 PM, Todd Thiessen wrote: > > > They are more powerful in the sense that you can still call > any goal > > independantly > > But if I have two tasks implemented with AntRun, there's no > way to call them independently because there's only one goal: > run. I guess most of my problems boil down to the limitations > of the AntRun plugin. > > > Perhaps the doxia plugin would work? > > > > http://maven.apache.org/doxia/book/index.html > > That plugin is fine if you want to use DocBook as a source > for Doxia, but it's not designed for stand-alone > documentation created using DocBook and the DocBook XSL > stylesheets. The Xslt task in Ant works great for that, though. > > > Not sure what you are doing in your profile that solves your issue > > though. If you give some further info on this, perhaps some of the > > more experieced Maven users can provide you with a pure Maven > > solution. > > Let me use a different plugin as an example. Let's say I'm > developing a desktop application, and it runs in two > different modes depending on the command-line options. I > don't want to keep typing in the same long string of options > all the time, so I pickle them into two separate Ant targets, > "mode1" and "mode2". Then I can run them like this: > > ant mode1 > ant mode2 > > How would I accomplish this in Maven? There's the exec > plugin, but it has only one goal (exec:java). There's no way > to run the application in two different ways with just that > one goal. I believe that there is. I know you can configure a goal with different executions. There is a decent explanation here: > Not without profiles, that is. With profiles, I can > create two profiles, "mode1" and "mode2", and define an exec > plugin in each one. Then I can run them like this: > > mvn -Pmode1 exec:java > mvn -Pmode2 exec:java > > So there's an example where profiles have nothing to do with > build portability and are playing the same role as Ant targets. > > > If you wish to run something independently, you don't need ant or > > Maven for this. Run run the executable. > > Isn't that like saying Ant or Maven aren't necessary for > compiling Java code because you can just run the javac > executable? Doesn't make sense... > > Trevor > > > - > To unsubscribe, e-mail: users-unsubscr...@maven.apache.org > For additional commands, e-mail: users-h...@maven.apache.org > > - To unsubscribe, e-mail: users-unsubscr...@maven.apache.org For additional commands, e-mail: users-h...@maven.apache.org
RE: Are Maven profiles like Ant targets?
Bah. Ignore last. Hit send by mistake. --- Todd Thiessen > Let me use a different plugin as an example. Let's say I'm > developing a desktop application, and it runs in two > different modes depending on the command-line options. I > don't want to keep typing in the same long string of options > all the time, so I pickle them into two separate Ant targets, > "mode1" and "mode2". Then I can run them like this: > > ant mode1 > ant mode2 > > How would I accomplish this in Maven? There's the exec > plugin, but it has only one goal (exec:java). There's no way > to run the application in two different ways with just that > one goal. I believe there is. Plugin can have different executions. There is some documentation about that here: http://maven.apache.org/guides/introduction/introduction-to-the-lifecycl e.html#Plugins and I believe the definitive guide has some examples too. You should be able to execute the same exe with as many different parameters as you like. But you still would have to bind it to a phase, which you don't want to do. So I agree with you that Maven is definitely heavy weight if all you wish to do is execute an exe with different parameters each time. It doesn't do this nicely. You probably just want a simple script for that. > > If you wish to run something independently, you don't need ant or > > Maven for this. Run run the executable. > > Isn't that like saying Ant or Maven aren't necessary for > compiling Java code because you can just run the javac > executable? Doesn't make sense... Not at all. If all I wanted to do is compile java code, then javac would be the tool of choice. But developers generally want to do a whole lot more in conjuntion with compiling java code. If all you want to do is run some exe, then using ant or maven is somewhat overkill. A script does this just fine. But if the reason why you are running this exe is somehow linked to building your overall project, then binding it to a certain phase starts to make sense. It all depends on what you want. - To unsubscribe, e-mail: users-unsubscr...@maven.apache.org For additional commands, e-mail: users-h...@maven.apache.org
Re: Are Maven profiles like Ant targets?
On Wed, Dec 17, 2008 at 6:58 AM, Trevor Harmon wrote: > That plugin is fine if you want to use DocBook as a source for Doxia, but > it's not designed for stand-alone documentation created using DocBook and > the DocBook XSL stylesheets. The Xslt task in Ant works great for that, > though. > I've had good luck with the docbkx plugin http://code.google.com/p/docbkx-tools/ I'm using it to generate html from DocBook files in Maven 2. - To unsubscribe, e-mail: users-unsubscr...@maven.apache.org For additional commands, e-mail: users-h...@maven.apache.org
Re: Are Maven profiles like Ant targets?
On Dec 16, 2008, at 5:24 PM, Todd Thiessen wrote: I believe there is. Plugin can have different executions. There is some documentation about that here: http://maven.apache.org/guides/introduction/introduction-to-the-lifecycl e.html#Plugins But that doesn't work for the exec plugin. I'd be grateful if someone could prove me wrong. and I believe the definitive guide has some examples too. No, in the book they always pass the exec arguments on the command line. See: http://books.sonatype.com/maven-book/reference/customizing.html#section-custom-exec But you still would have to bind it to a phase, which you don't want to do. I'm not trying to avoid anything. If binding to a phase would solve the problems, then I'd do it. But simply binding a plugin to a phase is not enough, for reasons I have shown. So I agree with you that Maven is definitely heavy weight if all you wish to do is execute an exe with different parameters each time. It doesn't do this nicely. You probably just want a simple script for that. Or I could just use profiles. Trevor - To unsubscribe, e-mail: users-unsubscr...@maven.apache.org For additional commands, e-mail: users-h...@maven.apache.org
Re: Are Maven profiles like Ant targets?
On Tuesday 16 December 2008 Trevor Harmon wrote: > On Dec 16, 2008, at 10:42 AM, Martin Höller wrote: > > You are doing it wrong. Maven has no targets like ant has. Maven has > > lifecylces [0] which is built of phases (e.g. 'compile', package', > > 'install'). Plugins are attached to phases and are executed whenever > > a phase is executed. > > Well, without profiles, I don't know how to do it right. For example, > I use the AntRun plugin to invoke install4j, which builds installers > for my artifact. Binding this to the deploy phase probably makes the > most sense, but if I do that, the deploy goal of the deploy plugin > also runs. There's no way to tell Maven to just run the install4j stuff. The problem is, that you are still thinking in ant tasks. Maven doesn't provide those tasks, it just knows about a lifecyle and its few phases. I don't know anything about install4j but from what you wrote it seems the work it does should be done in the package phase. So try to configure your antrun plugin to execute the install4j task in the package phase. This way install4j will be executed whenever it needs to, i.e. when the package phase or one of its successors is going to be excuted. > If, however, I split off the install4j stuff into an "install4j" > profile and bind it to the package phase, then I can do: > >mvn -Pinstall4j package Why would you have to use a profile for this? For attaching the antrun plugin to the package phase you don't have to use any profile. > And suddenly Maven does exactly what I want: It runs install4j and > nothing else. If you really want maven to do only _one_ specific thing (which is most of the time not the common way) you can execute a single plugin goal by specifying just this goal, e.g. "mvn deploy:deploy-file" or "mvn antrun:run". hth, - martin signature.asc Description: This is a digitally signed message part.
Re: Are Maven profiles like Ant targets?
On Tuesday 16 December 2008 Trevor Harmon wrote: > Let me use a different plugin as an example. Let's say I'm developing > a desktop application, and it runs in two different modes depending on > the command-line options. I don't want to keep typing in the same long > string of options all the time, so I pickle them into two separate Ant > targets, "mode1" and "mode2". Then I can run them like this: > > ant mode1 > ant mode2 I would say that is what profiles are for: to configure plugin's in different ways. But that is not even similar to ant's tasks. It's switching the build configuration, not executing another task. And BTW: Maven's primary goal is to help building and packaging software, not starting the developed piece of software, so IMHO the exec-plugin is not a good example here. hth, - martin signature.asc Description: This is a digitally signed message part.
Re: Are Maven profiles like Ant targets?
On Dec 17, 2008, at 9:14 AM, Todd Thiessen wrote: This prints hello and goodbye as part of the clean phase. ... Doesn't this fit your needs? No, it doesn't fit my needs because it always prints both "hello" and "goodbye". I want to print either "hello" or "goodbye". For example, in the scenario I mentioned earlier, I want to launch a desktop application with one particular command-line configuration. With your solution, I'd be launching the app multiple times. That's certainly not what I want. I've attached a rewrite of your code that uses profiles to select which configuration is run. For instance: mvn -Phello clean mvn -Pgoodbye clean Or I can do both at once: mvn -Phello,goodbye clean Is there a way to accomplish this without profiles? Trevor http://maven.apache.org/POM/4.0.0"; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd";> 4.0.0 com.vocaro antrun 1.0 pom hello org.codehaus.mojo exec-maven-plugin print-hello clean exec echo hello goodbye org.codehaus.mojo exec-maven-plugin print-goodbye clean exec echo goodbye - To unsubscribe, e-mail: users-unsubscr...@maven.apache.org For additional commands, e-mail: users-h...@maven.apache.org
Re: Are Maven profiles like Ant targets?
On Dec 17, 2008, at 3:33 AM, Martin Höller wrote: mvn -Pinstall4j package Why would you have to use a profile for this? Because it takes five minutes to run. I don't want to wait five minutes every time I package, install, or deploy my code. The install4j stuff only needs to happen when we're ready to ship the final installer to the customer. Without profiles, I don't know how to exercise control over when this time-consuming process kicks off. If you really want maven to do only _one_ specific thing (which is most of the time not the common way) you can execute a single plugin goal by specifying just this goal, e.g. "mvn deploy:deploy-file" or "mvn antrun:run". No, specifying a single goal does not run a single goal, it runs ALL of the configurations for that goal. I've attached a sample POM to demonstrate. Try this: mvn antrun:run package You will see both of the antrun:run configurations run. In that same POM, I've also shown how to run just one of the configurations using profiles. For example: mvn -Phello package mvn -Pgoodbye package Is there a way to achieve that without profiles? Trevor http://maven.apache.org/POM/4.0.0"; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd";> 4.0.0 com.vocaro antrun 1.0 pom maven-antrun-plugin say-hello package hello run maven-antrun-plugin say-goodbye package goodbye run hello maven-antrun-plugin say-hello package hello (profile) run goodbye maven-antrun-plugin say-goodbye package goodbye (profile) run - To unsubscribe, e-mail: users-unsubscr...@maven.apache.org For additional commands, e-mail: users-h...@maven.apache.org
Re: Are Maven profiles like Ant targets?
On Wednesday 17 December 2008 Trevor Harmon wrote: > On Dec 17, 2008, at 3:33 AM, Martin Höller wrote: > >> mvn -Pinstall4j package > > > > Why would you have to use a profile for this? > > Because it takes five minutes to run. Ok. My approach would then be to create one profile which is only executed before releasing or when running in the contiuous-integration server. This profile would configure the antrun plugin to execute install4j, run integration tests, and do some other time-consuming work. > > If you really want maven to do only _one_ specific thing (which is > > most of > > the time not the common way) you can execute a single plugin goal by > > specifying just this goal, e.g. "mvn deploy:deploy-file" or "mvn > > antrun:run". > > No, specifying a single goal does not run a single goal, it runs ALL > of the configurations for that goal. You say it: it runs all of the _configurations_, but it's still only _one_ goal that runs. In this case the 'run' goal of the antrun plugin. The antrun plugin is kind of special as it runs ant task within maven, which doesn't have the concept of tasks. All other plugins usually do just one thing. I think Geoffrey hit the nail on the head: we are not trying to say you should't use profiles. It's just that profiles in maven and tasks in ant are not the same. hth, - martin signature.asc Description: This is a digitally signed message part.
Re: Are Maven profiles like Ant targets?
On Wednesday 17 December 2008 Trevor Harmon wrote: > On Dec 17, 2008, at 3:54 AM, Martin Höller wrote: > > And BTW: Maven's primary goal is to help building and packaging > > software, > > not starting the developed piece of software, so IMHO the exec- > > plugin is > > not a good example here. > > Well I have to disagree with you there. Testing is also not about > building and packaging software, yet Maven provides lots of support > for testing because it's such an integral part of the development > process. What i meant with "building and packaging" included testing, so I think we could agree here rather than disagree. > Launching a desktop application that's being developed is > part of testing too. At least it's not automated testing, but we are getting off-topic here. Anyway, I didn't say don't use profiles. Actually I told you that I would use profiles in this special case. > Also, I don't want to maintain separate scripts in a separate language > just to launch an application. How would I make sure that the source > code has been compiled? How would I locate all the dependent JARs? > These problems are handled by the exec plugin, so I see no reason not > to use it just because profiles are "bad". Profiles are not bad, they are just not equals to ant tasks. > I simply want to keep everything contained within Maven, like I was > able to do with Ant. For example, in Ant I was able to define targets > like "run-test1" and "run-test2" that had dependencies on "compile" > and "jar". That way, whenever I ran either test, Ant would make sure > that the JAR was up to date with the latest code. I don't know of any > way to duplicate this functionality without using profiles. I still think the problem is that you are trying the solve your problems the ant way, but with maven as your tool. hth, - martin signature.asc Description: This is a digitally signed message part.
RE: Are Maven profiles like Ant targets?
Hmmm. Did you try putting something like this in your POM? ... org.codehaus.mojo exec-maven-plugin print-hello clean exec echo hello print-goodbye clean exec echo goodbye ... This prints hello and goodbye as part of the clean phase. All I had to do was issue the following mvn command: mvn clean and it printed both hello and goodbye by executing two commands at the command line. You can of course bind something like this to any phase you like. Doesn't this fit your needs? --- Todd Thiessen > -Original Message- > From: Trevor Harmon [mailto:tre...@vocaro.com] > Sent: Tuesday, December 16, 2008 6:02 PM > To: Maven Users List > Subject: Re: Are Maven profiles like Ant targets? > > On Dec 16, 2008, at 5:24 PM, Todd Thiessen wrote: > > > I believe there is. Plugin can have different executions. There is > > some documentation about that here: > > > > > http://maven.apache.org/guides/introduction/introduction-to-the-lifecy > > cl > > e.html#Plugins > > But that doesn't work for the exec plugin. I'd be grateful if > someone could prove me wrong. > > > and I believe the definitive guide has some examples too. > > No, in the book they always pass the exec arguments on the > command line. See: > > http://books.sonatype.com/maven-book/reference/customizing.htm > l#section-custom-exec > > > But you still would have to bind it to a phase, which you > don't want > > to do. > > I'm not trying to avoid anything. If binding to a phase would > solve the problems, then I'd do it. But simply binding a > plugin to a phase is not enough, for reasons I have shown. > > > So I agree with you that Maven is definitely heavy weight > if all you > > wish to do is execute an exe with different parameters each time. > > It doesn't do this nicely. You probably just want a simple > script for > > that. > > Or I could just use profiles. > > Trevor > > > - > To unsubscribe, e-mail: users-unsubscr...@maven.apache.org > For additional commands, e-mail: users-h...@maven.apache.org > > - To unsubscribe, e-mail: users-unsubscr...@maven.apache.org For additional commands, e-mail: users-h...@maven.apache.org
Re: Are Maven profiles like Ant targets?
On Dec 17, 2008, at 12:18 PM, Martin Höller wrote: Ok. My approach would then be to create one profile which is only executed before releasing or when running in the contiuous-integration server. This profile would configure the antrun plugin to execute install4j, run integration tests, and do some other time-consuming work. Yes, that's what I've been doing, but you said I was doing it wrong. I just wanted to make sure that profiles were the only way to do it in Maven, or if there was some other technique I didn't know about. You say it: it runs all of the _configurations_, but it's still only _one_ goal that runs. In this case the 'run' goal of the antrun plugin. The antrun plugin is kind of special as it runs ant task within maven, which doesn't have the concept of tasks. The exec plugin is like that too, and I find both to be very integral to the development process. Perhaps these plugins need a new feature that allows the user to specify which configuration is used. Something like: mvn exec:java:config1 mvn exec:java:config2 mvn antrun:run:config1 mvn antrun:run:config2 Trevor - To unsubscribe, e-mail: users-unsubscr...@maven.apache.org For additional commands, e-mail: users-h...@maven.apache.org
Re: Are Maven profiles like Ant targets?
On Wed, Dec 17, 2008 at 12:17 PM, Trevor Harmon wrote: > Yes, I was trying to simplify things with that subject line but I guess I > just made them more confusing. Perhaps a better question would be, "Are > Maven profiles the only way to accomplish what I was able to accomplish with > Ant targets?" > > I hadn't thought about using modules for this; I will look into it. Although I will note that it wouldn't be uncommon to include or exclude modules using profiles, which might take you back to where you are now. ;) -- Geoffrey Wiseman http://www.geoffreywiseman.ca/
Re: Are Maven profiles like Ant targets?
On Dec 17, 2008, at 3:54 AM, Martin Höller wrote: And BTW: Maven's primary goal is to help building and packaging software, not starting the developed piece of software, so IMHO the exec- plugin is not a good example here. Well I have to disagree with you there. Testing is also not about building and packaging software, yet Maven provides lots of support for testing because it's such an integral part of the development process. Launching a desktop application that's being developed is part of testing too. Also, I don't want to maintain separate scripts in a separate language just to launch an application. How would I make sure that the source code has been compiled? How would I locate all the dependent JARs? These problems are handled by the exec plugin, so I see no reason not to use it just because profiles are "bad". I simply want to keep everything contained within Maven, like I was able to do with Ant. For example, in Ant I was able to define targets like "run-test1" and "run-test2" that had dependencies on "compile" and "jar". That way, whenever I ran either test, Ant would make sure that the JAR was up to date with the latest code. I don't know of any way to duplicate this functionality without using profiles. Trevor - To unsubscribe, e-mail: users-unsubscr...@maven.apache.org For additional commands, e-mail: users-h...@maven.apache.org
Re: Are Maven profiles like Ant targets?
On Dec 17, 2008, at 11:45 AM, Geoffrey Wiseman wrote: All I'm really trying to say (and I suspect what others are trying to say) is that the answer to your original question, "Are profiles intended to play the same role as Ant targets?" is "No. They aren't." Yes, I was trying to simplify things with that subject line but I guess I just made them more confusing. Perhaps a better question would be, "Are Maven profiles the only way to accomplish what I was able to accomplish with Ant targets?" I hadn't thought about using modules for this; I will look into it. Trevor - To unsubscribe, e-mail: users-unsubscr...@maven.apache.org For additional commands, e-mail: users-h...@maven.apache.org
Re: Are Maven profiles like Ant targets?
On Wed, Dec 17, 2008 at 11:17 AM, Trevor Harmon wrote: > No, it doesn't fit my needs because it always prints both "hello" and > "goodbye". I want to print either "hello" or "goodbye". > > For example, in the scenario I mentioned earlier, I want to launch a > desktop application with one particular command-line configuration. With > your solution, I'd be launching the app multiple times. That's certainly not > what I want. > > I've attached a rewrite of your code that uses profiles to select which > configuration is run. For instance: > > mvn -Phello clean > mvn -Pgoodbye clean > > Or I can do both at once: > > mvn -Phello,goodbye clean > > Is there a way to accomplish this without profiles? > In some of the examples you used previously (installer, docbook), I'd probably be inclined to make each of these modules if I were trying to follow "The Maven Way." Then again, you can certainly do what you're currently doing, if it works for you. Finally, you could use a tool that's intended to accomplish relatively arbitrary tasks, like Ant. All of those will work, and it's up to you decide what makes sense for you. All I'm really trying to say (and I suspect what others are trying to say) is that the answer to your original question, "Are profiles intended to play the same role as Ant targets?" is "No. They aren't." Doesn't mean you can't use 'em that way, but if you're trying to understand the Maven approach to accomplishing what you're going for, I'd say that using profiles this way is not really the intent. - Geoffrey -- Geoffrey Wiseman http://www.geoffreywiseman.ca/
Re: Are Maven profiles like Ant targets?
On Wednesday 17 December 2008 Trevor Harmon wrote: > On Dec 17, 2008, at 12:18 PM, Martin Höller wrote: > > Ok. My approach would then be to create one profile which is only > > executed > > before releasing or when running in the contiuous-integration > > server. This > > profile would configure the antrun plugin to execute install4j, run > > integration tests, and do some other time-consuming work. > > Yes, that's what I've been doing, but you said I was doing it wrong. In your original mail you tried to use profiles like you would use tasks in ant. That's not the maven way and that's what I meant when I was saying you are doing it wrong. I never said using profiles is wrong. > > You say it: it runs all of the _configurations_, but it's still only > > _one_ > > goal that runs. In this case the 'run' goal of the antrun plugin. The > > antrun plugin is kind of special as it runs ant task within maven, > > which > > doesn't have the concept of tasks. > > The exec plugin is like that too, and I find both to be very integral > to the development process. Perhaps these plugins need a new feature > that allows the user to specify which configuration is used. Yes, maybe. However, adding such a feature is quite equivalent to using profiles to select a configuration. And this is how it all started ;-) - martin signature.asc Description: This is a digitally signed message part.
Re: Are Maven profiles like Ant targets?
2008/12/18 Martin Höller > > > > > Yes, that's what I've been doing, but you said I was doing it wrong. > > In your original mail you tried to use profiles like you would use tasks in > ant. That's not the maven way and that's what I meant when I was saying you > are doing it wrong. I never said using profiles is wrong. > And btw, the subject was "Are Maven profiles like ant targets" ? The answer was clearly no. I guess it also started with this :-). And I'm also really wondering why you try to use maven in what seems to me an ant-ish way. If you need more specific and totally unrelated tasks, and you don't want a predefined packaging lifecycle like maven provides you with, why don't you simply use ant alone? Imo, Ant can turn your head upside down to configure a whole project packaging/testing/site generation/etc. (I mean without things like Ivy or so, I guess). But it seems almost better than maven to execute a specific task in the way we sometimes do with specific plugin goal (still in my opinion). Cheers. -- Baptiste MATHUS - http://batmat.net Save a tree, Eat a beaver!
Re: Are Maven profiles like Ant targets?
This reminds me of this "best practice" that uses a single maven profile to run an ant task: http://ionixx.wordpress.com/2008/03/10/running-specified-ant-tasks-within-maven2-outside-the-lifecycle/ Basically, you can run an ant target from maven like this: mvn -Pant -Dtarget=my-target. This is better than using ant alone, because it lets maven construct an appropriate classpath which the ant target can use. So, maven tasks were not designed to be like ant targets, but can be used like them, if you're using ant targets as standalone scripts outside of the build lifecycle. -Alex
Re: Are Maven profiles like Ant targets?
On Dec 19, 2008, at 4:24 PM, Baptiste MATHUS wrote: And I'm also really wondering why you try to use maven in what seems to me an ant-ish way. I made a mistake in even mentioning Ant. It seems to give a sense that I'm closed-minded and unable to think in the "Maven way". I should have simply asked, "How do I do such-and-such in Maven?" and left it at that. If you need more specific and totally unrelated tasks, and you don't want a predefined packaging lifecycle I don't know how I've given the impression that I'm trying to avoid the Maven lifecycle, or that I somehow want to twist Maven into an Ant clone. I'm simply giving examples of use cases that are common in my development cycle and wanting to know how to implement them with Maven. like maven provides you with, why don't you simply use ant alone? We used to use Ant, but the management decided to switch to Maven. I guess the idea was to take advantage of the broader Maven features such as dependency resolution, convention-over-configuration, and so on. However, I'm now facing difficulty trying to do things in Maven that we used to do with Ant -- building an installer, launching desktop apps in two different ways, etc. It seems that Maven makes some tasks very simple, but at the same time it makes others very complex. Trevor - To unsubscribe, e-mail: users-unsubscr...@maven.apache.org For additional commands, e-mail: users-h...@maven.apache.org
RE: Are Maven profiles like Ant targets?
> -Original Message- > From: Trevor Harmon [mailto:tre...@vocaro.com] > > I don't know how I've given the impression that I'm trying to > avoid the Maven lifecycle I get this impression from you when you ask about how to run tasks, that are specific to a particular project, directly from a UI or the command line. The whole mantra "Convention over Configuration" is to not have to define specific new tasks for a project but rather to think about how this task is related to the overall build lifecycle and plug it into the appropriate place. > > However, I'm now facing difficulty trying to do things in > Maven that we used to do with Ant -- building an installer, > launching desktop apps in two different ways, etc. It seems > that Maven makes some tasks very simple, but at the same time > it makes others very complex. I think the question you need to ask yourself is how are these tasks related to the build lifecycle of your project. For example, when during the build do you want to launch an app in one way and when do you want to launch it in another? I think the reason why you are having so much trouble with Maven is that you want to "configure" it to do what you want by giving it a specific command. I do agree with you that it is more complex in the sense that Maven does require more upfront thought regarding how a task fits into the lifecycle. But this isn't necessarily a bad thing. --- Todd Thiessen - To unsubscribe, e-mail: users-unsubscr...@maven.apache.org For additional commands, e-mail: users-h...@maven.apache.org
Re: Are Maven profiles like Ant targets?
On Dec 22, 2008, at 12:38 PM, Todd Thiessen wrote: I think the reason why you are having so much trouble with Maven is that you want to "configure" it to do what you want by giving it a specific command. But actually, I can give Maven a specific command to do what I want ... as long as a plugin exists for it. Take for example DocBook. There's a plugin for that, so I can invoke one of its goals explicitly, or at the same time I can have it run automatically by binding it to a phase. That's exactly the kind of flexibility I need. For install4j, however, there's no plugin, so I have to emulate one with AntRun. That's when my problems start, since there's no way to target a particular AntRun configuration without using profiles. So I think the lesson here is that I should try to avoid AntRun and Exec, and use a specific plugin for the task, even if that means writing my own. Trevor - To unsubscribe, e-mail: users-unsubscr...@maven.apache.org For additional commands, e-mail: users-h...@maven.apache.org
RE: Are Maven profiles like Ant targets?
Trevor Its the culture I think your missing. Yes you can call goals directly but this isn't something you should be needing very often. It isn't the "Maven way" as they say nor does it follow "Convention over configuration". If you find yourself calling a plugin goal directly all the time you should be asking yourself why. Good luck. --- Todd Thiessen > -Original Message- > From: Trevor Harmon [mailto:tre...@vocaro.com] > Sent: Monday, December 22, 2008 1:49 PM > To: Maven Users List > Subject: Re: Are Maven profiles like Ant targets? > > On Dec 22, 2008, at 12:38 PM, Todd Thiessen wrote: > > > I think the reason why you are having so much trouble with Maven is > > that you want to "configure" it to do what you want by giving it a > > specific command. > > But actually, I can give Maven a specific command to do what > I want ... as long as a plugin exists for it. Take for > example DocBook. > There's a plugin for that, so I can invoke one of its goals > explicitly, or at the same time I can have it run > automatically by binding it to a phase. That's exactly the > kind of flexibility I need. > > For install4j, however, there's no plugin, so I have to > emulate one with AntRun. That's when my problems start, since > there's no way to target a particular AntRun configuration > without using profiles. > > So I think the lesson here is that I should try to avoid > AntRun and Exec, and use a specific plugin for the task, even > if that means writing my own. > > Trevor > > > - > To unsubscribe, e-mail: users-unsubscr...@maven.apache.org > For additional commands, e-mail: users-h...@maven.apache.org > > - To unsubscribe, e-mail: users-unsubscr...@maven.apache.org For additional commands, e-mail: users-h...@maven.apache.org
Re: Are Maven profiles like Ant targets?
2008/12/22 Todd Thiessen > Trevor > > Its the culture I think your missing. Yes you can call goals directly > but this isn't something you should be needing very often. It isn't the +1. I only know maybe 10 special goals or so, mostly for debugging purpose (dependency:list or tree, dependency:purge-local-repository, help:effective-settings, test, verify...) I almost call them directly. For example, I don't think I ran mvn install once during the last 2 or 3 months. Since it's just a task CI will handle better than me. If you need docbook generation, that's the same. Bind it to some phase, and just generate it automatically. Cheers -- Baptiste