Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Build Tapestry 5.5 from Source with Eclipse Photon and Java 9 in a Docker container

Build Tapestry 5.5 from source with Eclipse Photon and Java 9 in a Docker container

To have a constant and easy reproducible dev environment we're using Eclipse in a Docker container.

Build Container

  1. Save Dockerfile and docker-entrypoint.sh somewhere in the same folder
  2. Run docker build -t desktop/eclipse:tapestry . in that folder
  3. Wait...

Preprare for Container run

See the file eclipse for the mounted files and needed directories:

  • Location of source files
  • Maven
  • Gradle
  • Eclipse

Everything should be self-explanatory

Run the container

Save eclipse in your path and execute it, maybe chmod +x first.

Configure Eclipse

Some settings might be off, lets fix that:

  • Window -> Preferences -> Groovy -> Compiler -> Switch to 2.4.15.xx
  • Window -> Preferences -> General -> Workspace -> Text File Encoding -> UTF-8

TestNG can't be installed via Dockerfile, so need to do it now:

Import Tapestry

File -> Import... -> Gradle -> Existing Gradle Project -> Choose Tapestry and "Finish"

Prepare Tapestry

You need to run some gradle tasks for the errors to go away:

  • Project "beanmodel" -> Run As -> Run Configurations -> Gradle Project -> Choose working directory and set task "generateGrammarSource" I've run it twice before Eclipse picking it up, weird...
  • Project "beanmodel" -> Properties - Java Build Path -> Source -> Add Folder -> "build/generated-src/antlr/main"
  • Project tapestry-core -> Run As -> Run Configurations -> Gradle Project -> Choose working directory and set task "compileCoffeeScript compileTestCoffeeScript"

Now only 3 errors should be left:

  • Fix "/tapestry-core/src/test/groovy/org/apache/tapestry5/LaunchJetty8.groovy" package declaration
  • Close project "tapestry-javadoc"

Voila! You can build Tapestry now!

#!/bin/bash
if [ -n "${MEM_XMS}" ]; then
sudo grep -q '\-Xms' /opt/eclipse/eclipse.ini && sudo sed -i s/-Xms.*/-Xms${MEM_XMS}/ /opt/eclipse/eclipse.ini \
|| sudo sh -c "echo \"-Xms${MEM_XMS}\" >> /opt/eclipse/eclipse.ini"
fi
if [ -n "${MEM_XMX}" ]; then
sudo grep -q '\-Xmx' /opt/eclipse/eclipse.ini && sudo sed -i s/-Xmx.*/-Xmx${MEM_XMX}/ /opt/eclipse/eclipse.ini \
|| sudo sh -c "echo \"-Xmx${MEM_XMX}\" >> /opt/eclipse/eclipse.ini"
fi
if [ -n "${MEM_XMN}" ]; then
sudo grep -q '\-Xmn' /opt/eclipse/eclipse.ini && sudo sed -i s/-Xmn.*/-Xms${MEM_XMN}/ /opt/eclipse/eclipse.ini \
|| sudo sh -c "echo \"-Xmn${MEM_XMN}\" >> /opt/eclipse/eclipse.ini"
fi
/opt/eclipse/eclipse
FROM ubuntu:16.04
# SETTINGS
ARG ECLIPSE_URL=http://ftp-stud.fht-esslingen.de/pub/Mirrors/eclipse/technology/epp/downloads/release/photon/R/eclipse-java-photon-R-linux-gtk-x86_64.tar.gz
ARG NODE_VERSION=8.11.3
# PREPARE USER:
# A generic user with uid/gid 1000/1000 will match the permissions with the host
# so your files won't be all created by root
ENV USERNAME docker
ENV HOME /home/$USERNAME
RUN addgroup --system \
--gid=1000 \
$USERNAME
RUN adduser --system \
--uid=1000 \
--gid=1000 \
--home ${HOME} \
--shell /bin/bash ${USERNAME}
# GENERIC DEPENDENCIES:
# Install some software every container might need and clean up afterwards
# These dependencies are "borrowed" from another Dockerfile, so there might be more
# than actually needed by Eclipse
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
sudo \
unzip \
curl \
wget \
software-properties-common \
light-themes \
libcanberra-gtk-module \
&& apt-get clean \
&& apt-get purge
# SUDO FOR CUSTOM USER
# Enable sudo for the user, just in case
RUN echo "$USERNAME ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/$USERNAME \
&& chmod 0440 /etc/sudoers.d/$USERNAME
# MORE SPECIFIC DEPENDENCIES
RUN echo "deb http://archive.ubuntu.com/ubuntu/ trusty multiverse\ndeb http://us.archive.ubuntu.com/ubuntu/ trusty-updates multiverse\ndeb http://us.archive.ubuntu.com/ubuntu/ trusty-backports main restricted universe multiverse" >> /etc/apt/sources.list.d/multiverse.list \
&& apt-get update \
&& apt-get install -y --no-install-recommends \
git \
maven \
gradle \
python-keyring \
python-pip \
wget \
curl \
libwebkitgtk-1.0-0 \
firefox \
&& rm -rf /var/lib/apt-lists/* \
&& apt-get clean \
&& apt-get purge
# OPEN JDK 9
ENV JAVA_HOME=/usr/lib/jvm/java-9-openjdk-amd64
ENV JAVA_ENV "-Djava.io.tmpdir=/tmp"
RUN add-apt-repository ppa:openjdk-r/ppa \
&& apt-get update \
&& apt-get install -y --no-install-recommends \
openjdk-9-jdk \
&& rm -rf /var/lib/apt-lists/* \
&& apt-get clean \
&& apt-get purge
# ECLIPSE
RUN chown $USERNAME:$USERNAME /opt \
&& mkdir -p /opt/eclipse \
&& chown $USERNAME:$USERNAME /opt/eclipse \
&& curl -L -o /tmp/eclipse.tar.gz $ECLIPSE_URL \
&& tar -xf /tmp/eclipse.tar.gz -C /opt \
&& rm /tmp/eclipse.tar.gz \
&& update-alternatives --install /usr/bin/eclipse eclipse /opt/eclipse/eclipse 100
# ECLIPSE PLUGINS
# AutoDeriv
RUN /opt/eclipse/eclipse -clean -application org.eclipse.equinox.p2.director -noSplash -repository "http://nodj.github.io/AutoDeriv/update" -installIU "net.nodj.AutoDerivFeature.feature.group"
# Tapestry Plugin
RUN /opt/eclipse/eclipse -clean -application org.eclipse.equinox.p2.director -noSplash -repository "https://dl.bintray.com/anjlab/eclipse-tapestry5-plugin" -installIU "com.anjlab.eclipse.tapestry5.feature.feature.group"
# Greclipse
RUN /opt/eclipse/eclipse -clean -application org.eclipse.equinox.p2.director -noSplash -repository "http://dist.springsource.org/snapshot/GRECLIPSE/e4.8/" -installIUs "org.codehaus.groovy.eclipse.feature.feature.group,org.codehaus.groovy24.feature.feature.group"
# RunJettyRun (with older Jettys)
RUN /opt/eclipse/eclipse -clean -application org.eclipse.equinox.p2.director -noSplash -repository "http://xzer.github.io/run-jetty-run-updatesite/nightly/" -installIUs "runjettyrun_feature.feature.group,runjettyrun_feature_support_jetty93.feature.group,runjettyrun_feature_support_jetty9.feature.group,runjettyrun_feature_support_jetty8.feature.group,runjettyrun_feature_support_jetty7.feature.group"
# NODE
ENV NPM_CONFIG_LOGLEVEL info
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
xz-utils \
&& rm -rf /var/lib/apt-lists/* \
&& apt-get clean \
&& apt-get purge
RUN curl -SLO "https://nodejs.org/dist/v$NODE_VERSION/node-v$NODE_VERSION-linux-x64.tar.xz" \
&& tar -xJf "node-v$NODE_VERSION-linux-x64.tar.xz" -C /usr/local --strip-components=1 --no-same-owner \
&& rm "node-v$NODE_VERSION-linux-x64.tar.xz"
# ADD ENTRYPOINT SCRIPT
ADD docker-entrypoint.sh /docker-entrypoint.sh
RUN chmod 555 /docker-entrypoint.sh
# SWITCH TO CORRECT USER
USER $USERNAME
# CREATE NECESSARY FOLDERS
RUN mkdir -p ~/.m2 ~/.config
# RUN ECLIPSE
CMD /docker-entrypoint.sh
docker run \
--rm \
--name eclipse \
-v ~/code:/home/docker/code \
-v ~/.gitconfig:/home/docker/.gitconfig:ro \
-v ~/.m2/settings.xml:/home/docker/.m2/settings.xml:ro \
-v ~/.m2/repository:/home/docker/.m2/repository \
-v ~/.docker-data/eclipse:/home/docker/.eclipse \
-v ~/.docker-data/eclipse/gradle:/home/docker/.gradle \
-v /etc/localtime:/etc/localtime:ro \
-v /etc/timezone:/etc/timezone:ro \
-v /tmp/.X11-unix:/tmp/.X11-unix \
-e DISPLAY=$DISPLAY \
-e SWT_GTK3=0 \
-e MEM_XMS=3G \
-e MEM_XMX=5G \
-e MEM_MAX_PERM_SIZE=4G \
--net docker_dev \
desktop/eclipse:tapestry
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.