diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..77f8dbe --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,18 @@ +version: 2 +updates: +- package-ecosystem: maven + directory: "/" + schedule: + interval: weekly + groups: + maven: + patterns: + - "*" +- package-ecosystem: github-actions + directory: "/" + schedule: + interval: weekly + groups: + github-actions: + patterns: + - "*" diff --git a/.github/workflows/maven.yaml b/.github/workflows/maven.yaml index d456a91..5e45454 100644 --- a/.github/workflows/maven.yaml +++ b/.github/workflows/maven.yaml @@ -1,15 +1,3 @@ -# Licensed 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. - # This workflow will build a Java project with Maven # For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven @@ -26,22 +14,24 @@ jobs: strategy: matrix: os: [ubuntu-latest, windows-latest, macOS-latest] + java: [17] fail-fast: false runs-on: ${{ matrix.os }} steps: - - uses: actions/checkout@v2 - - name: Set up JDK 11 - uses: actions/setup-java@v1 + - uses: actions/checkout@v4 + - name: Set up JDK + uses: actions/setup-java@v4 with: - java-version: 11 + java-version: ${{ matrix.java }} + distribution: zulu - name: Cache local maven repository - uses: actions/cache@v2 + uses: actions/cache@v4 with: path: ~/.m2 key: ${{ matrix.os }}-m2-${{ hashFiles('**/pom.xml') }} restore-keys: ${{ matrix.os }}-m2 - name: Build with Maven - run: mvn -B -V -e "-Dstyle.color=always" verify + run: mvn -B -V -e "-Dstyle.color=always" verify -DskipFormat -DverifyFormat env: MAVEN_OPTS: -Djansi.force=true diff --git a/pom.xml b/pom.xml index 5d7cc55..efb387c 100644 --- a/pom.xml +++ b/pom.xml @@ -1,25 +1,26 @@ 4.0.0 - org.apache - apache - 23 + net.revelc.code + revelc + 5 - net.revelc.code warbucks-maven-plugin 1.2.0-SNAPSHOT maven-plugin @@ -27,101 +28,28 @@ A Maven plugin to enforce the requirement for particular annotations (for specified classes) https://code.revelc.net/warbucks-maven-plugin 2016 - - Revelc - https://github.com/revelc - - - - Apache License, Version 2.0 - https://www.apache.org/licenses/LICENSE-2.0 - repo - - Christopher Tubbs - - - - ${maven.min-version} + 3.6.3 - scm:git:https://github.com/revelc/warbucks-maven-plugin.git - scm:git:git@github.com:revelc/warbucks-maven-plugin.git HEAD - https://github.com/revelc/warbucks-maven-plugin - - GitHub - https://github.com/revelc/warbucks-maven-plugin/issues - - - GitHub - https://github.com/revelc/warbucks-maven-plugin/actions - - - - - sonatype-nexus-staging - Sonatype Release Distribution Staging Repository - https://oss.sonatype.org/service/local/staging/deploy/maven2 - - - sonatype-nexus-snapshots - Sonatype Snapshot Distribution Repository - https://oss.sonatype.org/content/repositories/snapshots - - - src/tools/modified-google-style.xml - warbucks-maven-plugin - revelc + src/tools/modified-google-style.xml 8 - 1.8 - 1.8 - 3.6.0 - - true - 1.10.19 - UTF-8 - UTF-8 - source-release-tar + src/main/spotbugs/exclude-filter.xml com.google.guava guava - 29.0-jre - - - junit - junit - 4.13.1 - - - org.apache.maven - maven-core - 3.6.3 - - - org.apache.maven - maven-plugin-api - 3.6.3 - - - org.apache.maven.plugin-tools - maven-plugin-annotations - 3.6.0 - - - org.mockito - mockito-all - ${mockitoVersion} + 33.0.0-jre @@ -130,189 +58,9 @@ com.google.guava guava - - org.apache.maven - maven-core - provided - - - org.apache.maven - maven-plugin-api - provided - - - org.apache.maven.plugin-tools - maven-plugin-annotations - provided - - - junit - junit - test - - - org.mockito - mockito-all - test - - - - - - org.codehaus.mojo - versions-maven-plugin - 2.7 - - - org.gaul - modernizer-maven-plugin - 1.8.0 - - ${maven.compiler.target} - - - - com.github.github - site-maven-plugin - 0.12 - - - com.github.ekryd.sortpom - sortpom-maven-plugin - 2.10.0 - - recommended_2008_06 - false - \n - false - 2 - scope,groupId,artifactId - true - - - - org.apache.maven.plugins - maven-compiler-plugin - 3.8.1 - - true - true - true - - -Xlint:all - -Xlint:-processing - -Xmaxwarns - 5 - - - - - org.apache.maven.plugins - maven-release-plugin - - false - false - true - - - - net.revelc.code.formatter - formatter-maven-plugin - 2.11.0 - - ${maven.compiler.source} - ${maven.compiler.source} - ${maven.compiler.target} - LF - true - true - true - true - true - true - ${formatterConfigFile} - - - - net.revelc.code - impsort-maven-plugin - 1.4.1 - - java.,javax.,org.,com. - - - - org.apache.maven.plugins - maven-checkstyle-plugin - 3.1.0 - - - com.github.spotbugs - spotbugs-maven-plugin - 4.0.4 - - true - Max - true - true - 20 - src/main/spotbugs/exclude-filter.xml - - - - - - net.revelc.code.formatter - formatter-maven-plugin - - - format-java-source - - format - - - - - - net.revelc.code - impsort-maven-plugin - - - sort-imports - - sort - - - - - - com.github.ekryd.sortpom - sortpom-maven-plugin - - - sort-pom - - sort - - validate - - - - - org.gaul - modernizer-maven-plugin - - - modernizer - - modernizer - - - - org.apache.maven.plugins maven-checkstyle-plugin @@ -328,41 +76,6 @@ - - org.apache.maven.plugins - maven-enforcer-plugin - - - enforce-mvn - - enforce - - - - - [${maven.min-version},) - - - [11,) - - - - - - - - org.apache.maven.plugins - maven-failsafe-plugin - - - run-integration-tests - - integration-test - verify - - - - com.github.spotbugs spotbugs-maven-plugin @@ -375,210 +88,6 @@ - - org.apache.rat - apache-rat-plugin - - - check-licenses - - check - - - - - - com.github.github - site-maven-plugin - - - create-github-pages - - site - - site-deploy - - github - Creating site for ${project.version} - true - - - - - - org.apache.maven.plugins - maven-invoker-plugin - - ${project.build.directory}/it - - */pom.xml - - ${project.build.directory}/local-repo - src/it/settings.xml - - -e - - clean - verify - -Dwarbucks.ignoreRuleFailures - - - - - integration-test - - install - run - - - - - - - - org.apache.maven.plugins - maven-plugin-plugin - 3.6.0 - - - org.apache.maven.plugins - maven-project-info-reports-plugin - 3.0.0 - - - - - - eclipse - - - m2e.version - - - - - - - - org.eclipse.m2e - lifecycle-mapping - 1.0.0 - - - - - - com.github.ekryd.sortpom - sortpom-maven-plugin - [0,) - - sort - - - - - - - - - org.gaul - modernizer-maven-plugin - [0,) - - modernizer - - - - - - - - - org.apache.maven.plugins - maven-enforcer-plugin - [0,) - - enforce - - - - - - - - - org.apache.maven.plugins - maven-invoker-plugin - [0,) - - install - - - - - - - - - org.apache.maven.plugins - maven-remote-resources-plugin - [0,) - - process - - - - - - - - - org.apache.rat - apache-rat-plugin - [0,) - - check - - - - - - - - - org.apache.maven.plugins - maven-checkstyle-plugin - [0,) - - check - - - - - - - - - org.apache.maven.plugins - maven-plugin-plugin - [0,) - - descriptor - - - - - - - - - - - - - - - diff --git a/src/it/plugin-test/invoker.properties b/src/it/plugin-test/invoker.properties new file mode 100644 index 0000000..07ae3c5 --- /dev/null +++ b/src/it/plugin-test/invoker.properties @@ -0,0 +1,18 @@ +# +# Licensed 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 +# +# https://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. +# + +invoker.goals = clean verify -X -D"warbucks.ignoreRuleFailures" + +# The expected result of the build, possible values are "success" (default) and "failure" +invoker.buildResult = success diff --git a/src/it/plugin-test/pom.xml b/src/it/plugin-test/pom.xml index 24cac86..cd5a6ac 100644 --- a/src/it/plugin-test/pom.xml +++ b/src/it/plugin-test/pom.xml @@ -1,16 +1,18 @@ 4.0.0 diff --git a/src/it/plugin-test/postbuild.groovy b/src/it/plugin-test/postbuild.groovy index ee02fb2..6f70d28 100644 --- a/src/it/plugin-test/postbuild.groovy +++ b/src/it/plugin-test/postbuild.groovy @@ -3,7 +3,7 @@ * 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 + * https://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, diff --git a/src/it/plugin-test/src/main/java/net/revelc/code/wmp/Noop.java b/src/it/plugin-test/src/main/java/net/revelc/code/wmp/Noop.java index bcc5ddf..4ad1be9 100644 --- a/src/it/plugin-test/src/main/java/net/revelc/code/wmp/Noop.java +++ b/src/it/plugin-test/src/main/java/net/revelc/code/wmp/Noop.java @@ -3,7 +3,7 @@ * 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 + * https://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, diff --git a/src/it/plugin-test/src/test/java/net/revelc/code/wmp/PluginIT.java b/src/it/plugin-test/src/test/java/net/revelc/code/wmp/PluginIT.java index 0ce16c8..efd09eb 100644 --- a/src/it/plugin-test/src/test/java/net/revelc/code/wmp/PluginIT.java +++ b/src/it/plugin-test/src/test/java/net/revelc/code/wmp/PluginIT.java @@ -3,7 +3,7 @@ * 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 + * https://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, diff --git a/src/it/settings.xml b/src/it/settings.xml index 978e5b2..935a0dc 100644 --- a/src/it/settings.xml +++ b/src/it/settings.xml @@ -1,16 +1,18 @@ diff --git a/src/main/java/net/revelc/code/warbucks/maven/plugin/CheckMojo.java b/src/main/java/net/revelc/code/warbucks/maven/plugin/CheckMojo.java index 4869f67..13cee76 100644 --- a/src/main/java/net/revelc/code/warbucks/maven/plugin/CheckMojo.java +++ b/src/main/java/net/revelc/code/warbucks/maven/plugin/CheckMojo.java @@ -3,7 +3,7 @@ * 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 + * https://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, @@ -15,7 +15,6 @@ package net.revelc.code.warbucks.maven.plugin; import java.util.List; - import org.apache.maven.plugin.AbstractMojo; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; diff --git a/src/main/java/net/revelc/code/warbucks/maven/plugin/Rule.java b/src/main/java/net/revelc/code/warbucks/maven/plugin/Rule.java index 79ac4fa..1178f6a 100644 --- a/src/main/java/net/revelc/code/warbucks/maven/plugin/Rule.java +++ b/src/main/java/net/revelc/code/warbucks/maven/plugin/Rule.java @@ -3,7 +3,7 @@ * 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 + * https://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, @@ -16,8 +16,8 @@ public class Rule { - private String classAnnotationPattern; - private String classPattern; + private String classAnnotationPattern = null; + private String classPattern = null; private boolean includeMainClasses = true; private boolean includeTestClasses = false; private boolean includePublicClasses = true; @@ -25,10 +25,18 @@ public class Rule { private boolean includeProtectedClasses = true; private boolean includePrivateClasses = true; + public void setClassAnnotationPattern(String pattern) { + classAnnotationPattern = pattern; + } + public String getClassAnnotationPattern() { return classAnnotationPattern; } + public void setClassPattern(String pattern) { + classPattern = pattern; + } + public String getClassPattern() { return classPattern; } diff --git a/src/main/java/net/revelc/code/warbucks/maven/plugin/RuleProcessor.java b/src/main/java/net/revelc/code/warbucks/maven/plugin/RuleProcessor.java index 41154c3..83b353c 100644 --- a/src/main/java/net/revelc/code/warbucks/maven/plugin/RuleProcessor.java +++ b/src/main/java/net/revelc/code/warbucks/maven/plugin/RuleProcessor.java @@ -3,7 +3,7 @@ * 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 + * https://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, @@ -14,6 +14,9 @@ package net.revelc.code.warbucks.maven.plugin; +import com.google.common.annotations.VisibleForTesting; +import com.google.common.reflect.ClassPath; +import com.google.common.reflect.ClassPath.ClassInfo; import java.io.File; import java.io.IOException; import java.lang.annotation.Annotation; @@ -27,15 +30,10 @@ import java.util.concurrent.atomic.AtomicLong; import java.util.function.Predicate; import java.util.regex.Pattern; - import org.apache.maven.artifact.DependencyResolutionRequiredException; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.logging.Log; -import com.google.common.annotations.VisibleForTesting; -import com.google.common.reflect.ClassPath; -import com.google.common.reflect.ClassPath.ClassInfo; - class RuleProcessor { private final Rule rule; diff --git a/src/main/resources/META-INF/m2e/lifecycle-mapping-metadata.xml b/src/main/resources/META-INF/m2e/lifecycle-mapping-metadata.xml index fffee66..0c1548e 100644 --- a/src/main/resources/META-INF/m2e/lifecycle-mapping-metadata.xml +++ b/src/main/resources/META-INF/m2e/lifecycle-mapping-metadata.xml @@ -5,7 +5,7 @@ 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 + https://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, diff --git a/src/main/resources/META-INF/revelc/revelc-maven-plugin b/src/main/resources/META-INF/revelc/revelc-maven-plugin new file mode 100644 index 0000000..f919243 --- /dev/null +++ b/src/main/resources/META-INF/revelc/revelc-maven-plugin @@ -0,0 +1,14 @@ +# +# Licensed 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 +# +# https://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. +# + diff --git a/src/main/spotbugs/exclude-filter.xml b/src/main/spotbugs/exclude-filter.xml index c4bd6aa..77ebc33 100644 --- a/src/main/spotbugs/exclude-filter.xml +++ b/src/main/spotbugs/exclude-filter.xml @@ -1,15 +1,17 @@ diff --git a/src/site/markdown/index.md.vm b/src/site/markdown/index.md.vm index bb30739..9496737 100644 --- a/src/site/markdown/index.md.vm +++ b/src/site/markdown/index.md.vm @@ -1,21 +1,22 @@ #set ($d = "$") -Description ------------ +## Description This `warbucks-maven-plugin` makes it possible to evaluate your project's classes to ensure they are annotated as desired. @@ -29,8 +30,7 @@ Description A rule is composed of a pattern for identifying the classes to evaluate, and a pattern for the annotations one requires to be used. -Getting Started ---------------- +## Getting Started To add this plugin to your project, configure the plugin similarly to: diff --git a/src/site/site.xml b/src/site/site.xml index c8e2b31..789eb1d 100644 --- a/src/site/site.xml +++ b/src/site/site.xml @@ -1,34 +1,27 @@ org.apache.maven.skins maven-fluido-skin - 1.5 + ${version.maven-fluido-skin} - - - revelc/warbucks-maven-plugin - right - - - - - true true @@ -39,11 +32,5 @@ - diff --git a/src/test/java/net/revelc/code/warbucks/maven/plugin/TestRuleProcessor.java b/src/test/java/net/revelc/code/warbucks/maven/plugin/TestRuleProcessor.java index 3e3f76b..2963251 100644 --- a/src/test/java/net/revelc/code/warbucks/maven/plugin/TestRuleProcessor.java +++ b/src/test/java/net/revelc/code/warbucks/maven/plugin/TestRuleProcessor.java @@ -3,7 +3,7 @@ * 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 + * https://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, @@ -14,18 +14,16 @@ package net.revelc.code.warbucks.maven.plugin; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.util.ArrayList; import java.util.Arrays; import java.util.EnumSet; import java.util.List; import java.util.stream.Collectors; - -import org.junit.Test; -import org.mockito.Mockito; +import org.junit.jupiter.api.Test; public class TestRuleProcessor { @@ -84,26 +82,27 @@ private static List> merge(List> lhs, * @return a mock Rule having passed modifiers */ private static Rule createRule(EnumSet modifiers) { - Rule rule = Mockito.mock(Rule.class); - for (Modifier mod : Modifier.values()) { - boolean value = modifiers.contains(mod); - switch (mod) { - case PUBLIC: - Mockito.when(rule.getIncludePublicClasses()).thenReturn(value); - break; - case PACKAGE_PRIVATE: - Mockito.when(rule.getIncludePackagePrivateClasses()).thenReturn(value); - break; - case PROTECTED: - Mockito.when(rule.getIncludeProtectedClasses()).thenReturn(value); - break; - case PRIVATE: - Mockito.when(rule.getIncludePrivateClasses()).thenReturn(value); - break; - default: - throw new RuntimeException("Unsupported modififer:" + mod); + Rule rule = new Rule() { + @Override + public boolean getIncludePublicClasses() { + return modifiers.contains(Modifier.PUBLIC); } - } + + @Override + public boolean getIncludePackagePrivateClasses() { + return modifiers.contains(Modifier.PACKAGE_PRIVATE); + } + + @Override + public boolean getIncludeProtectedClasses() { + return modifiers.contains(Modifier.PROTECTED); + } + + @Override + public boolean getIncludePrivateClasses() { + return modifiers.contains(Modifier.PRIVATE); + } + }; return rule; } diff --git a/src/tools/modified-google-style.xml b/src/tools/modified-google-style.xml index b5a9136..9009f8a 100644 --- a/src/tools/modified-google-style.xml +++ b/src/tools/modified-google-style.xml @@ -1,16 +1,18 @@