Skip to content

Commit

Permalink
[MJAVADOC-765] Fix build with Java 20
Browse files Browse the repository at this point in the history
  • Loading branch information
slachiewicz committed Aug 15, 2023
1 parent b4da86e commit ea0ddf5
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 51 deletions.
1 change: 1 addition & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,7 @@ under the License.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-invoker-plugin</artifactId>
<version>3.6.0</version>
<configuration>
<localRepositoryPath>${project.build.directory}/local-repo</localRepositoryPath>
<projectsDirectory>src/it/projects</projectsDirectory>
Expand Down
1 change: 1 addition & 0 deletions src/it/projects/MJAVADOC-538/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@

<profiles>
<profile>
<id>java10+</id>
<activation>
<jdk>10</jdk>
</activation>
Expand Down
60 changes: 34 additions & 26 deletions src/it/projects/MJAVADOC-538/src/main/java/foo/bar/MyClass.java
Original file line number Diff line number Diff line change
@@ -1,26 +1,34 @@
package foo.bar;

/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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.
*/
/**
* App class
*/
public class MyClass
{
}
package foo.bar;

/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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.
*/

/**
* App class
*
*/
public class MyClass
{
/**
* Constructor
*/
MyClass()
{
}
}
6 changes: 3 additions & 3 deletions src/it/projects/MJAVADOC-592_detectApiLink/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@
<groupId>org.apache.maven.plugins.javadoc.it</groupId>
<artifactId>mjavadoc592</artifactId>
<version>1.0-SNAPSHOT</version>

<url>https://issues.apache.org/jira/browse/MJAVADOC-592</url>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>7</maven.compiler.source>
<maven.compiler.target>7</maven.compiler.target>
<maven.compiler.source>@maven.compiler.source@</maven.compiler.source>
<maven.compiler.target>@maven.compiler.target@</maven.compiler.target>
</properties>

<build>
Expand Down
4 changes: 2 additions & 2 deletions src/it/projects/MJAVADOC-592_detectApiLink/verify.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@
* specific language governing permissions and limitations
* under the License.
*/

def options = new File(basedir,'target/site/apidocs/options')
assert options.readLines().dropWhile{it!='-linkoffline'}.get(1).startsWith("'https://docs.oracle.com/javase/7/docs/api'")
assert options.readLines().dropWhile{it!='-linkoffline'}.get(1).startsWith("'https://docs.oracle.com/javase/8/docs/api")
4 changes: 2 additions & 2 deletions src/it/projects/MJAVADOC-599/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.source>@maven.compiler.source@</maven.compiler.source>
<maven.compiler.target>@maven.compiler.target@</maven.compiler.target>
</properties>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
import org.apache.maven.plugin.testing.stubs.MavenProjectStub;
import org.apache.maven.plugins.javadoc.AbstractFixJavadocMojo.JavaEntityTags;
import org.apache.maven.shared.invoker.MavenInvocationException;
import org.codehaus.plexus.languages.java.version.JavaVersion;
import org.codehaus.plexus.util.FileUtils;
import org.codehaus.plexus.util.StringUtils;

Expand Down Expand Up @@ -536,20 +535,6 @@ private void invokeCompileGoal(File testPom, File globalSettingsFile, Log log) t

Properties properties = new Properties();

if (JavaVersion.JAVA_SPECIFICATION_VERSION.isAtLeast("12")) {
properties.put("maven.compiler.source", "1.7");
properties.put("maven.compiler.target", "1.7");
} else if (JavaVersion.JAVA_SPECIFICATION_VERSION.isAtLeast("9")) {
properties.put("maven.compiler.source", "1.6");
properties.put("maven.compiler.target", "1.6");
}

// @todo unittests shouldn't need to go remote
if (JavaVersion.JAVA_SPECIFICATION_VERSION.isBefore("8")) {
// ensure that Java7 picks up TLSv1.2 when connecting with Central
properties.put("https.protocols", "TLSv1.2");
}

JavadocUtil.invokeMaven(
log,
new File(getBasedir(), "target/local-repo"),
Expand Down
6 changes: 3 additions & 3 deletions src/test/resources/unit/fix-test/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@
<version>1.1-SNAPSHOT</version>
<name>Javadoc Test Project</name>
<packaging>jar</packaging>

<properties>
<maven.compiler.source>1.5</maven.compiler.source>
<maven.compiler.target>1.5</maven.compiler.target>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
</properties>

<build>
Expand Down

0 comments on commit ea0ddf5

Please sign in to comment.