You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by mi...@apache.org on 2023/02/04 22:35:45 UTC

[maven-site-plugin] branch MSITE-921 updated (c2884650 -> e4ddb332)

This is an automated email from the ASF dual-hosted git repository.

michaelo pushed a change to branch MSITE-921
in repository https://gitbox.apache.org/repos/asf/maven-site-plugin.git


    omit c2884650 [MSITE-921] Populate SiteRenderingContext#getPublishDate() with ${project.build.outputTimestamp}
     new e4ddb332 [MSITE-921] Populate SiteRenderingContext#getPublishDate() with ${project.build.outputTimestamp}

This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version.  This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:

 * -- * -- B -- O -- O -- O   (c2884650)
            \
             N -- N -- N   refs/heads/MSITE-921 (e4ddb332)

You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.

Any revisions marked "omit" are not gone; other references still
refer to them.  Any revisions marked "discard" are gone forever.

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 src/site/apt/usage.apt | 13 +++++++++++++
 1 file changed, 13 insertions(+)


[maven-site-plugin] 01/01: [MSITE-921] Populate SiteRenderingContext#getPublishDate() with ${project.build.outputTimestamp}

Posted by mi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

michaelo pushed a commit to branch MSITE-921
in repository https://gitbox.apache.org/repos/asf/maven-site-plugin.git

commit e4ddb332e35ffa6419718ccad6dbba81befd4618
Author: Michael Osipov <mi...@apache.org>
AuthorDate: Sun Jan 15 01:02:51 2023 +0100

    [MSITE-921] Populate SiteRenderingContext#getPublishDate() with ${project.build.outputTimestamp}
    
    This closes #123
---
 src/it/projects/publishDate/pom.xml                | 64 ++++++++++++++++++++++
 src/it/projects/publishDate/verify.groovy          | 24 ++++++++
 .../site/render/AbstractSiteRenderingMojo.java     | 12 ++++
 src/site/apt/usage.apt                             | 13 +++++
 4 files changed, 113 insertions(+)

diff --git a/src/it/projects/publishDate/pom.xml b/src/it/projects/publishDate/pom.xml
new file mode 100644
index 00000000..ee953711
--- /dev/null
+++ b/src/it/projects/publishDate/pom.xml
@@ -0,0 +1,64 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+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.
+-->
+
+<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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>org.apache.maven.plugins.site.its</groupId>
+  <artifactId>publishDate</artifactId>
+  <version>1.0-SNAPSHOT</version>
+  <packaging>jar</packaging>
+
+  <name>maven-site-plugin IT: publish date</name>
+  <description>check that publish date is populated from 'project.build.outputTimestamp'</description>
+  <url>http://maven.apache.org</url>
+
+  <properties>
+    <projectInfoReportsPluginVersion>@projectInfoReportsPluginVersion@</projectInfoReportsPluginVersion>
+    <project.build.outputTimestamp>2000-01-01T00:00:00Z</project.build.outputTimestamp>
+  </properties>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-site-plugin</artifactId>
+        <version>@project.version@</version>
+      </plugin>
+    </plugins>
+  </build>
+  <reporting>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-project-info-reports-plugin</artifactId>
+        <version>@projectInfoReportsPluginVersion@</version>
+        <reportSets>
+          <reportSet>
+            <reports>
+              <report>index</report>
+            </reports>
+          </reportSet>
+        </reportSets>
+      </plugin>
+    </plugins>
+  </reporting>
+</project>
diff --git a/src/it/projects/publishDate/verify.groovy b/src/it/projects/publishDate/verify.groovy
new file mode 100644
index 00000000..af6a09b0
--- /dev/null
+++ b/src/it/projects/publishDate/verify.groovy
@@ -0,0 +1,24 @@
+
+/*
+ * 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.
+ */
+
+sitedir = new File( basedir, 'target/site' );
+index = new File( sitedir, 'index.html' );
+assert index.exists();
+assert index.getText().contains( '<li id="publishDate">Last Published: 2000-01-01' );
diff --git a/src/main/java/org/apache/maven/plugins/site/render/AbstractSiteRenderingMojo.java b/src/main/java/org/apache/maven/plugins/site/render/AbstractSiteRenderingMojo.java
index 921ac25f..bb02ffe3 100644
--- a/src/main/java/org/apache/maven/plugins/site/render/AbstractSiteRenderingMojo.java
+++ b/src/main/java/org/apache/maven/plugins/site/render/AbstractSiteRenderingMojo.java
@@ -19,6 +19,7 @@ package org.apache.maven.plugins.site.render;
  * under the License.
  */
 
+import org.apache.maven.archiver.MavenArchiver;
 import org.apache.maven.artifact.Artifact;
 import org.apache.maven.doxia.site.decoration.DecorationModel;
 import org.apache.maven.doxia.site.decoration.Menu;
@@ -39,6 +40,7 @@ import org.apache.maven.plugin.descriptor.PluginDescriptor;
 import org.apache.maven.plugins.annotations.Component;
 import org.apache.maven.plugins.annotations.Parameter;
 import org.apache.maven.plugins.site.descriptor.AbstractSiteDescriptorMojo;
+import org.apache.maven.project.MavenProject;
 import org.apache.maven.reporting.MavenReport;
 import org.apache.maven.reporting.exec.MavenReportExecution;
 import org.apache.maven.reporting.exec.MavenReportExecutor;
@@ -50,6 +52,7 @@ import java.io.File;
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Collection;
+import java.util.Date;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.LinkedHashMap;
@@ -313,6 +316,15 @@ public abstract class AbstractSiteRenderingMojo extends AbstractSiteDescriptorMo
                 + e.getMessage(), e );
         }
 
+        // Add publish date
+        MavenProject p = attributes.get( "project" ) != null ? (MavenProject) attributes.get( "project" ) : project;
+        String outputTimestamp = p.getProperties().getProperty( "project.build.outputTimestamp" );
+        MavenArchiver.parseBuildOutputTimestamp( outputTimestamp ).ifPresent( v ->
+            {
+                context.setPublishDate( Date.from( v ) );
+            }
+        );
+
         // Generate static site
         context.setRootDirectory( project.getBasedir() );
         if ( !locale.equals( SiteTool.DEFAULT_LOCALE ) )
diff --git a/src/site/apt/usage.apt b/src/site/apt/usage.apt
index f4981823..b74e859d 100644
--- a/src/site/apt/usage.apt
+++ b/src/site/apt/usage.apt
@@ -181,3 +181,16 @@ mvn site:run
 
   <<Note:>> Running a site only works for single-module sites.
   To preview a multi-module site one should use <<<site:stage>>>.
+
+* Rebuilding a Published (Released) Site
+
+  In general, site documentation is published as part of a release. This means that changes
+  to the documentation depend on a new release before being visible <or> you must accept
+  that the documentation refers to a snapshot version instead of the latest release version.
+  To solve that problem, you first of all need to configure your project for reproducibility
+  by setting the <<<project.build.outputTimestamp>>> model property. Then branch off from the
+  SCM tag you want to modify, perform the changes, commit them and then rebuild, finally
+  publish updated site. The underlying Maven Doxia Sitetools will automatically inject that
+  property as <<<publishDate>>> Velocity context property into the site and the skin won't
+  render a newer (current) date, but use this one. Checkout the <<<publishDate>>> IT for
+  configuration details.