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 support for new Java version style "6.0" instead of "1.6" #81

Merged
merged 1 commit into from
Oct 12, 2015
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 4 additions & 0 deletions src/main/java/de/thetaphi/forbiddenapis/Checker.java
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,10 @@ private void parseBundledSignatures(String name, String jdkTargetVersion, boolea
InputStream in = Checker.class.getResourceAsStream("signatures/" + name + ".txt");
// automatically expand the compiler version in here (for jdk-* signatures without version):
if (in == null && jdkTargetVersion != null && name.startsWith("jdk-") && !name.matches(".*?\\-\\d\\.\\d")) {
// convert the "new" version number "major.0" to old-style "1.major" (as this matches our resources):
if (!jdkTargetVersion.startsWith("1.") && jdkTargetVersion.matches("\\d\\.0")) {
jdkTargetVersion = "1." + jdkTargetVersion.substring(0, 1);
}
name = name + "-" + jdkTargetVersion;
in = Checker.class.getResourceAsStream("signatures/" + name + ".txt");
}
Expand Down
19 changes: 15 additions & 4 deletions src/test/antunit/TestMavenMojo.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,19 @@
<syspropertyset refid="injected-properties"/>
</artifact:mvn>
<au:assertLogContains text=" 0 error(s)."/>
<au:assertLogContains text="Reading bundled API signatures: jdk-deprecated"/>
<au:assertLogContains text="Reading bundled API signatures: jdk-unsafe"/>
<au:assertLogContains text="Reading bundled API signatures: jdk-deprecated-${jdk.version}"/>
<au:assertLogContains text="Reading bundled API signatures: jdk-unsafe-${jdk.version}"/>
</target>

<target name="testMyselfMaven2NewJavaVersion">
<artifact:mvn pom="${antunit.fake-pom}" mavenVersion="${maven.version}" failonerror="true" fork="${maven.fork}">
<arg value="${groupId}:${artifactId}:${version}:check"/>
<syspropertyset refid="injected-properties"/>
<sysproperty key="maven.compiler.target" value="6.0"/>
</artifact:mvn>
<au:assertLogContains text=" 0 error(s)."/>
<au:assertLogContains text="Reading bundled API signatures: jdk-deprecated-1.6"/>
<au:assertLogContains text="Reading bundled API signatures: jdk-unsafe-1.6"/>
</target>

<target name="testInlineSignaturesMaven2">
Expand Down Expand Up @@ -105,8 +116,8 @@
<syspropertyset refid="injected-properties"/>
</artifact:mvn>
<au:assertLogContains text=" 0 error(s)."/>
<au:assertLogContains text="Reading bundled API signatures: jdk-deprecated"/>
<au:assertLogContains text="Reading bundled API signatures: jdk-unsafe"/>
<au:assertLogContains text="Reading bundled API signatures: jdk-deprecated-${jdk.version}"/>
<au:assertLogContains text="Reading bundled API signatures: jdk-unsafe-${jdk.version}"/>
</target>

<target name="testSigArtifacts-Maven2">
Expand Down