Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add clone of IgnoreEmptyDirectories annotation to allow compiling forbiddenapis task with it #193

Merged
merged 4 commits into from
Mar 24, 2022
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 {
}