System.out.println( "Projects added." );
System.out.println( "=====================" );
for ( Iterator i = result.getProjects().iterator(); i.hasNext(); )
{
ProjectSummary p = (ProjectSummary) i.next();
printProjectSummary( client.getProjectSummary( p.getId() ) );
}
System.out.println();
System.out.println( "Waiting the end of the check out..." );
ProjectSummary ps = (ProjectSummary) result.getProjects().get( 0 );
while ( !"New".equals( client.getProjectStatusAsString( ps.getState() ) ) )
{
ps = client.refreshProjectSummary( ps );
System.out.println( "State of " + ps.getName() + "(" + ps.getId() + "): " +
client.getProjectStatusAsString( ps.getState() ) );
Thread.sleep( 1000 );
}
System.out.println();
System.out.println( "Add the project to the build queue." );
client.buildProject( ps.getId() );
while ( !"Building".equals( client.getProjectStatusAsString( ps.getState() ) ) )
{
ps = client.refreshProjectSummary( ps );
Thread.sleep( 1000 );
}
System.out.println( "Building..." );
String state = "unknown";
while ( "Updating".equals( client.getProjectStatusAsString( ps.getState() ) ) ||
"Building".equals( client.getProjectStatusAsString( ps.getState() ) ) )
{
ps = client.refreshProjectSummary( ps );
state = client.getProjectStatusAsString( ps.getState() );
System.out.println( "State of " + ps.getName() + "(" + ps.getId() + "): " + state );
Thread.sleep( 1000 );
}
System.out.println( "Build done with state=" + state + "." );
System.out.println( "Build result." );
System.out.println( "=====================" );
printBuildResult( client.getLatestBuildResult( ps.getId() ) );
System.out.println();
System.out.println( "Build output." );
System.out.println( "=====================" );
System.out.println( client.getBuildOutput( ps.getId(), ps.getLatestBuildId() ) );
System.out.println();
System.out.println( "Removing build results." );
System.out.println( "============================" );
BuildResultSummary brs;
List results = client.getBuildResultsForProject( ps.getId() );
for ( Iterator i = results.iterator(); i.hasNext(); )
{
brs = (BuildResultSummary) i.next();
System.out.print( "Removing build result (" + brs.getId() + ") - " );
BuildResult br = client.getBuildResult( ps.getId(), brs.getId() );
System.out.println( (client.removeBuildResult( br ) == 0 ? "OK" : "Error" ) );
}
System.out.println( "Done.");
System.out.println();
System.out.println( "Projects list." );
System.out.println( "=====================" );
List projects = client.getProjects( projectGroupId );
for ( Iterator i = projects.iterator(); i.hasNext(); )
{
ps = (ProjectSummary) i.next();
printProjectSummary( ps );
System.out.println();
}
System.out.println();
System.out.println( "Remove all projects." );
System.out.println( "=====================" );
for ( Iterator i = projects.iterator(); i.hasNext(); )
{
ps = (ProjectSummary) i.next();
System.out.println( "Removing '" + ps.getName() + "' - " + ps.getVersion() + " (" + ps.getId() + ")'..." );
client.removeProject( ps.getId() );
System.out.println( "Done." );
}
System.out.println();