Search in sources :

Example 1 with Log

use of org.apache.maven.plugin.logging.Log in project jangaroo-tools by CoreMedia.

the class AbstractCompilerMojo method buildOutputFile.

private void buildOutputFile(File tempOutputDir, File outputFile) throws MojoExecutionException {
    final Log log = getLog();
    if (log.isDebugEnabled()) {
        log.debug("Output file: " + outputFile);
    }
    try {
        // If the directory where the output file is going to land
        // doesn't exist then create it.
        File outputFileDirectory = outputFile.getParentFile();
        if (!outputFileDirectory.exists()) {
            //noinspection ResultOfMethodCallIgnored
            if (outputFileDirectory.mkdirs()) {
                log.debug("created output directory " + outputFileDirectory);
            }
        }
        @SuppressWarnings({ "unchecked" }) List<File> // resource bundle classes should always be loaded dynamically:
        files = FileUtils.getFiles(tempOutputDir, "**/*.js", "**/*_properties_*.js");
        // We should now have all the files we want to concat so let's do it.
        Writer fos = new OutputStreamWriter(new FileOutputStream(outputFile), "UTF-8");
        int tempOutputDirPathLength = tempOutputDir.getAbsolutePath().length() + 1;
        for (File file : files) {
            String className = file.getAbsolutePath();
            className = className.substring(tempOutputDirPathLength, className.length() - ".js".length());
            className = className.replace(File.separatorChar, '.');
            fos.write("// class " + className + "\n");
            IOUtil.copy(new FileInputStream(file), fos, "UTF-8");
            fos.write('\n');
        }
        fos.close();
    } catch (IOException e) {
        throw new MojoExecutionException("could not build output file " + outputFile + ": " + e.toString(), e);
    }
}
Also used : MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) AbstractCompileLog(net.jangaroo.jooc.AbstractCompileLog) Log(org.apache.maven.plugin.logging.Log) FileOutputStream(java.io.FileOutputStream) OutputStreamWriter(java.io.OutputStreamWriter) IOException(java.io.IOException) File(java.io.File) OutputStreamWriter(java.io.OutputStreamWriter) Writer(java.io.Writer) FileInputStream(java.io.FileInputStream)

Example 2 with Log

use of org.apache.maven.plugin.logging.Log in project maven-plugins by apache.

the class AbstractAssemblyMojo method isThisTheExecutionRoot.

/**
     * Returns true if the current project is located at the Execution Root Directory (where mvn was launched)
     *
     * @return if this is the execution root
     */
boolean isThisTheExecutionRoot() {
    final Log log = getLog();
    log.debug("Root Folder:" + mavenSession.getExecutionRootDirectory());
    log.debug("Current Folder:" + basedir);
    final boolean result = mavenSession.getExecutionRootDirectory().equalsIgnoreCase(basedir.toString());
    if (result) {
        log.debug("This is the execution root.");
    } else {
        log.debug("This is NOT the execution root.");
    }
    return result;
}
Also used : Log(org.apache.maven.plugin.logging.Log)

Example 3 with Log

use of org.apache.maven.plugin.logging.Log in project maven-plugins by apache.

the class AbstractJavadocMojoTest method testMJAVADOC432_DetectLinksMessages.

public void testMJAVADOC432_DetectLinksMessages() {
    Log log = mock(Log.class);
    when(log.isErrorEnabled()).thenReturn(true);
    mojo.setLog(log);
    mojo.outputDirectory = new File("target/test-classes");
    // first continues after warning, next exits with warning
    assertFalse(mojo.isValidJavadocLink(new File("pom.xml").getPath(), true));
    assertFalse(mojo.isValidJavadocLink("file://%%", true));
    assertFalse(mojo.isValidJavadocLink(new File("pom.xml").toURI().toString(), true));
    verify(log, times(4)).warn(anyString());
    verify(log, never()).error(anyString());
    // first continues after error, next exits with error
    assertFalse(mojo.isValidJavadocLink(new File("pom.xml").getPath(), false));
    assertFalse(mojo.isValidJavadocLink("file://%%", false));
    assertFalse(mojo.isValidJavadocLink(new File("pom.xml").toURI().toString(), false));
    verify(log, times(4)).error(anyString());
    // no extra warnings
    verify(log, times(4)).warn(anyString());
}
Also used : Log(org.apache.maven.plugin.logging.Log) File(java.io.File)

Example 4 with Log

use of org.apache.maven.plugin.logging.Log in project maven-plugins by apache.

the class GitHubDownloaderTestCase method testConfigureAuthenticationWithNoServer.

public void testConfigureAuthenticationWithNoServer() throws Exception {
    IssueManagement issueManagement = newGitHubIssueManagement();
    GitHubDownloader gitHubDownloader = newGitHubDownloader(issueManagement);
    Settings settings = new Settings();
    Server server = newServer("not-the-right-one");
    settings.addServer(server);
    SettingsDecrypter decrypter = mock(SettingsDecrypter.class);
    SettingsDecryptionResult result = mock(SettingsDecryptionResult.class);
    Log log = mock(Log.class);
    when(result.getProblems()).thenReturn(Collections.<SettingsProblem>emptyList());
    when(result.getServer()).thenReturn(server);
    when(decrypter.decrypt(new DefaultSettingsDecryptionRequest(server))).thenReturn(result);
    gitHubDownloader.configureAuthentication(decrypter, "github-server", settings, log);
    verify(log).warn("Can't find server id [github-server] configured in githubAPIServerId.");
}
Also used : Server(org.apache.maven.settings.Server) SettingsDecrypter(org.apache.maven.settings.crypto.SettingsDecrypter) Log(org.apache.maven.plugin.logging.Log) DefaultSettingsDecryptionRequest(org.apache.maven.settings.crypto.DefaultSettingsDecryptionRequest) SettingsDecryptionResult(org.apache.maven.settings.crypto.SettingsDecryptionResult) IssueManagement(org.apache.maven.model.IssueManagement) Settings(org.apache.maven.settings.Settings)

Example 5 with Log

use of org.apache.maven.plugin.logging.Log in project maven-plugins by apache.

the class MinijarFilterTest method finsishedShouldProduceMessageForClassesTotalNonZero.

@Test
public void finsishedShouldProduceMessageForClassesTotalNonZero() {
    ArgumentCaptor<CharSequence> logCaptor = ArgumentCaptor.forClass(CharSequence.class);
    Log log = mock(Log.class);
    MinijarFilter m = new MinijarFilter(1, 50, log);
    m.finished();
    verify(log, times(1)).info(logCaptor.capture());
    assertEquals("Minimized 51 -> 1 (1%)", logCaptor.getValue());
}
Also used : Log(org.apache.maven.plugin.logging.Log) Test(org.junit.Test)

Aggregations

Log (org.apache.maven.plugin.logging.Log)20 File (java.io.File)7 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)5 Test (org.junit.Test)4 IOException (java.io.IOException)3 ArrayList (java.util.ArrayList)3 AbstractCompileLog (net.jangaroo.jooc.AbstractCompileLog)3 MojoFailureException (org.apache.maven.plugin.MojoFailureException)3 Entry (java.util.Map.Entry)2 IssueManagement (org.apache.maven.model.IssueManagement)2 SilentLog (org.apache.maven.plugin.testing.SilentLog)2 MavenProject (org.apache.maven.project.MavenProject)2 Server (org.apache.maven.settings.Server)2 Settings (org.apache.maven.settings.Settings)2 DefaultSettingsDecryptionRequest (org.apache.maven.settings.crypto.DefaultSettingsDecryptionRequest)2 SettingsDecrypter (org.apache.maven.settings.crypto.SettingsDecrypter)2 SettingsDecryptionResult (org.apache.maven.settings.crypto.SettingsDecryptionResult)2 FileInputStream (java.io.FileInputStream)1 FileOutputStream (java.io.FileOutputStream)1 OutputStreamWriter (java.io.OutputStreamWriter)1