List of usage examples for org.apache.maven.plugin.logging Log info
void info(Throwable error);
From source file:com.spotify.plugin.dockerfile.BuildMojo.java
License:Apache License
@Nullable static String buildImage(@Nonnull DockerClient dockerClient, @Nonnull Log log, boolean verbose, @Nonnull File contextDirectory, @Nullable String repository, @Nonnull String tag, boolean pullNewerImage, boolean noCache) throws MojoExecutionException, MojoFailureException { log.info(MessageFormat.format("Building Docker context {0}", contextDirectory)); final LoggingProgressHandler progressHandler = new LoggingProgressHandler(log, verbose); final ArrayList<DockerClient.BuildParam> buildParameters = new ArrayList<>(); if (pullNewerImage) { buildParameters.add(DockerClient.BuildParam.pullNewerImage()); }//from w w w. j a v a 2s . c om if (noCache) { buildParameters.add(DockerClient.BuildParam.noCache()); } final DockerClient.BuildParam[] buildParametersArray = buildParameters .toArray(new DockerClient.BuildParam[buildParameters.size()]); log.info(""); // Spacing around build progress try { if (repository != null) { final String name = formatImageName(repository, tag); log.info(MessageFormat.format("Image will be built as {0}", name)); log.info(""); // Spacing around build progress dockerClient.build(contextDirectory.toPath(), name, progressHandler, buildParametersArray); } else { log.info("Image will be built without a name"); log.info(""); // Spacing around build progress dockerClient.build(contextDirectory.toPath(), progressHandler, buildParametersArray); } } catch (DockerException | IOException | InterruptedException e) { throw new MojoExecutionException("Could not build image", e); } log.info(""); // Spacing around build progress return progressHandler.builtImageId(); }
From source file:com.spotify.plugin.dockerfile.PushMojo.java
License:Apache License
@Override protected void execute(DockerClient dockerClient) throws MojoExecutionException, MojoFailureException { final Log log = getLog(); if (skipPush) { log.info("Skipping execution because 'dockerfile.push.skip' is set"); return;/*from ww w . j ava2s. c o m*/ } if (repository == null) { repository = readMetadata(Metadata.REPOSITORY); } // Do this hoop jumping so that the override order is correct if (tag == null) { tag = readMetadata(Metadata.TAG); } if (tag == null) { tag = "latest"; } if (repository == null) { throw new MojoExecutionException("Can't push image; image repository not known " + "(specify dockerfile.repository parameter, or run the tag goal before)"); } try { dockerClient.push(formatImageName(repository, tag), LoggingProgressHandler.forLog(log, verbose)); } catch (DockerException | InterruptedException e) { throw new MojoExecutionException("Could not push image", e); } }
From source file:com.spotify.plugin.dockerfile.TagMojo.java
License:Apache License
@Override protected void execute(DockerClient dockerClient) throws MojoExecutionException, MojoFailureException { final Log log = getLog(); if (skipTag) { log.info("Skipping execution because 'dockerfile.tag.skip' is set"); return;//from w w w . j a v a 2 s. com } final String imageId = readMetadata(Metadata.IMAGE_ID); final String imageName = formatImageName(repository, tag); final String message = MessageFormat.format("Tagging image {0} as {1}", imageId, imageName); log.info(message); try { dockerClient.tag(imageId, imageName, force); } catch (DockerException | InterruptedException e) { throw new MojoExecutionException("Could not tag Docker image", e); } writeImageInfo(repository, tag); writeMetadata(log); }
From source file:com.squareup.osstrich.JavadocPublisher.java
License:Apache License
public static void main(String[] args) throws IOException { Log log = new SystemStreamLog(); if (args.length != 3 && args.length != 5) { log.info(String.format( "" + "Usage: %1$s <directory> <repo URL> <group ID>\n" + " %1$s <directory> <repo URL> <group ID> <artifact ID> <version>\n", JavadocPublisher.class.getName())); System.exit(1);/*from w w w.ja v a 2s .c o m*/ return; } File directory = new File(args[0]); String repoUrl = args[1]; String groupId = args[2]; JavadocPublisher javadocPublisher = new JavadocPublisher(new MavenCentral(), new Cli(), log, directory); int artifactsPublished; if (args.length == 3) { artifactsPublished = javadocPublisher.publishLatest(repoUrl, groupId); } else { String artifactId = args[3]; String version = args[4]; artifactsPublished = javadocPublisher.publish(repoUrl, groupId, artifactId, version); } log.info("Published Javadoc for " + artifactsPublished + " artifacts of " + groupId + " to " + repoUrl); }
From source file:com.sri.vt.majic.util.clean.Cleaner.java
License:Apache License
/** * Creates a new cleaner./* ww w.ja v a 2s. c om*/ * * @param log The logger to use, may be <code>null</code> to disable logging. * @param verbose Whether to perform verbose logging. */ public Cleaner(final Log log, boolean verbose) { logDebug = (log == null || !log.isDebugEnabled()) ? null : new Logger() { public void log(CharSequence message) { log.debug(message); } }; logInfo = (log == null || !log.isInfoEnabled()) ? null : new Logger() { public void log(CharSequence message) { log.info(message); } }; logWarn = (log == null || !log.isWarnEnabled()) ? null : new Logger() { public void log(CharSequence message) { log.warn(message); } }; logVerbose = verbose ? logInfo : logDebug; }
From source file:com.stratio.crossdata.connector.plugin.installer.InstallerGoalLauncher.java
License:Apache License
public static void launchInstallerGoal(InstallerGoalConfig config, Log log) throws IOException { log.info("Create TARGET directory."); File targetDirectory = new File( FilenameUtils.concat(config.getOutputDirectory(), config.getConnectorName())); if (targetDirectory.exists()) { log.info("Remove previous TARGET directory"); FileUtils.forceDelete(targetDirectory); }/*from w w w . jav a2 s . co m*/ File includeConfigDirectory = new File(config.getIncludeDirectory()); FileUtils.copyDirectory(includeConfigDirectory, targetDirectory); log.info("Create LIB directory."); File libDirectory = new File(FilenameUtils.concat(targetDirectory.toString(), "lib")); FileUtils.copyFileToDirectory(config.getMainJarRepo(), libDirectory); for (File jarFile : config.getDependenciesJarRepo()) { FileUtils.copyFileToDirectory(jarFile, libDirectory); } log.info("Create CONF directory."); File confDirectory = new File(FilenameUtils.concat(targetDirectory.toString(), "conf")); File confConfigDirectory = new File(config.getConfigDirectory()); FileUtils.copyDirectory(confConfigDirectory, confDirectory); log.info("Create BIN Directory"); File binDirectory = new File(FilenameUtils.concat(targetDirectory.toString(), "bin")); FileUtils.forceMkdir(binDirectory); log.info("Launch template"); String outputString = (config.getUnixScriptTemplate()); outputString = outputString.replaceAll("<name>", config.getConnectorName()); outputString = outputString.replaceAll("<desc>", config.getDescription()); String user = config.getUserService(); if (config.isUseCallingUserAsService()) { user = System.getProperty("user.name"); } outputString = outputString.replaceAll("<user>", user); outputString = outputString.replaceAll("<mainClass>", config.getMainClass()); int index = config.getMainClass().lastIndexOf('.'); String className = config.getMainClass(); if (index != -1) { className = config.getMainClass().substring(index + 1); } outputString = outputString.replaceAll("<mainClassName>", className); outputString = outputString.replaceAll("<jmxPort>", config.getJmxPort()); String pidFileName = ""; if (config.getPidFileName() != null) { pidFileName = config.getPidFileName(); } outputString = outputString.replaceAll("<pidFileName>", pidFileName); File binFile = new File(FilenameUtils.concat(binDirectory.toString(), config.getConnectorName())); FileUtils.writeStringToFile(binFile, outputString); if (!binFile.setExecutable(true)) { throw new IOException("Can't change executable option."); } log.info("Process complete: " + targetDirectory); }
From source file:com.synedge.enforcer.EnforceImportRelease.java
License:Apache License
public void execute(EnforcerRuleHelper helper) throws EnforcerRuleException { Log log = helper.getLog(); log.info("Entering enforcer"); try {// w ww .j a v a 2 s . co m // get the various expressions out of the helper. MavenProject project = (MavenProject) helper.evaluate("${project}"); if (project == null) { throw new EnforcerRuleException("There is no project"); } if (onlyWhenRelease && project.getArtifact().isSnapshot()) { log.warn("Project is SNAPSHOT, not validating"); return; } if (project.getDependencyManagement() == null) { log.info("No dependency management found. All ok"); return; } if (project.getDependencyManagement().getDependencies() == null) { log.info("No dependency management dependencies found. All ok"); return; } helper.getLog().debug("Getting POM, parse and check it"); DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); //Using factory get an instance of document builder DocumentBuilder db = dbf.newDocumentBuilder(); //parse using builder to get DOM representation of the XML file Document doc = db.parse(project.getFile().getAbsolutePath()); XPathFactory xPathfactory = XPathFactory.newInstance(); XPath xpath = xPathfactory.newXPath(); XPathExpression expr = xpath.compile( "/*[local-name()='project']/*[local-name()='dependencyManagement']/*[local-name()='dependencies']/*[local-name()='dependency']/*[local-name()='scope' and text()='import']/../*[local-name()='version']"); NodeList nl = (NodeList) expr.evaluate(doc, XPathConstants.NODESET); for (int i = 0; i < nl.getLength(); i++) { Node version = nl.item(i); if (version.getTextContent().contains("-SNAPSHOT")) { throw new EnforcerRuleException("Found an artifact in the import scope containing SNAPSHOT!"); } } helper.getLog().debug("Checked them all"); } catch (ExpressionEvaluationException e) { throw new EnforcerRuleException("Unable to lookup an expression " + e.getLocalizedMessage(), e); } catch (ParserConfigurationException e) { throw new EnforcerRuleException("Unable to parse POM", e); } catch (SAXException e) { throw new EnforcerRuleException("Unable to parse POM", e); } catch (IOException e) { throw new EnforcerRuleException("Unable to parse POM", e); } catch (XPathExpressionException e) { throw new EnforcerRuleException("Internal error in XPath parser", e); } }
From source file:com.taobao.android.JassitMojo.java
License:Apache License
private void doExec(final Log log) throws NotFoundException, CannotCompileException, IOException, MappingFormatError { log.info("kee: config ClassPool ..."); ClassPool classPool = ClassPool.getDefault(); log.info(String.format("kee: append class path %s", projectOutputDirectory.getAbsolutePath())); classPool.appendClassPath(projectOutputDirectory.getAbsolutePath()); for (Artifact artifact : project.getArtifacts()) { File artFile = artifact.getFile(); log.info(String.format("kee: inserting class path %s", artFile.getAbsolutePath())); classPool.insertClassPath(artFile.getAbsolutePath()); }// w ww .ja v a2 s . c om log.info("kee: obtain and defrost MyActivity CtClass"); CtClass activityCtClz = classPool.getCtClass("com.example.testapp.MyActivity"); activityCtClz.defrost(); CtClass bundleCtClz = classPool.getCtClass("android.os.Bundle"); CtMethod method = activityCtClz.getDeclaredMethod("onCreate", new CtClass[] { bundleCtClz }); log.info("kee: load mappings ..."); instrumentMappings.load(log); log.info("kee: start instrumentation ..."); long startTime = System.currentTimeMillis(); doInstrumentExpEditor(classPool, activityCtClz, method); log.info(String.format("kee: instrument cost %d ms", System.currentTimeMillis() - startTime)); byte[] byteCode = activityCtClz.toBytecode(); log.info(String.format("kee: generated bytecode length = %d", byteCode.length)); log.info("kee: writting to class file ..."); toClassFile(byteCode); }
From source file:com.topekalabs.maven.javaflow.JavaflowEnhanceMojo.java
License:Open Source License
private void instrumentClassFiles(File baseDirectory, File backupDirectory, List<File> classFiles) throws MojoExecutionException { Log log = getLog(); ResourceTransformer transformer = new AsmClassTransformer(); for (File classFile : classFiles) { try {//from w w w .j a v a 2 s. c o m File instrumentedClassFile = new File(String.format(CLASSFILE_REWRITE_TEMPLATE, classFile)); File backupClassFile = com.topekalabs.file.utils.FileUtils.rebase(baseDirectory, backupDirectory, classFile); if (backupClassFile.exists() && (classFile.lastModified() <= backupClassFile.lastModified())) { log.info(classFile + " is up to date"); continue; } log.info(String.format("Enhancing class file bytecode for Javaflow: %s", classFile)); RewritingUtils.rewriteClassFile(classFile, transformer, instrumentedClassFile); if (backupClassFile.exists()) { log.debug(String.format("Backup for original class file %s already exists - removing it", backupClassFile)); backupClassFile.delete(); } log.info(String.format("Renaming original class file from %s to %s", classFile, backupClassFile)); FileUtils.moveFile(classFile, backupClassFile); log.info(String.format("Renaming rewritten class file from %s to %s", instrumentedClassFile, classFile)); FileUtils.moveFile(instrumentedClassFile, classFile); backupClassFile.setLastModified(classFile.lastModified()); } catch (IOException e) { throw new MojoExecutionException(e.getMessage()); } } }
From source file:com.tvarit.plugin.StackMaker.java
License:Open Source License
public Stack makeStack(CreateStackRequest createStackRequest, AmazonCloudFormationClient amazonCloudFormationClient, Log log) throws MojoFailureException { CreateStackResult createStackResult = amazonCloudFormationClient.createStack(createStackRequest); final String stackName = createStackRequest.getStackName(); DescribeStacksResult describeStacksResult = amazonCloudFormationClient .describeStacks(new DescribeStacksRequest().withStackName(stackName)); while (describeStacksResult.getStacks().get(0).getStackStatus() .equals(StackStatus.CREATE_IN_PROGRESS.toString())) { try {/*www.ja v a 2s .c o m*/ log.info("Awaiting stack create completion!"); Thread.sleep(5000); } catch (InterruptedException e) { log.error(e); throw new RuntimeException(e); } describeStacksResult = amazonCloudFormationClient .describeStacks(new DescribeStacksRequest().withStackName(stackName)); } final Stack stack = describeStacksResult.getStacks().get(0); final String stackStatus = stack.getStackStatus(); if (!stackStatus.equals(StackStatus.CREATE_COMPLETE.toString())) { throw new MojoFailureException("Could not create infrastructure. Stack Status is: " + stackStatus + ". Please review details on the AWS console and open a new github issue on https://github.com/sdole/tvarit-maven/issues/new that is needed."); } return stack; }