Skip to content

Commit cde7c56

Browse files
committed
[MJAVADOC-812] [REGRESSION] maven-javadoc-plugin 3.10.0 creates empty JARs
This closes #320
1 parent db6d7f6 commit cde7c56

File tree

4 files changed

+99
-17
lines changed

4 files changed

+99
-17
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
18+
invoker.goals = javadoc:jar
19+

src/it/projects/MJAVADOC-812/pom.xml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
~ Licensed under the Apache License, Version 2.0 (the "License");
4+
~ you may not use this file except in compliance with the License.
5+
~ You may obtain a copy of the License at
6+
~
7+
~ http://www.apache.org/licenses/LICENSE-2.0
8+
~
9+
~ Unless required by applicable law or agreed to in writing, software
10+
~ distributed under the License is distributed on an "AS IS" BASIS,
11+
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
~ See the License for the specific language governing permissions and
13+
~ limitations under the License.
14+
-->
15+
<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">
16+
<modelVersion>4.0.0</modelVersion>
17+
18+
<groupId>org.apache.maven.plugins.javadoc.it</groupId>
19+
<artifactId>mjavadoc812</artifactId>
20+
<version>1.0-SNAPSHOT</version>
21+
<packaging>jar</packaging>
22+
23+
<url>https://issues.apache.org/jira/browse/MJAVADOC-812</url>
24+
25+
<properties>
26+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
27+
</properties>
28+
29+
<build>
30+
<plugins>
31+
<plugin>
32+
<artifactId>maven-javadoc-plugin</artifactId>
33+
<version>@project.version@</version>
34+
</plugin>
35+
</plugins>
36+
</build>
37+
</project>
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
def javadocJar = new File( basedir, 'target/mjavadoc812-1.0-SNAPSHOT-javadoc.jar')
21+
22+
assert !javadocJar.exists()

src/main/java/org/apache/maven/plugins/javadoc/JavadocJarMojo.java

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -171,24 +171,28 @@ protected void doExecute() throws MojoExecutionException {
171171
failOnError("RuntimeException: Error while generating Javadoc", e);
172172
}
173173

174-
try {
175-
File outputFile = generateArchive(
176-
new File(getPluginReportOutputDirectory()), finalName + "-" + getClassifier() + ".jar");
177-
178-
if (!attach) {
179-
getLog().info("NOT adding javadoc to attached artifacts list.");
180-
} else {
181-
// TODO: these introduced dependencies on the project are going to become problematic - can we
182-
// export it
183-
// through metadata instead?
184-
projectHelper.attachArtifact(project, "javadoc", getClassifier(), outputFile);
174+
File javadocOutputDirectory = new File(getPluginReportOutputDirectory());
175+
if (javadocOutputDirectory.exists()) {
176+
try {
177+
File outputFile = generateArchive(javadocOutputDirectory, finalName + "-" + getClassifier() + ".jar");
178+
179+
if (!attach) {
180+
getLog().info("NOT adding javadoc to attached artifacts list.");
181+
} else {
182+
// TODO: these introduced dependencies on the project are going to become problematic - can we
183+
// export it
184+
// through metadata instead?
185+
projectHelper.attachArtifact(project, "javadoc", getClassifier(), outputFile);
186+
}
187+
} catch (ArchiverException e) {
188+
failOnError("ArchiverException: Error while creating archive", e);
189+
} catch (IOException e) {
190+
failOnError("IOException: Error while creating archive", e);
191+
} catch (RuntimeException e) {
192+
failOnError("RuntimeException: Error while creating archive", e);
185193
}
186-
} catch (ArchiverException e) {
187-
failOnError("ArchiverException: Error while creating archive", e);
188-
} catch (IOException e) {
189-
failOnError("IOException: Error while creating archive", e);
190-
} catch (RuntimeException e) {
191-
failOnError("RuntimeException: Error while creating archive", e);
194+
} else {
195+
getLog().info("No Javadoc in project. Archive not created.");
192196
}
193197
}
194198

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy