Skip to content

Commit

Permalink
Add clone of IgnoreEmptyDirectories annotation to allow compiling for…
Browse files Browse the repository at this point in the history
…biddenapis task with it (#193)
  • Loading branch information
uschindler authored Mar 24, 2022
1 parent d9203a9 commit b95dc27
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 1 deletion.
2 changes: 1 addition & 1 deletion build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@
<ivy:cachefileset setid="fileset.bundle" conf="bundle" log="${ivy.logging}"/>
<mkdir dir="dist"/>
<jarjar destfile="${jar-file}">
<zipfileset dir="build/main"/>
<zipfileset dir="build/main" excludes="org/gradle/**"/>
<restrict>
<name name="**/*.class" handledirsep="true"/>
<not>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,14 @@
import org.gradle.api.file.FileTreeElement;
import org.gradle.api.specs.Spec;
import org.gradle.api.tasks.CompileClasspath;
import org.gradle.api.tasks.IgnoreEmptyDirectories;
import org.gradle.api.tasks.Input;
import org.gradle.api.tasks.InputFiles;
import org.gradle.api.tasks.Internal;
import org.gradle.api.tasks.Optional;
import org.gradle.api.tasks.ParallelizableTask;
import org.gradle.api.tasks.PathSensitive;
import org.gradle.api.tasks.PathSensitivity;
import org.gradle.api.tasks.SkipWhenEmpty;
import org.gradle.api.tasks.TaskAction;
import org.gradle.api.tasks.VerificationTask;
Expand Down Expand Up @@ -465,6 +468,8 @@ public CheckForbiddenApis include(@SuppressWarnings("rawtypes") Closure arg0) {
/** Returns the classes to check. */
@InputFiles
@SkipWhenEmpty
@IgnoreEmptyDirectories
@PathSensitive(PathSensitivity.RELATIVE)
public FileTree getClassFiles() {
return getClassesDirs().getAsFileTree().matching(getPatternSet());
}
Expand Down
40 changes: 40 additions & 0 deletions src/main/java/org/gradle/api/tasks/IgnoreEmptyDirectories.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* Copyright 2020 the original author or authors.
*
* 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.
*/

package org.gradle.api.tasks;

import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

import de.thetaphi.forbiddenapis.gradle.CheckForbiddenApis;

/**
* Attached to an input property to specify that directories should be ignored
* when snapshotting inputs. Files within directories and subdirectories will be
* snapshot, but the directories themselves will be ignored. Empty directories,
* and directories that contain only empty directories will have no effect on the
* resulting snapshot.
* <p>Copy of Gradle 6.8 annotation to allow compilation of {@link CheckForbiddenApis}.
* It is excluded from the JAR file (runtime annotations are still optional at runtime).
*/
@Documented
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.METHOD, ElementType.FIELD})
public @interface IgnoreEmptyDirectories {
}

0 comments on commit b95dc27

Please sign in to comment.