Use plexus-input-handler instead of System.in

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@170717 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Emmanuel Venisse 2005-05-18 07:53:16 +00:00
parent ecde534c5a
commit c4db798207
3 changed files with 20 additions and 9 deletions

View File

@ -40,5 +40,10 @@
<artifactId>jaxen</artifactId> <artifactId>jaxen</artifactId>
<version>1.0-FCS</version> <version>1.0-FCS</version>
</dependency> </dependency>
<dependency>
<groupId>plexus</groupId>
<artifactId>plexus-input-handler</artifactId>
<version>1.0-alpha-1-SNAPSHOT</version>
</dependency>
</dependencies> </dependencies>
</project> </project>

View File

@ -111,6 +111,11 @@ protected ScmBean getScm()
return scm; return scm;
} }
public PlexusContainer getContainer()
{
return container;
}
public void execute() public void execute()
throws MojoExecutionException throws MojoExecutionException
{ {

View File

@ -28,6 +28,7 @@
import org.apache.maven.project.MavenProject; import org.apache.maven.project.MavenProject;
import org.apache.maven.scm.ScmException; import org.apache.maven.scm.ScmException;
import org.apache.maven.scm.ScmFile; import org.apache.maven.scm.ScmFile;
import org.codehaus.plexus.components.inputhandler.InputHandler;
import org.codehaus.plexus.util.StringUtils; import org.codehaus.plexus.util.StringUtils;
import java.io.BufferedReader; import java.io.BufferedReader;
@ -71,15 +72,15 @@ public class PrepareReleaseMojo
protected void executeTask() protected void executeTask()
throws MojoExecutionException throws MojoExecutionException
{ {
//checkStatus(); checkStatus();
//checkDependencies(); checkDependencies();
transformPom(); transformPom();
//checkin(); checkin();
//tag(); tag();
} }
private boolean isSnapshot( String version ) private boolean isSnapshot( String version )
@ -185,14 +186,14 @@ private void transformPom()
try try
{ {
getLog().info( "What is the new version? [" + projectVersion + "]" ); getLog().info( "What is the new version? [" + projectVersion + "]" );
BufferedReader input = new BufferedReader( new InputStreamReader( System.in ) ); InputHandler handler = (InputHandler) getContainer().lookup( InputHandler.ROLE );
String inputVersion = input.readLine(); String inputVersion = handler.readLine();
if ( !StringUtils.isEmpty( inputVersion ) ) if ( !StringUtils.isEmpty( inputVersion ) )
{ {
projectVersion = inputVersion; projectVersion = inputVersion;
} }
} }
catch ( IOException e ) catch ( Exception e )
{ {
throw new MojoExecutionException( "Can't read user input.", e ); throw new MojoExecutionException( "Can't read user input.", e );
} }
@ -284,8 +285,8 @@ private void tag()
if ( getScm().getTag() == null ) if ( getScm().getTag() == null )
{ {
getLog().info( "What is the new tag name?" ); getLog().info( "What is the new tag name?" );
BufferedReader input = new BufferedReader( new InputStreamReader( System.in ) ); InputHandler handler = (InputHandler) getContainer().lookup( InputHandler.ROLE );
getScm().setTag( input.readLine() ); getScm().setTag( handler.readLine() );
} }
getScm().tag(); getScm().tag();
} }