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

Issue #68: Add Gradle plugin #70

Merged
merged 40 commits into from
Sep 9, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
dc4059a
First empty commit of Gradle task, plugin still missing; completely u…
uschindler Sep 5, 2015
769a75a
Use type safety for targetVersion
uschindler Sep 5, 2015
fd6ad30
Commit current state
uschindler Sep 5, 2015
4e29e6c
Remove additional signature configurations for now, fix NPE
uschindler Sep 5, 2015
62bb081
Rename some properties, add docs
uschindler Sep 5, 2015
38596b5
Add plugin descriptor
uschindler Sep 5, 2015
3ff24df
Add first implementation of the Gradle plugin
uschindler Sep 5, 2015
ef781fb
Fix wrong name in docs
uschindler Sep 5, 2015
18a1d00
Docs cleanup; NPE fixes; type change to file collections; inline sign…
uschindler Sep 5, 2015
d0c8297
Fix bugs, add classes output directory to classpath (otherwise scanni…
uschindler Sep 5, 2015
395921f
add newline
uschindler Sep 5, 2015
acb6596
fix more bugs and improve targetVersion checks
uschindler Sep 5, 2015
29a5aa5
fix error message
uschindler Sep 5, 2015
cca1291
fix NPE with configurations
uschindler Sep 5, 2015
2d2648d
Add more task dependencies, based on dependency graph of Gradle Java …
uschindler Sep 5, 2015
45dd647
Remove targetVersion property. Gradle does not allow to set it on com…
uschindler Sep 5, 2015
f68673b
Fix lookup of classesDir (horrible in plain Java); add main classesDi…
uschindler Sep 6, 2015
4b1430c
Insert the tasks into the chain in a better way: We run before classe…
uschindler Sep 6, 2015
9680b10
Code simplifications
uschindler Sep 6, 2015
4a04324
Make the Inputs/Outputs work correctly (plain fields don't work, alth…
uschindler Sep 6, 2015
5c1c8d0
Make the include/exclude pattern handling according to Gradle's guide…
uschindler Sep 6, 2015
36ecd69
Add File-taking methods to Checker
uschindler Sep 6, 2015
ed14d03
Rename some class files so the API is more useable in Gradle scripts.…
uschindler Sep 6, 2015
e00b372
Refactor plugin initialization to use a Groovy script, executed by Gr…
uschindler Sep 6, 2015
70dca88
Improve error message
uschindler Sep 6, 2015
2d2e50a
Make it work with all SourceSets
uschindler Sep 6, 2015
c6bed96
More code cleanup in task-init.groovy
uschindler Sep 6, 2015
6dd1eee
Add descriptions to task (not yet the group); make "this" correct in …
uschindler Sep 6, 2015
81c7daf
Add a task to execute on all sourcesets with one call
uschindler Sep 6, 2015
69359a4
Small cleanup by using GString
uschindler Sep 6, 2015
0cba435
Minor cleanups & constants
uschindler Sep 6, 2015
ba99795
Add missing license header
uschindler Sep 6, 2015
6268bb1
Code cleanups, also implement VerificationTask
uschindler Sep 6, 2015
e35cf6d
Delay initialization of task until whole project is parsed.
uschindler Sep 7, 2015
974e441
Allow use of Extension to define task defaults. The extension name is…
uschindler Sep 7, 2015
a230ded
Code cleanups
uschindler Sep 7, 2015
9f57dbb
Add missing patterns to Extension, simplify loading of plugin-init sc…
uschindler Sep 7, 2015
3374587
Use convention mapping also for classesDir and classpath
uschindler Sep 7, 2015
7c98f72
Fix patternset in extension
uschindler Sep 8, 2015
d321804
Fix clone problems caused by PatternFilterable interface in the exten…
uschindler Sep 9, 2015
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
1 change: 1 addition & 0 deletions build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@
<target name="-init" depends="-install.ivy">
<echo level="info" message="Detected Java runtime major version: ${build.java.runtime}"/>
<echo level="info" message="Java runtime: ${build.java.info}"/>
<ivy:configure file="ivy-settings.xml"/>
<ivy:resolve log="${ivy.logging}"/>
<local name="ivy.version-message"/>
<condition property="ivy.version-message"
Expand Down
32 changes: 32 additions & 0 deletions ivy-settings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
* (C) Copyright Uwe Schindler (Generics Policeman) and others.
*
* 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.
-->
<ivysettings>
<settings defaultResolver="default"/>

<include url="${ivy.default.settings.dir}/ivysettings-public.xml"/>
<include url="${ivy.default.settings.dir}/ivysettings-shared.xml"/>
<include url="${ivy.default.settings.dir}/ivysettings-local.xml"/>
<include url="${ivy.default.settings.dir}/ivysettings-main-chain.xml"/>

<resolvers>
<ibiblio name="gradle" root="http://repo.gradle.org/gradle/libs-releases-local" m2compatible="true" />
<chain name="default" returnFirst="true" checkmodified="true" changingPattern=".*SNAPSHOT">
<resolver ref="main"/>
<resolver ref="gradle" />
</chain>
</resolvers>
</ivysettings>
7 changes: 6 additions & 1 deletion ivy.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@
<dependency org="org.apache.ant" name="ant" rev="1.7.0" conf="build"/>
<dependency org="org.apache.maven" name="maven-plugin-api" rev="2.0" conf="build"/>
<dependency org="org.apache.maven.plugin-tools" name="maven-plugin-annotations" rev="3.2" conf="build"/>
<!-- we compile against older Gradle 1.12 version (latest of 1.x), because 1.x still works with Java 1.5: -->
<dependency org="org.gradle" name="gradle-core" rev="1.12" conf="build"/>
<dependency org="org.gradle" name="gradle-base-services" rev="1.12" conf="build"/>
<dependency org="org.slf4j" name="slf4j-api" rev="1.7.5" conf="build"/>
<!-- Gradle also needs Groovy, but we need it as build tool, too: -->
<dependency org="org.codehaus.groovy" name="groovy-all" rev="2.2.2" conf="build,buildtools"/>
<!-- ASM 5.0.4 minimal: -->
<dependency org="org.ow2.asm" name="asm" rev="5.0.4" conf="build,bundle"/>
<dependency org="org.ow2.asm" name="asm-commons" rev="5.0.4" conf="build,bundle"/>
Expand All @@ -39,7 +45,6 @@
<dependency org="commons-cli" name="commons-cli" rev="1.2" conf="build,bundle"/>
<dependency org="com.googlecode.jarjar" name="jarjar" rev="1.3" conf="buildtools"/>
<dependency org="org.apache.maven" name="maven-ant-tasks" rev="2.1.3" conf="buildtools"/>
<dependency org="org.codehaus.groovy" name="groovy-all" rev="2.2.2" conf="buildtools"/>
<dependency org="org.apache.ant" name="ant-antunit" rev="1.3" conf="test"/>
<dependency org="ant-contrib" name="ant-contrib" rev="1.0b3" conf="test"/>
<dependency org="junit" name="junit" rev="4.12" conf="test"/>
Expand Down
11 changes: 11 additions & 0 deletions src/main/java/de/thetaphi/forbiddenapis/Checker.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import org.objectweb.asm.commons.Method;

import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
Expand Down Expand Up @@ -351,6 +352,11 @@ public final void parseSignaturesFile(InputStream in) throws IOException,ParseEx
parseSignaturesFile(in, false);
}

/** Reads a list of API signatures from the given file. */
public final void parseSignaturesFile(File f) throws IOException,ParseException {
parseSignaturesFile(new FileInputStream(f));
}

/** Reads a list of API signatures from a String. */
public final void parseSignaturesString(String signatures) throws IOException,ParseException {
parseSignaturesFile(new StringReader(signatures), false);
Expand Down Expand Up @@ -405,6 +411,11 @@ public final void addClassToCheck(final InputStream in) throws IOException {
classesToCheck.put(reader.getClassName(), new ClassSignature(reader, false, true));
}

/** Parses and adds a class from the given file to the list of classes to check. */
public final void addClassToCheck(File f) throws IOException {
addClassToCheck(new FileInputStream(f));
}

public final boolean hasNoSignatures() {
return forbiddenMethods.isEmpty() && forbiddenFields.isEmpty() && forbiddenClasses.isEmpty() && forbiddenClassPatterns.isEmpty() && (!options.contains(Option.INTERNAL_RUNTIME_FORBIDDEN));
}
Expand Down
5 changes: 2 additions & 3 deletions src/main/java/de/thetaphi/forbiddenapis/cli/CliMain.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

import java.io.Closeable;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.Arrays;
import java.util.EnumSet;
Expand Down Expand Up @@ -266,7 +265,7 @@ public void run() throws ExitException {
if (signaturesFiles != null) for (String sf : signaturesFiles) {
final File f = new File(sf).getAbsoluteFile();
LOG.info("Reading API signatures: " + f);
checker.parseSignaturesFile(new FileInputStream(f));
checker.parseSignaturesFile(f);
}
} catch (IOException ioe) {
throw new ExitException(EXIT_ERR_OTHER, "IO problem while reading files with API signatures: " + ioe);
Expand All @@ -284,7 +283,7 @@ public void run() throws ExitException {
LOG.info("Loading classes to check...");
try {
for (String f : files) {
checker.addClassToCheck(new FileInputStream(new File(classesDirectory, f)));
checker.addClassToCheck(new File(classesDirectory, f));
}
} catch (IOException ioe) {
throw new ExitException(EXIT_ERR_OTHER, "Failed to load one of the given class files: " + ioe);
Expand Down
Loading