Repository: tomee-site-generator Updated Branches: refs/heads/master 61cae98ed -> eb450892c
working svnpub impl Project: http://git-wip-us.apache.org/repos/asf/tomee-site-generator/repo Commit: http://git-wip-us.apache.org/repos/asf/tomee-site-generator/commit/eb450892 Tree: http://git-wip-us.apache.org/repos/asf/tomee-site-generator/tree/eb450892 Diff: http://git-wip-us.apache.org/repos/asf/tomee-site-generator/diff/eb450892 Branch: refs/heads/master Commit: eb450892c3e1cb58ea302635dca9679b1961de28 Parents: 61cae98 Author: rmannibucau <rmannibu...@apache.org> Authored: Tue Jul 4 23:32:29 2017 +0200 Committer: rmannibucau <rmannibu...@apache.org> Committed: Tue Jul 4 23:32:29 2017 +0200 ---------------------------------------------------------------------- README.adoc | 13 +++- pom.xml | 19 +++++- .../java/org/apache/tomee/website/SvnPub.java | 65 +++++++++++++++++--- src/main/jbake/content/community/index.adoc | 8 ++- 4 files changed, 90 insertions(+), 15 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/tomee-site-generator/blob/eb450892/README.adoc ---------------------------------------------------------------------- diff --git a/README.adoc b/README.adoc index 0fefd33..8ee6431 100755 --- a/README.adoc +++ b/README.adoc @@ -71,11 +71,20 @@ Finally note that the site generation will rely on the cache as well to generate == Publish (needs an ASF account) -`SvnPub` is a main to push to the staging the site content once built, you need to set the system properties (`MAVEN_OPTS`) `site.password` -to your asf password and `site.username` if you user name is not `USER` environment variable for it to work. +`SvnPub` is a main to push to the staging the site content once built, you need to set the system properties (or properties in ~/.m2/settings.xml) +`site.password` to your asf password and `site.username` if you user name is not `USER` environment variable for it to work. It will checkout/update the site from svn then copy the site folder from target directory to synchronize it with the svn version and finally it will commit everything. You can set the system property `site.message` to not use the default commit message. +NOTE: `.content-site-checkout` will be the local copy of the website (if you need to modify manually the files or delete some old ones. + +NOTE: if the process fails unexpectedly (wrong update in the logic or anything) you can unlock the `.content-site-checkout` executing inside `svn cleanup`. + +To build and deploy on staging at once: `mvn clean compile pre-site`. + +Then to deploy to "prod": go on https://cms.apache.org/tomee/publish and hit "Submit" (note: you can review changes before if you want to check what the CMS took as changes). + +TIP: the staging is available when https://ci.apache.org/builders/tomee-site-staging build is done (triggered on commit), you can't deploy before. http://git-wip-us.apache.org/repos/asf/tomee-site-generator/blob/eb450892/pom.xml ---------------------------------------------------------------------- diff --git a/pom.xml b/pom.xml index 7a229e6..1b74108 100755 --- a/pom.xml +++ b/pom.xml @@ -14,7 +14,6 @@ <jbake.http>false</jbake.http> <jbake.pdf>false</jbake.pdf> - <site.password>notset</site.password> <site.message>notset</site.message> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> @@ -91,7 +90,7 @@ <dependency> <groupId>org.tmatesoft.svnkit</groupId> <artifactId>svnkit</artifactId> - <version>1.8.9</version> + <version>1.8.15</version> </dependency> </dependencies> @@ -109,7 +108,7 @@ <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>exec-maven-plugin</artifactId> - <version>1.5.0</version> + <version>1.6.0</version> <executions> <execution> <id>tomee-site</id> @@ -147,4 +146,18 @@ </plugin> </plugins> </build> + + <repositories> + <repository> + <id>svnkit</id> + <name>SVNKit</name> + <url>https://maven.tmatesoft.com/content/repositories/releases/</url> + <releases> + <enabled>true</enabled> + </releases> + <snapshots> + <enabled>false</enabled> + </snapshots> + </repository> + </repositories> </project> http://git-wip-us.apache.org/repos/asf/tomee-site-generator/blob/eb450892/src/main/java/org/apache/tomee/website/SvnPub.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/tomee/website/SvnPub.java b/src/main/java/org/apache/tomee/website/SvnPub.java index 9e3ec0a..31d1c06 100644 --- a/src/main/java/org/apache/tomee/website/SvnPub.java +++ b/src/main/java/org/apache/tomee/website/SvnPub.java @@ -20,12 +20,15 @@ import org.apache.commons.io.FileUtils; import org.tmatesoft.svn.core.SVNCommitInfo; import org.tmatesoft.svn.core.SVNDepth; import org.tmatesoft.svn.core.SVNException; -import org.tmatesoft.svn.core.SVNProperties; import org.tmatesoft.svn.core.SVNURL; import org.tmatesoft.svn.core.auth.ISVNAuthenticationManager; +import org.tmatesoft.svn.core.internal.util.jna.SVNJNAUtil; import org.tmatesoft.svn.core.internal.wc.DefaultSVNOptions; +import org.tmatesoft.svn.core.wc.ISVNStatusHandler; import org.tmatesoft.svn.core.wc.SVNClientManager; import org.tmatesoft.svn.core.wc.SVNRevision; +import org.tmatesoft.svn.core.wc.SVNStatus; +import org.tmatesoft.svn.core.wc.SVNStatusType; import org.tmatesoft.svn.core.wc.SVNUpdateClient; import org.tmatesoft.svn.core.wc.SVNWCUtil; import org.tmatesoft.svn.core.wc2.SvnRevert; @@ -33,10 +36,15 @@ import org.tmatesoft.svn.core.wc2.SvnTarget; import java.io.File; import java.io.IOException; +import java.nio.file.Path; +import java.util.ArrayList; +import java.util.Collection; import java.util.Date; +import java.util.stream.Stream; import static java.util.Arrays.asList; import static java.util.Optional.ofNullable; +import static java.util.stream.Collectors.toList; public class SvnPub { private SvnPub() { @@ -44,6 +52,8 @@ public class SvnPub { } public static void main(final String[] args) throws SVNException, IOException { + SVNJNAUtil.setJNAEnabled(false); // svnkit and java 8 == easy sigsev on ubuntu (fixed when upgrading svnkit version) + final String username = System.getProperty("site.username", System.getenv("USER")); final String password = args == null || args.length == 0 ? System.getProperty("site.password") : ofNullable(args[0]).filter(s -> !"notset".equalsIgnoreCase(s)).orElse(null); @@ -51,13 +61,16 @@ public class SvnPub { throw new IllegalArgumentException("No site.password system property set"); } - final ISVNAuthenticationManager authenticationManager = SVNWCUtil.createDefaultAuthenticationManager(username, password.toCharArray()); final SVNClientManager client = SVNClientManager.newInstance(new DefaultSVNOptions(), authenticationManager); final SVNUpdateClient update = client.getUpdateClient(); update.setIgnoreExternals(true); final File copy = new File(".content-site-checkout"); if (copy.exists()) { + System.out.println("Cleaning up local copy"); + client.getWCClient().doCleanup(copy); + + System.out.println("Reverting local copy to start from a clean one"); final SvnRevert revert = update.getOperationsFactory().createRevert(); revert.setPreserveModifiedCopies(false); revert.setRevertMissingDirectories(true); @@ -80,13 +93,49 @@ public class SvnPub { } FileUtils.copyDirectory(site[0], copy); - System.out.println(client.getStatusClient().doStatus(copy, false)); + final Collection<File> added = new ArrayList<>(); + final Collection<File> updated = new ArrayList<>(); + client.getStatusClient().doStatus(copy, SVNRevision.HEAD, SVNDepth.INFINITY, false, false, false, false, new ISVNStatusHandler() { + @Override + public void handleStatus(final SVNStatus status) throws SVNException { + final SVNStatusType contentsStatus = status.getContentsStatus(); + if (contentsStatus == SVNStatusType.STATUS_UNVERSIONED) { + added.add(status.getFile()); + } else if (contentsStatus == SVNStatusType.STATUS_MODIFIED || contentsStatus == SVNStatusType.STATUS_REPLACED) { + updated.add(status.getFile()); + } // else we don't care + } + }, null); + + final Collection<File> copies = Stream.concat(added.stream(), updated.stream()).collect(toList()); + // remove the .pdf without their .html, likely means there is no real update + added.removeIf(f -> f.getName().endsWith(".pdf") && !copies.contains(new File(f.getParentFile(), f.getName().replace(".pdf", ".html")))); + updated.removeIf(f -> f.getName().endsWith(".pdf") && !copies.contains(new File(f.getParentFile(), f.getName().replace(".pdf", ".html")))); + + if (updated.size() + added.size() == 0) { + System.out.println("Nothing to commit!"); + return; + } + + added.forEach(f -> { + try { + client.getWCClient().doAdd(f, false, false, false, SVNDepth.INFINITY, false, false, true); + } catch (final SVNException e) { + throw new IllegalStateException(e); + } + }); + + final Path sitePath = copy.getAbsoluteFile().toPath(); + added.forEach(f -> System.out.println("A " + sitePath.relativize(f.getAbsoluteFile().toPath()))); + updated.forEach(f -> System.out.println("M " + sitePath.relativize(f.getAbsoluteFile().toPath()))); - // now update it remotely - final SVNCommitInfo commitInfo = client.getCommitClient().doCommit(new File[]{copy}, false, - ofNullable(args == null || args.length < 2 ? System.getProperty("site.message") : args[1]) - .orElseGet(() -> "(test) Update of the website on the " + new Date() + " from " + username), - new SVNProperties(), new String[]{""}, false, false, SVNDepth.INFINITY); + // now update it remotely, note: we could use the status output to do it more efficiently + final String message = ofNullable(args == null || args.length < 2 ? System.getProperty("site.message") : args[1]) + .filter(m -> !"notset".equalsIgnoreCase(m)) + .orElseGet(() -> "Maven update of the website on the " + new Date() + " from " + username); + final SVNCommitInfo commitInfo = client.getCommitClient().doCommit( + Stream.concat(added.stream(), updated.stream()).toArray(File[]::new), false, message, + null, null, false, false, SVNDepth.IMMEDIATES); if (commitInfo.getErrorMessage() != null) { throw new IllegalStateException(commitInfo.getErrorMessage().toString()); } http://git-wip-us.apache.org/repos/asf/tomee-site-generator/blob/eb450892/src/main/jbake/content/community/index.adoc ---------------------------------------------------------------------- diff --git a/src/main/jbake/content/community/index.adoc b/src/main/jbake/content/community/index.adoc index 1e4fd22..3ad41fe 100755 --- a/src/main/jbake/content/community/index.adoc +++ b/src/main/jbake/content/community/index.adoc @@ -21,10 +21,14 @@ For more information about available support for TomEE please have a look on lin === Contribute the this website -This website is a simple JBake project you can find at http://svn.apache.org/repos/asf/tomee/site/trunk/generators/site-tomee-ng/. +This website is a simple JBake project you can find at https://git-wip-us.apache.org/repos/asf/tomee-site-generator.git. -For more information please have a look to http://svn.apache.org/repos/asf/tomee/site/trunk/generators/site-tomee-ng/README.adoc +For more information please have a look to +https://git-wip-us.apache.org/repos/asf?p=tomee-site-generator.git;a=blob;f=README.adoc;h=0fefd33b398fca05854ce46f3c5ebcb4a5ef107a;hb=refs/heads/master and http://jbake.org/. To submit a change create a ticket on http://issues.apache.org/jira/browse/TOMEE and attach a diff with the content. Then a committer will review it and redeploy the website using Apache CMS. + +Building the website is mainly about running `mvn compile`, note you can use `JBake` main to develop. +Publishing the website is about running `mvn pre-site` - needs to be a TomEE committer.