Skip to content

Commit

Permalink
[MJAVADOC-620] Integration test for JAR with version without dots
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
fwienber committed Nov 20, 2019
1 parent 769b73f commit efd0e47
Show file tree
Hide file tree
Showing 6 changed files with 223 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/it/projects/MJAVADOC-620_no-dot-in-version/invoker.properties
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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.
-->

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>org.apache.maven.plugins.maven-javadoc-plugin.it</groupId>
<artifactId>maven-MJAVADOC620-jar</artifactId>
<version>1-SNAPSHOT</version>
<packaging>jar</packaging>
</project>
Original file line number Diff line number Diff line change
@@ -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
{
}
52 changes: 52 additions & 0 deletions src/it/projects/MJAVADOC-620_no-dot-in-version/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<!--
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.
-->

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>org.apache.maven.plugins.maven-javadoc-plugin.it</groupId>
<artifactId>maven-MJAVADOC-620-test</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>

<name>Maven MJAVADOC-620 Test</name>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<dependencies>
<dependency>
<groupId>org.apache.maven.plugins.maven-javadoc-plugin.it</groupId>
<artifactId>maven-MJAVADOC620-jar</artifactId>
<version>1-SNAPSHOT</version>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>@project.version@</version>
</plugin>
</plugins>
</build>

</project>
Original file line number Diff line number Diff line change
@@ -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();
}
}
63 changes: 63 additions & 0 deletions src/it/projects/MJAVADOC-620_no-dot-in-version/verify.bsh
Original file line number Diff line number Diff line change
@@ -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;

0 comments on commit efd0e47

Please sign in to comment.