@@ -527,6 +527,7 @@ public abstract class AbstractJavadocMojo
527
527
* The added Javadoc <code>-link</code> parameter will be <code>http://commons.apache.org/lang/apidocs</code>.
528
528
*
529
529
* @see #links
530
+ * @see #dependencyLinks
530
531
* @since 2.6
531
532
*/
532
533
@ Parameter ( property = "detectLinks" , defaultValue = "false" )
@@ -1142,9 +1143,31 @@ public abstract class AbstractJavadocMojo
1142
1143
*
1143
1144
* @see #detectLinks
1144
1145
* @see #detectJavaApiLink
1146
+ * @see #dependencyLinks
1145
1147
*/
1146
1148
@ Parameter ( property = "links" )
1147
1149
protected ArrayList <String > links ;
1150
+
1151
+
1152
+ /**
1153
+ * Redefine the apidoc URL for specific dependencies when using {@link #detectLinks}.
1154
+ * Useful if the dependency wasn't build with Maven or when the apidocs have been moved.
1155
+ * <pre>
1156
+ * <dependencyLinks>
1157
+ * <dependencyLink>
1158
+ * <groupId>groupId</groupId>
1159
+ * <artifactId>artifactId</artifactId>
1160
+ * <classifier>classifier</classifier> <!-- optional -->
1161
+ * <url>version</url>
1162
+ * </dependencyLink>
1163
+ * </dependencyLinks>
1164
+ * </pre>
1165
+ *
1166
+ * @see #detectLinks
1167
+ * @since 3.3.0
1168
+ */
1169
+ @ Parameter
1170
+ private List <DependencyLink > dependencyLinks = new ArrayList <>();
1148
1171
1149
1172
/**
1150
1173
* Creates an HTML version of each source file (with line numbers) and adds links to them from the standard
@@ -6390,32 +6413,61 @@ private List<String> getDependenciesLinks()
6390
6413
continue ;
6391
6414
}
6392
6415
6393
- try
6416
+ Optional <DependencyLink > depLink =
6417
+ this .dependencyLinks .stream ().filter ( d -> matches ( d , artifact ) ).findAny ();
6418
+
6419
+ final String url ;
6420
+ final boolean detected ;
6421
+ if ( depLink .isPresent () )
6394
6422
{
6395
- MavenProject artifactProject =
6396
- mavenProjectBuilder .build ( artifact , getProjectBuildingRequest ( project ) ).getProject ();
6397
-
6398
- if ( StringUtils .isNotEmpty ( artifactProject .getUrl () ) )
6423
+ url = depLink .get ().getUrl ();
6424
+ detected = false ;
6425
+ }
6426
+ else
6427
+ {
6428
+ try
6399
6429
{
6400
- String url = getJavadocLink ( artifactProject );
6401
-
6402
- if ( isValidJavadocLink ( url , true ) )
6403
- {
6404
- getLog ().debug ( "Added Javadoc link: " + url + " for " + artifactProject .getId () );
6430
+ MavenProject artifactProject =
6431
+ mavenProjectBuilder .build ( artifact , getProjectBuildingRequest ( project ) ).getProject ();
6405
6432
6406
- dependenciesLinks .add ( url );
6407
- }
6433
+ url = getJavadocLink ( artifactProject );
6434
+ detected = true ;
6435
+ }
6436
+ catch ( ProjectBuildingException e )
6437
+ {
6438
+ logError ( "ProjectBuildingException for " + artifact .toString () + ": " + e .getMessage (), e );
6439
+ continue ;
6408
6440
}
6409
6441
}
6410
- catch ( ProjectBuildingException e )
6442
+
6443
+ if ( isValidJavadocLink ( url , detected ) )
6411
6444
{
6412
- logError ( "ProjectBuildingException for " + artifact .toString () + ": " + e .getMessage (), e );
6445
+ getLog ().debug ( "Added Javadoc link: " + url + " for " + artifact .getId () );
6446
+
6447
+ dependenciesLinks .add ( url );
6413
6448
}
6414
6449
}
6415
6450
6416
6451
return dependenciesLinks ;
6417
6452
}
6418
6453
6454
+ private boolean matches ( DependencyLink d , Artifact artifact )
6455
+ {
6456
+ if ( d .getGroupId () != null && !d .getGroupId ().equals ( artifact .getGroupId () ) )
6457
+ {
6458
+ return false ;
6459
+ }
6460
+ if ( d .getArtifactId () != null && !d .getArtifactId ().equals ( artifact .getArtifactId () ) )
6461
+ {
6462
+ return false ;
6463
+ }
6464
+ if ( d .getClassifier () != null && !d .getClassifier ().equals ( artifact .getClassifier () ) )
6465
+ {
6466
+ return false ;
6467
+ }
6468
+ return true ;
6469
+ }
6470
+
6419
6471
/**
6420
6472
* @return if {@link #detectJavaApiLink}, the Java API link based on the {@link #javaApiLinks} properties and the
6421
6473
* value of the <code>source</code> parameter in the
0 commit comments