From efd0e478df6738adb8c9f89311f8671fc2c11e84 Mon Sep 17 00:00:00 2001 From: fwienber Date: Wed, 20 Nov 2019 13:21:30 +0100 Subject: [PATCH] [MJAVADOC-620] Integration test for JAR with version without dots The second case in which the module info retrieval fails is a JAR with a file name that contains a number *not* followed by a dot. This is the case we experienced, because we often use 1-SNAPSHOT as the working version, resulting in a JAR file name like "foo-1-SNAPSHOT.jar". The FindException has a root cause that says that the module name derived from the file name, "foo.1.SNAPSHOT", is invalid because "1" is not a valid Java identifier. Compared to the first integration test, the version number of the test project has been changed from "1.0" to just "1". To test one failure cause at a time, the test class Test has been moved from the top-level package into package "somepackage". Without the fix, maven-MJAVADOC620-jar-1-SNAPSHOT.jar is not added to the classpath and building the JavaDoc fails, because class Test is not found. With the fix, maven-MJAVADOC620-jar-1-SNAPSHOT.jar is added to the classpath and building the JavaDoc succeeds. --- .../invoker.properties | 20 ++++++ .../maven-MJAVADOC620-jar/pom.xml | 27 ++++++++ .../src/main/java/somepackage/Test.java | 27 ++++++++ .../MJAVADOC-620_no-dot-in-version/pom.xml | 52 +++++++++++++++ .../src/main/java/TestUsage.java | 34 ++++++++++ .../MJAVADOC-620_no-dot-in-version/verify.bsh | 63 +++++++++++++++++++ 6 files changed, 223 insertions(+) create mode 100644 src/it/projects/MJAVADOC-620_no-dot-in-version/invoker.properties create mode 100644 src/it/projects/MJAVADOC-620_no-dot-in-version/maven-MJAVADOC620-jar/pom.xml create mode 100644 src/it/projects/MJAVADOC-620_no-dot-in-version/maven-MJAVADOC620-jar/src/main/java/somepackage/Test.java create mode 100644 src/it/projects/MJAVADOC-620_no-dot-in-version/pom.xml create mode 100644 src/it/projects/MJAVADOC-620_no-dot-in-version/src/main/java/TestUsage.java create mode 100644 src/it/projects/MJAVADOC-620_no-dot-in-version/verify.bsh diff --git a/src/it/projects/MJAVADOC-620_no-dot-in-version/invoker.properties b/src/it/projects/MJAVADOC-620_no-dot-in-version/invoker.properties new file mode 100644 index 00000000..30638151 --- /dev/null +++ b/src/it/projects/MJAVADOC-620_no-dot-in-version/invoker.properties @@ -0,0 +1,20 @@ +# 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. + +invoker.goals.1 = -f maven-MJAVADOC620-jar install + +invoker.goals.2 = javadoc:aggregate diff --git a/src/it/projects/MJAVADOC-620_no-dot-in-version/maven-MJAVADOC620-jar/pom.xml b/src/it/projects/MJAVADOC-620_no-dot-in-version/maven-MJAVADOC620-jar/pom.xml new file mode 100644 index 00000000..6e87c007 --- /dev/null +++ b/src/it/projects/MJAVADOC-620_no-dot-in-version/maven-MJAVADOC620-jar/pom.xml @@ -0,0 +1,27 @@ + + + + 4.0.0 + + org.apache.maven.plugins.maven-javadoc-plugin.it + maven-MJAVADOC620-jar + 1-SNAPSHOT + jar + diff --git a/src/it/projects/MJAVADOC-620_no-dot-in-version/maven-MJAVADOC620-jar/src/main/java/somepackage/Test.java b/src/it/projects/MJAVADOC-620_no-dot-in-version/maven-MJAVADOC620-jar/src/main/java/somepackage/Test.java new file mode 100644 index 00000000..18cb6fcd --- /dev/null +++ b/src/it/projects/MJAVADOC-620_no-dot-in-version/maven-MJAVADOC620-jar/src/main/java/somepackage/Test.java @@ -0,0 +1,27 @@ +/* + * 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. + */ + +package somepackage; + +/** + * Sample top-level class that is packaged into a non-module JAR. + */ +public class Test +{ +} diff --git a/src/it/projects/MJAVADOC-620_no-dot-in-version/pom.xml b/src/it/projects/MJAVADOC-620_no-dot-in-version/pom.xml new file mode 100644 index 00000000..f857e767 --- /dev/null +++ b/src/it/projects/MJAVADOC-620_no-dot-in-version/pom.xml @@ -0,0 +1,52 @@ + + + + 4.0.0 + + org.apache.maven.plugins.maven-javadoc-plugin.it + maven-MJAVADOC-620-test + 1.0-SNAPSHOT + jar + + Maven MJAVADOC-620 Test + + + UTF-8 + + + + + org.apache.maven.plugins.maven-javadoc-plugin.it + maven-MJAVADOC620-jar + 1-SNAPSHOT + + + + + + + org.apache.maven.plugins + maven-javadoc-plugin + @project.version@ + + + + + \ No newline at end of file diff --git a/src/it/projects/MJAVADOC-620_no-dot-in-version/src/main/java/TestUsage.java b/src/it/projects/MJAVADOC-620_no-dot-in-version/src/main/java/TestUsage.java new file mode 100644 index 00000000..e0a79b14 --- /dev/null +++ b/src/it/projects/MJAVADOC-620_no-dot-in-version/src/main/java/TestUsage.java @@ -0,0 +1,34 @@ +/* + * 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. + */ + +import somepackage.Test; + +/** + * Sample class that tries to use top-level class from a non-module JAR. + */ +public class TestUsage +{ + /** + * Sample method that uses the top-level Test class from the other project. + */ + public Test getTest() + { + return new Test(); + } +} diff --git a/src/it/projects/MJAVADOC-620_no-dot-in-version/verify.bsh b/src/it/projects/MJAVADOC-620_no-dot-in-version/verify.bsh new file mode 100644 index 00000000..bd4c872f --- /dev/null +++ b/src/it/projects/MJAVADOC-620_no-dot-in-version/verify.bsh @@ -0,0 +1,63 @@ + +/* + * 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. + */ + +import java.io.*; +import org.codehaus.plexus.util.*; + +boolean result = true; + +try +{ + File target = new File( basedir, "target" ); + if ( !target.exists() || !target.isDirectory() ) + { + System.err.println( "target file is missing or not a directory." ); + return false; + } + + File apidocs = new File( basedir, "target/site/apidocs" ); + if ( !apidocs.exists() || !apidocs.isDirectory() ) + { + System.err.println( "target/site/apidocs file is missing or not a directory." ); + return false; + } + + File options = new File( apidocs, "options" ); + if ( !options.exists() || !options.isFile() ) + { + System.err.println( "target/site/apidocs/options file is missing or not a file." ); + return false; + } + + String str = FileUtils.fileRead( options ); + + if ( !str.contains( "maven-MJAVADOC620-jar-1-SNAPSHOT.jar" ) ) + { + System.err.println( "Javadoc doesn't use correct artifacts." ); + return false; + } +} +catch( IOException e ) +{ + e.printStackTrace(); + result = false; +} + +return result;