You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Grant Ingersoll <gs...@apache.org> on 2007/05/10 20:02:45 UTC
System.in and release preparation goals
Hi,
Long time M1 user upgrading to M2...
I have a Mojo that I have written that asks for user input concerning
it's operation (I use a BufferedReader wrapping System.in). When I
run the goal standalone, everything works fine. However, when I run
the goal as preparationGoal of the maven-release-plugin, it hangs and
never seems to get the input from the command line. I think the
issue lies in the fact that it is a forked JVM but I am not sure. I
have trouble debugging it, b/c the debugging options specified in the
mvn command (via MAVEN_OPTS) don't work b/c I get errors saying the
port is already in use (it starts up and listens on the port, but
then a subprocess seems to try to acquire the same port, resulting in
an error.)
Below is the code I have in my mojo.
BufferedReader reader
= new BufferedReader(new InputStreamReader(System.in));
String line = null;
try
{
getLog().warn("Pre loop");
while (true)
{
getLog().warn
(tagDir
+ " exists in the repository - [d]elete or
[a]bort?");
line = reader.readLine();
getLog().debug("Before check: " + line);
if (line.equalsIgnoreCase("a") ||
line.equalsIgnoreCase("d"))
{
break;
}
getLog().debug("Here: " + line);
}
getLog().warn("Line: " + line);
if (getLog().isDebugEnabled())
{
getLog().debug("Line: " + line);
}
Thanks,
Grant
--------------------------
Grant Ingersoll
Center for Natural Language Processing
http://www.cnlp.org/tech/lucene.asp
Read the Lucene Java FAQ at http://wiki.apache.org/jakarta-lucene/
LuceneFAQ
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: System.in and release preparation goals
Posted by Grant Ingersoll <gr...@gmail.com>.
Also, by the looks of it, if it is using the DefaultInputHandler,
etc. all it is doing is wrapping System.in much like I am, so I am
not sure what the best way to go is. I really don't think what I am
doing is appropriately handled by setting a sys. property, as those
are likely forgotten.
Thanks,
Grant
On May 11, 2007, at 9:34 AM, Grant Ingersoll wrote:
> From what I can tell, it uses the Prompter interface from the
> Plexus interactivity component, but how I would initialize it is
> beyond me. I'm guessing it uses the IoC stuff, but I am not
> familiar w/ the setup of all of that. Any pointers people have
> would be greatly appreciated.
>
> -Grant
>
> On May 10, 2007, at 5:47 PM, Wayne Fay wrote:
>
>> Sorry about that, and good point, I had forgotten about release
>> plugin.
>>
>> In that case, I would probably check out the release mojo code and
>> follow their approach for your own plugin. But you already knew that.
>> ;-)
>>
>> Wayne
>>
>> On 5/10/07, Grant Ingersoll <gs...@apache.org> wrote:
>>>
>>> On May 10, 2007, at 4:35 PM, Wayne Fay wrote:
>>>
>>> > In M2, things like this are generally either passed as parameters
>>> > (-D...) or simply specified as configurations for the plugin in
>>> the
>>> > pom.xml configuration.
>>> >
>>> > Actually, I can't think of a single M2 plugin that prompts the
>>> user
>>> > for input while processing etc. There is probably a good reason
>>> for
>>> > this (the forked JVM etc) so perhaps reconsider your approach?
>>> >
>>>
>>> release:prepare seems to be asking me what to bump the version to,
>>> etc. and says it does at http://maven.apache.org/plugins/maven-
>>> release-plugin/examples/prepare-release.html?
>>>
>>> -Grant
>>>
>>> --------------------------------------------------------------------
>>> -
>>> 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
>>
>
> --------------------------
> Grant Ingersoll
> Center for Natural Language Processing
> http://www.cnlp.org/tech/lucene.asp
>
> Read the Lucene Java FAQ at http://wiki.apache.org/jakarta-lucene/
> LuceneFAQ
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
------------------------------------------------------
Grant Ingersoll
http://www.grantingersoll.com/
http://lucene.grantingersoll.com
http://www.paperoftheweek.com/
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: System.in and release preparation goals
Posted by Grant Ingersoll <gs...@apache.org>.
So, is this a bug? Or just lack of documentation on how it is done?
-Grant
On May 11, 2007, at 11:16 AM, Max Bowsher wrote:
> Grant Ingersoll wrote:
>> From what I can tell, it uses the Prompter interface from the Plexus
>> interactivity component, but how I would initialize it is beyond me.
>> I'm guessing it uses the IoC stuff, but I am not familiar w/ the
>> setup
>> of all of that. Any pointers people have would be greatly
>> appreciated.
>
> Even if you did get it set up, I don't think it would work from inside
> the inner invocation of Maven - as a test, I tricked release:prepare
> into running itself as a preparationGoal, and it hung (without even
> showing the prompt) when it got to the stage of prompting.
>
> Max.
>
--------------------------
Grant Ingersoll
Center for Natural Language Processing
http://www.cnlp.org/tech/lucene.asp
Read the Lucene Java FAQ at http://wiki.apache.org/jakarta-lucene/
LuceneFAQ
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: System.in and release preparation goals
Posted by Max Bowsher <ma...@ukf.net>.
Grant Ingersoll wrote:
> From what I can tell, it uses the Prompter interface from the Plexus
> interactivity component, but how I would initialize it is beyond me.
> I'm guessing it uses the IoC stuff, but I am not familiar w/ the setup
> of all of that. Any pointers people have would be greatly appreciated.
Even if you did get it set up, I don't think it would work from inside
the inner invocation of Maven - as a test, I tricked release:prepare
into running itself as a preparationGoal, and it hung (without even
showing the prompt) when it got to the stage of prompting.
Max.
Re: System.in and release preparation goals
Posted by Grant Ingersoll <gs...@apache.org>.
From what I can tell, it uses the Prompter interface from the Plexus
interactivity component, but how I would initialize it is beyond me.
I'm guessing it uses the IoC stuff, but I am not familiar w/ the
setup of all of that. Any pointers people have would be greatly
appreciated.
-Grant
On May 10, 2007, at 5:47 PM, Wayne Fay wrote:
> Sorry about that, and good point, I had forgotten about release
> plugin.
>
> In that case, I would probably check out the release mojo code and
> follow their approach for your own plugin. But you already knew that.
> ;-)
>
> Wayne
>
> On 5/10/07, Grant Ingersoll <gs...@apache.org> wrote:
>>
>> On May 10, 2007, at 4:35 PM, Wayne Fay wrote:
>>
>> > In M2, things like this are generally either passed as parameters
>> > (-D...) or simply specified as configurations for the plugin in the
>> > pom.xml configuration.
>> >
>> > Actually, I can't think of a single M2 plugin that prompts the user
>> > for input while processing etc. There is probably a good reason for
>> > this (the forked JVM etc) so perhaps reconsider your approach?
>> >
>>
>> release:prepare seems to be asking me what to bump the version to,
>> etc. and says it does at http://maven.apache.org/plugins/maven-
>> release-plugin/examples/prepare-release.html?
>>
>> -Grant
>>
>> ---------------------------------------------------------------------
>> 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
>
--------------------------
Grant Ingersoll
Center for Natural Language Processing
http://www.cnlp.org/tech/lucene.asp
Read the Lucene Java FAQ at http://wiki.apache.org/jakarta-lucene/
LuceneFAQ
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: System.in and release preparation goals
Posted by Wayne Fay <wa...@gmail.com>.
Sorry about that, and good point, I had forgotten about release plugin.
In that case, I would probably check out the release mojo code and
follow their approach for your own plugin. But you already knew that.
;-)
Wayne
On 5/10/07, Grant Ingersoll <gs...@apache.org> wrote:
>
> On May 10, 2007, at 4:35 PM, Wayne Fay wrote:
>
> > In M2, things like this are generally either passed as parameters
> > (-D...) or simply specified as configurations for the plugin in the
> > pom.xml configuration.
> >
> > Actually, I can't think of a single M2 plugin that prompts the user
> > for input while processing etc. There is probably a good reason for
> > this (the forked JVM etc) so perhaps reconsider your approach?
> >
>
> release:prepare seems to be asking me what to bump the version to,
> etc. and says it does at http://maven.apache.org/plugins/maven-
> release-plugin/examples/prepare-release.html?
>
> -Grant
>
> ---------------------------------------------------------------------
> 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: System.in and release preparation goals
Posted by Grant Ingersoll <gs...@apache.org>.
On May 10, 2007, at 4:35 PM, Wayne Fay wrote:
> In M2, things like this are generally either passed as parameters
> (-D...) or simply specified as configurations for the plugin in the
> pom.xml configuration.
>
> Actually, I can't think of a single M2 plugin that prompts the user
> for input while processing etc. There is probably a good reason for
> this (the forked JVM etc) so perhaps reconsider your approach?
>
release:prepare seems to be asking me what to bump the version to,
etc. and says it does at http://maven.apache.org/plugins/maven-
release-plugin/examples/prepare-release.html?
-Grant
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: System.in and release preparation goals
Posted by Grant Ingersoll <gr...@gmail.com>.
I think the main issue is it is running in a forked JVM, but I am not
sure, since I haven't gotten to the low-level details. It runs fine
if I call the goal from the command line (and not as part of a
preparationGoal during release)
My guess is that Plexus is somehow redirecting the owner process
System.in and passing it to the forked process, but I really have no
clue. All I know is it hangs on bufferedReader.readLine()
-Grant
On May 11, 2007, at 10:08 AM, Daniel Kulp wrote:
> On Thursday 10 May 2007 16:35, Wayne Fay wrote:
>> In M2, things like this are generally either passed as parameters
>> (-D...) or simply specified as configurations for the plugin in the
>> pom.xml configuration.
>>
>> Actually, I can't think of a single M2 plugin that prompts the user
>> for input while processing etc. There is probably a good reason for
>> this (the forked JVM etc) so perhaps reconsider your approach?
>
> The GPG plugin will prompt for a passphrase. It just uses straight
> System.in stuff without a problem. Not sure why it works and yours
> doesn't.
>
> Dan
>
>
>>
>> Wayne
>>
>> On 5/10/07, Grant Ingersoll <gs...@apache.org> wrote:
>>> Hi,
>>>
>>> Long time M1 user upgrading to M2...
>>>
>>> I have a Mojo that I have written that asks for user input
>>> concerning it's operation (I use a BufferedReader wrapping
>>> System.in). When I run the goal standalone, everything works fine.
>>> However, when I run the goal as preparationGoal of the
>>> maven-release-plugin, it hangs and never seems to get the input from
>>> the command line. I think the issue lies in the fact that it is a
>>> forked JVM but I am not sure. I have trouble debugging it, b/c the
>>> debugging options specified in the mvn command (via MAVEN_OPTS)
>>> don't work b/c I get errors saying the port is already in use (it
>>> starts up and listens on the port, but then a subprocess seems to
>>> try to acquire the same port, resulting in an error.)
>>>
>>> Below is the code I have in my mojo.
>>>
>>>
>>> BufferedReader reader
>>> = new BufferedReader(new
>>> InputStreamReader(System.in)); String line = null;
>>> try
>>> {
>>> getLog().warn("Pre loop");
>>> while (true)
>>> {
>>> getLog().warn
>>> (tagDir
>>> + " exists in the repository - [d]elete or
>>> [a]bort?");
>>> line = reader.readLine();
>>> getLog().debug("Before check: " + line);
>>> if (line.equalsIgnoreCase("a") ||
>>> line.equalsIgnoreCase("d"))
>>> {
>>> break;
>>> }
>>> getLog().debug("Here: " + line);
>>> }
>>>
>>> getLog().warn("Line: " + line);
>>> if (getLog().isDebugEnabled())
>>> {
>>> getLog().debug("Line: " + line);
>>> }
>>>
>>> Thanks,
>>> Grant
>>>
>>> --------------------------
>>> Grant Ingersoll
>>> Center for Natural Language Processing
>>> http://www.cnlp.org/tech/lucene.asp
>>>
>>> Read the Lucene Java FAQ at http://wiki.apache.org/jakarta-lucene/
>>> LuceneFAQ
>>>
>>>
>>>
>>> --------------------------------------------------------------------
>>> - 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
>
> --
> J. Daniel Kulp
> Principal Engineer
> IONA
> P: 781-902-8727 C: 508-380-7194
> daniel.kulp@iona.com
> http://www.dankulp.com/blog
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
------------------------------------------------------
Grant Ingersoll
http://www.grantingersoll.com/
http://lucene.grantingersoll.com
http://www.paperoftheweek.com/
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: System.in and release preparation goals
Posted by Daniel Kulp <dk...@apache.org>.
On Thursday 10 May 2007 16:35, Wayne Fay wrote:
> In M2, things like this are generally either passed as parameters
> (-D...) or simply specified as configurations for the plugin in the
> pom.xml configuration.
>
> Actually, I can't think of a single M2 plugin that prompts the user
> for input while processing etc. There is probably a good reason for
> this (the forked JVM etc) so perhaps reconsider your approach?
The GPG plugin will prompt for a passphrase. It just uses straight
System.in stuff without a problem. Not sure why it works and yours
doesn't.
Dan
>
> Wayne
>
> On 5/10/07, Grant Ingersoll <gs...@apache.org> wrote:
> > Hi,
> >
> > Long time M1 user upgrading to M2...
> >
> > I have a Mojo that I have written that asks for user input
> > concerning it's operation (I use a BufferedReader wrapping
> > System.in). When I run the goal standalone, everything works fine.
> > However, when I run the goal as preparationGoal of the
> > maven-release-plugin, it hangs and never seems to get the input from
> > the command line. I think the issue lies in the fact that it is a
> > forked JVM but I am not sure. I have trouble debugging it, b/c the
> > debugging options specified in the mvn command (via MAVEN_OPTS)
> > don't work b/c I get errors saying the port is already in use (it
> > starts up and listens on the port, but then a subprocess seems to
> > try to acquire the same port, resulting in an error.)
> >
> > Below is the code I have in my mojo.
> >
> >
> > BufferedReader reader
> > = new BufferedReader(new
> > InputStreamReader(System.in)); String line = null;
> > try
> > {
> > getLog().warn("Pre loop");
> > while (true)
> > {
> > getLog().warn
> > (tagDir
> > + " exists in the repository - [d]elete or
> > [a]bort?");
> > line = reader.readLine();
> > getLog().debug("Before check: " + line);
> > if (line.equalsIgnoreCase("a") ||
> > line.equalsIgnoreCase("d"))
> > {
> > break;
> > }
> > getLog().debug("Here: " + line);
> > }
> >
> > getLog().warn("Line: " + line);
> > if (getLog().isDebugEnabled())
> > {
> > getLog().debug("Line: " + line);
> > }
> >
> > Thanks,
> > Grant
> >
> > --------------------------
> > Grant Ingersoll
> > Center for Natural Language Processing
> > http://www.cnlp.org/tech/lucene.asp
> >
> > Read the Lucene Java FAQ at http://wiki.apache.org/jakarta-lucene/
> > LuceneFAQ
> >
> >
> >
> > --------------------------------------------------------------------
> >- 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
--
J. Daniel Kulp
Principal Engineer
IONA
P: 781-902-8727 C: 508-380-7194
daniel.kulp@iona.com
http://www.dankulp.com/blog
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: System.in and release preparation goals
Posted by Wayne Fay <wa...@gmail.com>.
In M2, things like this are generally either passed as parameters
(-D...) or simply specified as configurations for the plugin in the
pom.xml configuration.
Actually, I can't think of a single M2 plugin that prompts the user
for input while processing etc. There is probably a good reason for
this (the forked JVM etc) so perhaps reconsider your approach?
Wayne
On 5/10/07, Grant Ingersoll <gs...@apache.org> wrote:
> Hi,
>
> Long time M1 user upgrading to M2...
>
> I have a Mojo that I have written that asks for user input concerning
> it's operation (I use a BufferedReader wrapping System.in). When I
> run the goal standalone, everything works fine. However, when I run
> the goal as preparationGoal of the maven-release-plugin, it hangs and
> never seems to get the input from the command line. I think the
> issue lies in the fact that it is a forked JVM but I am not sure. I
> have trouble debugging it, b/c the debugging options specified in the
> mvn command (via MAVEN_OPTS) don't work b/c I get errors saying the
> port is already in use (it starts up and listens on the port, but
> then a subprocess seems to try to acquire the same port, resulting in
> an error.)
>
> Below is the code I have in my mojo.
>
>
> BufferedReader reader
> = new BufferedReader(new InputStreamReader(System.in));
> String line = null;
> try
> {
> getLog().warn("Pre loop");
> while (true)
> {
> getLog().warn
> (tagDir
> + " exists in the repository - [d]elete or
> [a]bort?");
> line = reader.readLine();
> getLog().debug("Before check: " + line);
> if (line.equalsIgnoreCase("a") ||
> line.equalsIgnoreCase("d"))
> {
> break;
> }
> getLog().debug("Here: " + line);
> }
>
> getLog().warn("Line: " + line);
> if (getLog().isDebugEnabled())
> {
> getLog().debug("Line: " + line);
> }
>
> Thanks,
> Grant
>
> --------------------------
> Grant Ingersoll
> Center for Natural Language Processing
> http://www.cnlp.org/tech/lucene.asp
>
> Read the Lucene Java FAQ at http://wiki.apache.org/jakarta-lucene/
> LuceneFAQ
>
>
>
> ---------------------------------------------------------------------
> 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