Skip to content

Commit

Permalink
Merge branch 'upstream/4.x' into plugin-doc-more-tags
Browse files Browse the repository at this point in the history
# Conflicts:
#	maven-confluence-reporting-plugin/src/main/java/org/bsc/maven/confluence/plugin/ConfluenceDeployMojo.java
  • Loading branch information
wattazoum committed Aug 7, 2016
2 parents d63f779 + a159499 commit 02e444a
Show file tree
Hide file tree
Showing 13 changed files with 116 additions and 51 deletions.
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,17 @@ originally hosted to [google code](https://code.google.com/p/maven-confluence-pl

### News ###

- | **Release 4.12-SNAPSHOT** | available from **[MAVEN CENTRAL REPO](https://oss.sonatype.org/content/repositories/snapshots/org/bsc/maven/confluence-reporting-maven-plugin/4.12-SNAPSHOT/)**
---- | ---- | ----

* Refer to [Issue 114](https://github.com/bsorrentino/maven-confluence-plugin/issues/114) - Generation plugin doc ignores home page from site inline code format
* Refer to [Issue 116](https://github.com/bsorrentino/maven-confluence-plugin/issues/116) - Attachments wrongly assigned
* Refer to [Pull Request 117](https://github.com/bsorrentino/maven-confluence-plugin/pull/117) - Fix attachements on homepage

> **Thanks to [wattazoum](https://github.com/wattazoum) for providing such feature**.


Aug 5,2016 | **Release 4.11** | available from **[MAVEN CENTRAL REPO](http://search.maven.org/#artifactdetails%7Corg.bsc.maven%7Cconfluence-reporting-maven-plugin%7C4.11%7Cmaven-plugin)**
---- | ---- | ----

Expand Down
2 changes: 1 addition & 1 deletion maven-confluence-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<artifactId>maven-confluence-parent</artifactId>
<groupId>org.bsc.maven</groupId>
<version>4.11</version>
<version>4.12-SNAPSHOT</version>
</parent>

<modelVersion>4.0.0</modelVersion>
Expand Down
6 changes: 4 additions & 2 deletions maven-confluence-reporting-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<parent>
<artifactId>maven-confluence-parent</artifactId>
<groupId>org.bsc.maven</groupId>
<version>4.11</version>
<version>4.12-SNAPSHOT</version>
</parent>

<properties>
Expand Down Expand Up @@ -347,7 +347,9 @@ TEST
<parentPageTitle>Home</parentPageTitle>
<serverId>softphone-server</serverId>
<wikiFilesExt>.confluence</wikiFilesExt>
<templateWiki>${basedir}/src/site/confluence/codehaus-home.confluence</templateWiki>
<!--
<templateWiki>${basedir}/src/site/confluence/index.confluence</templateWiki>
-->
<removeSnapshots>true</removeSnapshots>
</configuration>
</plugin>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
import org.codehaus.swizzle.confluence.Confluence;
import org.codehaus.swizzle.confluence.Page;

import static java.lang.String.format;

/**
*
* @author bsorrentino
Expand Down Expand Up @@ -76,7 +78,7 @@ private void setPageUriFormFile( Site.Page page, java.io.File source ) {
*/
private void generateAttachments( Site.Page page, Confluence confluence, Page confluencePage) /*throws MavenReportException*/ {

getLog().info(String.format("generateAttachments pageId [%s]", confluencePage.getId()));
getLog().info(format("generateAttachments pageId [%s] title [%s]", confluencePage.getId(), confluencePage.getTitle()));

for( Site.Attachment attachment : page.getAttachments() ) {

Expand All @@ -85,26 +87,26 @@ private void generateAttachments( Site.Page page, Confluence confluence, Page c
try {
confluenceAttachment = confluence.getAttachment(confluencePage.getId(), attachment.getName(), attachment.getVersion());
} catch (Exception e) {
getLog().warn(String.format("Error getting attachment [%s] from confluence: [%s]", attachment.getName(), e.getMessage()));
getLog().debug(format("Error getting attachment [%s] from confluence: [%s]", attachment.getName(), e.getMessage()));
}

if (confluenceAttachment != null) {


java.util.Date date = confluenceAttachment.getCreated();

if (date == null) {
getLog().warn(String.format("creation date of attachments [%s] is undefined. It will be replaced! ", confluenceAttachment.getFileName()));
getLog().warn(format("creation date of attachments [%s] is undefined. It will be replaced! ", confluenceAttachment.getFileName()));
} else {
if (attachment.hasBeenUpdatedFrom(date)) {
getLog().info(String.format("attachment [%s] is more recent than the remote one. It will be replaced! ", confluenceAttachment.getFileName()));
getLog().info(format("attachment [%s] is more recent than the remote one. It will be replaced! ", confluenceAttachment.getFileName()));
} else {
getLog().info(String.format("attachment [%s] skipped! no updated detected", confluenceAttachment.getFileName()));
getLog().info(format("attachment [%s] skipped! no updated detected", confluenceAttachment.getFileName()));
continue;

}
}
} else {
getLog().info(format("Creating new attachment for [%s]", attachment.getName()));
confluenceAttachment = new Attachment();
confluenceAttachment.setFileName(attachment.getName());
confluenceAttachment.setContentType(attachment.getContentType());
Expand All @@ -116,7 +118,7 @@ private void generateAttachments( Site.Page page, Confluence confluence, Page c
try {
ConfluenceUtils.addAttchment(confluence, confluencePage, confluenceAttachment, attachment.getUri().toURL() );
} catch (Exception e) {
getLog().error(String.format("Error uploading attachment [%s] ", attachment.getName()), e);
getLog().error(format("Error uploading attachment [%s] ", attachment.getName()), e);
}

}
Expand All @@ -140,7 +142,7 @@ protected void generateChildren( final Confluence confluence,
final String titlePrefix)
{

getLog().info(String.format("generateChildren # [%d]", parentPage.getChildren().size()));
getLog().info(format("generateChildren # [%d]", parentPage.getChildren().size()));


generateAttachments(parentPage, confluence, confluenceParentPage);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -690,7 +690,7 @@ public void execute(Confluence confluence) throws Exception {
final PluginToolsRequest request =
new DefaultPluginToolsRequest(project, pluginDescriptor);

generator.processMojoDescriptors(
Page confluenceHomePage = generator.processMojoDescriptors(
request.getPluginDescriptor(),
confluence,
parentPage,
Expand All @@ -699,15 +699,15 @@ public void execute(Confluence confluence) throws Exception {

for( String label : site.getHome().getComputedLabels() ) {

confluence.addLabelByName(label, Long.parseLong(parentPage.getId()) );
confluence.addLabelByName(label, Long.parseLong(confluenceHomePage.getId()) );
}

// Issue 32
final String title = getTitle();

generateChildren( confluence,
site.getHome(),
parentPage,
site.getHome(),
confluenceHomePage,
title,
title);

Expand All @@ -734,17 +734,16 @@ class PluginGenerator extends PluginConfluenceDocGenerator {
*
* @throws IOException
*/
public void processMojoDescriptors( final PluginDescriptor pluginDescriptor,
final Confluence confluence,
final Page parentPage,
final Site site,
final Locale locale) throws Exception
public Page processMojoDescriptors(final PluginDescriptor pluginDescriptor,
final Confluence confluence,
final Page parentPage,
final Site site,
final Locale locale) throws Exception
{
final List<MojoDescriptor> mojos = pluginDescriptor.getMojos();

if (mojos == null) {
getLog().warn("no mojos found [pluginDescriptor.getMojos()]");
return;
} else if (getLog().isDebugEnabled()) {
getLog().debug("Found the following Mojos:");
for (MojoDescriptor mojo : mojos) {
Expand All @@ -760,8 +759,13 @@ public void processMojoDescriptors( final PluginDescriptor pluginDescriptor,
getProperties().put("artifactId", getProject().getArtifactId());
getProperties().put("version", getProject().getVersion());

MiniTemplator t = null;
final java.io.InputStream is = Site.processUri(site.getHome().getUri(), getTitle()) ;

final MiniTemplator t = new MiniTemplator.Builder()
.setSkipUndefinedVars(true)
.build( is, getCharset() );

/*
if (templateWiki == null || !templateWiki.exists()) {
getLog().warn("template not set! default using ...");
Expand Down Expand Up @@ -799,7 +803,7 @@ public void processMojoDescriptors( final PluginDescriptor pluginDescriptor,
}
}

*/
Page page = ConfluenceUtils.getOrCreatePage(confluence, parentPage, title);

if (!isSnapshot() && isRemoveSnapshots()) {
Expand All @@ -819,7 +823,7 @@ public void processMojoDescriptors( final PluginDescriptor pluginDescriptor,
{
final StringWriter writer = new StringWriter(100 * 1024);

writeSummary(writer, pluginDescriptor, mojos);
writeSummary(writer, pluginDescriptor);

writer.flush();

Expand All @@ -839,22 +843,24 @@ public void processMojoDescriptors( final PluginDescriptor pluginDescriptor,
/////////////////////////////////////////////////////////////////
// GOALS
/////////////////////////////////////////////////////////////////

final java.util.List<Goal> goals;
{
StringWriter writer = new StringWriter(100 * 1024);
final java.util.List<Goal> goals = new ArrayList<Goal>();

//writeGoals(writer, mojos);
goals = writeGoalsAsChildren(writer, page, title, mojos);
if (mojos != null) {
{
StringWriter writer = new StringWriter(100 * 1024);

writer.flush();
//writeGoals(writer, mojos);
goals.addAll(writeGoalsAsChildren(writer, page, title, mojos));

try {
t.setVariable(PLUGIN_GOALS_VAR, writer.toString());
} catch (VariableNotDefinedException e) {
getLog().warn(String.format("variable %s not defined in template", "plugin.goals"));
}
writer.flush();

try {
t.setVariable(PLUGIN_GOALS_VAR, writer.toString());
} catch (VariableNotDefinedException e) {
getLog().warn(String.format("variable %s not defined in template", "plugin.goals"));
}

}
}

/*
Expand All @@ -869,15 +875,16 @@ public void processMojoDescriptors( final PluginDescriptor pluginDescriptor,
page = confluence.storePage(page);

// GENERATE GOAL
for( Goal goal : goals ) {
for (Goal goal : goals) {
try {
goal.generatePage(confluence, page, title);
}
catch( Exception ex ) {
getLog().warn( format("error generatig page for goal [%s]", goal.descriptor.getGoal()), ex);
} catch (Exception ex) {
getLog().warn(format("error generatig page for goal [%s]", goal.descriptor.getGoal()), ex);
}
}

return page;
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -211,9 +211,8 @@ public void execute(File destinationDirectory, PluginToolsRequest request) throw
*
* @param writer
* @param pluginDescriptor
* @param mojos
*/
protected void writeSummary(Writer writer, PluginDescriptor pluginDescriptor, List<MojoDescriptor> mojos) {
protected void writeSummary(Writer writer, PluginDescriptor pluginDescriptor) {

ConfluenceWikiWriter w = new ConfluenceWikiWriter(writer);

Expand All @@ -235,7 +234,7 @@ protected java.util.List<Goal> writeGoalsAsChildren( Writer writer, Page parent,

final ConfluenceWikiWriter w = new ConfluenceWikiWriter(writer);

w.printBiggerHeading("Plugin Goals");
w.printBiggestHeading("Plugin Goals");

w.println("|| Name || Description ||");

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,21 @@
h1. Index
{panel}
{toc}
{panel}


h2. Index
{toc}
${project.summary}

----

${project.team}

${plugin.summary}
----

${project.scmManager}

----

${plugin.goals}

----
Original file line number Diff line number Diff line change
@@ -1,9 +1,23 @@

h1. Index
{panel}
{toc}
{panel}


${project.summary}

----

${project.team}

----

${project.scmManager}

----

${plugin.dependencies}

----

${project.dependencies}
19 changes: 19 additions & 0 deletions maven-confluence-reporting-plugin/src/site/confluence/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Index

{toc}


${project.summary}


${plugin.goals}


${project.team}


${project.scmManager}




Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
xmlns:bsc='https://github.com/bsorrentino/maven-confluence-plugin'
xsi:schemaLocation='https://github.com/bsorrentino/maven-confluence-plugin https://raw.githubusercontent.com/bsorrentino/maven-confluence-plugin/master/schemas/site-schema-3.4.0.xsd'>

<home uri="codehaus-home.confluence">
<home uri="index.md">

<!--child name="Usage" uri="../markdown/usage.md"-->
<child name="Usage" uri="usage.confluence">
Expand Down
2 changes: 1 addition & 1 deletion maven-confluence-test/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<parent>
<artifactId>maven-confluence-parent</artifactId>
<groupId>org.bsc.maven</groupId>
<version>4.11</version>
<version>4.12-SNAPSHOT</version>
</parent>

<modelVersion>4.0.0</modelVersion>
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<groupId>org.bsc.maven</groupId>
<artifactId>maven-confluence-parent</artifactId>
<packaging>pom</packaging>
<version>4.11</version>
<version>4.12-SNAPSHOT</version>
<name>CONFLUENCE-REPORTING::Parent - ${project.version}</name>
<description><![CDATA[
Maven's plugin that allow to generate "project's documentation" directly to confluence allowing, in the same time, to keep in-sync both project & documentation
Expand Down

0 comments on commit 02e444a

Please sign in to comment.