Example usage for org.apache.maven.plugin.logging Log warn

List of usage examples for org.apache.maven.plugin.logging Log warn

Introduction

In this page you can find the example usage for org.apache.maven.plugin.logging Log warn.

Prototype

void warn(Throwable error);

Source Link

Document

Send an exception to the user in the warn error level.
The stack trace for this exception will be output when this error level is enabled.

Usage

From source file:BuildMojo.java

License:Open Source License

@Override
public void execute() throws MojoExecutionException, MojoFailureException {
    final Log log = getLog();

    sourceDirectory = sourceDirectory.getAbsoluteFile();

    if (!(sourceDirectory.exists() && sourceDirectory.isDirectory())) {
        log.warn(String.format("Not executing brunch as source directory [%s] does not exist.",
                sourceDirectory));//from   w  ww.  j  a v a  2 s . c o m
        return;
    }

    Map<String, String> myEnv = new HashMap<String, String>(System.getenv());
    myEnv.putAll(env);

    new Brunch(new WrappingConsoleProvider(MavenConsole.fromMavenLog(log)), getJavascriptFilesDirectory(),
            sourceDirectory, myEnv, minify);

}

From source file:biz.paluch.maven.configurator.ZipFileCompressor.java

License:Open Source License

/**
 * Compress the files.//from w w  w . j  av a 2  s  .co m
 *
 * @param log
 * @throws IOException
 */
public void compress(Log log) throws IOException {

    Set<String> uniqueEntryNames = new HashSet<String>();
    for (Entry entry : container.getEntries()) {

        File source = new File(compressionBase, entry.getName());

        if (!uniqueEntryNames.add(entry.getName().toLowerCase())) {
            log.warn("Container " + container.getName() + ", Entry " + entry.getName()
                    + " already exists, skipping");
            continue;

        }

        ZipEntry ze = getZipEntry(entry.getName(), source);

        if (entry instanceof CompressedContainer && source.isDirectory()) {
            compress(log, (CompressedContainer) entry, source, ze);
            continue;
        }

        if (source.isDirectory()) {
            continue;
        }

        zos.putNextEntry(ze);
        Files.copy(source, zos);
        zos.closeEntry();
    }

    zos.close();
}

From source file:ch.ivyteam.ivy.maven.engine.deploy.MarkerFileDeployer.java

License:Apache License

@Override
@SuppressWarnings("hiding")
public void deployIar(String iarFilePath, Log log) throws MojoExecutionException {
    File iar = new File(deployDir, iarFilePath);
    if (!iar.exists() || !iar.isFile()) {
        log.warn("Skipping deployment of '" + iarFilePath + "'. The IAR '" + iar + "' does not exist.");
        return;//from  w w  w .j  a  v  a  2s  .  c  o m
    }

    this.markerFile = new DeploymentMarkerFiles(iar);
    this.log = log;

    deployInternal();
}

From source file:ch.sourcepond.maven.plugin.jenkins.config.ConfigImpl.java

License:Apache License

/**
 * @throws MojoExecutionException//w  ww . j  a v a 2 s .c  om
 */
void validate(final Log pLog) throws MojoExecutionException {
    // Do not allow noKeyAuth when private key is set
    if (isNoKeyAuth() && getPrivateKeyOrNull() != null) {
        throw new MojoExecutionException(messages
                .getMessage(CONFIG_VALIDATION_ERROR_NO_KEY_AUTH_AND_PRIVATE_KEY_SET, getPrivateKeyOrNull()));
    }

    // If a secure base-uri has been set, there must be a trust-store if
    // certificate check is not disabled.
    if (isSecure() && !isNoCertificateCheck() && getTrustStoreOrNull() == null) {
        throw new MojoExecutionException(
                messages.getMessage(CONFIG_VALIDATION_ERROR_SECURE_BUT_NO_TRUSTSTORE_SPECIFIED));
    }

    // If a trust-store has been specified, insure that a password is set
    if (getTrustStoreOrNull() != null) {
        if (isBlank(getTrustStorePasswordOrNull())) {
            throw new MojoExecutionException(messages.getMessage(
                    CONFIG_VALIDATION_ERROR_NO_TRUSTSTORE_PASSWORD_SPECIFIED, getTrustStoreOrNull()));
        }

        if (MIN_TRUSTSTORE_PWD_LENGTH > getTrustStorePasswordOrNull().length()) {
            throw new MojoExecutionException(messages.getMessage(
                    CONFIG_VALIDATION_ERROR_TRUSTSTORE_PASSWORD_TOO_SHORT, MIN_TRUSTSTORE_PWD_LENGTH));
        }
    }

    if (getTrustStoreOrNull() == null && !isBlank(getTrustStorePasswordOrNull())) {
        pLog.warn(messages.getMessage(CONFIG_VALIDATION_WARN_TRUSTSTORE_PASSWORD_NOT_NECESSARY));
    }

    warnFieldCannotBeApplied(CONFIG_VALIDATION_WARN_XSLT_NOT_APPLIABLE, pLog, stdin, stdinXslt, STDIN_FIELD,
            STDIN_XSLT_FIELD);
    warnFieldCannotBeApplied(CONFIG_VALIDATION_WARN_XSLT_NOT_APPLIABLE, pLog, stdout, stdoutXslt, STDOUT_FIELD,
            STDOUT_XSLT_FIELD);
    warnFieldCannotBeApplied(CONFIG_VALIDATION_WARN_PARAMS_NOT_APPLIABLE, pLog, stdinXslt, stdinXsltParams,
            STDIN_XSLT_FIELD, STDIN_PARAMS_FIELD);
    warnFieldCannotBeApplied(CONFIG_VALIDATION_WARN_PARAMS_NOT_APPLIABLE, pLog, stdoutXslt, stdoutXsltParams,
            STDOUT_XSLT_FIELD, STDOUT_PARAMS_FIELD);
}

From source file:ch.sourcepond.maven.plugin.jenkins.config.ConfigImpl.java

License:Apache License

/**
 * @param pLog//from   ww  w . ja va  2 s  .  c o  m
 * @param pRequired
 * @param pDependant
 * @param pMessageKey
 */
private void warnFieldCannotBeApplied(final String pMessageKey, final Log pLog, final Object pRequired,
        final Object pDependant, final String pRequiredFieldName, final String pDependantFieldName) {
    if (pRequired == null && pDependant != null) {
        pLog.warn(messages.getMessage(pMessageKey, pDependantFieldName, pRequiredFieldName));
    }
}

From source file:cn.org.once.cstack.maven.plugin.utils.RestUtils.java

License:Open Source License

/**
 * sendGetCommand/*w  w  w .  j  a va 2s  .  c om*/
 * 
 * @param url
 * @param log
 * @return
 * @throws MojoExecutionException
 * @throws CheckException
 */
public Map<String, String> sendGetCommand(String url, Log log) throws CheckException {
    Map<String, String> response = new HashMap<String, String>();
    CloseableHttpClient httpclient = HttpClients.createDefault();
    HttpGet httpget = new HttpGet(url);
    try {
        CloseableHttpResponse httpResponse = httpclient.execute(httpget, localContext);
        ResponseHandler<String> handler = new ResponseErrorHandler();
        String body = handler.handleResponse(httpResponse);
        response.put("body", body);
        httpResponse.close();

    } catch (Exception e) {
        log.warn("GET request failed!");

        throw new CheckException("Send GET to server failed!", e);
    }

    return response;
}

From source file:cn.org.once.cstack.maven.plugin.utils.RestUtils.java

License:Open Source License

/**
 * @param url/*from   w  ww . j  a  v a  2  s .c  o m*/
 * @param parameters
 * @return
 * @throws MojoExecutionException
 * @throws CheckException
 */
public Map<String, Object> sendPostCommand(String url, Map<String, String> parameters, Log log)
        throws CheckException {
    Map<String, Object> response = new HashMap<String, Object>();
    CloseableHttpClient httpclient = HttpClients.createDefault();

    HttpPost httpPost = new HttpPost(url);
    httpPost.setHeader("Accept", "application/json");
    httpPost.setHeader("Content-type", "application/json");

    try {
        ObjectMapper mapper = new ObjectMapper();
        StringEntity entity = new StringEntity(mapper.writeValueAsString(parameters));
        httpPost.setEntity(entity);
        CloseableHttpResponse httpResponse = httpclient.execute(httpPost, localContext);
        ResponseHandler<String> handler = new ResponseErrorHandler();
        String body = handler.handleResponse(httpResponse);
        response.put("body", body);
        httpResponse.close();
    } catch (Exception e) {
        log.warn("POST request failed!");

        throw new CheckException("Send POST to server failed!", e);
    }

    return response;
}

From source file:com.alibaba.citrus.maven.eclipse.base.eclipse.reader.ReadWorkspaceLocations.java

License:Apache License

/**
 * Read the JRE definition configured in the workspace. They will be put in a HashMap with as key there path and as
 * value the JRE constant. a second key is included with the JRE version as a key.
 *
 * @param workspaceLocation the workspace location
 * @param logger            the logger to error messages
 * @return the map with found jre's//w w  w  .j a v a2s  . c  o m
 */
private HashMap readAvailableJREs(File workspaceLocation, Log logger) {
    Xpp3Dom vms;
    try {
        File prefs = new File(workspaceLocation,
                ReadWorkspaceLocations.METADATA_PLUGINS_ORG_ECLIPSE_CORE_RUNTIME_LAUNCHING_PREFS);
        if (!prefs.exists()) {
            return null;
        }
        Properties properties = new Properties();
        properties.load(new FileInputStream(prefs));
        vms = Xpp3DomBuilder.build(new StringReader(properties
                .getProperty(ReadWorkspaceLocations.METADATA_PLUGINS_ORG_ECLIPSE_CORE_RUNTIME_PREFS_VM_KEY)));
    } catch (Exception e) {
        logger.error("Could not read workspace JRE preferences", e);
        return null;
    }

    HashMap jreMap = new HashMap();
    jreMap.put("1.2", CLASSPATHENTRY_STANDARD + "J2SE-1.2");
    jreMap.put("1.3", CLASSPATHENTRY_STANDARD + "J2SE-1.3");
    jreMap.put("1.4", CLASSPATHENTRY_STANDARD + "J2SE-1.4");
    jreMap.put("1.5", CLASSPATHENTRY_STANDARD + "J2SE-1.5");
    jreMap.put("5", jreMap.get("1.5"));
    jreMap.put("1.6", CLASSPATHENTRY_STANDARD + "JavaSE-1.6");
    jreMap.put("6", jreMap.get("1.6"));
    String defaultJRE = vms.getAttribute("defaultVM").trim();
    Xpp3Dom[] vmTypes = vms.getChildren("vmType");
    for (int vmTypeIndex = 0; vmTypeIndex < vmTypes.length; vmTypeIndex++) {
        String typeId = vmTypes[vmTypeIndex].getAttribute("id");
        Xpp3Dom[] vm = vmTypes[vmTypeIndex].getChildren("vm");
        for (int vmIndex = 0; vmIndex < vm.length; vmIndex++) {
            try {
                String path = vm[vmIndex].getAttribute("path");
                String name = vm[vmIndex].getAttribute("name");
                String vmId = vm[vmIndex].getAttribute("id").trim();
                String classpathEntry = MessageFormat.format(ReadWorkspaceLocations.CLASSPATHENTRY_FORMAT,
                        new Object[] { typeId, name });
                String jrePath = new File(path).getCanonicalPath();
                File rtJarFile = new File(new File(jrePath), "jre/lib/rt.jar");
                if (!rtJarFile.exists()) {
                    logger.warn(Messages.getString("EclipsePlugin.invalidvminworkspace", jrePath));
                    continue;
                }
                JarFile rtJar = new JarFile(rtJarFile);
                String version = rtJar.getManifest().getMainAttributes().getValue("Specification-Version");
                if (defaultJRE.endsWith("," + vmId)) {
                    jreMap.put(jrePath, ReadWorkspaceLocations.CLASSPATHENTRY_DEFAULT);
                    jreMap.put(version, ReadWorkspaceLocations.CLASSPATHENTRY_DEFAULT);
                    logger.debug("Default Classpath Container version: " + version + "  location: " + jrePath);
                } else if (!jreMap.containsKey(jrePath)) {
                    if (!jreMap.containsKey(version)) {
                        jreMap.put(version, classpathEntry);
                    }
                    jreMap.put(jrePath, classpathEntry);
                    logger.debug("Additional Classpath Container version: " + version + " " + classpathEntry
                            + " location: " + jrePath);
                } else {
                    logger.debug("Ignored (duplicated) additional Classpath Container version: " + version + " "
                            + classpathEntry + " location: " + jrePath);
                }
            } catch (IOException e) {
                logger.warn("Could not interpret entry: " + vm[vmIndex].toString());
            }
        }
    }
    return jreMap;
}

From source file:com.alibaba.citrus.maven.eclipse.base.ide.IdeUtils.java

License:Apache License

/**
 * Calculate the project name template from the specified value <code>projectNameTemplate</code>,
 * <code>addVersionToProjectName</code> and <code>addGroupIdToProjectName</code>
 * <p/>//from  w  ww.jav a  2s . com
 * Note: if projectNameTemplate is not null then that value will be used regardless of the values for
 * addVersionToProjectName or addGroupIdToProjectName and a warning will be issued.
 *
 * @param projectNameTemplate     the current projectNameTemplate, if available
 * @param addVersionToProjectName whether to include Version in the project name
 * @param addGroupIdToProjectName whether to include GroupId in the project name.
 * @return the project name template.
 */
public static String calculateProjectNameTemplate(String projectNameTemplate, boolean addVersionToProjectName,
        boolean addGroupIdToProjectName, Log log) {
    if (projectNameTemplate != null) {
        if (addVersionToProjectName || addGroupIdToProjectName) {
            log.warn("projectNameTemplate definition overrides "
                    + "addVersionToProjectName or addGroupIdToProjectName");
        }
        return projectNameTemplate;
    } else if (addVersionToProjectName && addGroupIdToProjectName) {
        return IdeUtils.PROJECT_NAME_WITH_GROUP_AND_VERSION_TEMPLATE;
    } else if (addVersionToProjectName) {
        return IdeUtils.PROJECT_NAME_WITH_VERSION_TEMPLATE;
    } else if (addGroupIdToProjectName) {
        return IdeUtils.PROJECT_NAME_WITH_GROUP_TEMPLATE;
    }
    return IdeUtils.PROJECT_NAME_DEFAULT_TEMPLATE;
}

From source file:com.alibaba.citrus.maven.eclipse.base.ide.IdeUtils.java

License:Apache License

/**
 * Wrapper around {@link ArtifactResolver#resolve(Artifact, List, ArtifactRepository)}
 *
 * @param artifactResolver see {@link ArtifactResolver#resolve(Artifact, List, ArtifactRepository)}
 * @param artifact         see {@link ArtifactResolver#resolve(Artifact, List, ArtifactRepository)}
 * @param remoteRepos      see {@link ArtifactResolver#resolve(Artifact, List, ArtifactRepository)}
 * @param localRepository  see {@link ArtifactResolver#resolve(Artifact, List, ArtifactRepository)}
 * @param log              Logger//from   ww w .j  a v a2 s.  c  o  m
 * @return the artifact, resolved if possible.
 */
public static Artifact resolveArtifact(ArtifactResolver artifactResolver, Artifact artifact, List remoteRepos,
        ArtifactRepository localRepository, Log log)

{
    try {
        artifactResolver.resolve(artifact, remoteRepos, localRepository);
    } catch (ArtifactNotFoundException e) {
        // ignore, the jar has not been found

        /*
         * This method gets called with no remote repositories to avoid remote trips (which would ideally be
         * realized by means of a per-request offline flag), the set of available remote repos can however affect
         * the resolution from the local repo as well, in particular in Maven 3. So double check whether the local
         * file is really not present.
         */
        if (artifact.getFile() != null && artifact.getFile().isFile()) {
            artifact.setResolved(true);
        }
    } catch (ArtifactResolutionException e) {
        String message = Messages.getString("IdeUtils.errorresolving",
                new Object[] { artifact.getClassifier(), artifact.getId(), e.getMessage() });

        log.warn(message);
    }

    return artifact;
}