Skip to content

Commit

Permalink
Add a deprecation warning and update some docs. Also add null checks.
Browse files Browse the repository at this point in the history
  • Loading branch information
uschindler committed Jul 19, 2017
1 parent 5ded20c commit 7e9fd78
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -126,26 +126,32 @@ public FileCollection getClassesDirs() {

/** @see #getClassesDirs */
public void setClassesDirs(FileCollection classesDirs) {
if (classesDirs == null) throw new NullPointerException("classesDirs");
this.classesDirs = classesDirs;
}

/**
* Directory with the class files to check.
* Defaults to current sourseSet's output directory.
* @deprecated use {@link #getClassesDirs()} instead
* Defaults to current sourseSet's output directory (Gradle 2/3 only).
* @deprecated use {@link #getClassesDirs()} instead. If there are more than one
* {@code classesDir} set by {@link #setClassesDirs(FileCollection)}, this getter may
* throw an exception!
*/
@Deprecated
public File getClassesDir() {
final FileCollection col = getClassesDirs();
return (col == null) ? null : col.getSingleFile();
}

/** Sets the directory where to look for classes. Overwrites any value set by {@link #setClassesDirs()}!
* @deprecated use {@link #setClassesDirs()} instead
/** Sets the directory where to look for classes. Overwrites any value set by {@link #setClassesDirs(FileCollection)}!
* @deprecated use {@link #setClassesDirs(FileCollection)} instead.
* @see #getClassesDir
*/
@Deprecated
public void setClassesDir(File classesDir) {
if (classesDir == null) throw new NullPointerException("classesDir");
getLogger().warn("The 'classesDir' property on the '{}' task is deprecated. Use 'classesDirs' of type FileCollection instead!",
getName());
setClassesDirs(getProject().files(classesDir));
}

Expand All @@ -170,6 +176,7 @@ public FileCollection getClasspath() {

/** @see #getClasspath */
public void setClasspath(FileCollection classpath) {
if (classpath == null) throw new NullPointerException("classpath");
this.classpath = classpath;
}

Expand Down
3 changes: 2 additions & 1 deletion src/test/gradle/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,13 @@ forbiddenApis {
}

forbiddenApisMain {
classesDir = new File(forbiddenRootDir, 'build/main')
classesDirs = files(new File(forbiddenRootDir, 'build/main'))
classpath = files(forbiddenClasspath.tokenize(File.pathSeparator))
bundledSignatures += 'jdk-system-out'
}

forbiddenApisTest {
// use classesDir here to check backwards compatibility!:
classesDir = new File(forbiddenRootDir, 'build/test')
classpath = files(forbiddenTestClasspath.tokenize(File.pathSeparator))
}

0 comments on commit 7e9fd78

Please sign in to comment.