@Override public void onExistingHeader(Document document, Header header) { debug("Header OK in: %s", document.getFilePath()); } };
@Override public void onExistingHeader(Document document, Header header) { debug("Header OK in: %s", document.getFilePath()); } };
@Override public void run() { Document document = documentFactory.createDocuments(file); debug("Selected file: %s [header style: %s]", document.getFilePath(), document.getHeaderDefinition()); if (document.isNotSupported()) { callback.onUnknownFile(document, h); } else if (document.is(h)) { debug("Skipping header file: %s", document.getFilePath()); } else if (document.hasHeader(h, strictCheck)) { callback.onExistingHeader(document, h); } else { boolean headerFound = false; for (Header validHeader : validHeaders) { if (headerFound = document.hasHeader(validHeader, strictCheck)) { callback.onExistingHeader(document, h); break; } } if (!headerFound) { callback.onHeaderNotFound(document, h); } } } }, null);
private void remove(Document document) { document.parseHeader(); if (document.headerDetected()) document.removeHeader(); if (!dryRun) { document.save(); } else { String name = document.getFile().getName() + ".licensed"; File copy = new File(document.getFile().getParentFile(), name); info("Result saved to: %s", copy); document.saveTo(copy); } }
@Override public void onHeaderNotFound(Document document, Header header) { if (skipExistingHeaders) { document.parseHeader(); if (document.headerDetected()) { debug("Existing header in: %s", document.getFilePath()); return; } } warn("Missing header in: %s", document.getFilePath()); missingHeaders.add(document.getFile()); }
@Override public void onUnknownFile(Document document, Header header) { warn("Unknown file extension: %s", document.getFilePath()); unknownFiles.add(document.getFile()); }
private String[] listSelectedFiles() { Selection selection = new Selection(basedir, includes, buildExcludes(), useDefaultExcludes); debug("From: %s", basedir); debug("Including: %s", deepToString(selection.getIncluded())); debug("Excluding: %s", deepToString(selection.getExcluded())); return selection.getSelectedFiles(); }
/** * Retrieves the credentials for the given server or null if none could be * found * * @param serverID * @return */ public Credentials findCredentials(String serverID) { List<Server> decryptedServers = getDecryptedServers(); for (Server ds : decryptedServers) { if (ds.getId().equals(serverID)) { getLog().debug("credentials have been found for server: " + serverID + ", login:" + ds.getUsername() + ", password:" + starEncrypt(ds.getPassword())); return new Credentials(ds.getUsername(), ds.getPassword()); } } getLog().debug("no credentials found for server: " + serverID); return null; }
@Override public void execute() throws MojoExecutionException, MojoFailureException { if(!skip) { getLog().info("Removing license headers..."); } AbstractCallback callback = new AbstractCallback() { @Override public void onHeaderNotFound(Document document, Header header) { debug("Header was not found in: %s (But keep trying to find another header to remove)", document.getFile()); remove(document); } @Override public void onExistingHeader(Document document, Header header) { info("Removing license header from: %s", document.getFile()); remove(document); } }; execute(callback); callback.checkUnknown(); }
@Override public void execute() throws MojoExecutionException, MojoFailureException { if(!skip) { getLog().info("Updating license headers..."); execute(callback); callback.checkUnknown();
private void setSVNClientManager(AbstractLicenseMojo mojo, String svnServerID) { SVNClientManager c = svnClientThreadLocal.get(); if (c == null) { Credentials svnCredentials = mojo.findCredentials(svnServerID); if (svnCredentials == null) { c = SVNClientManager.newInstance(new DefaultSVNOptions()); } else { c = SVNClientManager.newInstance(new DefaultSVNOptions(), svnCredentials.getLogin(), svnCredentials.getPassword()); } svnClientThreadLocal.set(c); } }
public final void info(String format, Object... params) { if (!quiet) { getLog().info(format(format, params)); } }
private Node findSingleChild( Node node, String elementName ) throws MojoExecutionException { List<Node> elementsByTagName = findNamedChild( node, elementName ); if ( elementsByTagName.isEmpty() ) { return null; } if ( elementsByTagName.size() > 1 ) { throw new MojoExecutionException( "Multiple " + elementName + "in plugin-help.xml" ); } return elementsByTagName.get( 0 ); }
private String getValue( Node node, String elementName ) throws MojoExecutionException { return getSingleChild( node, elementName ).getTextContent(); }
/** * Append a description to the buffer by respecting the indentSize and lineLength parameters. * <b>Note</b>: The last character is always a new line. * * @param sb The buffer to append the description, not <code>null</code>. * @param description The description, not <code>null</code>. * @param indent The base indentation level of each line, must not be negative. */ private void append( StringBuilder sb, String description, int indent ) { for ( String line : toLines( description, indent, indentSize, lineLength ) ) { sb.append( line ).append( '\n' ); } }
public final void debug(String format, Object... params) { if (!quiet) { getLog().debug(format(format, params)); } }
private Node getSingleChild( Node node, String elementName ) throws MojoExecutionException { List<Node> namedChild = findNamedChild( node, elementName ); if ( namedChild.isEmpty() ) { throw new MojoExecutionException( "Could not find " + elementName + " in plugin-help.xml" ); } if ( namedChild.size() > 1 ) { throw new MojoExecutionException( "Multiple " + elementName + " in plugin-help.xml" ); } return namedChild.get( 0 ); }
public final void warn(String format, Object... params) { if (!quiet) { getLog().warn(format(format, params)); } }