From a97d2c209f0372487ca6a4fe955f1c3f58f2a474 Mon Sep 17 00:00:00 2001
From: Gaetan Boismal <gaetan.boismal@forgerock.com>
Date: Wed, 09 Mar 2016 17:40:33 +0000
Subject: [PATCH] OPENDJSDK-88 Move opendj-copyright-maven-plugin
---
/dev/null | 28 ----------------------------
opendj-sdk/opendj-sdk-parent/pom.xml | 1 -
2 files changed, 0 insertions(+), 29 deletions(-)
diff --git a/opendj-sdk/opendj-copyright-maven-plugin/pom.xml b/opendj-sdk/opendj-copyright-maven-plugin/pom.xml
deleted file mode 100644
index 606c33a..0000000
--- a/opendj-sdk/opendj-copyright-maven-plugin/pom.xml
+++ /dev/null
@@ -1,108 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- The contents of this file are subject to the terms of the Common Development and
- Distribution License (the License). You may not use this file except in compliance with the
- License.
-
- You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the
- specific language governing permission and limitations under the License.
-
- When distributing Covered Software, include this CDDL Header Notice in each file and include
- the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL
- Header, with the fields enclosed by brackets [] replaced by your own identifying
- information: "Portions Copyright [year] [name of copyright owner]".
-
- Copyright 2015 ForgeRock AS.
- -->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <artifactId>opendj-sdk-parent</artifactId>
- <groupId>org.forgerock.opendj</groupId>
- <version>4.0.0-SNAPSHOT</version>
- <relativePath>../opendj-sdk-parent/pom.xml</relativePath>
- </parent>
-
- <artifactId>opendj-copyright-maven-plugin</artifactId>
- <name>OpenDJ Copyright Check Maven Plugin</name>
- <description>Checks ForgeRock source file copyrights.</description>
-
- <packaging>maven-plugin</packaging>
-
-
- <properties>
- <maven.version>3.2.3</maven.version>
- <maven-plugin-plugin.version>3.2</maven-plugin-plugin.version>
- </properties>
-
-
- <dependencies>
- <!-- Maven -->
- <dependency>
- <groupId>org.apache.maven</groupId>
- <artifactId>maven-core</artifactId>
- <version>${maven.version}</version>
- <scope>provided</scope>
- </dependency>
-
- <dependency>
- <groupId>org.apache.maven</groupId>
- <artifactId>maven-model</artifactId>
- <version>${maven.version}</version>
- <scope>provided</scope>
- </dependency>
-
- <dependency>
- <groupId>org.apache.maven</groupId>
- <artifactId>maven-plugin-api</artifactId>
- <version>${maven.version}</version>
- <scope>provided</scope>
- </dependency>
-
- <dependency>
- <groupId>org.apache.maven.plugin-tools</groupId>
- <artifactId>maven-plugin-annotations</artifactId>
- <version>${maven-plugin-plugin.version}</version>
- <scope>provided</scope>
- </dependency>
-
- <!-- Testing -->
- <dependency>
- <groupId>org.forgerock</groupId>
- <artifactId>forgerock-build-tools</artifactId>
- <scope>test</scope>
- </dependency>
-
- <!-- Other -->
- <dependency>
- <groupId>org.twdata.maven</groupId>
- <artifactId>mojo-executor</artifactId>
- <version>2.2.0</version>
- </dependency>
-
- <!-- Runtime -->
- <dependency>
- <groupId>org.forgerock.commons</groupId>
- <artifactId>forgerock-util</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.apache.maven.scm</groupId>
- <artifactId>maven-scm-api</artifactId>
- <version>1.9.2</version>
- </dependency>
-
- <dependency>
- <groupId>org.apache.maven.scm</groupId>
- <artifactId>maven-scm-provider-svn-commons</artifactId>
- <version>1.9.2</version>
- </dependency>
-
- <dependency>
- <groupId>org.apache.maven.scm</groupId>
- <artifactId>maven-scm-provider-gitexe</artifactId>
- <version>1.9.2</version>
- </dependency>
- </dependencies>
-</project>
diff --git a/opendj-sdk/opendj-copyright-maven-plugin/src/main/java/org/forgerock/maven/CheckCopyrightMojo.java b/opendj-sdk/opendj-copyright-maven-plugin/src/main/java/org/forgerock/maven/CheckCopyrightMojo.java
deleted file mode 100644
index 6276f57..0000000
--- a/opendj-sdk/opendj-copyright-maven-plugin/src/main/java/org/forgerock/maven/CheckCopyrightMojo.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * The contents of this file are subject to the terms of the Common Development and
- * Distribution License (the License). You may not use this file except in compliance with the
- * License.
- *
- * You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the
- * specific language governing permission and limitations under the License.
- *
- * When distributing Covered Software, include this CDDL Header Notice in each file and include
- * the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL
- * Header, with the fields enclosed by brackets [] replaced by your own identifying
- * information: "Portions Copyright [year] [name of copyright owner]".
- *
- * Copyright 2015-2016 ForgeRock AS.
- */
-package org.forgerock.maven;
-
-import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.plugin.MojoFailureException;
-import org.apache.maven.plugins.annotations.LifecyclePhase;
-import org.apache.maven.plugins.annotations.Mojo;
-import org.apache.maven.plugins.annotations.Parameter;
-
-/**
- * This be used to check that if a modified file contains a line that appears to
- * be a comment and includes the word "copyright", then it should contain the
- * current year.
- */
-@Mojo(name = "check-copyright", defaultPhase = LifecyclePhase.VALIDATE)
-public class CheckCopyrightMojo extends CopyrightAbstractMojo {
- private static final String IGNORE_COPYRIGHT_ERRORS_PROPERTY = "ignoreCopyrightErrors";
-
- /**
- * The property that may be used to prevent copyright date problems from
- * failing the build.
- */
- @Parameter(required = true, property = IGNORE_COPYRIGHT_ERRORS_PROPERTY, defaultValue = "false")
- private boolean ignoreCopyrightErrors;
-
- @Parameter(required = true, property = "skipCopyrightCheck", defaultValue = "false")
- private boolean checkDisabled;
-
- /**
- * Uses maven-scm API to identify all modified files in the current
- * workspace. For all source files, check if the copyright is up to date.
- *
- * @throws MojoFailureException
- * if any
- * @throws MojoExecutionException
- * if any
- */
- @Override
- public void execute() throws MojoFailureException, MojoExecutionException {
- if (checkDisabled) {
- getLog().info("Copyright check is disabled");
- return;
- }
-
- checkCopyrights();
- if (!getIncorrectCopyrightFilePaths().isEmpty()) {
- getLog().warn("Potential copyright year updates needed for the following files:");
- for (String filename : getIncorrectCopyrightFilePaths()) {
- getLog().warn(" " + filename);
- }
-
- if (!ignoreCopyrightErrors) {
- getLog().warn("Fix copyright date problems before proceeding, "
- + "or use '-D" + IGNORE_COPYRIGHT_ERRORS_PROPERTY + "=true' to ignore copyright errors.");
- getLog().warn("You can use update-copyrights maven profile "
- + "(mvn validate -Pupdate-copyrights) to automatically update copyrights.");
- getLog().warn("Use '-D" + DIFF_REFERENCE_BRANCH_NAME_PROPERTY + "=branchname' to change the reference "
- + "branch which is used against your active local branch to check committed changes.");
- throw new MojoExecutionException("Found files with potential copyright year updates needed");
- }
- } else {
- getLog().info("Copyrights are up to date");
- }
- }
-}
diff --git a/opendj-sdk/opendj-copyright-maven-plugin/src/main/java/org/forgerock/maven/CopyrightAbstractMojo.java b/opendj-sdk/opendj-copyright-maven-plugin/src/main/java/org/forgerock/maven/CopyrightAbstractMojo.java
deleted file mode 100644
index f76d085..0000000
--- a/opendj-sdk/opendj-copyright-maven-plugin/src/main/java/org/forgerock/maven/CopyrightAbstractMojo.java
+++ /dev/null
@@ -1,415 +0,0 @@
-/*
- * The contents of this file are subject to the terms of the Common Development and
- * Distribution License (the License). You may not use this file except in compliance with the
- * License.
- *
- * You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the
- * specific language governing permission and limitations under the License.
- *
- * When distributing Covered Software, include this CDDL Header Notice in each file and include
- * the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL
- * Header, with the fields enclosed by brackets [] replaced by your own identifying
- * information: "Portions Copyright [year] [name of copyright owner]".
- *
- * Copyright 2015-2016 ForgeRock AS.
- */
-package org.forgerock.maven;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileReader;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Calendar;
-import java.util.LinkedList;
-import java.util.List;
-
-import org.apache.maven.plugin.AbstractMojo;
-import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.plugin.MojoFailureException;
-import org.apache.maven.plugins.annotations.Parameter;
-import org.apache.maven.project.MavenProject;
-import org.apache.maven.scm.ScmException;
-import org.apache.maven.scm.ScmFile;
-import org.apache.maven.scm.ScmFileSet;
-import org.apache.maven.scm.ScmFileStatus;
-import org.apache.maven.scm.ScmResult;
-import org.apache.maven.scm.ScmVersion;
-import org.apache.maven.scm.command.diff.DiffScmResult;
-import org.apache.maven.scm.command.status.StatusScmResult;
-import org.apache.maven.scm.log.ScmLogDispatcher;
-import org.apache.maven.scm.log.ScmLogger;
-import org.apache.maven.scm.manager.BasicScmManager;
-import org.apache.maven.scm.manager.NoSuchScmProviderException;
-import org.apache.maven.scm.manager.ScmManager;
-import org.apache.maven.scm.provider.ScmProviderRepository;
-import org.apache.maven.scm.provider.git.command.GitCommand;
-import org.apache.maven.scm.provider.git.command.diff.GitDiffConsumer;
-import org.apache.maven.scm.provider.git.gitexe.GitExeScmProvider;
-import org.apache.maven.scm.provider.git.gitexe.command.GitCommandLineUtils;
-import org.apache.maven.scm.provider.git.gitexe.command.diff.GitDiffCommand;
-import org.apache.maven.scm.repository.ScmRepository;
-import org.apache.maven.scm.repository.ScmRepositoryException;
-import org.codehaus.plexus.util.cli.CommandLineUtils;
-import org.codehaus.plexus.util.cli.CommandLineUtils.StringStreamConsumer;
-import org.codehaus.plexus.util.cli.Commandline;
-
-/**
- * Abstract class which is used for both copyright checks and updates.
- */
-public abstract class CopyrightAbstractMojo extends AbstractMojo {
- static final String DIFF_REFERENCE_BRANCH_NAME_PROPERTY = "checkCopyrightDiffReferenceBranchName";
-
- /** The Maven Project. */
- @Parameter(required = true, property = "project", readonly = true)
- private MavenProject project;
-
- /**
- * Copyright owner.
- * This string token must be present on the same line with 'copyright' keyword and the current year.
- */
- @Parameter(required = true, defaultValue = "ForgeRock AS")
- private String copyrightOwnerToken;
-
- /** The path to the root of the scm local workspace to check. */
- @Parameter(required = true, defaultValue = "${basedir}")
- private String baseDir;
-
- @Parameter(required = true, defaultValue = "${project.scm.connection}")
- private String scmRepositoryUrl;
-
- /** The Git master branch name of the repository. **/
- @Parameter(required = true, property = DIFF_REFERENCE_BRANCH_NAME_PROPERTY, defaultValue = "origin/master")
- private String gitMasterBranchName;
-
- /**
- * List of file patterns for which copyright check and/or update will be skipped.
- * Pattern can contain the following wildcards (*, ?, **{@literal /}).
- */
- @Parameter(required = false)
- private List<String> disabledFiles;
-
- /** The file extensions to test. */
- public static final List<String> CHECKED_EXTENSIONS = Arrays.asList(
- "bat", "c", "fml", "h", "html", "java", "java.stub", "ldif", "mc",
- "md", "properties", "security", "sh", "txt", "xjb", "xml", "xml.vm", "xsd", "xsl");
-
- private final class CustomGitExeScmProvider extends GitExeScmProvider {
- @Override
- protected GitCommand getDiffCommand() {
- return new CustomGitDiffCommand();
- }
- }
-
- private class CustomGitDiffCommand extends GitDiffCommand implements GitCommand {
- @Override
- protected DiffScmResult executeDiffCommand(ScmProviderRepository repo, ScmFileSet fileSet,
- ScmVersion unused, ScmVersion unused2) throws ScmException {
- final GitDiffConsumer consumer = new GitDiffConsumer(getLogger(), fileSet.getBasedir());
- final StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer();
- final Commandline cl = GitCommandLineUtils.getBaseGitCommandLine(fileSet.getBasedir(), "diff");
- cl.addArguments(new String[] { "--no-ext-diff", "--relative", gitMasterBranchName + "...HEAD", "." });
-
- if (GitCommandLineUtils.execute(cl, consumer, stderr, getLogger()) != 0) {
- return new DiffScmResult(cl.toString(), "The git-diff command failed.", stderr.getOutput(), false);
- }
- return new DiffScmResult(
- cl.toString(), consumer.getChangedFiles(), consumer.getDifferences(), consumer.getPatch());
- }
-
- }
-
- private static String resolveExtension(final String filePath) {
- int firstPeriodPos = filePath.indexOf('.');
- if (firstPeriodPos > 0) {
- return filePath.substring(firstPeriodPos + 1);
- }
- return "";
- }
-
- enum CommentParser {
- BAT("rem"),
- DEFAULT("#", "*", "!", "//"),
- JAVA("/*", "*/", Arrays.asList("*", "//", "")),
- MC(";"),
- SH("#"),
- XML("<!--", "-->", Arrays.asList("!", "~", ""));
-
- static CommentParser createParserForFile(final String filePath) {
- switch (resolveExtension(filePath)) {
- case "java":
- case "c":
- case "h":
- return JAVA;
- case "fml":
- case "html":
- case "md":
- case "xjb":
- case "xml":
- case "xml.vm":
- case "xsd":
- case "xsl":
- return XML;
- case "bat":
- return BAT;
- case "security":
- case "sh":
- case "ldif":
- case "properties":
- return SH;
- case "mc":
- return MC;
- default:
- return DEFAULT;
- }
- }
-
- private final String startBlock;
- private final String endBlock;
- private final List<String> middleBlockTokens;
- private String currentLine = "";
- private boolean supportCommentBlocks;
- private boolean commentBlockOpened;
-
- CommentParser(final String... middleBlockTokens) {
- this(null, null, Arrays.asList(middleBlockTokens));
- }
-
- CommentParser(final String startBlock, final String endBlock, final List<String> middleBlockTokens) {
- this.startBlock = startBlock;
- this.endBlock = endBlock;
- this.middleBlockTokens = middleBlockTokens;
- this.supportCommentBlocks = startBlock != null && endBlock != null;
- }
-
- void consumeLine(final String line) {
- if (line != null) {
- if (supportCommentBlocks && currentLine.endsWith(endBlock)) {
- commentBlockOpened = false;
- }
- currentLine = line.trim();
- if (supportCommentBlocks && currentLine.startsWith(startBlock)) {
- commentBlockOpened = true;
- }
- }
- }
-
- boolean isCommentLine() {
- return commentBlockOpened
- || startsWithCommentLineToken();
- }
-
- private boolean startsWithCommentLineToken() {
- return getCommentTokenInLine(currentLine) != null;
- }
-
- private String getCommentTokenInLine(final String line) {
- for (final String token : middleBlockTokens) {
- if (line.startsWith(token)) {
- return token;
- }
- }
- return null;
- }
-
- String getNewCommentedLine(final String line) throws Exception {
- final String commentToken = getCommentTokenInLine(line.trim());
- if (commentToken == null) {
- throw new Exception("Incompatibles comments lines in the file.");
- }
-
- String resultLine = "";
- if (commentToken.isEmpty()) {
- resultLine = " ";
- }
- return resultLine + line.substring(0, line.indexOf(commentToken) + commentToken.length());
- }
-
- boolean isNonEmptyCommentedLine() {
- final String commentToken = getCommentTokenInLine(currentLine);
- return commentToken == null || !commentToken.equals(currentLine);
- }
- }
-
- /** The string representation of the current year. */
- Integer currentYear = Calendar.getInstance().get(Calendar.YEAR);
-
- private final List<String> incorrectCopyrightFilePaths = new LinkedList<>();
-
- /** The overall SCM Client Manager. */
- private ScmManager scmManager;
-
- private ScmRepository scmRepository;
-
- List<String> getIncorrectCopyrightFilePaths() {
- return incorrectCopyrightFilePaths;
- }
-
- private ScmManager getScmManager() throws MojoExecutionException {
- if (scmManager == null) {
- scmManager = new BasicScmManager();
- String scmProviderID = getScmProviderID();
- if (!"git".equals(scmProviderID)) {
- throw new MojoExecutionException(
- "Unsupported scm provider: " + scmProviderID + " or " + getIncorrectScmRepositoryUrlMsg());
- }
- scmManager.setScmProvider(scmProviderID, new CustomGitExeScmProvider());
- }
-
- return scmManager;
- }
-
- private String getScmProviderID() throws MojoExecutionException {
- try {
- return scmRepositoryUrl.split(":")[1];
- } catch (Exception e) {
- throw new MojoExecutionException(getIncorrectScmRepositoryUrlMsg(), e);
- }
- }
-
- String getIncorrectScmRepositoryUrlMsg() {
- return "the scmRepositoryUrl property with value '" + scmRepositoryUrl + "' is incorrect. "
- + "The URL has to respect the format: scm:[provider]:[provider_specific_url]";
- }
-
- ScmRepository getScmRepository() throws MojoExecutionException {
- if (scmRepository == null) {
- try {
- scmRepository = getScmManager().makeScmRepository(scmRepositoryUrl);
- } catch (NoSuchScmProviderException e) {
- throw new MojoExecutionException("Could not find a provider.", e);
- } catch (ScmRepositoryException e) {
- throw new MojoExecutionException("Error while connecting to the repository", e);
- }
- }
-
- return scmRepository;
- }
-
- String getBaseDir() {
- return baseDir;
- }
-
- /**
- * Performs a diff with current working directory state against remote HEAD revision.
- * Then do a status to check uncommited changes as well.
- */
- List<File> getChangedFiles() throws MojoExecutionException, MojoFailureException {
- try {
- final ScmFileSet workspaceFileSet = new ScmFileSet(new File(getBaseDir()));
- final DiffScmResult diffMasterHeadResult = getScmManager().diff(
- getScmRepository(), workspaceFileSet, null, null);
- ensureCommandSuccess(diffMasterHeadResult, "diff " + gitMasterBranchName + "...HEAD .");
-
- final StatusScmResult statusResult = getScmManager().status(getScmRepository(), workspaceFileSet);
- ensureCommandSuccess(statusResult, "status");
-
- final List<File> changedFilePaths = new ArrayList<>();
- addToChangedFiles(diffMasterHeadResult.getChangedFiles(), getBaseDir(), changedFilePaths);
- final String localScmRootPath = getLocalScmRootPath(new File(getBaseDir()));
- addToChangedFiles(statusResult.getChangedFiles(), localScmRootPath, changedFilePaths);
-
- return changedFilePaths;
- } catch (ScmException e) {
- throw new MojoExecutionException("Encountered an error while examining modified files, SCM status: "
- + e.getMessage() + "No further checks will be performed.", e);
- }
- }
-
- private String getLocalScmRootPath(final File basedir) throws ScmException {
- final Commandline cl = GitCommandLineUtils.getBaseGitCommandLine(basedir, "rev-parse");
- cl.addArguments(new String[] { "--show-toplevel" });
-
- final StringStreamConsumer stdout = new CommandLineUtils.StringStreamConsumer();
- final StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer();
- final ScmLogger dummyLogger = new ScmLogDispatcher();
-
- final int exitCode = GitCommandLineUtils.execute(cl, stdout, stderr, dummyLogger);
- return exitCode == 0 ? stdout.getOutput().trim().replace(" ", "%20")
- : basedir.getPath();
- }
-
- private void ensureCommandSuccess(final ScmResult result, final String cmd) throws MojoFailureException {
- if (!result.isSuccess()) {
- final String message = "Impossible to perform scm " + cmd + " command because " + result.getCommandOutput();
- getLog().error(message);
- throw new MojoFailureException(message);
- }
- }
-
- private void addToChangedFiles(
- final List<ScmFile> scmChangedFiles, final String rootPath, final List<File> changedFiles) {
- for (final ScmFile scmFile : scmChangedFiles) {
- final String scmFilePath = scmFile.getPath();
- final File file = new File(rootPath, scmFilePath);
-
- if (scmFile.getStatus() != ScmFileStatus.UNKNOWN
- && file.exists()
- && !changedFiles.contains(file)
- && !fileIsDisabled(scmFilePath)) {
- changedFiles.add(file);
- }
- }
- }
-
- private boolean fileIsDisabled(final String scmFilePath) {
- if (disabledFiles == null) {
- return false;
- }
- for (final String disableFile : disabledFiles) {
- String regexp = disableFile.replace("**/", "(.+/)+").replace("?", ".?").replace("*", ".*?");
- if (scmFilePath.matches(regexp)) {
- return true;
- }
- }
- return false;
- }
-
- /** Examines the provided files list to determine whether each changed file copyright is acceptable. */
- void checkCopyrights() throws MojoExecutionException, MojoFailureException {
- for (final File changedFile : getChangedFiles()) {
- if (!changedFile.exists()
- || !changedFile.isFile()
- || !CHECKED_EXTENSIONS.contains(resolveExtension(changedFile.getPath()).toLowerCase())
- || (fileNameEquals("bin", changedFile.getParentFile())
- && fileNameEquals("resource", changedFile.getParentFile().getParentFile()))) {
- // Verify that the file must be checked (ignore bin/resource directory)
- continue;
- }
-
- if (!checkCopyrightForFile(changedFile)) {
- incorrectCopyrightFilePaths.add(changedFile.getAbsolutePath());
- }
- }
- }
-
- private boolean fileNameEquals(String folderName, File file) {
- return file != null && folderName.equals(file.getName());
- }
-
- /**
- * Check to see whether the provided file has a comment line containing a
- * copyright without the current year.
- */
- private boolean checkCopyrightForFile(File changedFile) throws MojoExecutionException {
- try (BufferedReader reader = new BufferedReader(new FileReader(changedFile))) {
- final CommentParser commentParser = CommentParser.createParserForFile(changedFile.getPath());
- String line;
- while ((line = reader.readLine()) != null) {
- commentParser.consumeLine(line);
- if (commentParser.isCommentLine()
- && line.toLowerCase().trim().contains("copyright")
- && line.contains(currentYear.toString())
- && line.contains(copyrightOwnerToken)) {
- return true;
- }
- }
-
- return false;
- } catch (IOException ioe) {
- throw new MojoExecutionException("Could not read file " + changedFile.getPath()
- + " to check copyright date. No further copyright date checking will be performed.");
- }
- }
-}
diff --git a/opendj-sdk/opendj-copyright-maven-plugin/src/main/java/org/forgerock/maven/UpdateCopyrightMojo.java b/opendj-sdk/opendj-copyright-maven-plugin/src/main/java/org/forgerock/maven/UpdateCopyrightMojo.java
deleted file mode 100644
index a3d6abc..0000000
--- a/opendj-sdk/opendj-copyright-maven-plugin/src/main/java/org/forgerock/maven/UpdateCopyrightMojo.java
+++ /dev/null
@@ -1,432 +0,0 @@
-/*
- * The contents of this file are subject to the terms of the Common Development and
- * Distribution License (the License). You may not use this file except in compliance with the
- * License.
- *
- * You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the
- * specific language governing permission and limitations under the License.
- *
- * When distributing Covered Software, include this CDDL Header Notice in each file and include
- * the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL
- * Header, with the fields enclosed by brackets [] replaced by your own identifying
- * information: "Portions Copyright [year] [name of copyright owner]".
- *
- * Copyright 2015-2016 ForgeRock AS.
- */
-package org.forgerock.maven;
-
-import static java.util.regex.Pattern.*;
-
-import static org.apache.maven.plugins.annotations.LifecyclePhase.*;
-
-import java.io.BufferedReader;
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileReader;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.plugin.MojoFailureException;
-import org.apache.maven.plugins.annotations.Mojo;
-import org.apache.maven.plugins.annotations.Parameter;
-import org.forgerock.util.Utils;
-
-/**
- * This goals can be used to automatically updates copyrights of modified files.
- *
- * <p>
- * Copyright sections must respect the following format:
- * <pre>
- * (.)* //This line references 0..N lines.
- * [COMMMENT_CHAR][lineBeforeCopyrightRegExp]
- * [COMMMENT_CHAR]* //This line references 0..N commented empty lines.
- * ([COMMMENT_CHAR][oldCopyrightToken])*
- * ([COMMMENT_CHAR] [YEAR] [copyrightEndToken])?
- * </pre>
- * <p>
- * Formatter details:
- * <ul>
- * <li>COMMENT_CHAR: Auto-detected by plugin.
- * Comment character used in comment blocks ('*' for Java, '!' for xml...)</li>
- *
- * <li>lineBeforeCopyrightRegExp: Parameter regExp case insensitive
- * Used by the plugin to start it's inspection for the copyright line.
- * Next non blank commented lines after this lines must be
- * old copyright owner lines or/and old ForgeRock copyright lines.</li>
- *
- * <li>oldCopyrightToken: Detected by plugin ('copyright' keyword case insensitive)
- * If one line contains this token, the plugin will use
- * the newPortionsCopyrightLabel instead of the newCopyrightLabel
- * if there is no ForgeRock copyrighted line.</li>
- *
- * <li>forgerockCopyrightRegExp: Parameter regExp case insensitive
- * The regular expression which identifies a copyrighted line as a ForgeRock one.</li>
- *
- * <li>YEAR: Computed by plugin
- * Current year if there is no existing copyright line.
- * If the copyright section already exists, the year will be updated as follow:
- * <ul>
- * <li>OLD_YEAR => OLD_YEAR-CURRENT_YEAR</li>
- * <li>VERY_OLD_YEAR-OLD_YEAR => VERY_OLD_YEAR-CURRENT_YEAR</li>
- * </ul></li>
- * </ul>
- * </p>
- * <p>
- * If no ForgeRock copyrighted line is detected, the plugin will add according to the following format
- * <ul>
- * <li> If there is one or more old copyright lines:
- * <pre>
- * [COMMMENT_CHAR][lineBeforeCopyrightRegExp]
- * [COMMMENT_CHAR]* //This line references 0..N commented empty lines.
- * ([COMMMENT_CHAR][oldCopyrightToken])*
- * [indent][newPortionsCopyrightLabel] [YEAR] [forgerockCopyrightLabel]
- * </pre></li><br>
- * <li> If there is no old copyright lines:
- * <pre>
- * [COMMMENT_CHAR][lineBeforeCopyrightRegExp]
- * [COMMMENT_CHAR]*{nbLinesToSkip} //This line nbLinesToSkip commented empty lines.
- * [indent][newCopyrightLabel] [YEAR] [forgerockCopyrightLabel]
- * </pre></li>
- * </ul>
- *
- */
-@Mojo(name = "update-copyright", defaultPhase = VALIDATE)
-public class UpdateCopyrightMojo extends CopyrightAbstractMojo {
-
- private final class UpdateCopyrightFile {
- private final String filePath;
- private final List<String> bufferedLines = new LinkedList<>();
- private boolean copyrightUpdated;
- private boolean lineBeforeCopyrightReaded;
- private boolean commentBlockEnded;
- private boolean portionsCopyrightNeeded;
- private boolean copyrightSectionPresent;
- private CommentParser commentParser;
- private String curLine;
- private Integer startYear;
- private Integer endYear;
- private final BufferedReader reader;
- private final BufferedWriter writer;
-
- private UpdateCopyrightFile(String filePath) throws IOException {
- this.filePath = filePath;
- reader = new BufferedReader(new FileReader(filePath));
- commentParser = CommentParser.createParserForFile(filePath);
- final File tmpFile = new File(filePath + ".tmp");
- if (!tmpFile.exists()) {
- tmpFile.createNewFile();
- }
- writer = new BufferedWriter(new FileWriter(tmpFile));
- }
-
- private void updateCopyrightForFile() throws MojoExecutionException {
- try {
- readLineBeforeCopyrightToken();
- portionsCopyrightNeeded = readOldCopyrightLine();
- copyrightSectionPresent = readCopyrightLine();
- writeCopyrightLine();
- writeChanges();
- } catch (final Exception e) {
- throw new MojoExecutionException(e.getMessage(), e);
- } finally {
- Utils.closeSilently(reader, writer);
- }
- }
-
- private void writeChanges() throws Exception {
- while (curLine != null) {
- nextLine();
- }
- reader.close();
-
- for (final String line : bufferedLines) {
- writer.write(line);
- writer.newLine();
- }
- writer.close();
-
- if (!dryRun) {
- final File updatedFile = new File(filePath);
- if (!updatedFile.delete()) {
- throw new Exception("impossible to perform rename on the file.");
- }
- new File(filePath + ".tmp").renameTo(updatedFile);
- }
- }
-
- private void writeCopyrightLine() throws Exception {
- if (copyrightSectionPresent) {
- updateExistingCopyrightLine();
- copyrightUpdated = true;
- return;
- }
-
- int indexAdd = bufferedLines.size() - 1;
- final Pattern stopRegExp = portionsCopyrightNeeded ? OLD_COPYRIGHT_REGEXP
- : lineBeforeCopyrightCompiledRegExp;
- String previousLine = curLine;
- while (!lineMatches(previousLine, stopRegExp)) {
- indexAdd--;
- previousLine = bufferedLines.get(indexAdd);
- }
- indexAdd++;
- final String newCommentedLine = commentParser.getNewCommentedLine(previousLine);
- if (!portionsCopyrightNeeded) {
- for (int i = 0; i < nbLinesToSkip; i++) {
- if (!bufferedLines.get(indexAdd).equals(newCommentedLine)) {
- // We have a blank line already so do not add a new one.
- bufferedLines.add(indexAdd, newCommentedLine);
- }
- indexAdd++;
- }
- }
- final String newCopyrightLine = newCommentedLine
- + indent() + (portionsCopyrightNeeded ? newPortionsCopyrightLabel : newCopyrightLabel)
- + " " + currentYear + " " + forgeRockCopyrightLabel;
- bufferedLines.add(indexAdd, newCopyrightLine);
- copyrightUpdated = true;
- }
-
- private void updateExistingCopyrightLine() throws Exception {
- readYearSection();
- final String newCopyrightLine;
- if (endYear == null) {
- // OLD_YEAR => OLD_YEAR-CURRENT_YEAR
- newCopyrightLine = curLine.replace(startYear.toString(), intervalToString(startYear, currentYear));
- } else {
- // VERY_OLD_YEAR-OLD_YEAR => VERY_OLD_YEAR-CURRENT_YEAR
- newCopyrightLine = curLine.replace(intervalToString(startYear, endYear),
- intervalToString(startYear, currentYear));
- }
- bufferedLines.remove(bufferedLines.size() - 1);
- bufferedLines.add(newCopyrightLine);
- }
-
- private void readYearSection() throws Exception {
- final String copyrightLineRegExp = ".*\\s+(\\d{4})(-(\\d{4}))?\\s+" + forgerockCopyrightRegExp + ".*";
- final Matcher copyrightMatcher = Pattern.compile(copyrightLineRegExp, CASE_INSENSITIVE).matcher(curLine);
- if (copyrightMatcher.matches()) {
- startYear = Integer.parseInt(copyrightMatcher.group(1));
- final String endYearString = copyrightMatcher.group(3);
- if (endYearString != null) {
- endYear = Integer.parseInt(endYearString);
- }
- } else {
- throw new Exception("Malformed year section in copyright line " + curLine);
- }
- }
-
- private void readLineBeforeCopyrightToken() throws Exception {
- nextLine();
- while (curLine != null) {
- if (curLineMatches(lineBeforeCopyrightCompiledRegExp)) {
- if (!commentParser.isCommentLine()) {
- throw new Exception("The line before copyright token must be a commented line");
- }
- lineBeforeCopyrightReaded = true;
- return;
- } else if (commentBlockEnded) {
- throw new Exception("unexpected non commented line found before copyright section");
- }
- nextLine();
- }
- }
-
- private boolean readOldCopyrightLine() throws Exception {
- nextLine();
- while (curLine != null) {
- if (isOldCopyrightOwnerLine()) {
- return true;
- } else if (commentParser.isNonEmptyCommentedLine()
- || isCopyrightLine()
- || commentBlockEnded) {
- return false;
- }
- nextLine();
- }
- throw new Exception("unexpected end of file while trying to read copyright");
- }
-
- private boolean readCopyrightLine() throws Exception {
- while (curLine != null) {
- if (isCopyrightLine()) {
- return true;
- } else if ((commentParser.isNonEmptyCommentedLine() && !isOldCopyrightOwnerLine())
- || commentBlockEnded) {
- return false;
- }
- nextLine();
- }
- throw new Exception("unexpected end of file while trying to read copyright");
- }
-
- private boolean isOldCopyrightOwnerLine() {
- return curLineMatches(OLD_COPYRIGHT_REGEXP) && !curLineMatches(copyrightOwnerCompiledRegExp);
- }
-
- private boolean isCopyrightLine() {
- return curLineMatches(copyrightOwnerCompiledRegExp);
- }
-
- private boolean curLineMatches(Pattern compiledRegExp) {
- return lineMatches(curLine, compiledRegExp);
- }
-
- private boolean lineMatches(String line, Pattern compiledRegExp) {
- return compiledRegExp.matcher(line).matches();
- }
-
- private void nextLine() throws Exception {
- curLine = reader.readLine();
- commentParser.consumeLine(curLine);
- if (curLine == null && !copyrightUpdated) {
- throw new Exception("unexpected end of file while trying to read copyright");
- } else if (curLine != null) {
- bufferedLines.add(curLine);
- }
-
- if (!copyrightUpdated) {
- if (lineBeforeCopyrightReaded && !commentParser.isCommentLine()) {
- commentBlockEnded = true;
- }
- }
- }
- }
-
- private static final Pattern OLD_COPYRIGHT_REGEXP = Pattern.compile(".*copyright.*", CASE_INSENSITIVE);
-
- /**
- * Number of lines to add after the line which contains the lineBeforeCopyrightToken.
- * Used only if a new copyright line is needed.
- */
- @Parameter(required = true, defaultValue = "1")
- private Integer nbLinesToSkip;
-
- /**
- * Number of spaces to add after the comment line token before adding new
- * copyright section. Used only if a new copyright or portion copyright is
- * needed.
- */
- @Parameter(required = true, defaultValue = "1")
- private Integer numberSpaceIdentation;
-
- /** The last non empty commented line before the copyright section. */
- @Parameter(required = true, defaultValue = "\\\"Portions Copyright \\[year\\] \\[name of copyright owner\\]\\\"")
- private String lineBeforeCopyrightRegExp;
-
- /** The regular expression which identifies a copyrighted line. */
- @Parameter(required = true, defaultValue = "ForgeRock\\s+AS")
- private String forgerockCopyrightRegExp;
-
- /** Line to add if there is no existing copyright. */
- @Parameter(required = true, defaultValue = "Copyright")
- private String newCopyrightLabel;
-
- /** Portions copyright start line token. */
- @Parameter(required = true, defaultValue = "Portions Copyright")
- private String newPortionsCopyrightLabel;
-
- /** ForgeRock copyright label to print if a new (portions) copyright line is needed. */
- @Parameter(required = true, defaultValue = "ForgeRock AS.")
- private String forgeRockCopyrightLabel;
-
- /** A dry run will not change source code. It creates new files with '.tmp' extension. */
- @Parameter(required = true, defaultValue = "false")
- private boolean dryRun;
-
- /** RegExps corresponding to user token. */
- private Pattern lineBeforeCopyrightCompiledRegExp;
- private Pattern copyrightOwnerCompiledRegExp;
-
- private boolean buildOK = true;
-
-
- /**
- * Updates copyright of modified files.
- *
- * @throws MojoFailureException
- * if any
- * @throws MojoExecutionException
- * if any
- */
- @Override
- public void execute() throws MojoExecutionException, MojoFailureException {
- compileRegExps();
- checkCopyrights();
- for (final String filePath : getIncorrectCopyrightFilePaths()) {
- try {
- new UpdateCopyrightFile(filePath).updateCopyrightForFile();
- getLog().info("Copyright of file " + filePath + " has been successfully updated.");
- } catch (final Exception e) {
- getLog().error("Impossible to update copyright of file " + filePath);
- getLog().error(" Details: " + e.getMessage());
- getLog().error(" No modification has been performed on this file");
- buildOK = false;
- }
- }
-
- if (!buildOK) {
- throw new MojoFailureException("Error(s) occured while trying to update some copyrights.");
- }
- }
-
- private void compileRegExps() {
- lineBeforeCopyrightCompiledRegExp = compileRegExp(lineBeforeCopyrightRegExp);
- copyrightOwnerCompiledRegExp = compileRegExp(forgerockCopyrightRegExp);
- }
-
- private Pattern compileRegExp(String regExp) {
- return Pattern.compile(".*" + regExp + ".*", CASE_INSENSITIVE);
- }
-
- private String intervalToString(Integer startYear, Integer endYear) {
- return startYear + "-" + endYear;
- }
-
- private String indent() {
- String indentation = "";
- for (int i = 0; i < numberSpaceIdentation; i++) {
- indentation += " ";
- }
- return indentation;
- }
-
- // Setters to allow tests
-
- void setLineBeforeCopyrightToken(String lineBeforeCopyrightToken) {
- this.lineBeforeCopyrightRegExp = lineBeforeCopyrightToken;
- }
-
- void setNbLinesToSkip(Integer nbLinesToSkip) {
- this.nbLinesToSkip = nbLinesToSkip;
- }
-
- void setNumberSpaceIdentation(Integer numberSpaceIdentation) {
- this.numberSpaceIdentation = numberSpaceIdentation;
- }
-
- void setNewPortionsCopyrightString(String portionsCopyrightString) {
- this.newPortionsCopyrightLabel = portionsCopyrightString;
- }
-
- void setNewCopyrightOwnerString(String newCopyrightOwnerString) {
- this.forgeRockCopyrightLabel = newCopyrightOwnerString;
- }
-
- void setNewCopyrightStartToken(String copyrightStartString) {
- this.newCopyrightLabel = copyrightStartString;
- }
-
- void setCopyrightEndToken(String copyrightEndToken) {
- this.forgerockCopyrightRegExp = copyrightEndToken;
- }
-
- void setDryRun(final boolean dryRun) {
- this.dryRun = dryRun;
- }
-}
diff --git a/opendj-sdk/opendj-copyright-maven-plugin/src/main/java/org/forgerock/maven/package-info.java b/opendj-sdk/opendj-copyright-maven-plugin/src/main/java/org/forgerock/maven/package-info.java
deleted file mode 100644
index 97eece1..0000000
--- a/opendj-sdk/opendj-copyright-maven-plugin/src/main/java/org/forgerock/maven/package-info.java
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- * The contents of this file are subject to the terms of the Common Development and
- * Distribution License (the License). You may not use this file except in compliance with the
- * License.
- *
- * You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the
- * specific language governing permission and limitations under the License.
- *
- * When distributing Covered Software, include this CDDL Header Notice in each file and include
- * the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL
- * Header, with the fields enclosed by brackets [] replaced by your own identifying
- * information: "Portions Copyright [year] [name of copyright owner]".
- *
- * Copyright 2015 ForgeRock AS.
- */
-
-/** Classes implementing the maven plugin to check and update source file copyrights. */
-package org.forgerock.maven;
-
diff --git a/opendj-sdk/opendj-copyright-maven-plugin/src/test/java/org/forgerock/maven/UpdateCopyrightTestCase.java b/opendj-sdk/opendj-copyright-maven-plugin/src/test/java/org/forgerock/maven/UpdateCopyrightTestCase.java
deleted file mode 100644
index d71bc81..0000000
--- a/opendj-sdk/opendj-copyright-maven-plugin/src/test/java/org/forgerock/maven/UpdateCopyrightTestCase.java
+++ /dev/null
@@ -1,174 +0,0 @@
-/*
- * The contents of this file are subject to the terms of the Common Development and
- * Distribution License (the License). You may not use this file except in compliance with the
- * License.
- *
- * You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the
- * specific language governing permission and limitations under the License.
- *
- * When distributing Covered Software, include this CDDL Header Notice in each file and include
- * the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL
- * Header, with the fields enclosed by brackets [] replaced by your own identifying
- * information: "Portions Copyright [year] [name of copyright owner]".
- *
- * Copyright 2015-2016 ForgeRock AS.
- */
-package org.forgerock.maven;
-
-import static org.mockito.Mockito.*;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileReader;
-import java.io.FilenameFilter;
-import java.util.Calendar;
-import java.util.LinkedList;
-import java.util.List;
-
-import org.forgerock.testng.ForgeRockTestCase;
-import org.testng.annotations.AfterTest;
-import org.testng.annotations.DataProvider;
-import org.testng.annotations.Test;
-
-@Test
-public class UpdateCopyrightTestCase extends ForgeRockTestCase {
-
- private final class FilenameExtensionFilter implements FilenameFilter {
- private final String extension;
-
- private FilenameExtensionFilter(String suffix) {
- this.extension = suffix;
- }
-
- @Override
- public boolean accept(File directory, String fileName) {
- return fileName.endsWith(extension);
- }
- }
-
- private static final String CURRENT_YEAR = Integer.toString(Calendar.getInstance().get(Calendar.YEAR));
- private static final String RESOURCE_DIR = "src/test/resources/files/";
- private static final String[] TEST_FOLDERS = { "forgerock-copyrights", "openidm-copyrights"};
-
- /** Customs tags in tests files. */
- private static final String MUST_BE_REMOVED_TAG = "MUST BE REMOVED:";
- private static final String EXPECTED_OUTPUT_TAG = "EXPECTED OUTPUT:";
- private static final String YEAR_TAG = "YEAR";
-
- @AfterTest
- public void deleteTempFiles() {
- FilenameFilter tmpFilter = new FilenameExtensionFilter(".tmp");
- for (String testFolder : TEST_FOLDERS) {
- for (File file : new File(RESOURCE_DIR, testFolder).listFiles(tmpFilter)) {
- file.delete();
- }
- }
- }
-
- @DataProvider
- public Object[][] testCases() {
- return new Object[][] {
- // Test case folder, Line before copyright regexp, NB lines to skip, NB spaces indentation,
- // New portion copyright string, New copyright start string, Copyright end regexp,
- // New copyright end String
- { TEST_FOLDERS[0], "Portions\\s+Copyright\\s+\\[year\\]\\s+\\[name\\s+of\\s+copyright\\s+owner\\]",
- 1, 1, "Portions copyright", "Copyright", "ForgeRock\\s+AS", "ForgeRock AS." },
- { TEST_FOLDERS[1],
- "DO\\s+NOT\\s+ALTER\\s+OR\\s+REMOVE\\s+COPYRIGHT\\s+NOTICES\\s+OR\\s+THIS\\s+HEADER.", 1, 1,
- "Portions Copyrighted", "Copyright (c)", "ForgeRock\\s+AS\\.",
- "ForgeRock AS. All rights reserved." }
- };
- }
-
- @Test(dataProvider = "testCases")
- public void testUpdateCopyright(String testCaseFolderPath, String lineBeforeCopyrightToken,
- int nbLinesToSkip, int numberSpacesIndentation, String newPortionCopyrightString,
- String newCopyrightStartString, String copyrightEndToken, String newCopyrightOwnerStr) throws Exception {
- List<String> testFilePaths = new LinkedList<>();
- List<File> updatedTestFilePaths = new LinkedList<>();
-
- File[] changedFiles = new File(RESOURCE_DIR, testCaseFolderPath)
- .listFiles(new FilenameExtensionFilter(".txt"));
- for (File file : changedFiles) {
- testFilePaths.add(file.getAbsolutePath());
- updatedTestFilePaths.add(new File(file.getPath() + ".tmp"));
- }
-
- UpdateCopyrightMojo spyMojo = spy(new UpdateCopyrightMojo());
- spyMojo.setDryRun(true);
- spyMojo.setLineBeforeCopyrightToken(lineBeforeCopyrightToken);
- spyMojo.setNbLinesToSkip(nbLinesToSkip);
- spyMojo.setNumberSpaceIdentation(numberSpacesIndentation);
- spyMojo.setNewPortionsCopyrightString(newPortionCopyrightString);
- spyMojo.setNewCopyrightStartToken(newCopyrightStartString);
- spyMojo.setNewCopyrightOwnerString(newCopyrightOwnerStr);
- spyMojo.setCopyrightEndToken(copyrightEndToken);
-
- doNothing().when(spyMojo).checkCopyrights();
- when(spyMojo.getIncorrectCopyrightFilePaths()).thenReturn(testFilePaths);
- spyMojo.execute();
-
- // Check copyrights of updated files
- CheckCopyrightMojo spyMojoCheck = spy(new CheckCopyrightMojo());
- doReturn(updatedTestFilePaths).when(spyMojoCheck).getChangedFiles();
- spyMojoCheck.execute();
-
- // Check updated files content
- for (String filePath : testFilePaths) {
- checkMofidiedFile(filePath);
- }
- }
-
- private void checkMofidiedFile(String filePath) throws Exception {
- try (BufferedReader reader = new BufferedReader(new FileReader(filePath))) {
- String mustBeRemoved = null;
- String expectedOutput = null;
- String currentLine;
- while ((currentLine = reader.readLine()) != null) {
- if (currentLine.contains(MUST_BE_REMOVED_TAG)) {
- mustBeRemoved = currentLine.split(MUST_BE_REMOVED_TAG)[1].trim();
- } else if (currentLine.contains(EXPECTED_OUTPUT_TAG)) {
- expectedOutput = currentLine.split(EXPECTED_OUTPUT_TAG)[1].trim()
- .replace(YEAR_TAG, CURRENT_YEAR);
- }
- }
- checkIfNewFileIsValid(mustBeRemoved, expectedOutput, filePath + ".tmp");
- }
- }
-
-
- private void checkIfNewFileIsValid(String mustBeRemoved, String expectedOutput, String filePath) throws Exception {
- if (mustBeRemoved == null && expectedOutput == null) {
- return;
- }
-
- try (BufferedReader reader = new BufferedReader(new FileReader(filePath))) {
- boolean expectedOutputFound = false;
- String currentLine;
- while ((currentLine = reader.readLine()) != null) {
- if (lineContainsTagContent(currentLine, mustBeRemoved)) {
- throw new Exception("Generated file " + filePath + " must not contains " + mustBeRemoved);
- }
-
- if (!expectedOutputFound && lineContainsTagContent(currentLine, expectedOutput)) {
- expectedOutputFound = true;
- if (mustBeRemoved == null) {
- return;
- }
- }
- }
- if (!expectedOutputFound) {
- throw new Exception("Generated file " + filePath + " should contains " + expectedOutput);
- }
- }
- }
-
-
- private boolean lineContainsTagContent(String line, String content) {
- String trimedLine = line.trim();
- return content != null
- && !trimedLine.startsWith(MUST_BE_REMOVED_TAG)
- && !trimedLine.startsWith(MUST_BE_REMOVED_TAG)
- && trimedLine.contains(content);
- }
-}
diff --git a/opendj-sdk/opendj-copyright-maven-plugin/src/test/resources/files/forgerock-copyrights/forgerock-bad-copyright-1.java b/opendj-sdk/opendj-copyright-maven-plugin/src/test/resources/files/forgerock-copyrights/forgerock-bad-copyright-1.java
deleted file mode 100644
index 090cf59..0000000
--- a/opendj-sdk/opendj-copyright-maven-plugin/src/test/resources/files/forgerock-copyrights/forgerock-bad-copyright-1.java
+++ /dev/null
@@ -1,18 +0,0 @@
-/*
- * The contents of this file are subject to the terms of the Common Development and
- * Distribution License (the License). You may not use this file except in compliance with the
- * License.
- *
- * You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the
- * specific language governing permission and limitations under the License.
- *
- * When distributing Covered Software, include this CDDL Header Notice in each file and include
- * the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL
- * Header, with the fields enclosed by brackets [] replaced by your own identifying
- * information: "Portions copyright [year] [name of copyright owner]".
- *
- * Copyright 2012-2014 ForgeRock AS.
- */
-
- MUST BE REMOVED: Copyright 2012-2014 ForgeRock AS.
- EXPECTED OUTPUT: Copyright 2012-YEAR ForgeRock AS.
diff --git a/opendj-sdk/opendj-copyright-maven-plugin/src/test/resources/files/forgerock-copyrights/forgerock-bad-copyright-2.c b/opendj-sdk/opendj-copyright-maven-plugin/src/test/resources/files/forgerock-copyrights/forgerock-bad-copyright-2.c
deleted file mode 100644
index e89d838..0000000
--- a/opendj-sdk/opendj-copyright-maven-plugin/src/test/resources/files/forgerock-copyrights/forgerock-bad-copyright-2.c
+++ /dev/null
@@ -1,18 +0,0 @@
-/*
- * The contents of this file are subject to the terms of the Common Development and
- * Distribution License (the License). You may not use this file except in compliance with the
- * License.
- *
- * You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the
- * specific language governing permission and limitations under the License.
- *
- * When distributing Covered Software, include this CDDL Header Notice in each file and include
- * the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL
- * Header, with the fields enclosed by brackets [] replaced by your own identifying
- * information: "Portions copyright [year] [name of copyright owner]".
- *
- * Copyright 2010 ForgeRock AS.
- */
-
-MUST BE REMOVED: Copyright 2010 ForgeRock AS.
-EXPECTED OUTPUT: Copyright 2010-YEAR ForgeRock AS.
diff --git a/opendj-sdk/opendj-copyright-maven-plugin/src/test/resources/files/forgerock-copyrights/forgerock-bad-copyright-3.java b/opendj-sdk/opendj-copyright-maven-plugin/src/test/resources/files/forgerock-copyrights/forgerock-bad-copyright-3.java
deleted file mode 100644
index 7f738e2..0000000
--- a/opendj-sdk/opendj-copyright-maven-plugin/src/test/resources/files/forgerock-copyrights/forgerock-bad-copyright-3.java
+++ /dev/null
@@ -1,16 +0,0 @@
-/*
- * The contents of this file are subject to the terms of the Common Development and
- * Distribution License (the License). You may not use this file except in compliance with the
- * License.
- *
- * You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the
- * specific language governing permission and limitations under the License.
- *
- * When distributing Covered Software, include this CDDL Header Notice in each file and include
- * the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL
- * Header, with the fields enclosed by brackets [] replaced by your own identifying
- * information: "Portions copyright [year] [name of copyright owner]".
- *
- */
-
- EXPECTED OUTPUT: Copyright YEAR ForgeRock AS.
diff --git a/opendj-sdk/opendj-copyright-maven-plugin/src/test/resources/files/forgerock-copyrights/forgerock-bad-copyright-4.h b/opendj-sdk/opendj-copyright-maven-plugin/src/test/resources/files/forgerock-copyrights/forgerock-bad-copyright-4.h
deleted file mode 100644
index 9bf2ebe..0000000
--- a/opendj-sdk/opendj-copyright-maven-plugin/src/test/resources/files/forgerock-copyrights/forgerock-bad-copyright-4.h
+++ /dev/null
@@ -1,17 +0,0 @@
-/*
- * The contents of this file are subject to the terms of the Common Development and
- * Distribution License (the License). You may not use this file except in compliance with the
- * License.
- *
- * You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the
- * specific language governing permission and limitations under the License.
- *
- * When distributing Covered Software, include this CDDL Header Notice in each file and include
- * the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL
- * Header, with the fields enclosed by brackets [] replaced by your own identifying
- * information: "Portions copyright [year] [name of copyright owner]".
- *
- * Copyright 2010 Old Copyright Owner Inc.
- */
-
- EXPECTED OUTPUT: Portions copyright YEAR ForgeRock AS.
diff --git a/opendj-sdk/opendj-copyright-maven-plugin/src/test/resources/files/forgerock-copyrights/forgerock-bad-copyright-5.txt b/opendj-sdk/opendj-copyright-maven-plugin/src/test/resources/files/forgerock-copyrights/forgerock-bad-copyright-5.txt
deleted file mode 100644
index d785efa..0000000
--- a/opendj-sdk/opendj-copyright-maven-plugin/src/test/resources/files/forgerock-copyrights/forgerock-bad-copyright-5.txt
+++ /dev/null
@@ -1,18 +0,0 @@
-/*
- * The contents of this file are subject to the terms of the Common Development and
- * Distribution License (the License). You may not use this file except in compliance with the
- * License.
- *
- * You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the
- * specific language governing permission and limitations under the License.
- *
- * When distributing Covered Software, include this CDDL Header Notice in each file and include
- * the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL
- * Header, with the fields enclosed by brackets [] replaced by your own identifying
- * information: "Portions copyright [year] [name of copyright owner]".
- *
- * copyright 2010-2012 Very Old copyright owner Inc.
- * copyright 2013-2014 Old copyright owner Inc.
- */
-
- EXPECTED OUTPUT: Portions copyright YEAR ForgeRock AS.
diff --git a/opendj-sdk/opendj-copyright-maven-plugin/src/test/resources/files/forgerock-copyrights/forgerock-bad-copyright-6.txt b/opendj-sdk/opendj-copyright-maven-plugin/src/test/resources/files/forgerock-copyrights/forgerock-bad-copyright-6.txt
deleted file mode 100644
index edffc95..0000000
--- a/opendj-sdk/opendj-copyright-maven-plugin/src/test/resources/files/forgerock-copyrights/forgerock-bad-copyright-6.txt
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * The contents of this file are subject to the terms of the Common Development and
- * Distribution License (the License). You may not use this file except in compliance with the
- * License.
- *
- * You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the
- * specific language governing permission and limitations under the License.
- *
- * When distributing Covered Software, include this CDDL Header Notice in each file and include
- * the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL
- * Header, with the fields enclosed by brackets [] replaced by your own identifying
- * information: "Portions copyright [year] [name of copyright owner]".
- *
- * Copyright 2008-2010 Very Old copyright owner Inc.
- * Portions copyright 2011-2012 Old copyright owner Inc.
- * Portions copyright 2013-2014 ForgeRock AS.
- */
-
-MUST BE REMOVED: Portions copyright 2013-2014 ForgeRock AS.
-EXPECTED OUTPUT: Portions copyright 2013-YEAR ForgeRock AS.
diff --git a/opendj-sdk/opendj-copyright-maven-plugin/src/test/resources/files/forgerock-copyrights/forgerock-bad-copyright-7.html b/opendj-sdk/opendj-copyright-maven-plugin/src/test/resources/files/forgerock-copyrights/forgerock-bad-copyright-7.html
deleted file mode 100644
index 93f92af..0000000
--- a/opendj-sdk/opendj-copyright-maven-plugin/src/test/resources/files/forgerock-copyrights/forgerock-bad-copyright-7.html
+++ /dev/null
@@ -1,19 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- ! The contents of this file are subject to the terms of the Common Development and
- ! Distribution License (the License). You may not use this file except in compliance with the
- ! License.
- !
- ! You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the
- ! specific language governing permission and limitations under the License.
- !
- ! When distributing Covered Software, include this CDDL Header Notice in each file and include
- ! the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL
- ! Header, with the fields enclosed by brackets [] replaced by your own identifying
- ! information: "Portions Copyright [year] [name of copyright owner]".
- !
- ! Copyright 2012-2014 ForgeRock AS.
--->
-
-MUST BE REMOVED: Copyright 2012-2014 ForgeRock AS.
-EXPECTED OUTPUT: Copyright 2012-YEAR ForgeRock AS.
diff --git a/opendj-sdk/opendj-copyright-maven-plugin/src/test/resources/files/forgerock-copyrights/forgerock-bad-copyright-8.xml b/opendj-sdk/opendj-copyright-maven-plugin/src/test/resources/files/forgerock-copyrights/forgerock-bad-copyright-8.xml
deleted file mode 100644
index 66a3306..0000000
--- a/opendj-sdk/opendj-copyright-maven-plugin/src/test/resources/files/forgerock-copyrights/forgerock-bad-copyright-8.xml
+++ /dev/null
@@ -1,18 +0,0 @@
-<!--
- The contents of this file are subject to the terms of the Common Development and
- Distribution License (the License). You may not use this file except in compliance with the
- License.
-
- You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the
- specific language governing permission and limitations under the License.
-
- When distributing Covered Software, include this CDDL Header Notice in each file and include
- the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL
- Header, with the fields enclosed by brackets [] replaced by your own identifying
- information: "Portions Copyright [year] [name of copyright owner]".
-
- Copyright 2013 ForgeRock AS.
- -->
-
-MUST BE REMOVED: Copyright 2013 ForgeRock AS.
-EXPECTED OUTPUT: Copyright 2013-YEAR ForgeRock AS.
diff --git a/opendj-sdk/opendj-copyright-maven-plugin/src/test/resources/files/forgerock-copyrights/forgerock-bad-copyright-9.xsl b/opendj-sdk/opendj-copyright-maven-plugin/src/test/resources/files/forgerock-copyrights/forgerock-bad-copyright-9.xsl
deleted file mode 100644
index dc3b26e..0000000
--- a/opendj-sdk/opendj-copyright-maven-plugin/src/test/resources/files/forgerock-copyrights/forgerock-bad-copyright-9.xsl
+++ /dev/null
@@ -1,16 +0,0 @@
-<!--
- ~ The contents of this file are subject to the terms of the Common Development and
- ~ Distribution License (the License). You may not use this file except in compliance with the
- ~ License.
- ~
- ~ You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the
- ~ specific language governing permission and limitations under the License.
- ~
- ~ When distributing Covered Software, include this CDDL Header Notice in each file and include
- ~ the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL
- ~ Header, with the fields enclosed by brackets [] replaced by your own identifying
- ~ information: "Portions Copyright [year] [name of copyright owner]".
- ~
--->
-
-EXPECTED OUTPUT: Copyright YEAR ForgeRock AS.
diff --git a/opendj-sdk/opendj-copyright-maven-plugin/src/test/resources/files/openidm-copyrights/openidm-bad-copyright-1.java b/opendj-sdk/opendj-copyright-maven-plugin/src/test/resources/files/openidm-copyrights/openidm-bad-copyright-1.java
deleted file mode 100644
index e01ee4e..0000000
--- a/opendj-sdk/opendj-copyright-maven-plugin/src/test/resources/files/openidm-copyrights/openidm-bad-copyright-1.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
- *
- * Copyright (c) 2011-2014 ForgeRock AS. All rights reserved.
- *
- * The contents of this file are subject to the terms
- * of the Common Development and Distribution License
- * (the License). You may not use this file except in
- * compliance with the License.
- *
- * You can obtain a copy of the License at
- * http://forgerock.org/license/CDDLv1.0.html
- * See the License for the specific language governing
- * permission and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL
- * Header Notice in each file and include the License file
- * at http://forgerock.org/license/CDDLv1.0.html
- * If applicable, add the following below the CDDL Header,
- * with the fields enclosed by brackets [] replaced by
- * your own identifying information:
- * "Portions Copyrighted [year] [name of copyright owner]"
- */
-
-MUST BE REMOVED: Copyright (c) 2011-2014 ForgeRock AS. All rights reserved.
-EXPECTED OUTPUT: Copyright (c) 2011-YEAR ForgeRock AS. All rights reserved.
\ No newline at end of file
diff --git a/opendj-sdk/opendj-copyright-maven-plugin/src/test/resources/files/openidm-copyrights/openidm-bad-copyright-2.java b/opendj-sdk/opendj-copyright-maven-plugin/src/test/resources/files/openidm-copyrights/openidm-bad-copyright-2.java
deleted file mode 100644
index d748d88..0000000
--- a/opendj-sdk/opendj-copyright-maven-plugin/src/test/resources/files/openidm-copyrights/openidm-bad-copyright-2.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
- *
- * Copyright (c) 2012 ForgeRock AS. All rights reserved.
- *
- * The contents of this file are subject to the terms
- * of the Common Development and Distribution License
- * (the License). You may not use this file except in
- * compliance with the License.
- *
- * You can obtain a copy of the License at
- * http://forgerock.org/license/CDDLv1.0.html
- * See the License for the specific language governing
- * permission and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL
- * Header Notice in each file and include the License file
- * at http://forgerock.org/license/CDDLv1.0.html
- * If applicable, add the following below the CDDL Header,
- * with the fields enclosed by brackets [] replaced by
- * your own identifying information:
- * "Portions Copyrighted [year] [name of copyright owner]"
- */
-
-MUST BE REMOVED: Copyright (c) 2012 ForgeRock AS. All rights reserved.
-EXPECTED OUTPUT: Copyright (c) 2012-YEAR ForgeRock AS. All rights reserved.
\ No newline at end of file
diff --git a/opendj-sdk/opendj-copyright-maven-plugin/src/test/resources/files/openidm-copyrights/openidm-bad-copyright-3.java b/opendj-sdk/opendj-copyright-maven-plugin/src/test/resources/files/openidm-copyrights/openidm-bad-copyright-3.java
deleted file mode 100644
index 20a378f..0000000
--- a/opendj-sdk/opendj-copyright-maven-plugin/src/test/resources/files/openidm-copyrights/openidm-bad-copyright-3.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
- *
- *
- * The contents of this file are subject to the terms
- * of the Common Development and Distribution License
- * (the License). You may not use this file except in
- * compliance with the License.
- *
- * You can obtain a copy of the License at
- * http://forgerock.org/license/CDDLv1.0.html
- * See the License for the specific language governing
- * permission and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL
- * Header Notice in each file and include the License file
- * at http://forgerock.org/license/CDDLv1.0.html
- * If applicable, add the following below the CDDL Header,
- * with the fields enclosed by brackets [] replaced by
- * your own identifying information:
- * "Portions Copyrighted [year] [name of copyright owner]"
- */
-
-EXPECTED OUTPUT: Copyright (c) YEAR ForgeRock AS. All rights reserved.
\ No newline at end of file
diff --git a/opendj-sdk/opendj-copyright-maven-plugin/src/test/resources/files/openidm-copyrights/openidm-bad-copyright-4.java b/opendj-sdk/opendj-copyright-maven-plugin/src/test/resources/files/openidm-copyrights/openidm-bad-copyright-4.java
deleted file mode 100644
index 5f5a515..0000000
--- a/opendj-sdk/opendj-copyright-maven-plugin/src/test/resources/files/openidm-copyrights/openidm-bad-copyright-4.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
- *
- * Copyright (c) 2010-2011 Old Copyright Owner.
- *
- * The contents of this file are subject to the terms
- * of the Common Development and Distribution License
- * (the License). You may not use this file except in
- * compliance with the License.
- *
- * You can obtain a copy of the License at
- * http://forgerock.org/license/CDDLv1.0.html
- * See the License for the specific language governing
- * permission and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL
- * Header Notice in each file and include the License file
- * at http://forgerock.org/license/CDDLv1.0.html
- * If applicable, add the following below the CDDL Header,
- * with the fields enclosed by brackets [] replaced by
- * your own identifying information:
- * "Portions Copyrighted [year] [name of copyright owner]"
- */
-
- EXPECTED OUTPUT: Portions Copyrighted YEAR ForgeRock AS. All rights reserved.
\ No newline at end of file
diff --git a/opendj-sdk/opendj-copyright-maven-plugin/src/test/resources/files/openidm-copyrights/openidm-bad-copyright-5.java b/opendj-sdk/opendj-copyright-maven-plugin/src/test/resources/files/openidm-copyrights/openidm-bad-copyright-5.java
deleted file mode 100644
index 2e8c5d9..0000000
--- a/opendj-sdk/opendj-copyright-maven-plugin/src/test/resources/files/openidm-copyrights/openidm-bad-copyright-5.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
- *
- * Copyright (c) 2010-2011 Very Old Copyright Owner.
- * Copyright (c) 2012-2013 Old Copyright Owner.
- *
- * The contents of this file are subject to the terms
- * of the Common Development and Distribution License
- * (the License). You may not use this file except in
- * compliance with the License.
- *
- * You can obtain a copy of the License at
- * http://forgerock.org/license/CDDLv1.0.html
- * See the License for the specific language governing
- * permission and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL
- * Header Notice in each file and include the License file
- * at http://forgerock.org/license/CDDLv1.0.html
- * If applicable, add the following below the CDDL Header,
- * with the fields enclosed by brackets [] replaced by
- * your own identifying information:
- * "Portions Copyrighted [year] [name of copyright owner]"
- */
-
- EXPECTED OUTPUT: Portions Copyrighted YEAR ForgeRock AS. All rights reserved.
\ No newline at end of file
diff --git a/opendj-sdk/opendj-copyright-maven-plugin/src/test/resources/files/openidm-copyrights/openidm-bad-copyright-6.java b/opendj-sdk/opendj-copyright-maven-plugin/src/test/resources/files/openidm-copyrights/openidm-bad-copyright-6.java
deleted file mode 100644
index e05d576..0000000
--- a/opendj-sdk/opendj-copyright-maven-plugin/src/test/resources/files/openidm-copyrights/openidm-bad-copyright-6.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
- *
- * Copyright (c) 2010-2011 Very Old Copyright Owner.
- * Portions Copyrighted 2012-2013 Old Copyright Owner.
- * Portions Copyrighted 2013-2014 ForgeRock AS. All rights reserved.
- *
- * The contents of this file are subject to the terms
- * of the Common Development and Distribution License
- * (the License). You may not use this file except in
- * compliance with the License.
- *
- * You can obtain a copy of the License at
- * http://forgerock.org/license/CDDLv1.0.html
- * See the License for the specific language governing
- * permission and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL
- * Header Notice in each file and include the License file
- * at http://forgerock.org/license/CDDLv1.0.html
- * If applicable, add the following below the CDDL Header,
- * with the fields enclosed by brackets [] replaced by
- * your own identifying information:
- * "Portions Copyrighted [year] [name of copyright owner]"
- */
-
-MUST BE REMOVED: Portions Copyrighted 2013-2014 ForgeRock AS. All rights reserved.
-EXPECTED OUTPUT: Portions Copyrighted 2013-YEAR ForgeRock AS. All rights reserved.
\ No newline at end of file
diff --git a/opendj-sdk/opendj-sdk-parent/pom.xml b/opendj-sdk/opendj-sdk-parent/pom.xml
index 088aa25..f739537 100644
--- a/opendj-sdk/opendj-sdk-parent/pom.xml
+++ b/opendj-sdk/opendj-sdk-parent/pom.xml
@@ -35,7 +35,6 @@
<modules>
- <module>../opendj-copyright-maven-plugin</module>
<module>../opendj-doc-maven-plugin</module>
<module>../opendj-core</module>
<module>../opendj-grizzly</module>
--
Gitblit v1.10.0