Help:LanguageTool/Vagrant

Attempt on a common Vagrant instance.

Initial setup of Mediawiki-Vagrant

edit

The usual setup is as described on MediaWiki-Vagrant, and yes you need Git

$ mkdir ~/ltspace
$ cd ~/ltspace
$ git clone --recursive https://gerrit.wikimedia.org/r/mediawiki/vagrant .
$ ./setup.sh
$ vagrant box update
$ vagrant up

Git update

edit

At this point you should do a $ vagrant git-update in the host directory, otherwise you will probably run into problems later. Then do a $ vagrant reload to make sure everything works.

At this point you should clean up the client for outdated apt pakages. Do a

$ vagrant ssh
$ sudo apt-get update && sudo apt-get upgrade
$ sudo apt-get autoremove
$ exit

Note that this still leaves the box running old software, and you should do a sudo apt-get update && sudo apt-get upgrade from time to time.

Roles for the host

edit

Use the following additional roles

VisualEditor

edit

This is the new visual editor, which would be the primary accesspoint for LanguageTool.

$ vagrant enable-role visualeditor && vagrant provision && vagrant git-update

Java in the guest

edit

Not clear if the version should be 7 or 8. Only thing I got to pass was Java 8 from Oracle.

$ sudo sh -c 'echo "deb http://ppa.launchpad.net/webupd8team/java/ubuntu trusty main" >> /etc/apt/sources.list'
$ sudo sh -c 'echo "deb-src http://ppa.launchpad.net/webupd8team/java/ubuntu trusty main" >> /etc/apt/sources.list'
$ sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys EEA14886
$ sudo apt-get update && sudo apt-get upgrade
$ sudo apt-get install oracle-java8-installer
$ sudo apt-get install oracle-java8-set-default

Maven would now install as 3.0.5, which is to old for some packages as they need 3.3+. Latest as of this writing is 3.5.0[1][2]

$ sudo apt-get purge -y maven
$ wget http://apache.uib.no/maven/maven-3/3.5.0/binaries/apache-maven-3.5.0-bin.tar.gz
$ tar -zxf apache-maven-3.5.0-bin.tar.gz
$ sudo mv apache-maven-3.5.0 /usr/local
$ ln -s /usr/local/apache-maven-3.5.0/bin/mvn /usr/bin/mvn
$ echo "export M2_HOME=/usr/local/apache-maven-3.5.0" >> ~/.profile

Check versions, they should all report 1.8 -ish and 3.5 -ish

$ javac -version
$ java -version
$ mvn -version

Additional tweaks for maven is to set the environment variable MAVEN_OPTS in ~/.profile[3]

export MAVEN_OPTS="-Xmx512m -XX:MaxPermSize=256m"

It could also be necessary to add maven to the PATH

export PATH=/opt/apache-maven-3.5.0/bin:$PATH

Clone LanguageTool

edit

Create the dir for the LanguageTool and clone the repo[4] (Please avoid hammering the public API.[5])

$ mkdir /vagrant/languagetool
$ cd /vagrant/languagetool

For the official repo use

$ git clone --depth 5 https://github.com/languagetool-org/languagetool.git .

For the forked repo use

$ git clone --depth 5 https://github.com/jeblad/languagetool.git .

Now do a first test run (before this you should probably set more memory for the guest, like 3072MB)

$ mvn clean test package

Add the classpath to ~/.profile (could also be the common /etc/profile)

export CLASSPATH="$CLASSPATH:/vagrant/languagetool/languagetool-standalone/target/LanguageTool-3.9-SNAPSHOT/LanguageTool-3.9-SNAPSHOT/*"

Now source the ~/.profile (could also be the common /etc/profile) and start the server[6]

$ source ~/.profile
$ java org.languagetool.server.HTTPServer --port 8081

The server can now be tested by a call

$ curl --data "language=en-US&text=a simple test" http://localhost:8081/v2/check

References

edit
edit