FELIX-498: use attached javadoc as default documentation (unless Bundle-DocURL or project URL is set)
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@629290 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/bundleplugin/src/main/java/org/apache/felix/obrplugin/ObrDeploy.java b/bundleplugin/src/main/java/org/apache/felix/obrplugin/ObrDeploy.java
index 0b39caa..2c6f295 100644
--- a/bundleplugin/src/main/java/org/apache/felix/obrplugin/ObrDeploy.java
+++ b/bundleplugin/src/main/java/org/apache/felix/obrplugin/ObrDeploy.java
@@ -135,6 +135,11 @@
*/
private Artifact m_sourceArtifact;
+ /**
+ * Attached doc artifact
+ */
+ private Artifact m_docArtifact;
+
public void execute() throws MojoExecutionException
{
@@ -149,14 +154,17 @@
return;
}
- // check for any attached sources
+ // check for any attached sources or docs
for ( Iterator i = attachedArtifacts.iterator(); i.hasNext(); )
{
Artifact artifact = ( Artifact ) i.next();
if ( "sources".equals( artifact.getClassifier() ) )
{
m_sourceArtifact = artifact;
- break;
+ }
+ else if ( "javadoc".equals( artifact.getClassifier() ) )
+ {
+ m_docArtifact = artifact;
}
}
@@ -271,13 +279,19 @@
}
URI bundleJar = ObrUtils.getArtifactURI( localRepository, artifact );
- URI sourceJar = null;
+ URI sourceJar = null;
if ( null != m_sourceArtifact )
{
sourceJar = ObrUtils.getArtifactURI( localRepository, m_sourceArtifact );
}
- update.updateRepository( bundleJar, sourceJar );
+ URI docJar = null;
+ if ( null != m_docArtifact )
+ {
+ docJar = ObrUtils.getArtifactURI( localRepository, m_docArtifact );
+ }
+
+ update.updateRepository( bundleJar, sourceJar, docJar );
}
}
diff --git a/bundleplugin/src/main/java/org/apache/felix/obrplugin/ObrDeployFile.java b/bundleplugin/src/main/java/org/apache/felix/obrplugin/ObrDeployFile.java
index 7ec28ec..da4e7eb 100644
--- a/bundleplugin/src/main/java/org/apache/felix/obrplugin/ObrDeployFile.java
+++ b/bundleplugin/src/main/java/org/apache/felix/obrplugin/ObrDeployFile.java
@@ -194,7 +194,7 @@
update = new ObrUpdate( repositoryXml, obrXmlFile, project, mavenRepository, userConfig, log );
update.parseRepositoryXml();
- update.updateRepository( bundleJar, null );
+ update.updateRepository( bundleJar, null, null );
update.writeRepositoryXml();
diff --git a/bundleplugin/src/main/java/org/apache/felix/obrplugin/ObrInstall.java b/bundleplugin/src/main/java/org/apache/felix/obrplugin/ObrInstall.java
index 75219fa..9f313a1 100644
--- a/bundleplugin/src/main/java/org/apache/felix/obrplugin/ObrInstall.java
+++ b/bundleplugin/src/main/java/org/apache/felix/obrplugin/ObrInstall.java
@@ -87,6 +87,11 @@
*/
private Artifact m_sourceArtifact;
+ /**
+ * Attached doc artifact
+ */
+ private Artifact m_docArtifact;
+
public void execute()
{
@@ -101,14 +106,17 @@
return;
}
- // check for any attached sources
+ // check for any attached sources or docs
for ( Iterator i = attachedArtifacts.iterator(); i.hasNext(); )
{
Artifact artifact = ( Artifact ) i.next();
if ( "sources".equals( artifact.getClassifier() ) )
{
m_sourceArtifact = artifact;
- break;
+ }
+ else if ( "javadoc".equals( artifact.getClassifier() ) )
+ {
+ m_docArtifact = artifact;
}
}
@@ -150,13 +158,19 @@
}
URI bundleJar = ObrUtils.getArtifactURI( localRepository, artifact );
- URI sourceJar = null;
+ URI sourceJar = null;
if ( null != m_sourceArtifact )
{
sourceJar = ObrUtils.getArtifactURI( localRepository, m_sourceArtifact );
}
- update.updateRepository( bundleJar, sourceJar );
+ URI docJar = null;
+ if ( null != m_docArtifact )
+ {
+ docJar = ObrUtils.getArtifactURI( localRepository, m_docArtifact );
+ }
+
+ update.updateRepository( bundleJar, sourceJar, docJar );
}
}
diff --git a/bundleplugin/src/main/java/org/apache/felix/obrplugin/ObrInstallFile.java b/bundleplugin/src/main/java/org/apache/felix/obrplugin/ObrInstallFile.java
index 435b9c8..f880ca7 100644
--- a/bundleplugin/src/main/java/org/apache/felix/obrplugin/ObrInstallFile.java
+++ b/bundleplugin/src/main/java/org/apache/felix/obrplugin/ObrInstallFile.java
@@ -103,7 +103,7 @@
update = new ObrUpdate( repositoryXml, obrXmlFile, project, mavenRepository, userConfig, log );
update.parseRepositoryXml();
- update.updateRepository( bundleJar, null );
+ update.updateRepository( bundleJar, null, null );
update.writeRepositoryXml();
}
diff --git a/bundleplugin/src/main/java/org/apache/felix/obrplugin/ObrUpdate.java b/bundleplugin/src/main/java/org/apache/felix/obrplugin/ObrUpdate.java
index d3b45b7..fdb34e9 100644
--- a/bundleplugin/src/main/java/org/apache/felix/obrplugin/ObrUpdate.java
+++ b/bundleplugin/src/main/java/org/apache/felix/obrplugin/ObrUpdate.java
@@ -146,10 +146,11 @@
*
* @param bundleJar path to the bundle jar file
* @param sourceJar path to the source jar file
+ * @param docJar path to the docs jar file
*
* @throws MojoExecutionException if the plugin failed
*/
- public void updateRepository( URI bundleJar, URI sourceJar ) throws MojoExecutionException
+ public void updateRepository( URI bundleJar, URI sourceJar, URI docJar ) throws MojoExecutionException
{
m_logger.debug( " (f) repositoryXml = " + m_repositoryXml );
m_logger.debug( " (f) bundleJar = " + bundleJar );
@@ -229,20 +230,10 @@
throw new MojoExecutionException( "BindexException" );
}
- String sourcePath = null;
- if ( null != sourceJar )
- {
- if ( m_userConfig.isPathRelative() )
- {
- sourcePath = ObrUtils.getRelativeURI( m_baseURI, sourceJar ).toASCIIString();
- }
- else
- {
- sourcePath = sourceJar.toASCIIString();
- }
- }
+ String sourcePath = relativisePath( sourceJar );
+ String docPath = relativisePath( docJar );
- m_resourceBundle.construct( m_project, bindexExtractor, sourcePath );
+ m_resourceBundle.construct( m_project, bindexExtractor, sourcePath, docPath );
Element rootElement = m_repositoryDoc.getDocumentElement();
if ( !walkOnTree( rootElement ) )
@@ -254,6 +245,22 @@
}
+ private String relativisePath( URI uri )
+ {
+ if ( null != uri )
+ {
+ if ( m_userConfig.isPathRelative() )
+ {
+ return ObrUtils.getRelativeURI( m_baseURI, uri ).toASCIIString();
+ }
+
+ return uri.toASCIIString();
+ }
+
+ return null;
+ }
+
+
public void writeRepositoryXml() throws MojoExecutionException
{
m_logger.info( "Writing OBR metadata" );
diff --git a/bundleplugin/src/main/java/org/apache/felix/obrplugin/ResourcesBundle.java b/bundleplugin/src/main/java/org/apache/felix/obrplugin/ResourcesBundle.java
index 95c6ace..d187679 100644
--- a/bundleplugin/src/main/java/org/apache/felix/obrplugin/ResourcesBundle.java
+++ b/bundleplugin/src/main/java/org/apache/felix/obrplugin/ResourcesBundle.java
@@ -382,9 +382,10 @@
* @param project project information given by maven
* @param ebi bundle information extracted from bindex
* @param sourcePath path to local sources
+ * @param docPath path to local docs
* @return true
*/
- public boolean construct( MavenProject project, ExtractBindexInfo ebi, String sourcePath )
+ public boolean construct( MavenProject project, ExtractBindexInfo ebi, String sourcePath, String docPath )
{
if ( ebi.getPresentationName() != null )
@@ -444,25 +445,32 @@
setDescription( project.getDescription() );
}
+ // fallback to javadoc if no project URL
+ String documentation = project.getUrl();
+ if ( null == documentation )
+ {
+ documentation = docPath;
+ }
+
if ( ebi.getDocumentation() != null )
{
setDocumentation( ebi.getDocumentation() );
- if ( project.getUrl() != null )
+ if ( documentation != null )
{
- m_logger.debug( "pom property override:<documentation> " + project.getUrl() );
+ m_logger.debug( "pom property override:<documentation> " + documentation );
}
}
else
{
- setDocumentation( project.getUrl() );
+ setDocumentation( documentation );
}
if ( ebi.getSource() != null )
{
setSource( ebi.getSource() );
- if ( project.getScm() != null )
+ if ( sourcePath != null )
{
- m_logger.debug( "pom property override:<source> " + project.getScm() );
+ m_logger.debug( "pom property override:<source> " + sourcePath );
}
}
else