Skip to content

Commit

Permalink
Merge pull request #81 from policeman-tools/features/newJavaVersionFo…
Browse files Browse the repository at this point in the history
…rmat

Add support for new Java version style "6.0" instead of "1.6"
  • Loading branch information
uschindler committed Oct 12, 2015
2 parents 750176a + dc08346 commit 2c1676b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
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

0 comments on commit 2c1676b

Please sign in to comment.