You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Phillip Hellewell <ss...@gmail.com> on 2010/12/02 21:08:27 UTC

Catch 22 with clean phase

There's a batch file I want to run during the clean phase.  Problem
is, the batch file lives below target/dependency, and the clean phase
wipes "target" first, so then my batch file can't be found.

Is there a good solution to this?  Like a pre-clean phase or something?

The only other ideas I've come up with are:
1. Move the functionality of the batch file into a plugin.
2. Copy the batch file from target/dependency to the base directory
(where the pom.xml is) during process-sources after the unpack.

The downside of #1 is that a plugin is really overkill for what this
batch file does.
The downside of #2 is that I have yet another file cluttering up the
base directory (though of course it will be svn:ignored).

Phillip

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Catch 22 with clean phase

Posted by lukewpatterson <lu...@gmail.com>.
IMHO, a "not horrible" migration path is:

1. use antrun, surely it can do everything (and more) that your batch file
does
2. later, using knowledge of how you accomplished it in ANT, port it to a
groovy-based plugin that uses ANT DSL


I've found the "groovy-based ANT DSL plugin" approach great for one-off
tasks.
-- 
View this message in context: http://maven.40175.n5.nabble.com/Catch-22-with-clean-phase-tp3289922p3291117.html
Sent from the Maven - Users mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Catch 22 with clean phase

Posted by Tamás Cservenák <ta...@cservenak.net>.
FYI, "Simple things" (you say for bath file "a plugin is really overkill for
what this batch file does")  are the best candidates to make into plugins.

Especially if that's something "company specific" or "project specific"
thingy.

Thanks,
~t~

On Thu, Dec 2, 2010 at 9:36 PM, Wendy Smoak <ws...@gmail.com> wrote:

> On Thu, Dec 2, 2010 at 3:08 PM, Phillip Hellewell <ss...@gmail.com>
> wrote:
> > There's a batch file I want to run during the clean phase.  Problem
> > is, the batch file lives below target/dependency, and the clean phase
> > wipes "target" first, so then my batch file can't be found.
>
> What does the batch file do?
>
> Just guessing since you're trying to do it during clean, perhaps you
> could configure the clean plugin to delete some additional files?
>
> --
> Wendy
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>

Re: Catch 22 with clean phase

Posted by Phillip Hellewell <ss...@gmail.com>.
On Thu, Dec 2, 2010 at 1:36 PM, Wendy Smoak <ws...@gmail.com> wrote:
> On Thu, Dec 2, 2010 at 3:08 PM, Phillip Hellewell <ss...@gmail.com> wrote:
>> There's a batch file I want to run during the clean phase.  Problem
>> is, the batch file lives below target/dependency, and the clean phase
>> wipes "target" first, so then my batch file can't be found.
>
> What does the batch file do?

It just deletes a few generated files that get created during the
build that happen to not be inside target/ (most the generated files
go below target/bin so they aren't a problem).

> Just guessing since you're trying to do it during clean, perhaps you
> could configure the clean plugin to delete some additional files?

Oh, I didn't even think that the clean plugin could be configured to
delete additional files.  That is good to know, thanks!

Phillip

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Catch 22 with clean phase

Posted by Wendy Smoak <ws...@gmail.com>.
On Thu, Dec 2, 2010 at 3:08 PM, Phillip Hellewell <ss...@gmail.com> wrote:
> There's a batch file I want to run during the clean phase.  Problem
> is, the batch file lives below target/dependency, and the clean phase
> wipes "target" first, so then my batch file can't be found.

What does the batch file do?

Just guessing since you're trying to do it during clean, perhaps you
could configure the clean plugin to delete some additional files?

-- 
Wendy

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Catch 22 with clean phase

Posted by Hilco Wijbenga <hi...@gmail.com>.
On 2 December 2010 15:57, Phillip Hellewell <ss...@gmail.com> wrote:
> Is there any way to make it conditional so it won't try to run the
> batch file if the target/ directory is not there?  I'm using the
> exec-maven-plugin but I don't see any options that would help.

You could add a profile that's only triggered if your batch file exists.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Catch 22 with clean phase

Posted by Ron Wheeler <rw...@artifact-software.com>.
On 02/12/2010 8:12 PM, Brian Topping wrote:
> On Dec 2, 2010, at 7:05 PM, Wayne Fay wrote:
>
>>> Ok, so this is working great now, except for one problem.  It runs
>>> great the first time, but if I run "mvn clean" a second time, the
>>> batch file is not there so it can't call it and it returns with an
>>> error.
>> Turn your batch file into a plugin and these problems will magically go away.
> I have to agree here.  Creating a plugin is easy, and we will refund your purchase price of Maven if you do not find the Plugin interface to be the easiest one you've ever seen.
You guys are pretty free with the organization's cash ;-) .
I bet you don't have to pay off too much on this offer.
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


RE: Catch 22 with clean phase

Posted by "Yanko, Curtis" <cu...@uhc.com>.
Is there some compelling reason why these files are created outside of
*target*?  The idea of *target* is to be home to all artifacts of the
build process.

________________________________

Curt Yanko | Continuous Integration Services | UnitedHealth Group IT 
Making IT Happen, one build at a time, 600 times a day
 

> -----Original Message-----
> From: anders.g.hammar@gmail.com 
> [mailto:anders.g.hammar@gmail.com] On Behalf Of Anders Hammar
> Sent: Friday, December 03, 2010 3:22 AM
> To: Maven Users List
> Subject: Re: Catch 22 with clean phase
> 
> Phillip, you should notice (once again) that fighting Maven 
> best practice is causing you extra trouble. You should create 
> a mojo that cleans these files.
> It can be created smart enough to detect if anything needs to 
> be done or not. Put the mojo in the plugin that creates the 
> files in the first please, and you'll have everything nicely 
> packaged together.
> Then, if you find yourself configuring several maven projects 
> in a similar manner. where you're binding this plugin to 
> create files and then clean them, you should start to think 
> about creating your own packaging type. All of a sudden 
> you're following Maven best-practice and you (and every other 
> user in your corp doing the same thing) will think: "Hey, 
> Maven rocks!" As it does, if you don't fight it!
> 
> /Anders
> On Fri, Dec 3, 2010 at 02:12, Brian Topping 
> <to...@codehaus.org> wrote:
> 
> >
> > On Dec 2, 2010, at 7:05 PM, Wayne Fay wrote:
> >
> > >> Ok, so this is working great now, except for one 
> problem.  It runs 
> > >> great the first time, but if I run "mvn clean" a second 
> time, the 
> > >> batch file is not there so it can't call it and it 
> returns with an 
> > >> error.
> > >
> > > Turn your batch file into a plugin and these problems 
> will magically 
> > > go
> > away.
> >
> > I have to agree here.  Creating a plugin is easy, and we 
> will refund 
> > your purchase price of Maven if you do not find the Plugin 
> interface 
> > to be the easiest one you've ever seen.
> > 
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> > For additional commands, e-mail: users-help@maven.apache.org
> >
> >
> 

This e-mail, including attachments, may include confidential and/or
proprietary information, and may be used only by the person or entity
to which it is addressed. If the reader of this e-mail is not the intended
recipient or his or her authorized agent, the reader is hereby notified
that any dissemination, distribution or copying of this e-mail is
prohibited. If you have received this e-mail in error, please notify the
sender by replying to this message and delete this e-mail immediately.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Catch 22 with clean phase

Posted by Phillip Hellewell <ss...@gmail.com>.
On Fri, Dec 3, 2010 at 11:39 AM, Ron Wheeler
<rw...@artifact-software.com> wrote:
>
> You seem to have a pretty strong ego and a thick skin to deal with some of
> the comments.
> Keep it up.

Thanks Ron :)

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Catch 22 with clean phase

Posted by Ron Wheeler <rw...@artifact-software.com>.
On 03/12/2010 1:09 PM, Phillip Hellewell wrote:
> On Fri, Dec 3, 2010 at 1:22 AM, Anders Hammar<an...@hammar.net>  wrote:
>> Phillip, you should notice (once again) that fighting Maven best practice is
>> causing you extra trouble. You should create a mojo that cleans these files.
> You always jump on me so quickly about this, but I haven't even done
> anything yet except ask for advice about a fairly simple problem.  But
> since enough people have mentioned replacing my batch file with a
> plugin, that is looking very desirable right now.
Don't let the flack get to you.
I have followed your questions since you started.
You have done the right thing that most people do not have the courage 
to do.
You ask questions and you generally ask questions the right 
way(strategic first, details later).

 From the speed at which your conversion to Maven appears to be going, I 
think that you have done the right thing.

You seem to have a pretty strong ego and a thick skin to deal with some 
of the comments.
Keep it up.

Ron


> But you should know, the issue is so minor that I can pretty much
> ignore it without any real problems.  Also, one of my goals is to fix
> things so all generated files go below target/ (at the moment, there
> are a few that don't); once that happens I won't need to do anything
> special in the pre-clean phase.
>
> Phillip
>
> P.S.  Just to give a little more background for those who are curious:
> what I have right now is a build-tools component that provides a
> little batch file called buildsln.bat that essentially locates
> msbuild.exe and runs it for a given .sln.  You can also pass a /clean
> to get it to clean the solution.  Even though it is just a simple
> batch file right now, I think converting it into a plugin as many have
> suggested will probably be better in the long run.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Catch 22 with clean phase

Posted by Phillip Hellewell <ss...@gmail.com>.
On Fri, Dec 3, 2010 at 1:22 AM, Anders Hammar <an...@hammar.net> wrote:
> Phillip, you should notice (once again) that fighting Maven best practice is
> causing you extra trouble. You should create a mojo that cleans these files.

You always jump on me so quickly about this, but I haven't even done
anything yet except ask for advice about a fairly simple problem.  But
since enough people have mentioned replacing my batch file with a
plugin, that is looking very desirable right now.

But you should know, the issue is so minor that I can pretty much
ignore it without any real problems.  Also, one of my goals is to fix
things so all generated files go below target/ (at the moment, there
are a few that don't); once that happens I won't need to do anything
special in the pre-clean phase.

Phillip

P.S.  Just to give a little more background for those who are curious:
what I have right now is a build-tools component that provides a
little batch file called buildsln.bat that essentially locates
msbuild.exe and runs it for a given .sln.  You can also pass a /clean
to get it to clean the solution.  Even though it is just a simple
batch file right now, I think converting it into a plugin as many have
suggested will probably be better in the long run.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Catch 22 with clean phase

Posted by Anders Hammar <an...@hammar.net>.
Phillip, you should notice (once again) that fighting Maven best practice is
causing you extra trouble. You should create a mojo that cleans these files.
It can be created smart enough to detect if anything needs to be done or
not. Put the mojo in the plugin that creates the files in the first please,
and you'll have everything nicely packaged together.
Then, if you find yourself configuring several maven projects in a similar
manner. where you're binding this plugin to create files and then clean
them, you should start to think about creating your own packaging type. All
of a sudden you're following Maven best-practice and you (and every other
user in your corp doing the same thing) will think: "Hey, Maven rocks!" As
it does, if you don't fight it!

/Anders
On Fri, Dec 3, 2010 at 02:12, Brian Topping <to...@codehaus.org> wrote:

>
> On Dec 2, 2010, at 7:05 PM, Wayne Fay wrote:
>
> >> Ok, so this is working great now, except for one problem.  It runs
> >> great the first time, but if I run "mvn clean" a second time, the
> >> batch file is not there so it can't call it and it returns with an
> >> error.
> >
> > Turn your batch file into a plugin and these problems will magically go
> away.
>
> I have to agree here.  Creating a plugin is easy, and we will refund your
> purchase price of Maven if you do not find the Plugin interface to be the
> easiest one you've ever seen.
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>

Re: Catch 22 with clean phase

Posted by Brian Topping <to...@codehaus.org>.
On Dec 2, 2010, at 7:05 PM, Wayne Fay wrote:

>> Ok, so this is working great now, except for one problem.  It runs
>> great the first time, but if I run "mvn clean" a second time, the
>> batch file is not there so it can't call it and it returns with an
>> error.
> 
> Turn your batch file into a plugin and these problems will magically go away.

I have to agree here.  Creating a plugin is easy, and we will refund your purchase price of Maven if you do not find the Plugin interface to be the easiest one you've ever seen.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Catch 22 with clean phase

Posted by Wayne Fay <wa...@gmail.com>.
> Ok, so this is working great now, except for one problem.  It runs
> great the first time, but if I run "mvn clean" a second time, the
> batch file is not there so it can't call it and it returns with an
> error.

Turn your batch file into a plugin and these problems will magically go away.

Wayne

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Catch 22 with clean phase

Posted by Phillip Hellewell <ss...@gmail.com>.
On Thu, Dec 2, 2010 at 4:43 PM, Phillip Hellewell <ss...@gmail.com> wrote:
> On Thu, Dec 2, 2010 at 1:25 PM, Brian Topping <to...@codehaus.org> wrote:
>> There is a pre-clean, see http://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html#Lifecycle_Reference
>
> That's so weird.  I swear I was on this page looking for pre-clean and
> couldn't find it.  I don't know why.

Ok, so this is working great now, except for one problem.  It runs
great the first time, but if I run "mvn clean" a second time, the
batch file is not there so it can't call it and it returns with an
error.

Is there any way to make it conditional so it won't try to run the
batch file if the target/ directory is not there?  I'm using the
exec-maven-plugin but I don't see any options that would help.

Phillip

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Catch 22 with clean phase

Posted by Phillip Hellewell <ss...@gmail.com>.
On Thu, Dec 2, 2010 at 1:25 PM, Brian Topping <to...@codehaus.org> wrote:
> There is a pre-clean, see http://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html#Lifecycle_Reference

That's so weird.  I swear I was on this page looking for pre-clean and
couldn't find it.  I don't know why.

Oh well, thanks!

Phillip

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Catch 22 with clean phase

Posted by Brian Topping <to...@codehaus.org>.
There is a pre-clean, see http://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html#Lifecycle_Reference

On Dec 2, 2010, at 3:08 PM, Phillip Hellewell wrote:

> There's a batch file I want to run during the clean phase.  Problem
> is, the batch file lives below target/dependency, and the clean phase
> wipes "target" first, so then my batch file can't be found.
> 
> Is there a good solution to this?  Like a pre-clean phase or something?
> 
> The only other ideas I've come up with are:
> 1. Move the functionality of the batch file into a plugin.
> 2. Copy the batch file from target/dependency to the base directory
> (where the pom.xml is) during process-sources after the unpack.
> 
> The downside of #1 is that a plugin is really overkill for what this
> batch file does.
> The downside of #2 is that I have yet another file cluttering up the
> base directory (though of course it will be svn:ignored).
> 
> Phillip
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org