Repository: incubator-wave
Updated Branches:
  refs/heads/master 050fbb412 -> 800fbc87a


Built a Helper program to automate some tasks for the maintainers.

Has an automation task for style checking due to the fact that he gradle 
checkstyle plugin requires us to store the google_style.xml which would require 
license additions.


Project: http://git-wip-us.apache.org/repos/asf/incubator-wave/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-wave/commit/3a511515
Tree: http://git-wip-us.apache.org/repos/asf/incubator-wave/tree/3a511515
Diff: http://git-wip-us.apache.org/repos/asf/incubator-wave/diff/3a511515

Branch: refs/heads/master
Commit: 3a51151502650666138350a5be7fa6d5ab74b697
Parents: 050fbb4
Author: wisebaldone <[email protected]>
Authored: Thu Apr 20 00:28:15 2017 +1000
Committer: wisebaldone <[email protected]>
Committed: Tue Apr 25 00:58:55 2017 +1000

----------------------------------------------------------------------
 .gitignore            |  1 +
 MAINTAINERS.md        | 33 +++++++++++++++++
 helper/cli.go         | 84 ++++++++++++++++++++++++++++++++++++++++++
 helper/style/style.go | 91 ++++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 209 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/3a511515/.gitignore
----------------------------------------------------------------------
diff --git a/.gitignore b/.gitignore
index c800a52..23c107f 100755
--- a/.gitignore
+++ b/.gitignore
@@ -21,6 +21,7 @@
 war/WEB-INF
 *.old
 .DS_Store
+.helper
 
 ### IntelliJ Idea
 .idea

http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/3a511515/MAINTAINERS.md
----------------------------------------------------------------------
diff --git a/MAINTAINERS.md b/MAINTAINERS.md
new file mode 100644
index 0000000..b7a9881
--- /dev/null
+++ b/MAINTAINERS.md
@@ -0,0 +1,33 @@
+# Apache Wave
+
+Welcome Apache Wave Maintainer.
+
+This document is your cheat sheet to the resources which are spread around the 
Apache Wave
+repositories and websites. Many of the Apache specific documentation will be 
on the Wiki linked
+below while non-apache related items will be on the website.
+
+### Helpful Links
+
+- [Confluence 
Wiki](https://cwiki.apache.org/confluence/display/WAVE/Maintainer+Documentation)
+- [Maintainer Website](https://incubator.apache.org/wave/maintainers)
+
+
+### Helper Tool
+
+In the Apache Wave repository is a helper tool which is designed to make our 
lives easier. The 
+tool is ever growing to meet the demands of the project. The maintainers 
website is the stable 
+location for documentation on the tool.
+
+**Required: You must have go 1.7+ installed.**
+
+With go installed you can run the tool with: 
+
+- `go run helper/cli.go`
+- `go run helper/cli.go -h`
+- `go run helper/cli.go -help`
+
+It will produce files in the `.helper` directory which should not be used for 
permanent storage
+ as `-clean` will remove the entire folder.
+
+**Note: Once new website has been made and published formal docs will be 
located in the 
+maintainers section.**
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/3a511515/helper/cli.go
----------------------------------------------------------------------
diff --git a/helper/cli.go b/helper/cli.go
new file mode 100644
index 0000000..fb836b7
--- /dev/null
+++ b/helper/cli.go
@@ -0,0 +1,84 @@
+//
+// 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.
+
+/*
+A Simple helper program to help maintainers run the project.
+
+Current Feature List:
+       - Runs style checkers
+       - Runs style formatters ( todo )
+       - Runs build tools ( todo )
+       - Runs pre installers ( todo )
+       - Branch pull requests ( todo )
+       - Publishes website ( todo )
+
+Command line Flags:
+
+       -h | --help     : shows the help.
+       -clean          : removes all temporary files.
+
+@author: [email protected] ( Evan Hughes )
+ */
+package main
+
+import (
+       "os"
+       "fmt"
+       "./style"
+       "flag"
+       "log"
+)
+
+var openingText string = `
+                                Apache Wave Maintainer Helper!
+                                ------------------------------
+
+This tool is written for Apache Wave maintainers and may have undesired 
affects if used by other
+developers. This tool will need certain permissions which are not given to it 
automatically and will
+need to prompt the user for credentials.
+
+Use -h or --help to see the list of commands.
+----------------------------------------------------------------------------------------------------
+
+`
+/*
+       Main Helper entry.
+ */
+func main() {
+       // Welcome user.
+       fmt.Println(openingText)
+       // create temp folder
+       os.Mkdir(".helper", 0777)
+
+       clearFlag := flag.Bool("clear", false, "Clears all temporary files ( 
deletes .helper )")
+       styleFlag := flag.Bool("style", false, "Run the style checker on wave 
and pst projects.")
+       flag.Parse()
+
+       if (*clearFlag) {
+               clear()
+       }
+       if (*styleFlag) {
+               style.Run()
+       }
+}
+
+// Deletes the .helper folder
+func clear() {
+       log.Println("Removing all temporary files.")
+       os.RemoveAll(".helper")
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/3a511515/helper/style/style.go
----------------------------------------------------------------------
diff --git a/helper/style/style.go b/helper/style/style.go
new file mode 100644
index 0000000..c108702
--- /dev/null
+++ b/helper/style/style.go
@@ -0,0 +1,91 @@
+//
+// 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.
+
+/*
+Commands for running the style checkers.
+
+- Java uses stylechecker.
+
+@author: [email protected] ( Evan Hughes )
+ */
+package style
+
+import (
+       "os"
+       "log"
+       "net/http"
+       "io"
+       "os/exec"
+)
+
+const checkStyle = ".helper/checkstyle.jar"
+
+/*
+       Runs stylechecker based off the Google style guide.
+
+       runs on:
+               wave/src/main/java
+               pst/src/main/java
+ */
+func Run() {
+       _, err := os.Stat(checkStyle)
+       if os.IsNotExist(err) {
+               download()
+       }
+       run("wave/src/main/java/", ".helper/wave.style.xml")
+       run("pst/src/main/java/", ".helper/pst.style.xml")
+}
+
+// Downloads a set version of checkstyle, current version ( 7.6.1 )
+func download() {
+       out, err := os.Create(checkStyle)
+       if err != nil {
+               log.Fatalln(err)
+       }
+       log.Println("Downloading checkstyle.")
+       resp, err := http.Get(
+               
"https://nchc.dl.sourceforge.net/project/checkstyle/checkstyle/"; +
+                       "7.6.1/checkstyle-7.6.1-all.jar")
+       if err != nil {
+               log.Fatalln("Could not download checkstyle.")
+       }
+       defer resp.Body.Close()
+       _, err = io.Copy(out, resp.Body)
+       if err != nil {
+               log.Fatalln(err)
+       }
+}
+
+// Runs the style checker on the input and records the output in xml
+func run(directory string, outputFile string) {
+       log.Printf("Running checkstyle on %s outputting to %s\n", directory, 
outputFile)
+       cmd := exec.Command(
+               "java", "-jar",
+               checkStyle,
+               "-c", "/google_checks.xml",
+               directory,
+               "-o",
+               outputFile,
+               "-f",
+               "xml")
+       err := cmd.Run()
+       if err != nil {
+               log.Fatalln(err)
+       }
+       log.Printf("Finished checking %s\n", directory)
+}
\ No newline at end of file

Reply via email to