Skip to content

Commit

Permalink
Add clone of IgnoreEmptyDirectories annotation to allow compiling the…
Browse files Browse the repository at this point in the history
… forbiddenapis task with it. This works around problems with Grdale 7.4+. Closes #189
  • Loading branch information
uschindler committed Mar 24, 2022
1 parent 109e582 commit f72cf55
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
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
39 changes: 39 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,39 @@
/*
* 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}.
*/
@Documented
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.METHOD, ElementType.FIELD})
public @interface IgnoreEmptyDirectories {
}

0 comments on commit f72cf55

Please sign in to comment.