private boolean isSpecificVersion( String version ) { return !( StringUtils.isEmpty( version ) || version.startsWith( "[" ) || version.startsWith( "(" ) ); }
private static String getId( String gid, String aid, String type, String cls, String ver ) { return gid + ':' + aid + ':' + type + ( StringUtils.isNotEmpty( cls ) ? ':' + cls : "" ) + ':' + ver; }
public List<TaskSegment> calculateTaskSegments( MavenSession session ) throws PluginNotFoundException, PluginResolutionException, PluginDescriptorParsingException, MojoNotFoundException, NoPluginFoundForPrefixException, InvalidPluginDescriptorException, PluginVersionResolutionException, LifecyclePhaseNotFoundException, LifecycleNotFoundException { MavenProject rootProject = session.getTopLevelProject(); List<String> tasks = session.getGoals(); if ( ( tasks == null || tasks.isEmpty() ) && !StringUtils.isEmpty( rootProject.getDefaultGoal() ) ) { tasks = Arrays.asList( StringUtils.split( rootProject.getDefaultGoal() ) ); } return calculateTaskSegments( session, tasks ); }
/** * <p> * Reverses a String that is delimited by a specific character. * </p> * <p> * The Strings between the delimiters are not reversed. Thus java.lang.String becomes String.lang.java (if the * delimiter is <code>'.'</code>). * </p> * * @param str the String to reverse * @param delimiter the delimiter to use * @return the reversed String */ public static String reverseDelimitedString( String str, String delimiter ) { // could implement manually, but simple way is to reuse other, // probably slower, methods. String[] strs = split( str, delimiter ); reverseArray( strs ); return join( strs, delimiter ); }
public void set( String goals ) { mojos = new ArrayList<>(); if ( StringUtils.isNotEmpty( goals ) ) { String[] mojoGoals = StringUtils.split( goals, "," ); for ( String mojoGoal: mojoGoals ) { LifecycleMojo lifecycleMojo = new LifecycleMojo(); lifecycleMojo.setGoal( mojoGoal.trim() ); mojos.add( lifecycleMojo ); } } }
public void execute() throws MojoExecutionException, MojoFailureException getLog().info( "Skipping OpenAPI specification resolution" ); return; getLog().info( "Resolving OpenAPI specification.." ); String pEnc = project.getProperties().getProperty("project.build.sourceEncoding"); if (StringUtils.isNotBlank(pEnc)) { projectEncoding = pEnc; if (StringUtils.isBlank(encoding)) { encoding = projectEncoding; if (StringUtils.isNotBlank(openapiFilePath)) { Path openapiPath = Paths.get(openapiFilePath); if (openapiPath.toFile().exists() && openapiPath.toFile().isFile()) { String openapiFileContent = new String(Files.readAllBytes(openapiPath), encoding); if (StringUtils.isNotBlank(openapiFileContent)) { try { openAPIInput = Json.mapper().readValue(openapiFileContent, OpenAPI.class); GenericOpenApiContextBuilder builder = new JaxrsOpenApiContextBuilder() .openApiConfiguration(config); if (StringUtils.isNotBlank(contextId)) { builder.ctxId(contextId);
private void processIntegrationTest( File goalFile, File archetypeFile ) throws IntegrationTestFailure, MojoExecutionException getLog().info( "Processing Archetype IT project: " + goalFile.getParentFile().getName() ); ArchetypeGenerationRequest request = generate( project.getGroupId(), project.getArtifactId(), project.getVersion(), archetypeFile, properties, basedir.toString() ); getLog().info( "Comparing generated project with reference content: " + reference ); if ( StringUtils.isNotEmpty( goals ) )
public void execute() throws MojoExecutionException { String line = "sencha --time " + getSenchaLogLevelCmd(); if (!StringUtils.isEmpty(arguments)) { line += " " + arguments; } try { CommandLine cmdLine = getCommandLine(line); log.info(String.format("Executing Sencha Cmd '%s' in directory '%s'", line, workingDirectory)); internalExecute(cmdLine, new SenchaCmdLogOutputStream(log), workingDirectory); log.debug("Executed Sencha Cmd successfully"); } catch (IOException e) { throw new MojoExecutionException("Execution of Sencha Cmd failed.", e); } }
static void execute(final Log log, MavenProject project, Iterable<String> classpath, List<String> arguments) throws MojoExecutionException { final String cp = StringUtils.join(classpath.iterator(), File.pathSeparator); final String[] args = arguments.toArray(new String[arguments.size()]); Commandline commandline = new Commandline(); commandline.setWorkingDirectory(project.getBuild().getDirectory()); commandline.setExecutable(Paths.get(System.getProperty("java.home"), "bin", "java").toString()); commandline.addEnvironment("CLASSPATH", cp); commandline.addArguments(args); if (log.isDebugEnabled()) { log.debug("Classpath: " + cp); log.debug("Arguments: " + CommandLineUtils.toString(args)); throw new MojoExecutionException(e.getMessage(), e); throw new MojoExecutionException("GWT exited with status " + result);
private void copyNbmResources() throws MojoExecutionException { try { if ( StringUtils.isEmpty( encoding ) && isFilteringEnabled( nbmResources ) ) { getLog().warn( "File encoding has not been set, using platform encoding " + ReaderFactory.FILE_ENCODING + ", i.e. build is platform dependent!" ); } MavenResourcesExecution mavenResourcesExecution = new MavenResourcesExecution( Arrays.asList( nbmResources ), clusterDir, project, encoding, Collections.EMPTY_LIST, Collections.EMPTY_LIST, session ); mavenResourcesExecution.setEscapeWindowsPaths( true ); mavenResourcesFiltering.filterResources( mavenResourcesExecution ); } catch ( MavenFilteringException ex ) { throw new MojoExecutionException( ex.getMessage(), ex ); } }
if (StringUtils.isBlank(set) || !set.contains(SET_OPERATOR) || set.indexOf(SET_OPERATOR) <= 0) coll = (Collection<? extends Map<String, Object>>) parent.getData().get(Table.INDEXES); } else { getLog().error("Doc was of type " + doc.getClass()); return; edits.increment(); } else { getLog().error("Could not remove doc " + doc); getLog().info(format("Done! %d entries modified.", edits.longValue())); } else { throw new MojoExecutionException(format( "The configFile '%s' can't be loaded.", configLocation().toString()));
@Override public void execute() throws MojoExecutionException, MojoFailureException { getLog().debug( "Emma start working. Before parse configuration" ); parseConfiguration(); if ( parsedEnable ) { getLog().info( "Emma OVERWRITE compiled class is on for this project! " // + "Do NOT use this project on production" ); getLog().debug( "configuration: Class Folders - this file will be modified by emma " + parsedEmmaClassFolders ); getLog().debug( "configuration: parsedOutputMetadataFile " + parsedOutputMetadataFile ); InstrProcessor processor = InstrProcessor.create(); if ( StringUtils.isNotEmpty( parsedFilters ) ) { processor.setInclExclFilter( parsedFilters.split( "," ) ); } processor.setInstrPath( parsedEmmaClassFolders, true ); processor.setInstrOutDir( parsedEmmaClassFolders[ 0 ] ); // always to // first define // folder processor.setMetaOutFile( parsedOutputMetadataFile ); processor.setOutMode( OutMode.OUT_MODE_OVERWRITE ); processor.setMetaOutMerge( Boolean.TRUE ); processor.run(); } getLog().debug( "Emma OVERWRITE is OFF for this project (" + project.getArtifactId() + ") target/classes files are safe" ); }
private void unpack(File file, File destination, String includes, String excludes) throws MojoExecutionException { try { destination.mkdirs(); UnArchiver unArchiver = archiverManager.getUnArchiver(file); unArchiver.setSourceFile(file); unArchiver.setDestDirectory(destination); if (StringUtils.isNotEmpty(excludes) || StringUtils.isNotEmpty(includes)) { IncludeExcludeFileSelector[] selectors = new IncludeExcludeFileSelector[] { new IncludeExcludeFileSelector() }; if (StringUtils.isNotEmpty(excludes)) { selectors[0].setExcludes(excludes.split(",")); } if (StringUtils.isNotEmpty(includes)) { selectors[0].setIncludes(includes.split(",")); } unArchiver.setFileSelectors(selectors); } unArchiver.extract(); getLog().info("Unpacked " + file + " to " + destination); } catch (Exception e) { throw new MojoExecutionException("Failed unpacking " + file + " to " + destination, e); } }
@Override @SuppressWarnings("unchecked") protected void doExecute() throws Exception { JavaMainCaller jcmd = null; if (StringUtils.isNotEmpty(mainClass)) { jcmd = new JavaMainCallerByFork(this, mainClass, MainHelper.toMultiPath(project.getTestClasspathElements()), jvmArgs, args, forceUseArgFile); } else if ((launchers != null) && (launchers.length > 0)) { if (StringUtils.isNotEmpty(launcher)) { for(int i = 0; (i < launchers.length) && (jcmd == null); i++) { if (launcher.equals(launchers[i].id)) { getLog().info("launcher '"+ launchers[i].id + "' selected => "+ launchers[i].mainClass ); jcmd = new JavaMainCallerByFork(this, launchers[i].mainClass, MainHelper.toMultiPath(project.getTestClasspathElements()), launchers[i].jvmArgs, launchers[i].args, forceUseArgFile); } } } else { getLog().info("launcher '"+ launchers[0].id + "' selected => "+ launchers[0].mainClass ); jcmd = new JavaMainCallerByFork(this, launchers[0].mainClass, MainHelper.toMultiPath(project.getTestClasspathElements()), launchers[0].jvmArgs, launchers[0].args, forceUseArgFile); } } if (jcmd != null) { if (StringUtils.isNotEmpty(addArgs)) { jcmd.addArgs(StringUtils.split(addArgs, "|")); } jcmd.run(displayCmd); } else { getLog().warn("Not mainClass or valid launcher found/define"); } } }
private void displayCmd(boolean displayCmd, List<String> cmd) { if (displayCmd) { requester.getLog().info("cmd: " + " " + StringUtils.join(cmd.iterator(), " ")); } else if (requester.getLog().isDebugEnabled()) { requester.getLog().debug("cmd: " + " " + StringUtils.join(cmd.iterator(), " ")); } }
public String getRevision() throws MojoExecutionException { try { return this.getScmRevision(); } catch ( ScmException e ) { if ( !StringUtils.isEmpty( revisionOnScmFailure ) ) { getLog().warn( "Cannot get the revision information from the scm repository, proceeding with " + "revision of " + revisionOnScmFailure + " : \n" + e.getLocalizedMessage() ); return revisionOnScmFailure; } throw new MojoExecutionException( "Cannot get the revision information from the scm repository : \n" + e.getLocalizedMessage(), e ); } }
void execute(List<String> args) throws MojoExecutionException { ProcessBuilder pb = buildProcess(args); getLog().info("Running: " + StringUtils.join(pb.command().iterator(), " ")); try { Process p = pb.start(); BufferedReader br = new BufferedReader(new InputStreamReader(p.getInputStream())); String line; while ((line = br.readLine()) != null) getLog().info(line); int ec = p.waitFor(); if (ec != 0) throw new DockerComposeException(IOUtil.toString(p.getErrorStream())); } catch (Exception e) { throw new MojoExecutionException(e.getMessage()); } }
public static Commandline createCommandLine( PerforceScmProviderRepository repo, File workingDirectory, ScmVersion startRev, ScmVersion endRev ) { String start = startRev != null && StringUtils.isNotEmpty( startRev.getName() ) ? "@" + startRev.getName() : ""; String end = endRev != null && StringUtils.isNotEmpty( endRev.getName() ) ? endRev.getName() : "now"; Commandline command = PerforceScmProvider.createP4Command( repo, workingDirectory ); command.createArg().setValue( "diff2" ); command.createArg().setValue( "-u" ); // I'm assuming the "revs" are actually labels command.createArg().setValue( "..." + start ); command.createArg().setValue( "...@" + end ); return command; }
private InputStream[] getBaseSignatures() throws FileNotFoundException { List<InputStream> baseSignatures = new ArrayList<InputStream>(); for ( Iterator<Artifact> i = project.getArtifacts().iterator(); i.hasNext(); ) { Artifact artifact = i.next(); if ( StringUtils.equals( "signature", artifact.getType() ) ) { getLog().info( "Importing sigantures from " + artifact.getFile() ); baseSignatures.add( new FileInputStream( artifact.getFile() ) ); } } final InputStream[] baseSignatureInputStreams = (InputStream[]) baseSignatures.toArray( new InputStream[baseSignatures.size()] ); return baseSignatureInputStreams; }
@Override public String assureInputFromUser(String attribute, String defaultValue, List<String> options, String prompt) throws MojoFailureException { final String initValue = System.getProperty(attribute); final String input = StringUtils.isNotEmpty(initValue) ? initValue : defaultValue; if (validateInputByOptions(input, options)) { log.info(String.format("Use %s for %s", input, attribute)); return input; } throw new MojoFailureException(String.format("Invalid input for %s : %s", attribute, input)); }