Skip to content

[MJAVADOC-812] [REGRESSION] maven-javadoc-plugin 3.10.0 creates empty… #320

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

Merged
merged 1 commit into from
Sep 24, 2024
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
19 changes: 19 additions & 0 deletions src/it/projects/MJAVADOC-812/invoker.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# 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 = javadoc:jar

37 changes: 37 additions & 0 deletions src/it/projects/MJAVADOC-812/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Licensed 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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>org.apache.maven.plugins.javadoc.it</groupId>
<artifactId>mjavadoc812</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>

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

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

<build>
<plugins>
<plugin>
<artifactId>maven-javadoc-plugin</artifactId>
<version>@project.version@</version>
</plugin>
</plugins>
</build>
</project>
22 changes: 22 additions & 0 deletions src/it/projects/MJAVADOC-812/verify.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
* 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.
*/

def javadocJar = new File( basedir, 'target/mjavadoc812-1.0-SNAPSHOT-javadoc.jar')

assert !javadocJar.exists()
38 changes: 21 additions & 17 deletions src/main/java/org/apache/maven/plugins/javadoc/JavadocJarMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -171,24 +171,28 @@ protected void doExecute() throws MojoExecutionException {
failOnError("RuntimeException: Error while generating Javadoc", e);
}

try {
File outputFile = generateArchive(
new File(getPluginReportOutputDirectory()), finalName + "-" + getClassifier() + ".jar");

if (!attach) {
getLog().info("NOT adding javadoc to attached artifacts list.");
} else {
// TODO: these introduced dependencies on the project are going to become problematic - can we
// export it
// through metadata instead?
projectHelper.attachArtifact(project, "javadoc", getClassifier(), outputFile);
File javadocOutputDirectory = new File(getPluginReportOutputDirectory());
if (javadocOutputDirectory.exists()) {
try {
File outputFile = generateArchive(javadocOutputDirectory, finalName + "-" + getClassifier() + ".jar");

if (!attach) {
getLog().info("NOT adding javadoc to attached artifacts list.");
} else {
// TODO: these introduced dependencies on the project are going to become problematic - can we
// export it
// through metadata instead?
projectHelper.attachArtifact(project, "javadoc", getClassifier(), outputFile);
}
} catch (ArchiverException e) {
failOnError("ArchiverException: Error while creating archive", e);
} catch (IOException e) {
failOnError("IOException: Error while creating archive", e);
} catch (RuntimeException e) {
failOnError("RuntimeException: Error while creating archive", e);
}
} catch (ArchiverException e) {
failOnError("ArchiverException: Error while creating archive", e);
} catch (IOException e) {
failOnError("IOException: Error while creating archive", e);
} catch (RuntimeException e) {
failOnError("RuntimeException: Error while creating archive", e);
} else {
getLog().info("No Javadoc in project. Archive not created.");
}
}

Expand Down