package com.perforce.maven.mojo.jobs; /** * Copyright (c) 2010 Perforce Software. All rights reserved. */ import java.io.IOException; import java.util.List; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.scm.ScmException; import org.apache.maven.scm.ScmFileSet; import org.apache.maven.scm.ScmResult; import org.apache.maven.scm.repository.ScmRepository; import com.perforce.maven.mojo.P4Mojo; import com.perforce.maven.scm.provider.p4.repository.P4ScmProviderRepository; import com.perforce.maven.scm.provider.p4.util.P4Utils; import com.perforce.p4java.client.IClient; import com.perforce.p4java.core.IJob; import com.perforce.p4java.core.file.IFileSpec; import com.perforce.p4java.exception.P4JavaException; import com.perforce.p4java.option.server.GetJobsOptions; import com.perforce.p4java.server.IOptionsServer; /** * Perforce jobs command. */ @Mojo( name = "jobs", aggregator = true ) public class P4JobsMojo extends P4Mojo { /** The Constant command. */ public static final String command = "Perforce jobs command"; public void execute() throws MojoExecutionException, MojoFailureException { try { ScmRepository repository = getScmRepository(); P4ScmProviderRepository providerRepository = (P4ScmProviderRepository) repository.getProviderRepository(); ScmFileSet fileSet = new ScmFileSet( scmDirectory, includes, excludes ); if ( fileSet.getFileList().isEmpty() ) { this.getLog().warn( "No files for job goal." ); return; } ScmResult scmResult = executeJobsCommand( providerRepository, fileSet ); // return scmResult; } catch ( ScmException e ) { throw new MojoExecutionException( "Couldn't run jobs.", e ); } catch ( IOException e ) { throw new MojoExecutionException( "Problem occurred while running jobs.", e ); } } protected ScmResult executeJobsCommand( P4ScmProviderRepository p4Repo, ScmFileSet files ) throws ScmException { P4JobsResult p4Result = new P4JobsResult(); IClient client = p4ClientManager.getClient( p4Repo, files.getBasedir() ); IOptionsServer server = (IOptionsServer) client.getServer(); List<IFileSpec> fileSpecs = P4Utils.scmFileSet2P4FileSpecs( files ); try { GetJobsOptions getJobsOptions = new GetJobsOptions(); List<IJob> retJobs = server.getJobs( fileSpecs, getJobsOptions ); ( (P4JobsResult) p4Result ).processJobs( retJobs ); } catch ( P4JavaException e ) { throw new ScmException( e.getLocalizedMessage(), e ); } getLog().info( p4Result.getCommandOutput() ); return new ScmResult( command, p4Result.isSuccess() ? "Jobs command successful" : "Unable to run jobs", p4Result.getCommandOutput(), p4Result.isSuccess() ); } }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#5 | 14103 | dantran | Ugrade p4java, externalize p4mojo | ||
#4 | 9626 | dantran | rework on job goal | ||
#3 | 9527 | dantran |
Cleanup with - Source format - Remove all unused code - There is no reason for mojo to pickup maven-scm-plugin's config which is not recommend from Maven best practice. If needed, user need to do it himself use project <properties> |
||
#2 | 9526 | dantran | Remove P4Executor, use P4ClientManager instead | ||
#1 | 9520 | dantran | folder rename to match with its artifactId | ||
//guest/dantran/p4maven/com.perforce.maven.mojo/src/main/java/com/perforce/maven/mojo/jobs/P4JobsMojo.java | |||||
#4 | 9267 | dantran | More swapping of P4Executor for P4Utils | ||
#3 | 9191 | dantran |
jobs,shelve, and unshelve should run as aggregate, there is no need to tranverse. Ensure extracting credential from settings.xml working |
||
#2 | 9190 | dantran | Migrate to java annotation, add loading credential from settings.xml if not given | ||
#1 | 9167 | dantran |
Populate //guest/dantran/p4maven/... from //guest/perforce_software/p4maven/main/.... |
||
//guest/perforce_software/p4maven/main/com.perforce.maven.mojo/src/main/java/com/perforce/maven/mojo/jobs/P4JobsMojo.java | |||||
#1 | 8496 | Matt Attaway | Move P4Ant and P4Maven into their proper homes | ||
//public/perforce/p4maven/main/com.perforce.maven.mojo/src/main/java/com/perforce/maven/mojo/jobs/P4JobsMojo.java | |||||
#1 | 8270 | Matt Attaway | Initial add of P4Maven source code |