basic setup of the doc deployment in groovy
diff --git a/.travis.yml b/.travis.yml
index b13ef15..0caeaa7 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -42,7 +42,7 @@
- stage: master_build
env:
- STEP=Update Documentation
- script: mvn pre-site
+ script: cd winegrower-documentation && mvn pre-site gplus:execute@deploy-site -Pgh-pages
jdk: oraclejdk8
- stage: master_build
diff --git a/pom.xml b/pom.xml
index c9da577..be2bb67 100644
--- a/pom.xml
+++ b/pom.xml
@@ -183,4 +183,9 @@
</plugins>
</build>
+ <scm>
+ <developerConnection>scm:git:https://github.com/jbonofre/winegrower.git</developerConnection>
+ <connection>scm:git:https://github.com/jbonofre/winegrower.git</connection>
+ <url>https://github.com/jbonofre/winegrower</url>
+ </scm>
</project>
\ No newline at end of file
diff --git a/winegrower-core/pom.xml b/winegrower-core/pom.xml
index 9e7b31e..b05224f 100644
--- a/winegrower-core/pom.xml
+++ b/winegrower-core/pom.xml
@@ -57,5 +57,4 @@
<scope>test</scope>
</dependency>
</dependencies>
-
</project>
diff --git a/winegrower-documentation/pom.xml b/winegrower-documentation/pom.xml
index 288ea24..1ab7a52 100644
--- a/winegrower-documentation/pom.xml
+++ b/winegrower-documentation/pom.xml
@@ -117,4 +117,52 @@
</plugin>
</plugins>
</build>
+
+ <profiles>
+ <profile>
+ <id>gh-pages</id>
+
+ <properties>
+ <github.serverId>winegrower-github</github.serverId>
+ </properties>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.gmavenplus</groupId>
+ <artifactId>gmavenplus-plugin</artifactId>
+ <version>1.6</version>
+ <executions>
+ <execution>
+ <id>deploy-site</id>
+ <phase>none</phase>
+ <goals>
+ <goal>execute</goal>
+ </goals>
+ <configuration>
+ <allowSystemExits>true</allowSystemExits>
+ <scripts>
+ <script>${project.basedir}/src/build/GithubPages.groovy</script>
+ </scripts>
+ </configuration>
+ </execution>
+ </executions>
+ <dependencies>
+ <dependency>
+ <groupId>org.eclipse.jgit</groupId>
+ <artifactId>org.eclipse.jgit</artifactId>
+ <version>4.9.2.201712150930-r</version>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.groovy</groupId>
+ <artifactId>groovy-all</artifactId>
+ <version>2.5.3</version>
+ <type>pom</type>
+ </dependency>
+ </dependencies>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
</project>
\ No newline at end of file
diff --git a/winegrower-documentation/src/build/GithubPages.groovy b/winegrower-documentation/src/build/GithubPages.groovy
new file mode 100644
index 0000000..38c90b6
--- /dev/null
+++ b/winegrower-documentation/src/build/GithubPages.groovy
@@ -0,0 +1,61 @@
+/**
+ * Licensed 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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.
+ */
+import org.apache.maven.settings.crypto.DefaultSettingsDecryptionRequest
+import org.apache.maven.settings.crypto.SettingsDecrypter
+import org.eclipse.jgit.api.Git
+import org.eclipse.jgit.transport.UsernamePasswordCredentialsProvider
+
+import static java.util.Collections.singleton
+
+def source = new File(project.build.directory, 'documentation')
+if (!source.exists() || !new File(source, 'index.html').exists()) {
+ log.warn('Not ready to deploy, skipping')
+ return
+}
+
+def branch = 'refs/heads/gh-pages'
+def workDir = new File(project.build.directory, UUID.randomUUID().toString() + '_' + System.currentTimeMillis())
+
+def url = project.parent.scm.url
+def serverId = project.properties['github.serverId']
+log.info("Using server ${serverId}")
+
+def server = session.settings.servers.findAll { it.id == serverId }.iterator().next()
+def decryptedServer = session.container.lookup(SettingsDecrypter).decrypt(new DefaultSettingsDecryptionRequest(server))
+server = decryptedServer.server != null ? decryptedServer.server : server
+
+log.info("Using url=${url}")
+log.info("Using user=${server.username}")
+log.info("Using branch=${branch}")
+
+def credentialsProvider = new UsernamePasswordCredentialsProvider(server.username, server.password)
+def git = Git.cloneRepository()
+ .setCredentialsProvider(credentialsProvider)
+ .setURI(url)
+ .setDirectory(workDir)
+ .setBranchesToClone(singleton(branch))
+ .setBranch(branch)
+ .call()
+
+new AntBuilder().copy(todir: workDir.absolutePath, overwrite: true) {
+ fileset(dir: source.absolutePath)
+}
+// we don't drop old files, stay conservative for now
+
+def message = "Updating the documentation for version ${project.version} // " + new Date().toString()
+git.add().addFilepattern(".").call()
+git.commit().setAll(true).setMessage(message).call()
+git.status().call()
+git.push().setCredentialsProvider(credentialsProvider).add(branch).call()
+log.info("Updated the documentation on ${new Date()}")