Skip to content

Commit b95dc27

Browse files
authored
Add clone of IgnoreEmptyDirectories annotation to allow compiling forbiddenapis task with it (#193)
1 parent d9203a9 commit b95dc27

File tree

3 files changed

+46
-1
lines changed

3 files changed

+46
-1
lines changed

build.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,7 @@
414414
<ivy:cachefileset setid="fileset.bundle" conf="bundle" log="${ivy.logging}"/>
415415
<mkdir dir="dist"/>
416416
<jarjar destfile="${jar-file}">
417-
<zipfileset dir="build/main"/>
417+
<zipfileset dir="build/main" excludes="org/gradle/**"/>
418418
<restrict>
419419
<name name="**/*.class" handledirsep="true"/>
420420
<not>

src/main/java/de/thetaphi/forbiddenapis/gradle/CheckForbiddenApis.java

+5
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,14 @@
4040
import org.gradle.api.file.FileTreeElement;
4141
import org.gradle.api.specs.Spec;
4242
import org.gradle.api.tasks.CompileClasspath;
43+
import org.gradle.api.tasks.IgnoreEmptyDirectories;
4344
import org.gradle.api.tasks.Input;
4445
import org.gradle.api.tasks.InputFiles;
4546
import org.gradle.api.tasks.Internal;
4647
import org.gradle.api.tasks.Optional;
4748
import org.gradle.api.tasks.ParallelizableTask;
49+
import org.gradle.api.tasks.PathSensitive;
50+
import org.gradle.api.tasks.PathSensitivity;
4851
import org.gradle.api.tasks.SkipWhenEmpty;
4952
import org.gradle.api.tasks.TaskAction;
5053
import org.gradle.api.tasks.VerificationTask;
@@ -465,6 +468,8 @@ public CheckForbiddenApis include(@SuppressWarnings("rawtypes") Closure arg0) {
465468
/** Returns the classes to check. */
466469
@InputFiles
467470
@SkipWhenEmpty
471+
@IgnoreEmptyDirectories
472+
@PathSensitive(PathSensitivity.RELATIVE)
468473
public FileTree getClassFiles() {
469474
return getClassesDirs().getAsFileTree().matching(getPatternSet());
470475
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/*
2+
* Copyright 2020 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.gradle.api.tasks;
18+
19+
import java.lang.annotation.Documented;
20+
import java.lang.annotation.ElementType;
21+
import java.lang.annotation.Retention;
22+
import java.lang.annotation.RetentionPolicy;
23+
import java.lang.annotation.Target;
24+
25+
import de.thetaphi.forbiddenapis.gradle.CheckForbiddenApis;
26+
27+
/**
28+
* Attached to an input property to specify that directories should be ignored
29+
* when snapshotting inputs. Files within directories and subdirectories will be
30+
* snapshot, but the directories themselves will be ignored. Empty directories,
31+
* and directories that contain only empty directories will have no effect on the
32+
* resulting snapshot.
33+
* <p>Copy of Gradle 6.8 annotation to allow compilation of {@link CheckForbiddenApis}.
34+
* It is excluded from the JAR file (runtime annotations are still optional at runtime).
35+
*/
36+
@Documented
37+
@Retention(RetentionPolicy.RUNTIME)
38+
@Target({ElementType.METHOD, ElementType.FIELD})
39+
public @interface IgnoreEmptyDirectories {
40+
}

0 commit comments

Comments
 (0)