public String readFileWithChecks( File dir, String fileName, int maxChars, String errorMessage ) throws IOException { File file = new File( dir, fileName ); if ( file.exists() ) { return readFile( file, maxChars ); } else { getLog().warn( errorMessage + " - Filename: " + fileName ); return null; } }
private void addR( ZipArchiver zipArchiver ) throws MojoExecutionException, IOException { final File rFile = new File( targetDirectory, "R.txt" ); if ( !rFile.exists() ) { getLog().debug( "No resources - creating empty R.txt" ); if ( !rFile.createNewFile() ) { getLog().warn( "Unable to create R.txt in AAR" ); } } zipArchiver.addFile( rFile, "R.txt" ); getLog().debug( "Packaging R.txt in AAR" ); }
try { urls.add( file.toURI().toURL() ); getLog().debug( "Adding classpath entry for classes root " + file.getAbsolutePath() ); throw new MojoExecutionException( msg, e ); getLog().warn( msg ); try { urls.add( a.getFile().toURI().toURL() ); getLog().debug( "Adding classpath entry for dependency " + a.getId() ); throw new MojoExecutionException( msg, e ); getLog().warn( msg ); return new URLClassLoader( urls.toArray( new URL[urls.size()] ), Enhancer.class.getClassLoader() );
void createApkFile( File outputFile, boolean signWithDebugKeyStore ) throws MojoExecutionException File dexFile = new File( targetDirectory, "classes.dex" ); if ( !dexFile.exists() ) dexFile = new File( targetDirectory, "classes.zip" ); File zipArchive = new File( targetDirectory, finalName + ".ap_" ); ArrayList<File> sourceFolders = new ArrayList<File>(); if ( sourceDirectories != null ) getLog().info( "Adding native libraries : " + nativeFolders ); getLog().warn( "Output jar doesn't exist:" + outputJar ); throw new MojoExecutionException( "Could not add META-INF resources.", e );
/** * @param parent the returned classLoader will be a descendant of this one. * @return a context class loader with a classPath containing * the project dependencies. */ private ClassLoader getProjectDepsClassLoader(ClassLoader parent) { List urls = new ArrayList(); if (this.getClasspathElements() != null) // For instance, when run for testing. for(Iterator it = this.getClasspathElements().iterator(); it.hasNext(); ) { String pathElem = (String)it.next(); try { urls.add(new File(pathElem).toURL()); } catch (MalformedURLException e) { getLog().warn("Internal classpath element '" + pathElem +"' is was skiped due to: " + getAllExMsgs(e, true)); } } ClassLoader cl = new XJC1MojoClassLoader((URL[])urls.toArray(new URL[urls.size()]), parent); return cl; }
getLog().warn( "The parameter 'lineLength' should be positive, using '80' as default." ); lineLength = DEFAULT_LINE_LENGTH; getLog().warn( "The parameter 'indentSize' should be positive, using '2' as default." ); indentSize = 2; append( sb, "This plugin has " + mojos.size() + ( mojos.size() > 1 ? " goals:" : " goal:" ), 0 ); append( sb, "", 0 ); getLog().info( sb.toString() );
private Schema retainRoots(IdentifierSet identifierSet, Schema schema) { Stopwatch stopwatch = Stopwatch.createStarted(); int oldSize = countTypes(schema); Schema prunedSchema = schema.prune(identifierSet); int newSize = countTypes(prunedSchema); for (String rule : identifierSet.unusedIncludes()) { getLog().warn(String.format("Unused include: %s", rule)); } for (String rule : identifierSet.unusedExcludes()) { getLog().warn(String.format("Unused exclude: %s", rule)); } getLog().info(String.format("Pruned schema from %s types to %s types in %s", oldSize, newSize, stopwatch)); return prunedSchema; }
if ( androidManifestFilePre4.exists() && !androidManifestFilePre4.equals( androidManifestFile ) ) getLog().warn( "Non-standard location of AndroidManifest.xml file found, but not configured:\n " + androidManifestFilePre4 + "\nMove to the standard location src/main/AndroidManifest.xml\n" + "Or configure androidManifestFile. \n" ); getLog().warn( "Non-standard location of Android res folder found, but not configured:\n " + resourceDirectoryPre4 + "\nMove to the standard location src/main/res/\n" + "Or configure resourceDirectory. \n" ); getLog().warn( "Non-standard location assets folder found, but not configured:\n " + assetsDirectoryPre4 + "\nMove to the standard location src/main/assets/\n" + "Or configure assetsDirectory. \n" ); getLog().warn( "Non-standard location native libs folder found, but not configured:\n " + nativeLibrariesDirectoryPre4 + "\nMove to the standard location src/main/libs/\n" + "Or configure nativeLibrariesDirectory. \n" ); throw new MojoExecutionException( "\n\nFound files or folders in non-standard locations in the project!\n" + "....This might be a side-effect of a migration to Android Maven Plugin 4+.\n"
throws MojoExecutionException, MojoFailureException { log.info(MessageFormat.format("Building Docker context {0}", contextDirectory)); dockerClient.pull(image); log.info(MessageFormat.format("Build will use image {0} for cache-from", image)); cacheFromExistLocally.add(image); } catch (ImageNotFoundException e) { log.warn(MessageFormat.format( "Image {0} not found, build will not use it for cache-from", image)); } catch (DockerException | InterruptedException e) { throw new MojoExecutionException("Could not pull cache-from image", e); buildParameters.toArray(new DockerClient.BuildParam[buildParameters.size()]); log.info(""); // Spacing around build progress try { if (repository != null) { throw new MojoExecutionException("Could not build image", e); log.info(""); // Spacing around build progress
public int run(List<String> command, List<String> output) { int retCode = 1; ProcessBuilder pb = new ProcessBuilder(command); try { Process p = pb.start(); OutputBufferThread stdOut = new OutputBufferThread(p.getInputStream()); OutputBufferThread stdErr = new OutputBufferThread(p.getErrorStream()); stdOut.start(); stdErr.start(); retCode = p.waitFor(); if (retCode != 0) { mojo.getLog().warn(command + " failed with error code " + retCode); for (String s : stdErr.getOutput()) { mojo.getLog().debug(s); } } stdOut.join(); stdErr.join(); output.addAll(stdOut.getOutput()); } catch (Exception ex) { mojo.getLog().warn(command + " failed: " + ex.toString()); } return retCode; }
getLog().debug( "checkConflictingLayouts - conflicts : " + conflictingLayouts ); if ( !conflictingLayouts.isEmpty() ) builder.append( "\n" ); throw new MojoExecutionException( builder.toString() ); getLog().warn( line );
protected String findMainClass(MavenProject project) { List<String> mainClasses = U.list(); try { for (String path : project.getCompileClasspathElements()) { if (new File(path).isDirectory()) { getLog().info("Scanning classpath directory: " + path); scanForMainClass(path, mainClasses); } else if (!path.endsWith(".jar")) { getLog().warn("Ignoring classpath entry: " + path); } } } catch (Exception e) { throw U.rte(e); } switch (mainClasses.size()) { case 0: getLog().warn("Couldn't find the main class!"); return null; case 1: return U.first(mainClasses); default: getLog().warn("Found multiple main classes, trying to pick the right one: " + mainClasses); return pickMainClass(mainClasses, project); } }
private AbstractInputStreamContent getImageAsStream( File listingDir, String graphicPath ) throws MojoFailureException { File graphicDir = new File( listingDir, graphicPath ); if ( graphicDir.exists() ) { File[] files = graphicDir.listFiles(); if ( files == null || files.length == 0 ) { getLog().warn( "There are no images in " + graphicDir.getAbsolutePath() ); } else if ( files.length > 1 ) { throw new MojoFailureException( "There should be exactly 1 image in " + graphicDir.getAbsolutePath() ); } else { File graphicFile = files[0]; return new FileContent( AndroidPublisherHelper.MIME_TYPE_IMAGE, graphicFile ); } } return null; }
private ClassLoader toClassLoader(List<File> runtimeClasspath) throws MojoExecutionException { List<URL> urls = new ArrayList<URL>(); for ( File file : runtimeClasspath ) { try { urls.add( file.toURI().toURL() ); getLog().debug( "Adding classpath entry for classes root " + file.getAbsolutePath() ); } catch (MalformedURLException e) { String msg = "Unable to resolve classpath entry to URL: " + file.getAbsolutePath(); if ( failOnError ) { throw new MojoExecutionException( msg, e ); } getLog().warn( msg ); } } urls.addAll( dependenciesURLs() ); return new URLClassLoader( urls.toArray( new URL[urls.size()] ), null ); }
@Override protected Object executeInternal() throws MojoExecutionException, MojoFailureException { DescribeApplicationsRequest req = new DescribeApplicationsRequest().withApplicationNames(applicationName); DescribeApplicationsResult apps = getService().describeApplications(req); List<ApplicationDescription> applications = apps.getApplications(); if (applications.isEmpty()) { String errorMessage = "Application ('" + applicationName + "') not found!"; getLog().warn(errorMessage); throw new MojoFailureException(errorMessage); } ApplicationDescription desc = applications.get(0); List<String> configTemplates = desc.getConfigurationTemplates(); getLog().info(format("There are %d config templates", configTemplates.size())); return configTemplates; } }
private ClasspathRoot makeRootForProject(final MavenProject project) { File f = new File(project.getBuild() .getOutputDirectory()); if ( !f.exists() || !f.isDirectory() ) { this.getLog().warn("Cannot read from " + f.getAbsolutePath()); } this.getLog().info("Including dir " + project.getBuild() .getOutputDirectory()); return new DirectoryClassPathRoot(new File(project.getBuild() .getOutputDirectory())); }
getLog().warn("Null location for " + namespaceURI ); return null; File file = new File( schemaLocation ); if ( file.exists() ) { getLog().debug( "Resolving " + schemaLocation + " to " + schemaLocation ); return schemaLocation; String fileName = new File( schemaLocation ).getName(); file = new File( schemaSourceDirectory, fileName ); if ( file.exists() ) { getLog().debug( "Resolving " + schemaLocation + " to " + file.getAbsolutePath() ); return file.getAbsolutePath(); file = new File( schemaLookupDirectory, fileName ); if ( file.exists() ) { getLog().debug( "Resolving " + schemaLocation + " to " + file.getAbsolutePath() ); return file.getAbsolutePath(); getLog().warn( "Could not resolve location for: " + fileName ); return null;
@Override protected void processLine(String line, int level) { if (line.startsWith(SENCHA_DEBUG_PREFIX)) { log.debug(line.substring(SENCHA_PREFIX_SIZE)); } else if (line.startsWith(SENCHA_INFO_PREFIX)) { log.info(line.substring(SENCHA_PREFIX_SIZE)); } else if (line.startsWith(SENCHA_WARN_PREFIX)) { log.warn(line.substring(SENCHA_PREFIX_SIZE)); } else if (line.startsWith(SENCHA_ERROR_PREFIX)) { log.error(line.substring(SENCHA_PREFIX_SIZE)); } else { log.info(line); } } }