This is an automated email from the ASF dual-hosted git repository. claude pushed a commit to branch feature/restructure in repository https://gitbox.apache.org/repos/asf/creadur-rat.git
commit f68895c324408aabe6fd062ea39578ded3bad323 Author: Claude Warren <[email protected]> AuthorDate: Sun Dec 28 16:37:43 2025 +0000 Ant UI compiles -- no tests --- apache-rat-ant-parent/apache-rat-tasks/pom.xml | 9 +- .../src/main/java/org/apache/rat/ant/.gitignore | 1 + .../java/org/apache/rat/ant/AbstractAntReport.java | 32 +- .../main/java/org/apache/rat/ant/AntReport.java | 179 +++--- .../Family.java => ant/package-info.java} | 27 +- .../src/main/java/org/apache/rat/anttasks/All.java | 44 -- .../src/main/java/org/apache/rat/anttasks/Any.java | 43 -- .../java/org/apache/rat/anttasks/Copyright.java | 52 -- .../main/java/org/apache/rat/anttasks/Help.java | 232 -------- .../main/java/org/apache/rat/anttasks/License.java | 75 --- .../src/main/java/org/apache/rat/anttasks/Not.java | 44 -- .../main/java/org/apache/rat/anttasks/Regex.java | 48 -- .../main/java/org/apache/rat/anttasks/Report.java | 601 --------------------- .../main/java/org/apache/rat/anttasks/Spdx.java | 47 -- .../main/java/org/apache/rat/anttasks/Text.java | 46 -- .../java/org/apache/rat/anttasks/package-info.java | 24 - .../apache/rat/ant/CodeGenerator/AbstractAnt.vm | 1 + .../rat/ant/CodeGenerator/AntElementClass.vm | 2 +- .../rat/ant/CodeGenerator/defaultTypeTemplate.vm | 2 +- .../rat/ant/CodeGenerator/fileSetTemplate.vm | 2 +- .../rat/ant/CodeGenerator/textValueTemplate.vm | 2 +- 21 files changed, 125 insertions(+), 1388 deletions(-) diff --git a/apache-rat-ant-parent/apache-rat-tasks/pom.xml b/apache-rat-ant-parent/apache-rat-tasks/pom.xml index 05eceaa3..7345174f 100644 --- a/apache-rat-ant-parent/apache-rat-tasks/pom.xml +++ b/apache-rat-ant-parent/apache-rat-tasks/pom.xml @@ -139,18 +139,17 @@ <artifactId>exec-maven-plugin</artifactId> <executions> <execution> - <id>Create BaseAntTask</id> + <id>Create AntReport</id> <goals> <goal>java</goal> </goals> <phase>generate-sources</phase> <configuration> <classpathScope>test</classpathScope> - <mainClass>org.apache.rat.tools.AntGenerator</mainClass> + <mainClass>org.apache.rat.ant.CodeGenerator</mainClass> <arguments> - <argument>org.apache.rat.anttasks</argument> - <argument>BaseAntTask</argument> - <argument>${project.build.sourceDirectory}</argument> + <argument>-p</argument> + <argument>${build.sourceDirectory}</argument> </arguments> </configuration> </execution> diff --git a/apache-rat-ant-parent/apache-rat-tasks/src/main/java/org/apache/rat/ant/.gitignore b/apache-rat-ant-parent/apache-rat-tasks/src/main/java/org/apache/rat/ant/.gitignore new file mode 100644 index 00000000..4032758b --- /dev/null +++ b/apache-rat-ant-parent/apache-rat-tasks/src/main/java/org/apache/rat/ant/.gitignore @@ -0,0 +1 @@ +AntReport.java diff --git a/apache-rat-ant-parent/apache-rat-tasks/src/main/java/org/apache/rat/ant/AbstractAntReport.java b/apache-rat-ant-parent/apache-rat-tasks/src/main/java/org/apache/rat/ant/AbstractAntReport.java index e0edf2b3..5c243396 100644 --- a/apache-rat-ant-parent/apache-rat-tasks/src/main/java/org/apache/rat/ant/AbstractAntReport.java +++ b/apache-rat-ant-parent/apache-rat-tasks/src/main/java/org/apache/rat/ant/AbstractAntReport.java @@ -1,11 +1,29 @@ +/* +* Licensed to the Apache Software Foundation (ASF) under one +* or more contributor license agreements. See the NOTICE file +* distributed with this work for additional information +* regarding copyright ownership. The ASF licenses this file +* to you under the Apache License, Version 2.0 (the +* "License"); you may not use this file except in compliance +* with the License. You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, +* software distributed under the License is distributed on an +* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +* KIND, either express or implied. See the License for the +* specific language governing permissions and limitations +* under the License. +*/ package org.apache.rat.ant; import java.io.File; import java.io.IOException; -import java.io.OutputStream; import java.util.ArrayList; import java.util.List; import java.util.stream.Collectors; + import org.apache.commons.cli.Option; import org.apache.commons.cli.ParseException; import org.apache.commons.io.output.CloseShieldOutputStream; @@ -13,7 +31,6 @@ import org.apache.rat.ConfigurationException; import org.apache.rat.OptionCollection; import org.apache.rat.ReportConfiguration; import org.apache.rat.Reporter; -import org.apache.rat.anttasks.BaseAntTask; import org.apache.rat.commandline.Arg; import org.apache.rat.commandline.ArgumentContext; import org.apache.rat.commandline.StyleSheets; @@ -26,18 +43,14 @@ import org.apache.rat.utils.Log; import org.apache.tools.ant.BuildException; import org.apache.tools.ant.Project; import org.apache.tools.ant.Task; -import org.apache.tools.ant.taskdefs.Javadoc; import org.apache.tools.ant.taskdefs.LogOutputStream; import org.apache.tools.ant.types.ResourceCollection; import org.apache.tools.ant.types.resources.Union; public abstract class AbstractAntReport extends Task { - + /** The argument tracker for this report */ protected final ArgumentTracker argumentTracker; - - /** - * will hold any nested resource collection - */ + /** will hold any nested resource collection */ private Union nestedResources; protected AbstractAntReport() { @@ -155,6 +168,7 @@ public abstract class AbstractAntReport extends Task { * Base class for all none text command line types. */ protected static class TxtValue { + /** The value for this object */ private String value; protected TxtValue() { } @@ -163,7 +177,7 @@ public abstract class AbstractAntReport extends Task { return value; } - public void addText(String text) { + public void addText(final String text) { value = text.trim(); } } diff --git a/apache-rat-ant-parent/apache-rat-tasks/src/main/java/org/apache/rat/ant/AntReport.java b/apache-rat-ant-parent/apache-rat-tasks/src/main/java/org/apache/rat/ant/AntReport.java index 284cc8e0..d6fa6e6b 100644 --- a/apache-rat-ant-parent/apache-rat-tasks/src/main/java/org/apache/rat/ant/AntReport.java +++ b/apache-rat-ant-parent/apache-rat-tasks/src/main/java/org/apache/rat/ant/AntReport.java @@ -27,6 +27,7 @@ import org.apache.tools.ant.types.resources.FileResource; * Generated class to provide Ant support for standard RAT command line options. * DO NOT EDIT - GENERATED FILE */ +@SuppressWarnings("checkstyle:LineLength") public final class AntReport extends AbstractAntReport { /** @@ -120,12 +121,12 @@ public final class AntReport extends AbstractAntReport { * Handles Config processing. */ public class Config { - Config() {} + Config() { } /** * Adds a configured FileSet to the config. * @param fileSet The fileSet to add to config. */ - public void addConfiguredFileSet(FileSet fileSet) { + public void addConfiguredFileSet(final FileSet fileSet) { for (Resource resource : fileSet) { if (resource.isFilesystemOnly()) { argumentTracker.addArg("config", ((FileResource) resource).getFile().getAbsolutePath()); @@ -147,12 +148,12 @@ public final class AntReport extends AbstractAntReport { * Handles Licenses processing. */ public class Licenses { - Licenses() {} + Licenses() { } /** * Adds a configured FileSet to the licenses. * @param fileSet The fileSet to add to licenses. */ - public void addConfiguredFileSet(FileSet fileSet) { + public void addConfiguredFileSet(final FileSet fileSet) { for (Resource resource : fileSet) { if (resource.isFilesystemOnly()) { argumentTracker.addArg("licenses", ((FileResource) resource).getFile().getAbsolutePath()); @@ -198,19 +199,19 @@ public final class AntReport extends AbstractAntReport { * Handles LicensesApproved processing. */ public class LicensesApproved { - LicensesApproved() {} + LicensesApproved() { } /** * Adds the licenseID {@link AbstractAntReport.Lst} to licenses-approved. * @param licenseID The Lst to add to licenses-approved. */ - public void addConfiguredLst(Lst licenseID) { + public void addConfiguredLst(final Lst licenseID) { argumentTracker.addArg("licenses-approved", licenseID.toString()); } /** * Adds a configured FileSet to the licenses-approved. * @param fileSet The fileSet to add to licenses-approved. */ - public void addConfiguredFileSet(FileSet fileSet) { + public void addConfiguredFileSet(final FileSet fileSet) { for (Resource resource : fileSet) { if (resource.isFilesystemOnly()) { argumentTracker.addArg("licenses-approved", ((FileResource) resource).getFile().getAbsolutePath()); @@ -223,12 +224,12 @@ public final class AntReport extends AbstractAntReport { * Handles LicensesApprovedFile processing. */ public class LicensesApprovedFile { - LicensesApprovedFile() {} + LicensesApprovedFile() { } /** * Adds a configured FileSet to the licenses-approved. * @param fileSet The fileSet to add to licenses-approved. */ - public void addConfiguredFileSet(FileSet fileSet) { + public void addConfiguredFileSet(final FileSet fileSet) { for (Resource resource : fileSet) { if (resource.isFilesystemOnly()) { argumentTracker.addArg("licenses-approved", ((FileResource) resource).getFile().getAbsolutePath()); @@ -248,37 +249,37 @@ public final class AntReport extends AbstractAntReport { * Handles LicenseFamiliesApproved processing. */ public class LicenseFamiliesApproved { - LicenseFamiliesApproved() {} - /** - * Adds the familyID {@link AbstractAntReport.Lst} to license-families-approved. - * @param familyID The Lst to add to license-families-approved. - */ - public void addConfiguredLst(Lst familyID) { - argumentTracker.addArg("license-families-approved", familyID.toString()); - } + LicenseFamiliesApproved() { } /** * Adds a configured FileSet to the license-families-approved. * @param fileSet The fileSet to add to license-families-approved. */ - public void addConfiguredFileSet(FileSet fileSet) { + public void addConfiguredFileSet(final FileSet fileSet) { for (Resource resource : fileSet) { if (resource.isFilesystemOnly()) { argumentTracker.addArg("license-families-approved", ((FileResource) resource).getFile().getAbsolutePath()); } } } + /** + * Adds the familyID {@link AbstractAntReport.Lst} to license-families-approved. + * @param familyID The Lst to add to license-families-approved. + */ + public void addConfiguredLst(final Lst familyID) { + argumentTracker.addArg("license-families-approved", familyID.toString()); + } } /** * Handles LicenseFamiliesApprovedFile processing. */ public class LicenseFamiliesApprovedFile { - LicenseFamiliesApprovedFile() {} + LicenseFamiliesApprovedFile() { } /** * Adds a configured FileSet to the license-families-approved. * @param fileSet The fileSet to add to license-families-approved. */ - public void addConfiguredFileSet(FileSet fileSet) { + public void addConfiguredFileSet(final FileSet fileSet) { for (Resource resource : fileSet) { if (resource.isFilesystemOnly()) { argumentTracker.addArg("license-families-approved", ((FileResource) resource).getFile().getAbsolutePath()); @@ -298,12 +299,12 @@ public final class AntReport extends AbstractAntReport { * Handles LicensesDenied processing. */ public class LicensesDenied { - LicensesDenied() {} + LicensesDenied() { } /** * Adds a configured FileSet to the licenses-denied. * @param fileSet The fileSet to add to licenses-denied. */ - public void addConfiguredFileSet(FileSet fileSet) { + public void addConfiguredFileSet(final FileSet fileSet) { for (Resource resource : fileSet) { if (resource.isFilesystemOnly()) { argumentTracker.addArg("licenses-denied", ((FileResource) resource).getFile().getAbsolutePath()); @@ -314,7 +315,7 @@ public final class AntReport extends AbstractAntReport { * Adds the licenseID {@link AbstractAntReport.Lst} to licenses-denied. * @param licenseID The Lst to add to licenses-denied. */ - public void addConfiguredLst(Lst licenseID) { + public void addConfiguredLst(final Lst licenseID) { argumentTracker.addArg("licenses-denied", licenseID.toString()); } } @@ -323,12 +324,12 @@ public final class AntReport extends AbstractAntReport { * Handles LicensesDeniedFile processing. */ public class LicensesDeniedFile { - LicensesDeniedFile() {} + LicensesDeniedFile() { } /** * Adds a configured FileSet to the licenses-denied. * @param fileSet The fileSet to add to licenses-denied. */ - public void addConfiguredFileSet(FileSet fileSet) { + public void addConfiguredFileSet(final FileSet fileSet) { for (Resource resource : fileSet) { if (resource.isFilesystemOnly()) { argumentTracker.addArg("licenses-denied", ((FileResource) resource).getFile().getAbsolutePath()); @@ -348,19 +349,19 @@ public final class AntReport extends AbstractAntReport { * Handles LicenseFamiliesDenied processing. */ public class LicenseFamiliesDenied { - LicenseFamiliesDenied() {} + LicenseFamiliesDenied() { } /** * Adds the familyID {@link AbstractAntReport.Lst} to license-families-denied. * @param familyID The Lst to add to license-families-denied. */ - public void addConfiguredLst(Lst familyID) { + public void addConfiguredLst(final Lst familyID) { argumentTracker.addArg("license-families-denied", familyID.toString()); } /** * Adds a configured FileSet to the license-families-denied. * @param fileSet The fileSet to add to license-families-denied. */ - public void addConfiguredFileSet(FileSet fileSet) { + public void addConfiguredFileSet(final FileSet fileSet) { for (Resource resource : fileSet) { if (resource.isFilesystemOnly()) { argumentTracker.addArg("license-families-denied", ((FileResource) resource).getFile().getAbsolutePath()); @@ -373,12 +374,12 @@ public final class AntReport extends AbstractAntReport { * Handles LicenseFamiliesDeniedFile processing. */ public class LicenseFamiliesDeniedFile { - LicenseFamiliesDeniedFile() {} + LicenseFamiliesDeniedFile() { } /** * Adds a configured FileSet to the license-families-denied. * @param fileSet The fileSet to add to license-families-denied. */ - public void addConfiguredFileSet(FileSet fileSet) { + public void addConfiguredFileSet(final FileSet fileSet) { for (Resource resource : fileSet) { if (resource.isFilesystemOnly()) { argumentTracker.addArg("license-families-denied", ((FileResource) resource).getFile().getAbsolutePath()); @@ -398,12 +399,12 @@ public final class AntReport extends AbstractAntReport { * Handles CounterMax processing. */ public class CounterMax { - CounterMax() {} + CounterMax() { } /** * Adds the counterPattern {@link AbstractAntReport.Cntr} to counter-max. * @param counterPattern The Cntr to add to counter-max. */ - public void addConfiguredCntr(Cntr counterPattern) { + public void addConfiguredCntr(final Cntr counterPattern) { argumentTracker.addArg("counter-max", counterPattern.toString()); } } @@ -419,12 +420,12 @@ public final class AntReport extends AbstractAntReport { * Handles CounterMin processing. */ public class CounterMin { - CounterMin() {} + CounterMin() { } /** * Adds the counterPattern {@link AbstractAntReport.Cntr} to counter-min. * @param counterPattern The Cntr to add to counter-min. */ - public void addConfiguredCntr(Cntr counterPattern) { + public void addConfiguredCntr(final Cntr counterPattern) { argumentTracker.addArg("counter-min", counterPattern.toString()); } } @@ -442,12 +443,12 @@ public final class AntReport extends AbstractAntReport { * Handles Exclude processing. */ public class Exclude { - Exclude() {} + Exclude() { } /** * Adds the expression {@link AbstractAntReport.Expr} to exclude. * @param expression The Expr to add to exclude. */ - public void addConfiguredExpr(Expr expression) { + public void addConfiguredExpr(final Expr expression) { argumentTracker.addArg("exclude", expression.toString()); } } @@ -463,12 +464,19 @@ public final class AntReport extends AbstractAntReport { * Handles InputExclude processing. */ public class InputExclude { - InputExclude() {} + InputExclude() { } + /** + * Adds the standardCollection {@link AbstractAntReport.Std} to input-exclude. + * @param standardCollection The Std to add to input-exclude. + */ + public void addConfiguredStd(final Std standardCollection) { + argumentTracker.addArg("input-exclude", standardCollection.toString()); + } /** * Adds a configured FileSet to the input-exclude. * @param fileSet The fileSet to add to input-exclude. */ - public void addConfiguredFileSet(FileSet fileSet) { + public void addConfiguredFileSet(final FileSet fileSet) { for (Resource resource : fileSet) { if (resource.isFilesystemOnly()) { argumentTracker.addArg("input-exclude", ((FileResource) resource).getFile().getAbsolutePath()); @@ -479,42 +487,21 @@ public final class AntReport extends AbstractAntReport { * Adds the expression {@link AbstractAntReport.Expr} to input-exclude. * @param expression The Expr to add to input-exclude. */ - public void addConfiguredExpr(Expr expression) { + public void addConfiguredExpr(final Expr expression) { argumentTracker.addArg("input-exclude", expression.toString()); } - /** - * Adds the standardCollection {@link AbstractAntReport.Std} to input-exclude. - * @param standardCollection The Std to add to input-exclude. - */ - public void addConfiguredStd(Std standardCollection) { - argumentTracker.addArg("input-exclude", standardCollection.toString()); - } - } - - /** - * Handles InputExcludeStd processing. - */ - public class InputExcludeStd { - InputExcludeStd() {} - /** - * Adds the standardCollection {@link AbstractAntReport.Std} to input-exclude. - * @param standardCollection The Std to add to input-exclude. - */ - public void addConfiguredStd(Std standardCollection) { - argumentTracker.addArg("input-exclude", standardCollection.toString()); - } } /** * Handles InputExcludeFile processing. */ public class InputExcludeFile { - InputExcludeFile() {} + InputExcludeFile() { } /** * Adds a configured FileSet to the input-exclude. * @param fileSet The fileSet to add to input-exclude. */ - public void addConfiguredFileSet(FileSet fileSet) { + public void addConfiguredFileSet(final FileSet fileSet) { for (Resource resource : fileSet) { if (resource.isFilesystemOnly()) { argumentTracker.addArg("input-exclude", ((FileResource) resource).getFile().getAbsolutePath()); @@ -523,6 +510,20 @@ public final class AntReport extends AbstractAntReport { } } + /** + * Handles InputExcludeStd processing. + */ + public class InputExcludeStd { + InputExcludeStd() { } + /** + * Adds the standardCollection {@link AbstractAntReport.Std} to input-exclude. + * @param standardCollection The Std to add to input-exclude. + */ + public void addConfiguredStd(final Std standardCollection) { + argumentTracker.addArg("input-exclude", standardCollection.toString()); + } + } + /** * Reads <Expression> entries from a file. Entries will be excluded from processing. Argument should be a File. (See Argument Types for clarification) * @param excludeFile <Expression> entries from a file. @@ -552,12 +553,19 @@ public final class AntReport extends AbstractAntReport { * Handles InputInclude processing. */ public class InputInclude { - InputInclude() {} + InputInclude() { } + /** + * Adds the expression {@link AbstractAntReport.Expr} to input-include. + * @param expression The Expr to add to input-include. + */ + public void addConfiguredExpr(final Expr expression) { + argumentTracker.addArg("input-include", expression.toString()); + } /** * Adds a configured FileSet to the input-include. * @param fileSet The fileSet to add to input-include. */ - public void addConfiguredFileSet(FileSet fileSet) { + public void addConfiguredFileSet(final FileSet fileSet) { for (Resource resource : fileSet) { if (resource.isFilesystemOnly()) { argumentTracker.addArg("input-include", ((FileResource) resource).getFile().getAbsolutePath()); @@ -565,17 +573,24 @@ public final class AntReport extends AbstractAntReport { } } /** - * Adds the expression {@link AbstractAntReport.Expr} to input-include. - * @param expression The Expr to add to input-include. + * Adds the standardCollection {@link AbstractAntReport.Std} to input-include. + * @param standardCollection The Std to add to input-include. */ - public void addConfiguredExpr(Expr expression) { - argumentTracker.addArg("input-include", expression.toString()); + public void addConfiguredStd(final Std standardCollection) { + argumentTracker.addArg("input-include", standardCollection.toString()); } + } + + /** + * Handles InputIncludeStd processing. + */ + public class InputIncludeStd { + InputIncludeStd() { } /** * Adds the standardCollection {@link AbstractAntReport.Std} to input-include. * @param standardCollection The Std to add to input-include. */ - public void addConfiguredStd(Std standardCollection) { + public void addConfiguredStd(final Std standardCollection) { argumentTracker.addArg("input-include", standardCollection.toString()); } } @@ -584,12 +599,12 @@ public final class AntReport extends AbstractAntReport { * Handles InputIncludeFile processing. */ public class InputIncludeFile { - InputIncludeFile() {} + InputIncludeFile() { } /** * Adds a configured FileSet to the input-include. * @param fileSet The fileSet to add to input-include. */ - public void addConfiguredFileSet(FileSet fileSet) { + public void addConfiguredFileSet(final FileSet fileSet) { for (Resource resource : fileSet) { if (resource.isFilesystemOnly()) { argumentTracker.addArg("input-include", ((FileResource) resource).getFile().getAbsolutePath()); @@ -598,20 +613,6 @@ public final class AntReport extends AbstractAntReport { } } - /** - * Handles InputIncludeStd processing. - */ - public class InputIncludeStd { - InputIncludeStd() {} - /** - * Adds the standardCollection {@link AbstractAntReport.Std} to input-include. - * @param standardCollection The Std to add to input-include. - */ - public void addConfiguredStd(Std standardCollection) { - argumentTracker.addArg("input-include", standardCollection.toString()); - } - } - /** * Includes files matching <Expression>. Will override excluded files. Arguments should be Expression. (See Argument Types for clarification) * @deprecated Deprecated for removal since 0.17: Use <inputInclude> instead. @@ -625,12 +626,12 @@ public final class AntReport extends AbstractAntReport { * Handles Include processing. */ public class Include { - Include() {} + Include() { } /** * Adds the expression {@link AbstractAntReport.Expr} to include. * @param expression The Expr to add to include. */ - public void addConfiguredExpr(Expr expression) { + public void addConfiguredExpr(final Expr expression) { argumentTracker.addArg("include", expression.toString()); } } @@ -670,12 +671,12 @@ public final class AntReport extends AbstractAntReport { * Handles InputExcludeParsedScm processing. */ public class InputExcludeParsedScm { - InputExcludeParsedScm() {} + InputExcludeParsedScm() { } /** * Adds the standardCollection {@link AbstractAntReport.Std} to input-exclude-parsed-scm. * @param standardCollection The Std to add to input-exclude-parsed-scm. */ - public void addConfiguredStd(Std standardCollection) { + public void addConfiguredStd(final Std standardCollection) { argumentTracker.addArg("input-exclude-parsed-scm", standardCollection.toString()); } } diff --git a/apache-rat-ant-parent/apache-rat-tasks/src/main/java/org/apache/rat/anttasks/Family.java b/apache-rat-ant-parent/apache-rat-tasks/src/main/java/org/apache/rat/ant/package-info.java similarity index 54% rename from apache-rat-ant-parent/apache-rat-tasks/src/main/java/org/apache/rat/anttasks/Family.java rename to apache-rat-ant-parent/apache-rat-tasks/src/main/java/org/apache/rat/ant/package-info.java index 42fe8b51..8ad11428 100644 --- a/apache-rat-ant-parent/apache-rat-tasks/src/main/java/org/apache/rat/anttasks/Family.java +++ b/apache-rat-ant-parent/apache-rat-tasks/src/main/java/org/apache/rat/ant/package-info.java @@ -16,30 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.rat.anttasks; - -import org.apache.rat.DeprecationReporter; -import org.apache.rat.license.ILicenseFamily; - /** - * Creates a License Family - * @deprecated use configuration file. + * The Ant UI */ -@Deprecated [email protected](since = "0.17", forRemoval = true, use = "Configuration file and <config> element")// since 0.17 -public class Family { - - private final ILicenseFamily.Builder builder = ILicenseFamily.builder(); - - public ILicenseFamily build() { - return builder.build(); - } - - public void setId(String id) { - builder.setLicenseFamilyCategory(id); - } - - public void setName(String name) { - builder.setLicenseFamilyName(name); - } -} +package org.apache.rat.ant; diff --git a/apache-rat-ant-parent/apache-rat-tasks/src/main/java/org/apache/rat/anttasks/All.java b/apache-rat-ant-parent/apache-rat-tasks/src/main/java/org/apache/rat/anttasks/All.java deleted file mode 100644 index 46ce8fbe..00000000 --- a/apache-rat-ant-parent/apache-rat-tasks/src/main/java/org/apache/rat/anttasks/All.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.rat.anttasks; - -import org.apache.rat.DeprecationReporter; -import org.apache.rat.analysis.IHeaderMatcher; -import org.apache.rat.analysis.IHeaderMatcher.Builder; -import org.apache.rat.configuration.builders.AllBuilder; - -/** - * Creates an All matcher. - * @deprecated use configuration file. - */ -@Deprecated // since 0.17 [email protected](since = "0.17", forRemoval = true, use = "Configuration file and <configuration> element")// since 0.17 -public class All implements IHeaderMatcher.Builder { - - private final AllBuilder builder = Builder.all(); - - @Override - public IHeaderMatcher build() { - return builder.build(); - } - - public void add(IHeaderMatcher.Builder builder) { - this.builder.addEnclosed(builder); - } -} diff --git a/apache-rat-ant-parent/apache-rat-tasks/src/main/java/org/apache/rat/anttasks/Any.java b/apache-rat-ant-parent/apache-rat-tasks/src/main/java/org/apache/rat/anttasks/Any.java deleted file mode 100644 index 86398f1d..00000000 --- a/apache-rat-ant-parent/apache-rat-tasks/src/main/java/org/apache/rat/anttasks/Any.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.rat.anttasks; - -import org.apache.rat.DeprecationReporter; -import org.apache.rat.analysis.IHeaderMatcher; -import org.apache.rat.configuration.builders.AnyBuilder; - -/** - * Creates an Any matcher. - * @deprecated use configuration file. - */ -@Deprecated // since 0.17 [email protected](since = "0.17", forRemoval = true, use = "Configuration file and <config> element")// since 0.17 -public class Any implements IHeaderMatcher.Builder { - - private final AnyBuilder builder = new AnyBuilder(); - - @Override - public IHeaderMatcher build() { - return builder.build(); - } - - public void add(IHeaderMatcher.Builder builder) { - this.builder.addEnclosed(builder); - } -} diff --git a/apache-rat-ant-parent/apache-rat-tasks/src/main/java/org/apache/rat/anttasks/Copyright.java b/apache-rat-ant-parent/apache-rat-tasks/src/main/java/org/apache/rat/anttasks/Copyright.java deleted file mode 100644 index 719b20e3..00000000 --- a/apache-rat-ant-parent/apache-rat-tasks/src/main/java/org/apache/rat/anttasks/Copyright.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.rat.anttasks; - -import org.apache.rat.DeprecationReporter; -import org.apache.rat.analysis.IHeaderMatcher; -import org.apache.rat.configuration.builders.CopyrightBuilder; - -/** - * Creates a Copyright matcher. - * @deprecated use configuration file. - */ -@Deprecated // since 0.17 [email protected](since = "0.17", forRemoval = true, use = "Configuration file and <config> element")// since 0.17 -public class Copyright implements IHeaderMatcher.Builder { - - private final CopyrightBuilder builder = new CopyrightBuilder(); - - public void setStart(String start) { - builder.setStart(start); - } - - public void setEnd(String end) { - builder.setEnd(end); - } - - public void setOwner(String owner) { - builder.setOwner(owner); - } - - @Override - public IHeaderMatcher build() { - return builder.build(); - } - -} diff --git a/apache-rat-ant-parent/apache-rat-tasks/src/main/java/org/apache/rat/anttasks/Help.java b/apache-rat-ant-parent/apache-rat-tasks/src/main/java/org/apache/rat/anttasks/Help.java deleted file mode 100644 index c33c32bc..00000000 --- a/apache-rat-ant-parent/apache-rat-tasks/src/main/java/org/apache/rat/anttasks/Help.java +++ /dev/null @@ -1,232 +0,0 @@ -/* -* Licensed to the Apache Software Foundation (ASF) under one * -* or more contributor license agreements. See the NOTICE file * -* distributed with this work for additional information * -* regarding copyright ownership. The ASF licenses this file * -* to you under the Apache License, Version 2.0 (the * -* "License"); you may not use this file except in compliance * -* with the License. You may obtain a copy of the License at * -* * -* http://www.apache.org/licenses/LICENSE-2.0 * -* * -* Unless required by applicable law or agreed to in writing, * -* software distributed under the License is distributed on an * -* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * -* KIND, either express or implied. See the License for the * -* specific language governing permissions and limitations * -* under the License. * -*/ -package org.apache.rat.anttasks; - -import java.util.ArrayList; -import java.util.Comparator; -import java.util.Iterator; -import java.util.List; -import java.util.stream.Collectors; - -import org.apache.commons.cli.HelpFormatter; -import org.apache.commons.cli.Option; -import org.apache.commons.cli.Options; -import org.apache.commons.lang3.StringUtils; -import org.apache.rat.commandline.Arg; -import org.apache.rat.config.exclusion.StandardCollection; -import org.apache.rat.help.AbstractHelp; -import org.apache.rat.ui.AbstractOption; -import org.apache.rat.documentation.options.AntOption; -import org.apache.rat.utils.DefaultLog; -import org.apache.rat.utils.Log; - -import static java.lang.String.format; - -/** - * A basic Ant task that generates a report on all files specified by the nested - * resource collection(s). - * - * <p> - * IHeaderMatcher(s) can be specified as nested elements as well. - * </p> - * - * <p> - * The attribute <code>format</code> defines the output format and can take the - * values - * <ul> - * <li>xml - RAT's native XML output.</li> - * <li>styled - transforms the XML output using the given stylesheet. The - * stylesheet attribute must be set as well if this attribute is used.</li> - * <li>plain - plain text using RAT's built-in stylesheet. This is the - * default.</li> - * </ul> - */ -public class Help extends BaseAntTask { - - /** - * Constructor. - */ - public Help() { - // replace the logger only if it has not already been set. - Log oldLog = DefaultLog.getInstance(); - if (oldLog instanceof DefaultLog) { - DefaultLog.setInstance(new Logger()); - DefaultLog.getInstance().setLevel(oldLog.getLevel()); - } - } - - /** - * Generates the help. - */ - @Override - public void execute() { - org.apache.rat.help.Help helpObj = new org.apache.rat.help.Help(System.out) { - /** - * Print the usage to the specific PrintWriter. - * @param opts The defined options. - */ - public void printUsage(final Options opts) { - String syntax = "ant {target executing task <rat:help/>}"; - AntHelpFormatter helpFormatter = new AntHelpFormatter(); - helpFormatter.setOptPrefix("<"); - - helpFormatter.printHelp(writer, helpFormatter.getWidth(), syntax, AbstractHelp.header("Available options"), opts, - helpFormatter.getLeftPadding(), helpFormatter.getDescPadding(), header("Argument Types")); - - String argumentPadding = printArgumentTypes(); - - writer.println(header("Standard Collections")); - for (StandardCollection sc : StandardCollection.values()) { - writer.format("%n<%s>%n", sc.name()); - helpFormatter.printWrapped(writer, helpFormatter.getWidth(), helpFormatter.getLeftPadding() + HELP_PADDING + HELP_PADDING, - argumentPadding + sc.desc()); - helpFormatter.printWrapped(writer, helpFormatter.getWidth(), helpFormatter.getLeftPadding() + HELP_PADDING + HELP_PADDING, - argumentPadding + "File patterns: " + (sc.patterns().isEmpty() ? "<none>" : String.join(", ", sc.patterns()))); - helpFormatter.printWrapped(writer, helpFormatter.getWidth(), helpFormatter.getLeftPadding() + HELP_PADDING + HELP_PADDING, - argumentPadding + "Provides a path matcher: " + sc.hasStaticDocumentNameMatcher()); - helpFormatter.printWrapped(writer, helpFormatter.getWidth(), helpFormatter.getLeftPadding() + HELP_PADDING + HELP_PADDING, - argumentPadding + "Provides a file processor: " + sc.fileProcessorBuilder().hasNext()); - } - writer.println("\nA path matcher will match specific information about the file."); - writer.println("\nA file processor will process the associated \"ignore\" file for include and exclude directives"); - - writer.println(header("Notes")); - int idx = 1; - for (String note : NOTES) { - writer.format("%d. %s%n", idx++, note); - } - writer.flush(); - } - }; - - helpObj.printUsage(Arg.getOptions()); - } - - @Override - public void log(final String msg, final int msgLevel) { - if (getProject() != null) { - getProject().log(msg, msgLevel); - } else { - DefaultLog.createDefault().log(Report.fromProjectLevel(msgLevel), msg); - } - } - - @Override - public void log(final String msg, final Throwable t, final int msgLevel) { - if (getProject() == null) { - log(Log.formatLogEntry(msg, t), msgLevel); - } else { - getProject().log(this, msg, t, msgLevel); - } - } - - /** - * A facade for the Logger provided by Ant. - */ - private final class Logger implements Log { - @Override - public Level getLevel() { - return Level.DEBUG; - } - - @Override - public void log(final Level level, final String message, final Throwable throwable) { - log(level, Log.formatLogEntry(message, throwable)); - } - - @Override - public void log(final Level level, final String msg) { - Help.this.log(msg, Report.toProjectLevel(level)); - } - } - - public static class AntHelpFormatter extends HelpFormatter { - public AntHelpFormatter() { - super(); - setWidth(180); - } - @Override - public Comparator<Option> getOptionComparator() { - return Comparator.comparing(Option::getLongOpt); - } - - @Override - protected StringBuffer renderOptions(final StringBuffer sb, final int width, final Options options, final int leftPad, final int descPad) { - final String dpad = createPadding(descPad); - // first create list containing only <lpad>-a,--aaa where - // -a is opt and --aaa is long opt; in parallel look for - // the longest opt string this list will then be used to - // sort options ascending - String optionTitle = " -- Option --"; - String exampleTitle = " -- Example --"; - String descriptionTitle = " -- Description --"; - int max = optionTitle.length(); - int maxExample = exampleTitle.length(); - final List<AntOption> optList = options.getOptions().stream().filter(Option::hasLongOpt) - .map(AntOption::new).collect(Collectors.toList()); - if (getOptionComparator() != null) { - optList.sort(Comparator.comparing(AbstractOption::getName)); - } - List<String> exampleList = new ArrayList<>(); - for (final AntOption option : optList) { - String argName = StringUtils.defaultIfEmpty(option.getArgName(), "value"); - String fmt = option.isAttribute() ? "<rat:report %s='%s'>" : "<%1$s>%2$s</%1$s>"; - String example = format(fmt, option.getName(), argName); - exampleList.add(example); - max = Math.max(option.cleanupName().length(), max); - maxExample = Math.max(example.length(), maxExample); - } - - sb.append(optionTitle).append(createPadding(max - optionTitle.length())) - .append(dpad) - .append(exampleTitle).append(createPadding(maxExample - exampleTitle.length())) - .append(dpad) - .append(descriptionTitle) - .append(getNewLine()); - - int x = 0; - for (final Iterator<AntOption> it = optList.iterator(); it.hasNext();) { - final AntOption option = it.next(); - String name = option.cleanupName(); - String example = exampleList.get(x++); - - final StringBuilder optBuf = new StringBuilder(name); - if (name.length() < max) { - optBuf.append(createPadding(max - name.length())); - } - optBuf.append(dpad).append(example); - if (example.length() < maxExample) { - optBuf.append(createPadding(maxExample - example.length())); - } - optBuf.append(dpad); - final int nextLineTabStop = max + maxExample + 2 * descPad; - if (option.isDeprecated()) { - optBuf.append(option.getDeprecated()); - } else if (option.getDescription() != null) { - optBuf.append(option.getDescription()); - } - renderWrappedText(sb, width, nextLineTabStop, optBuf.toString()); - if (it.hasNext()) { - sb.append(getNewLine()); - } - } - return sb; - } - } -} diff --git a/apache-rat-ant-parent/apache-rat-tasks/src/main/java/org/apache/rat/anttasks/License.java b/apache-rat-ant-parent/apache-rat-tasks/src/main/java/org/apache/rat/anttasks/License.java deleted file mode 100644 index 7b369623..00000000 --- a/apache-rat-ant-parent/apache-rat-tasks/src/main/java/org/apache/rat/anttasks/License.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.rat.anttasks; - -import org.apache.rat.DeprecationReporter; -import org.apache.rat.license.ILicense; -import org.apache.rat.license.ILicenseFamily; - -import java.util.SortedSet; - -import org.apache.rat.analysis.IHeaderMatcher; - -/** - * Creates a License definition. - * @deprecated use configuration file. - */ -@Deprecated // since 0.17 [email protected](since = "0.17", forRemoval = true, use = "Configuration file and <config> element")// since 0.17 -public class License { - - private final ILicense.Builder builder = ILicense.builder(); - - ILicense.Builder asBuilder() { - return builder; - } - - public ILicense build(SortedSet<ILicenseFamily> context) { - return builder.setLicenseFamilies(context).build(); - } - - public void setNotes(String notes) { - builder.setNote(notes); - } - - public void addNotes(String notes) { - builder.setNote(notes); - } - - - public void setFamily(String licenseFamilyCategory) { - builder.setFamily(licenseFamilyCategory); - } - - public void setId(String id) { - builder.setId(id); - } - - public void setName(String name) { - builder.setName(name); - } - - public void add(IHeaderMatcher.Builder builder) { - this.builder.setMatcher(builder); - } - - public void add(IHeaderMatcher matcher) { - this.builder.setMatcher(matcher); - } -} diff --git a/apache-rat-ant-parent/apache-rat-tasks/src/main/java/org/apache/rat/anttasks/Not.java b/apache-rat-ant-parent/apache-rat-tasks/src/main/java/org/apache/rat/anttasks/Not.java deleted file mode 100644 index f82a0030..00000000 --- a/apache-rat-ant-parent/apache-rat-tasks/src/main/java/org/apache/rat/anttasks/Not.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.rat.anttasks; - -import org.apache.rat.DeprecationReporter; -import org.apache.rat.analysis.IHeaderMatcher; -import org.apache.rat.analysis.IHeaderMatcher.Builder; -import org.apache.rat.configuration.builders.NotBuilder; - -/** - * Creates a Not matcher. - * @deprecated use configuration file. - */ -@Deprecated // since 0.17 [email protected](since = "0.17", forRemoval = true, use = "Configuration file and <config> element")// since 0.17 -public class Not implements IHeaderMatcher.Builder { - - private final NotBuilder builder = Builder.not(); - - @Override - public IHeaderMatcher build() { - return builder.build(); - } - - public void add(IHeaderMatcher.Builder builder) { - this.builder.addEnclosed(builder); - } -} diff --git a/apache-rat-ant-parent/apache-rat-tasks/src/main/java/org/apache/rat/anttasks/Regex.java b/apache-rat-ant-parent/apache-rat-tasks/src/main/java/org/apache/rat/anttasks/Regex.java deleted file mode 100644 index becfcbb1..00000000 --- a/apache-rat-ant-parent/apache-rat-tasks/src/main/java/org/apache/rat/anttasks/Regex.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.rat.anttasks; - -import org.apache.rat.DeprecationReporter; -import org.apache.rat.analysis.IHeaderMatcher; -import org.apache.rat.analysis.matchers.SimpleRegexMatcher; -import org.apache.rat.configuration.builders.RegexBuilder; - -/** - * Creates a Regex matcher. - * @deprecated use configuration file. - */ -@Deprecated // since 0.17 [email protected](since = "0.17", forRemoval = true, use = "Configuration file and <config> element")// since 0.17 -public class Regex implements IHeaderMatcher.Builder { - - private final RegexBuilder builder = new RegexBuilder(); - - public void setExpr(String pattern) { - builder.setExpression(pattern); - } - - public void addText(String pattern) { - builder.setExpression(pattern); - } - - @Override - public SimpleRegexMatcher build() { - return builder.build(); - } -} diff --git a/apache-rat-ant-parent/apache-rat-tasks/src/main/java/org/apache/rat/anttasks/Report.java b/apache-rat-ant-parent/apache-rat-tasks/src/main/java/org/apache/rat/anttasks/Report.java deleted file mode 100644 index 75d7d83b..00000000 --- a/apache-rat-ant-parent/apache-rat-tasks/src/main/java/org/apache/rat/anttasks/Report.java +++ /dev/null @@ -1,601 +0,0 @@ -/* -* Licensed to the Apache Software Foundation (ASF) under one * -* or more contributor license agreements. See the NOTICE file * -* distributed with this work for additional information * -* regarding copyright ownership. The ASF licenses this file * -* to you under the Apache License, Version 2.0 (the * -* "License"); you may not use this file except in compliance * -* with the License. You may obtain a copy of the License at * -* * -* http://www.apache.org/licenses/LICENSE-2.0 * -* * -* Unless required by applicable law or agreed to in writing, * -* software distributed under the License is distributed on an * -* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * -* KIND, either express or implied. See the License for the * -* specific language governing permissions and limitations * -* under the License. * -*/ -package org.apache.rat.anttasks; - -import java.io.File; -import java.io.IOException; -import java.io.PrintWriter; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -import org.apache.commons.cli.Option; -import org.apache.commons.io.filefilter.IOFileFilter; -import org.apache.rat.ConfigurationException; -import org.apache.rat.DeprecationReporter; -import org.apache.rat.ImplementationException; -import org.apache.rat.OptionCollection; -import org.apache.rat.ReportConfiguration; -import org.apache.rat.Reporter; -import org.apache.rat.ant.ResourceCollectionContainer; -import org.apache.rat.commandline.Arg; -import org.apache.rat.commandline.StyleSheets; -import org.apache.rat.document.DocumentName; -import org.apache.rat.license.LicenseSetFactory; -import org.apache.rat.utils.DefaultLog; -import org.apache.rat.utils.Log; -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.Project; -import org.apache.tools.ant.taskdefs.LogOutputStream; -import org.apache.tools.ant.types.EnumeratedAttribute; -import org.apache.tools.ant.types.Resource; -import org.apache.tools.ant.types.ResourceCollection; -import org.apache.tools.ant.types.resources.Union; - -/** - * A basic Ant task that generates a report on all files specified by the nested - * resource collection(s). - * - * <p> - * IHeaderMatcher(s) can be specified as nested elements as well. - * </p> - * - * <p> - * The attribute <code>format</code> defines the output format and can take the - * values - * <ul> - * <li>xml - RAT's native XML output.</li> - * <li>styled - transforms the XML output using the given stylesheet. The - * stylesheet attribute must be set as well if this attribute is used.</li> - * <li>plain - plain text using RAT's built-in stylesheet. This is the - * default.</li> - * </ul> - */ -public class Report extends BaseAntTask { - /** - * The list of licenses - */ - @Deprecated - private final List<License> licenses = new ArrayList<>(); - /** - * The list of license families - */ - @Deprecated - private final List<Family> families = new ArrayList<>(); - /** - * the options that are deprecated. TODO remove this. - */ - private final DeprecatedConfig deprecatedConfig = new DeprecatedConfig(); - /** - * will hold any nested resource collection - */ - private Union nestedResources; - - /** - * Collection of objects that support Ant specific deprecated options - */ - private static final class DeprecatedConfig { - /** - * The input file filter - */ - private IOFileFilter inputFileFilter; - /** - * the set of approved license categories - */ - private final Set<String> approvedLicenseCategories = new HashSet<>(); - /** - * the set of removed (unapproved) license categories - */ - private final Set<String> removedLicenseCategories = new HashSet<>(); - } - - /** - * Constructor. - */ - public Report() { - super(); - // replace the logger only if it has not already been set. - Log oldLog = DefaultLog.getInstance(); - if (oldLog instanceof DefaultLog) { - DefaultLog.setInstance(new Logger()); - DefaultLog.getInstance().setLevel(oldLog.getLevel()); - } - } - - /** - * Adds resources that will be checked. - * - * @param rc resource to check. - */ - public void add(final ResourceCollection rc) { - if (nestedResources == null) { - nestedResources = new Union(); - } - nestedResources.add(rc); - } - - /** - * Adds an input file filter. - * - * @param inputFileFilter The input file filter to add. - */ - @Deprecated - public void setInputFileFilter(final IOFileFilter inputFileFilter) { - DeprecationReporter.logDeprecated("element inputFileFilter", "0.17", true, "outputFile element"); - deprecatedConfig.inputFileFilter = inputFileFilter; - } - - /** - * Sets the report file. - * - * @param reportFile the report file. - * @deprecated use outputFile element - */ - @Deprecated - public void setReportFile(final File reportFile) { - DeprecationReporter.logDeprecated("element reportFile", "0.17", true, "outputFile element"); - addArg("output-file", reportFile.getAbsolutePath()); - } - - /** - * Adds an inline License definition to the system. - * - * @param license the license to add. - * @deprecated Create a custom configuration file and use the config option. - */ - @Deprecated - public void addLicense(final License license) { - licenses.add(license); - } - - /** - * Add an inline license family definition to the system. - * - * @param family the license family to add. - * @deprecated Create a custom configuration file and use the config option. - */ - @Deprecated - public void addFamily(final Family family) { - families.add(family); - } - - /** - * Adds a style sheet to the system. - * - * @param styleSheet The style sheet to use for formatting. - * @deprecated use {@link #setStylesheet(String)} - */ - @Deprecated - public void addStylesheet(final Resource styleSheet) { - DeprecationReporter.logDeprecated("element stylesheet", "0.17", true, "<outputStyle> element"); - setStylesheet(styleSheet.getName()); - } - - /** - * Adds a given style sheet to the report. - * - * @param styleSheet style sheet to use in this report. - * @deprecated use {@link #setOutputStyle(String)} - */ - @Deprecated - public void addStyleSheet(final Resource styleSheet) { - DeprecationReporter.logDeprecated("attribute styleSheet", "0.17", true, "<outputStyle> element"); - setOutputStyle(styleSheet.getName()); - } - - /** - * Styles the report or deliver xml document. - * - * @param styleReport true to use the plain-rat style - * @deprecated use {@link #setOutputStyle(String)} and pass "xml" or "plain-rat". - */ - @Deprecated - public void setStyleReport(final boolean styleReport) { - setOutputStyle(styleReport ? "xml" : "plain-rat"); - } - - /** - * Determines if the output should be styled. - * - * @param style the name of the style sheet ot use, or "styled" for plain-rat style - * @deprecated use {@link #setStylesheet(String)} - */ - @Deprecated - public void setFormat(final String style) { - DeprecationReporter.logDeprecated("attribute format", "0.17", true, "outputStyle element"); - if ("styled".equalsIgnoreCase(style)) { - setOutputStyle("plain-rat"); - } else { - setOutputStyle(style); - } - } - - /** - * Adds as a file containing the definitions of licenses to the system. - * - * @param fileName the file to add. - * @deprecated create a configuration file and use the <config> child element. - */ - @Deprecated - public void setLicenses(final File fileName) { - DeprecationReporter.logDeprecated("attribute licenses", "0.17", true, "<licences> element"); - setArg(Arg.CONFIGURATION.option().getLongOpt(), fileName.getAbsolutePath()); - } - - /** - * Specifies whether to add the default list of license matchers. - * - * @param useDefaultLicenses if {@code true} use the default licenses. - * @deprecated use noDefaultLicenses attribute - */ - @Deprecated - public void setUseDefaultLicenses(final boolean useDefaultLicenses) { - DeprecationReporter.logDeprecated("attribute useDefaultLicenses", "0.17", true, "noDefaultLicenses attribute"); - setNoDefaultLicenses(!useDefaultLicenses); - } - - /** - * Adds a family category to the list of approved licenses. - * - * @param familyCategory the category to add. - * @deprecated use licensesApproved child element. - */ - @Deprecated - public void setAddApprovedLicense(final String familyCategory) { - DeprecationReporter.logDeprecated("attribute addApprovedLicense", "0.17", true, "<licensesApproved> element"); - deprecatedConfig.approvedLicenseCategories.add(familyCategory); - } - - /** - * Adds a family category to the list of approved licenses. - * - * @param familyCategory the category to add - * @deprecated use licensesFamiliesApproved child element - */ - @Deprecated - public void addAddApprovedLicense(final String familyCategory) { - DeprecationReporter.logDeprecated("element <addApprovedLicense>", "0.17", true, "<licenseFamiliesApproved> element"); - deprecatedConfig.approvedLicenseCategories.add(familyCategory); - } - - /** - * Removes a family category to the list of approved licenses. - * - * @param familyCategory the category to add. - * @deprecated use licensesFamiliesDenied child element - */ - @Deprecated - public void setRemoveApprovedLicense(final String familyCategory) { - DeprecationReporter.logDeprecated("attribute addApprovedLicense", "0.17", true, "<licenseFamiliesApproved> element"); - deprecatedConfig.removedLicenseCategories.add(familyCategory); - } - - /** - * Removes a family category to the list of approved licenses. - * - * @param familyCategory the category to add. - * @deprecated use licensesFamiliesDenied child element - */ - @Deprecated - public void addRemoveApprovedLicense(final String familyCategory) { - DeprecationReporter.logDeprecated("element <removeApprovedLicense>", "0.17", true, "<licenseFamiliesDenied> element"); - deprecatedConfig.removedLicenseCategories.add(familyCategory); - } - - /** - * Removes a family category to the list of approved licenses. - * - * @param familyCategory the category to remove - * @deprecated use licenseFamiliesDenied element - */ - @Deprecated - public void setRemoveApprovedLicense(final String[] familyCategory) { - DeprecationReporter.logDeprecated("attribute removeApprovedLicense", "0.17", true, "<licenseFamiliesDenied> element"); - deprecatedConfig.removedLicenseCategories.addAll(Arrays.asList(familyCategory)); - } - - /** - * Removes a family category to the list of approved licenses. - * - * @param familyCategory the category to remove. - * @deprecated use licenseFamilyDenied element - */ - @Deprecated - public void addRemoveApprovedLicense(final String[] familyCategory) { - DeprecationReporter.logDeprecated("element <removeApprovedLicense>", "0.17", true, "<licenseFamiliesDenied> element"); - deprecatedConfig.removedLicenseCategories.addAll(Arrays.asList(familyCategory)); - } - - /** - * Sets the copyright message. - * - * @param copyrightMessage the copyright message - * @deprecated use copyright attribute - */ - @Deprecated - public void setCopyrightMessage(final String copyrightMessage) { - setCopyright(copyrightMessage); - } - - /** - * Determines if license headers should be added. - * - * @param setting the setting. - * @deprecated use editLicense and editOverwrite attributes - */ - @Deprecated - public void setAddLicenseHeaders(final AddLicenseHeaders setting) { - DeprecationReporter.logDeprecated("attribute addLicenseHeaders", "0.17", true, "editLicense and editOverwrite attributes"); - switch (setting.getNative()) { - case TRUE: - setEditLicense(true); - break; - case FALSE: - setEditLicense(false); - break; - case FORCED: - setEditLicense(true); - setEditOverwrite(true); - break; - } - } - - /** - * Adds definition information. - * - * @param fileName the file to add - * @deprecated Use Config child element - */ - @Deprecated - public void setAddDefaultDefinitions(final File fileName) { - DeprecationReporter.logDeprecated("element <addDefaultDefinitions>", "0.17", true, "<config> element"); - setArg(Arg.CONFIGURATION.option().getLongOpt(), fileName.getAbsolutePath()); - } - - /** - * Reads values for the Arg. - * - * @param arg The Arg to get the values for. - * @return The list of values or an empty list. - */ - protected List<String> getValues(final Arg arg) { - List<String> result = new ArrayList<>(); - for (Option option : arg.group().getOptions()) { - if (option.getLongOpt() != null) { - List<String> args = getArg(option.getLongOpt()); - if (args != null) { - result.addAll(args); - } - } - } - return result; - } - - /** - * Removes the values for the arg. - * - * @param arg the arg to remove the values for. - */ - protected void removeKey(final Arg arg) { - for (Option option : arg.group().getOptions()) { - if (option.getLongOpt() != null) { - removeArg(option.getLongOpt()); - } - } - } - - /** - * Creates the ReportConfiguration from the Ant options. - * - * @return the ReportConfiguration. - */ - public ReportConfiguration getConfiguration() { - try { - boolean helpLicenses = !getValues(Arg.HELP_LICENSES).isEmpty(); - removeKey(Arg.HELP_LICENSES); - - final ReportConfiguration configuration = OptionCollection.parseCommands(new File("."), args().toArray(new String[0]), - o -> DefaultLog.getInstance().warn("Help option not supported"), - true); - if (getValues(Arg.OUTPUT_FILE).isEmpty()) { - configuration.setOut(() -> new LogOutputStream(this, Project.MSG_INFO)); - } - DocumentName name = DocumentName.builder(getProject().getBaseDir()).build(); - configuration.addSource(new ResourceCollectionContainer(name, configuration, nestedResources)); - configuration.addApprovedLicenseCategories(deprecatedConfig.approvedLicenseCategories); - configuration.removeApprovedLicenseCategories(deprecatedConfig.removedLicenseCategories); - if (deprecatedConfig.inputFileFilter != null) { - configuration.addExcludedFilter(deprecatedConfig.inputFileFilter); - } - families.stream().map(Family::build).forEach(configuration::addFamily); - licenses.stream().map(License::asBuilder) - .forEach(l -> configuration.addApprovedLicenseCategory(configuration.addLicense(l).getLicenseFamily())); - if (helpLicenses) { - new org.apache.rat.help.Licenses(configuration, new PrintWriter(DefaultLog.getInstance().asWriter())).printHelp(); - } - return configuration; - } catch (IOException | ImplementationException e) { - throw new BuildException(e.getMessage(), e); - } - } - - /** - * Generates the report. - */ - @Override - public void execute() { - try { - Reporter r = new Reporter(validate(getConfiguration())); - r.output(StyleSheets.PLAIN.getStyleSheet(), () -> new ReportConfiguration.NoCloseOutputStream(System.out)); - r.output(); - } catch (BuildException e) { - throw e; - } catch (Exception ioex) { - throw new BuildException(ioex); - } - } - - /** - * Validates the task's configuration. - */ - protected ReportConfiguration validate(final ReportConfiguration cfg) { - try { - cfg.validate(); - } catch (ConfigurationException e) { - throw new BuildException(e.getMessage(), e.getCause()); - } - if (nestedResources == null) { - throw new BuildException("You must specify at least one file to create the report for."); - } - return cfg; - } - - /** - * Add headers to files that do not have them. - * - * @deprecated use <editCopyright> amd <editOverwrite> instead. - */ - @Deprecated - public static class AddLicenseHeaders extends EnumeratedAttribute { - /** - * add license headers and create *.new file - */ - static final String TRUE = "true"; - /** - * do not add license headers - */ - static final String FALSE = "false"; - /** - * add license headers and overwrite existing files - */ - static final String FORCED = "forced"; - - public AddLicenseHeaders() { - } - - public AddLicenseHeaders(final String s) { - setValue(s); - } - - @Override - public String[] getValues() { - return new String[]{TRUE, FALSE, FORCED}; - } - - public org.apache.rat.config.AddLicenseHeaders getNative() { - return org.apache.rat.config.AddLicenseHeaders.valueOf(getValue().toUpperCase()); - } - } - - /** - * Specify the licenses that are approved. - * - * @deprecated use listLicenses or listFamilies attributes. - */ - @Deprecated - public static class ApprovalFilter extends EnumeratedAttribute { - - public ApprovalFilter() { - } - - public ApprovalFilter(final String s) { - setValue(s); - } - - @Override - public String[] getValues() { - return Arrays.stream(LicenseSetFactory.LicenseFilter.values()).map(LicenseSetFactory.LicenseFilter::name) - .toList().toArray(new String[LicenseSetFactory.LicenseFilter.values().length]); - } - - public LicenseSetFactory.LicenseFilter internalFilter() { - return LicenseSetFactory.LicenseFilter.valueOf(getValue()); - } - } - - @Override - public void log(final String msg, final int msgLevel) { - if (getProject() != null) { - getProject().log(msg, msgLevel); - } else { - DefaultLog.createDefault().log(fromProjectLevel(msgLevel), msg); - } - } - - @Override - public void log(final String msg, final Throwable t, final int msgLevel) { - if (getProject() == null) { - log(Log.formatLogEntry(msg, t), msgLevel); - } else { - getProject().log(this, msg, t, msgLevel); - } - } - - /** - * Converts to RAT log level from Ant Project log level. - * @param level the Ant Project log level to convert. - * @return the equivalent RAT log level. - */ - public static Log.Level fromProjectLevel(final int level) { - return switch (level) { - case Project.MSG_DEBUG, Project.MSG_VERBOSE -> Log.Level.DEBUG; - case Project.MSG_INFO -> Log.Level.INFO; - case Project.MSG_WARN -> Log.Level.WARN; - case Project.MSG_ERR -> Log.Level.ERROR; - default -> Log.Level.OFF; - }; - } - - /** - * Converts RAT log level to Ant Project log level. - * @param level the RAT log level to convert. - * @return the equivalent Ant Project log level. - */ - static int toProjectLevel(final Log.Level level) { - return switch (level) { - case DEBUG -> Project.MSG_DEBUG; - case INFO -> Project.MSG_INFO; - case WARN -> Project.MSG_WARN; - case ERROR -> Project.MSG_ERR; - default -> -1; - }; - } - - /** - * A facade for the Logger provided by Ant. - */ - private final class Logger implements Log { - @Override - public Level getLevel() { - return Level.DEBUG; - } - - @Override - public void log(final Log.Level level, final String message, final Throwable throwable) { - log(level, Log.formatLogEntry(message, throwable)); - } - - @Override - public void log(final Level level, final String msg) { - Report.this.log(msg, toProjectLevel(level)); - } - } -} diff --git a/apache-rat-ant-parent/apache-rat-tasks/src/main/java/org/apache/rat/anttasks/Spdx.java b/apache-rat-ant-parent/apache-rat-tasks/src/main/java/org/apache/rat/anttasks/Spdx.java deleted file mode 100644 index 228d4805..00000000 --- a/apache-rat-ant-parent/apache-rat-tasks/src/main/java/org/apache/rat/anttasks/Spdx.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.rat.anttasks; - -import org.apache.rat.DeprecationReporter; -import org.apache.rat.analysis.IHeaderMatcher; -import org.apache.rat.configuration.builders.SpdxBuilder; - -/** - * Creates a SPDX matcher. - * @deprecated use configuration file. - */ -@Deprecated // since 0.17 [email protected](since = "0.17", forRemoval = true, use = "Configuration file and <config> element")// since 0.17 -public class Spdx implements IHeaderMatcher.Builder { - - private final SpdxBuilder builder = new SpdxBuilder(); - - public void setName(String spdxId) { - builder.setName(spdxId); - } - - public void addText(String spdxId) { - builder.setName(spdxId); - } - - @Override - public IHeaderMatcher build() { - return builder.build(); - } -} diff --git a/apache-rat-ant-parent/apache-rat-tasks/src/main/java/org/apache/rat/anttasks/Text.java b/apache-rat-ant-parent/apache-rat-tasks/src/main/java/org/apache/rat/anttasks/Text.java deleted file mode 100644 index 6778343d..00000000 --- a/apache-rat-ant-parent/apache-rat-tasks/src/main/java/org/apache/rat/anttasks/Text.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.rat.anttasks; - -import org.apache.rat.DeprecationReporter; -import org.apache.rat.analysis.IHeaderMatcher; -import org.apache.rat.configuration.builders.TextBuilder; - -/** - * Creates a text matcher. - * @deprecated use configuration file. - */ -@Deprecated // since 0.17 [email protected](since = "0.17", forRemoval = true, use = "Configuration file and <config> element")// since 0.17 -public class Text implements IHeaderMatcher.Builder { - - private final TextBuilder builder = new TextBuilder(); - - public void addText(String text) { - builder.setSimpleText(text); - } - - public void setText(String text) { - builder.setSimpleText(text); - } - @Override - public IHeaderMatcher build() { - return builder.build(); - } -} diff --git a/apache-rat-ant-parent/apache-rat-tasks/src/main/java/org/apache/rat/anttasks/package-info.java b/apache-rat-ant-parent/apache-rat-tasks/src/main/java/org/apache/rat/anttasks/package-info.java deleted file mode 100644 index 23f7a765..00000000 --- a/apache-rat-ant-parent/apache-rat-tasks/src/main/java/org/apache/rat/anttasks/package-info.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one * - * or more contributor license agreements. See the NOTICE file * - * distributed with this work for additional information * - * regarding copyright ownership. The ASF licenses this file * - * to you under the Apache License, Version 2.0 (the * - * "License"); you may not use this file except in compliance * - * with the License. You may obtain a copy of the License at * - * * - * http://www.apache.org/licenses/LICENSE-2.0 * - * * - * Unless required by applicable law or agreed to in writing, * - * software distributed under the License is distributed on an * - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * - * KIND, either express or implied. See the License for the * - * specific language governing permissions and limitations * - * under the License. * - */ - -/** - * The base package for the RAT Apache Ant Task Library. - */ -package org.apache.rat.anttasks; - diff --git a/apache-rat-ant-parent/tools/src/main/resources/org/apache/rat/ant/CodeGenerator/AbstractAnt.vm b/apache-rat-ant-parent/tools/src/main/resources/org/apache/rat/ant/CodeGenerator/AbstractAnt.vm index b7fa9c99..61681709 100644 --- a/apache-rat-ant-parent/tools/src/main/resources/org/apache/rat/ant/CodeGenerator/AbstractAnt.vm +++ b/apache-rat-ant-parent/tools/src/main/resources/org/apache/rat/ant/CodeGenerator/AbstractAnt.vm @@ -27,6 +27,7 @@ import org.apache.tools.ant.types.resources.FileResource; * Generated class to provide Ant support for standard RAT command line options. * DO NOT EDIT - GENERATED FILE */ +@SuppressWarnings("checkstyle:LineLength") public final class AntReport extends AbstractAntReport { /** diff --git a/apache-rat-ant-parent/tools/src/main/resources/org/apache/rat/ant/CodeGenerator/AntElementClass.vm b/apache-rat-ant-parent/tools/src/main/resources/org/apache/rat/ant/CodeGenerator/AntElementClass.vm index 8493b058..b5287b0c 100644 --- a/apache-rat-ant-parent/tools/src/main/resources/org/apache/rat/ant/CodeGenerator/AntElementClass.vm +++ b/apache-rat-ant-parent/tools/src/main/resources/org/apache/rat/ant/CodeGenerator/AntElementClass.vm @@ -20,4 +20,4 @@ * Handles ${className} processing. */ public class ${className} { - ${className}() {} + ${className}() { } diff --git a/apache-rat-ant-parent/tools/src/main/resources/org/apache/rat/ant/CodeGenerator/defaultTypeTemplate.vm b/apache-rat-ant-parent/tools/src/main/resources/org/apache/rat/ant/CodeGenerator/defaultTypeTemplate.vm index 88312c9a..023f8a9a 100644 --- a/apache-rat-ant-parent/tools/src/main/resources/org/apache/rat/ant/CodeGenerator/defaultTypeTemplate.vm +++ b/apache-rat-ant-parent/tools/src/main/resources/org/apache/rat/ant/CodeGenerator/defaultTypeTemplate.vm @@ -2,6 +2,6 @@ * Sets the ${argName} (${option.keyValue}). * @param ${argName} The ${argName} value. */ - public void add${argType}(String ${argName}) { + public void add${argType}(final String ${argName}) { addArg("${option.keyValue}", ${argName}); } diff --git a/apache-rat-ant-parent/tools/src/main/resources/org/apache/rat/ant/CodeGenerator/fileSetTemplate.vm b/apache-rat-ant-parent/tools/src/main/resources/org/apache/rat/ant/CodeGenerator/fileSetTemplate.vm index 6a1d417c..b52689fc 100644 --- a/apache-rat-ant-parent/tools/src/main/resources/org/apache/rat/ant/CodeGenerator/fileSetTemplate.vm +++ b/apache-rat-ant-parent/tools/src/main/resources/org/apache/rat/ant/CodeGenerator/fileSetTemplate.vm @@ -2,7 +2,7 @@ * Adds a configured ${argType} to the ${option.keyValue}. * @param ${argName} The ${argName} to add to ${option.keyValue}. */ - public void addConfigured${argType}(${argType} ${argName}) { + public void addConfigured${argType}(final ${argType} ${argName}) { for (Resource resource : ${argName}) { if (resource.isFilesystemOnly()) { argumentTracker.addArg("${option.keyValue}", ((FileResource) resource).getFile().getAbsolutePath()); diff --git a/apache-rat-ant-parent/tools/src/main/resources/org/apache/rat/ant/CodeGenerator/textValueTemplate.vm b/apache-rat-ant-parent/tools/src/main/resources/org/apache/rat/ant/CodeGenerator/textValueTemplate.vm index fb7d7176..4d975724 100644 --- a/apache-rat-ant-parent/tools/src/main/resources/org/apache/rat/ant/CodeGenerator/textValueTemplate.vm +++ b/apache-rat-ant-parent/tools/src/main/resources/org/apache/rat/ant/CodeGenerator/textValueTemplate.vm @@ -2,6 +2,6 @@ * Adds the ${argName} {@link AbstractAntReport.${argType}} to ${option.keyValue}. * @param ${argName} The ${argType} to add to ${option.keyValue}. */ - public void addConfigured${argType}(${argType} ${argName}) { + public void addConfigured${argType}(final ${argType} ${argName}) { argumentTracker.addArg("${option.keyValue}", ${argName}.toString()); }
