Commit 0046909c authored by Jean-Marc Ronck's avatar Jean-Marc Ronck
Browse files

Merge branch 'development' into 'master'

New Installation / Update Procedure and a few Bug Fixes

See merge request !2
parents 507a4371 7715ab3c
Pipeline #76595 passed with stage
in 6 minutes and 48 seconds
...@@ -2,4 +2,8 @@ ...@@ -2,4 +2,8 @@
/.idea /.idea
# Build # Build
/target /target
\ No newline at end of file /src/main/resources/math-pretty-printer/
/src/main/resources/visualisation/
/src/main/resources/visualization.zip
/src/main/resources/math-pretty-printer.zip
\ No newline at end of file
...@@ -2,10 +2,10 @@ ...@@ -2,10 +2,10 @@
<p align="center"> <p align="center">
<a> <a>
<img src="https://img.shields.io/badge/Version-0.1.0-blue.svg?longCache=true&style=flat-square"/> <img src="https://img.shields.io/badge/Version-0.1.1-blue.svg?longCache=true&style=flat-square"/>
</a> </a>
<a href="https://rwth-aachen.sciebo.de/s/igDWzLpdO5zYHBj/download?path=%2Fshared%2F18.07.20.visualization-emam&files=visualization-emam.zip"> <a href="https://rwth-aachen.sciebo.de/s/igDWzLpdO5zYHBj/download?path=%2Fshared%2F18.10.02.visualization-emam&files=visualization-emam.zip">
<img src="https://img.shields.io/badge/Download-18.07.20-blue.svg?longCache=true&style=flat-square"/> <img src="https://img.shields.io/badge/Download-18.10.02-blue.svg?longCache=true&style=flat-square"/>
</a> </a>
</p> </p>
......
<project name="VisualizationEMAM" basedir=".">
<target name="visualization.exists()">
<condition property="!visualization.exists">
<not><available file="src/main/resources/visualisation/embeddedmontiarc-svggenerator.jar"/></not>
</condition>
</target>
<target name="visualization.download()" depends="visualization.exists()" if="!visualization.exists">
<get src="https://rwth-aachen.sciebo.de/s/igDWzLpdO5zYHBj/download?path=%2Fshared%2F${visualization.version}.visualisation&amp;files=visualisation.zip"
dest="src/main/resources/visualization.zip"
verbose="false"/>
<unzip src="src/main/resources/visualization.zip"
dest="src/main/resources"/>
<delete file="src/main/resources/visualisation/emam2ema.jar"/>
<delete file="src/main/resources/visualization.zip"/>
</target>
<target name="math-pretty-printer.exists()">
<condition property="!math-pretty-printer.exists">
<not><available file="src/main/resources/math-pretty-printer/math-pretty-printer.jar"/></not>
</condition>
</target>
<target name="math-pretty-printer.download()" depends="math-pretty-printer.exists()" if="!math-pretty-printer.exists">
<get src="https://rwth-aachen.sciebo.de/s/igDWzLpdO5zYHBj/download?path=%2Fshared%2F${math-pretty-printer.version}.math-pretty-printer&amp;files=math-pretty-printer.zip"
dest="src/main/resources/math-pretty-printer.zip"
verbose="false"/>
<unzip src="src/main/resources/math-pretty-printer.zip"
dest="src/main/resources"/>
<delete file="src/main/resources/math-pretty-printer.zip"/>
</target>
</project>
\ No newline at end of file
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
<groupId>de.monticore.lang.monticar</groupId> <groupId>de.monticore.lang.monticar</groupId>
<artifactId>visualization-emam</artifactId> <artifactId>visualization-emam</artifactId>
<version>0.2.0-SNAPSHOT</version> <version>0.1.1</version>
<properties> <properties>
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
<commons-cli.version>1.4</commons-cli.version> <commons-cli.version>1.4</commons-cli.version>
<commons-exec.version>1.3</commons-exec.version> <commons-exec.version>1.3</commons-exec.version>
<commons-io.version>2.4</commons-io.version> <commons-io.version>2.4</commons-io.version>
<zip4j.version>1.3.2</zip4j.version> <commons-codec.version>1.11</commons-codec.version>
<monticore.version>5.0.0</monticore.version> <monticore.version>5.0.0</monticore.version>
<!-- .. Plugins ....................................................... --> <!-- .. Plugins ....................................................... -->
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
<assembly.plugin>2.5.3</assembly.plugin> <assembly.plugin>2.5.3</assembly.plugin>
<compiler.plugin>3.2</compiler.plugin> <compiler.plugin>3.2</compiler.plugin>
<source.plugin>2.4</source.plugin> <source.plugin>2.4</source.plugin>
<antrun.version>1.8</antrun.version>
<!-- .. Classifiers ................................................... --> <!-- .. Classifiers ................................................... -->
...@@ -39,6 +40,11 @@ ...@@ -39,6 +40,11 @@
<java.version>1.8</java.version> <java.version>1.8</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<!-- .. Resources ..................................................... -->
<visualization.version>18.07.16</visualization.version>
<math-pretty-printer.version>18.10.01</math-pretty-printer.version>
</properties> </properties>
<!-- == PROJECT METAINFORMATION ========================================= --> <!-- == PROJECT METAINFORMATION ========================================= -->
...@@ -98,9 +104,9 @@ ...@@ -98,9 +104,9 @@
</dependency> </dependency>
<dependency> <dependency>
<groupId>net.lingala.zip4j</groupId> <groupId>commons-codec</groupId>
<artifactId>zip4j</artifactId> <artifactId>commons-codec</artifactId>
<version>${zip4j.version}</version> <version>${commons-codec.version}</version>
</dependency> </dependency>
...@@ -238,6 +244,43 @@ ...@@ -238,6 +244,43 @@
<check/> <check/>
</configuration> </configuration>
</plugin> </plugin>
<!-- Resource Download -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>${antrun.version}</version>
<executions>
<execution>
<id>Download Visualization</id>
<phase>process-resources</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<ant antfile="build.xml">
<target name="visualization.download()"/>
</ant>
</target>
</configuration>
</execution>
<execution>
<id>Download MathPrettyPrinter</id>
<phase>process-resources</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<ant antfile="build.xml">
<target name="math-pretty-printer.download()"/>
</ant>
</target>
</configuration>
</execution>
</executions>
</plugin>
</plugins> </plugins>
</build> </build>
......
package de.monticore.lang.monticar.visualization.emam.application; package de.monticore.lang.monticar.visualization.emam.application;
import com.google.common.eventbus.EventBus;
import com.google.inject.Guice; import com.google.inject.Guice;
import com.google.inject.Inject; import com.google.inject.Inject;
import com.google.inject.Injector; import com.google.inject.Injector;
...@@ -14,7 +13,7 @@ import de.monticore.lang.monticar.visualization.emam.models.ModelsModule; ...@@ -14,7 +13,7 @@ import de.monticore.lang.monticar.visualization.emam.models.ModelsModule;
import de.monticore.lang.monticar.visualization.emam.options.OptionsModule; import de.monticore.lang.monticar.visualization.emam.options.OptionsModule;
import de.monticore.lang.monticar.visualization.emam.options.OptionsService; import de.monticore.lang.monticar.visualization.emam.options.OptionsService;
import de.monticore.lang.monticar.visualization.emam.paths.PathsModule; import de.monticore.lang.monticar.visualization.emam.paths.PathsModule;
import de.monticore.lang.monticar.visualization.emam.url.URLModule; import de.monticore.lang.monticar.visualization.emam.resources.ResourcesModule;
import java.text.ParseException; import java.text.ParseException;
import java.util.Set; import java.util.Set;
...@@ -89,8 +88,8 @@ public class Application { ...@@ -89,8 +88,8 @@ public class Application {
public static void main(String[] args) { public static void main(String[] args) {
Injector injector = Guice.createInjector( Injector injector = Guice.createInjector(
new ApplicationModule(), new DependenciesModule(), new ExecutablesModule(), new ApplicationModule(), new DependenciesModule(), new ExecutablesModule(),
new OptionsModule(), new PathsModule(), new URLModule(), new ModelsModule(), new OptionsModule(), new PathsModule(), new ModelsModule(), new EventsModule(),
new EventsModule(), new GeneratorModule() new GeneratorModule(), new ResourcesModule()
); );
Application application = injector.getInstance(Application.class); Application application = injector.getInstance(Application.class);
......
...@@ -8,7 +8,7 @@ import de.monticore.lang.monticar.visualization.emam.generator.HTMLGeneratorImpl ...@@ -8,7 +8,7 @@ import de.monticore.lang.monticar.visualization.emam.generator.HTMLGeneratorImpl
import de.monticore.lang.monticar.visualization.emam.models.ModelsServiceImpl; import de.monticore.lang.monticar.visualization.emam.models.ModelsServiceImpl;
import de.monticore.lang.monticar.visualization.emam.options.OptionsServiceImpl; import de.monticore.lang.monticar.visualization.emam.options.OptionsServiceImpl;
import de.monticore.lang.monticar.visualization.emam.paths.PathsServiceImpl; import de.monticore.lang.monticar.visualization.emam.paths.PathsServiceImpl;
import de.monticore.lang.monticar.visualization.emam.url.URLServiceImpl; import de.monticore.lang.monticar.visualization.emam.resources.ResourcesServiceImpl;
public class ApplicationModule extends AbstractModule { public class ApplicationModule extends AbstractModule {
@Override @Override
...@@ -19,7 +19,7 @@ public class ApplicationModule extends AbstractModule { ...@@ -19,7 +19,7 @@ public class ApplicationModule extends AbstractModule {
contributions.addBinding().to(DependenciesServiceImpl.class); contributions.addBinding().to(DependenciesServiceImpl.class);
contributions.addBinding().to(ExecutablesServiceImpl.class); contributions.addBinding().to(ExecutablesServiceImpl.class);
contributions.addBinding().to(OptionsServiceImpl.class); contributions.addBinding().to(OptionsServiceImpl.class);
contributions.addBinding().to(URLServiceImpl.class); contributions.addBinding().to(ResourcesServiceImpl.class);
contributions.addBinding().to(PathsServiceImpl.class); contributions.addBinding().to(PathsServiceImpl.class);
contributions.addBinding().to(ModelsServiceImpl.class); contributions.addBinding().to(ModelsServiceImpl.class);
contributions.addBinding().to(HTMLGeneratorImpl.class); contributions.addBinding().to(HTMLGeneratorImpl.class);
......
package de.monticore.lang.monticar.visualization.emam.dependencies; package de.monticore.lang.monticar.visualization.emam.dependencies;
import com.google.common.eventbus.EventBus;
import com.google.inject.Inject; import com.google.inject.Inject;
import de.monticore.lang.monticar.visualization.emam.paths.PathsService; import de.monticore.lang.monticar.visualization.emam.paths.PathsService;
import de.monticore.lang.monticar.visualization.emam.url.URLService; import de.monticore.lang.monticar.visualization.emam.resources.ResourcesService;
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.commons.io.FileUtils;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.security.MessageDigest;
import java.util.Arrays;
import java.util.logging.Logger; import java.util.logging.Logger;
public abstract class AbstractDependenciesContribution extends EventBus implements DependenciesContribution { public abstract class AbstractDependenciesContribution implements DependenciesContribution {
protected final Logger logger; protected final Logger logger;
protected final PathsService pathsService; protected final PathsService pathsService;
protected final URLService urlService; protected final ResourcesService resourcesService;
@Inject @Inject
public AbstractDependenciesContribution(Logger logger, PathsService pathsService, URLService urlService) { public AbstractDependenciesContribution(Logger logger, PathsService pathsService, ResourcesService resourcesService) {
this.logger = logger; this.logger = logger;
this.pathsService = pathsService; this.pathsService = pathsService;
this.urlService = urlService; this.resourcesService = resourcesService;
}
protected boolean isInstalled(String id) throws Exception {
MessageDigest messageDigest = MessageDigest.getInstance("MD5");
DigestUtils digestUtils = new DigestUtils(messageDigest);
InputStream toInstall = this.resourcesService.getResourceAsStream(id);
File installed = this.pathsService.getPathAsFile(id);
return installed.exists() && Arrays.equals(digestUtils.digest(toInstall), digestUtils.digest(installed));
}
protected void install(String id) throws IOException {
InputStream toInstall = this.resourcesService.getResourceAsStream(id);
File destination = this.pathsService.getPathAsFile(id);
FileUtils.copyInputStreamToFile(toInstall, destination);
} }
} }
package de.monticore.lang.monticar.visualization.emam.dependencies; package de.monticore.lang.monticar.visualization.emam.dependencies;
import net.lingala.zip4j.exception.ZipException;
import java.io.IOException; import java.io.IOException;
public interface DependenciesContribution { public interface DependenciesContribution {
boolean isDownloaded(); boolean isInstalled() throws Exception;
void download() throws IOException; void install() throws IOException;
boolean isInstalled();
void install() throws ZipException;
boolean isCleaned();
void clean() throws IOException;
} }
package de.monticore.lang.monticar.visualization.emam.dependencies; package de.monticore.lang.monticar.visualization.emam.dependencies;
public interface DependenciesService { public interface DependenciesService {
void download() throws Exception;
void install() throws Exception; void install() throws Exception;
void clean() throws Exception;
} }
...@@ -20,12 +20,8 @@ public class DependenciesServiceImpl implements DependenciesService, Application ...@@ -20,12 +20,8 @@ public class DependenciesServiceImpl implements DependenciesService, Application
} }
@Override @Override
public void download() throws Exception { public void prepare(Application application) throws Exception {
this.logger.info("Downloading Dependencies..."); this.install();
for (DependenciesContribution contribution : this.contributions) {
if (!contribution.isDownloaded()) contribution.download();
}
} }
@Override @Override
...@@ -36,20 +32,4 @@ public class DependenciesServiceImpl implements DependenciesService, Application ...@@ -36,20 +32,4 @@ public class DependenciesServiceImpl implements DependenciesService, Application
if (!contribution.isInstalled()) contribution.install(); if (!contribution.isInstalled()) contribution.install();
} }
} }
@Override
public void clean() throws Exception {
this.logger.info("Cleaning Installation Files...");
for (DependenciesContribution contribution : this.contributions) {
if (!contribution.isCleaned()) contribution.clean();
}
}
@Override
public void prepare(Application application) throws Exception {
this.download();
this.install();
this.clean();
}
} }
...@@ -2,68 +2,24 @@ package de.monticore.lang.monticar.visualization.emam.dependencies; ...@@ -2,68 +2,24 @@ package de.monticore.lang.monticar.visualization.emam.dependencies;
import com.google.inject.Inject; import com.google.inject.Inject;
import de.monticore.lang.monticar.visualization.emam.paths.PathsServiceImpl; import de.monticore.lang.monticar.visualization.emam.paths.PathsServiceImpl;
import de.monticore.lang.monticar.visualization.emam.url.URLService; import de.monticore.lang.monticar.visualization.emam.resources.ResourcesService;
import net.lingala.zip4j.core.ZipFile;
import net.lingala.zip4j.exception.ZipException;
import org.apache.commons.io.FileUtils;
import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.net.URL;
import java.nio.file.Path;
import java.util.logging.Logger; import java.util.logging.Logger;
public class MathPrettyPrinterDependency extends AbstractDependenciesContribution { public class MathPrettyPrinterDependency extends AbstractDependenciesContribution {
@Inject @Inject
public MathPrettyPrinterDependency(Logger logger, PathsServiceImpl pathsService, URLService urlService) { public MathPrettyPrinterDependency(Logger logger, PathsServiceImpl pathsService, ResourcesService resourcesService) {
super(logger, pathsService, urlService); super(logger, pathsService, resourcesService);
} }
@Override @Override
public boolean isDownloaded() { public boolean isInstalled() throws Exception {
File mppZIP = this.pathsService.getPathAsFile("math-pretty-printer.zip"); return super.isInstalled("math-pretty-printer.jar");
return this.isInstalled() || mppZIP.exists();
}
@Override
public void download() throws IOException {
URL mppURL = this.urlService.getURL("math-pretty-printer.zip");
Path mppZIP = this.pathsService.getPath("math-pretty-printer.zip");
this.logger.info("Downloading \"math-pretty-printer.zip\"...");
FileUtils.copyURLToFile(mppURL, mppZIP.toFile());
}
@Override
public boolean isInstalled() {
File mppJAR = this.pathsService.getPathAsFile("math-pretty-printer.jar");
return mppJAR.exists();
} }
@Override @Override
public void install() throws ZipException { public void install() throws IOException {
File mppZIP = this.pathsService.getPathAsFile("math-pretty-printer.zip"); super.install("math-pretty-printer.jar");
Path projectDirectory = this.pathsService.getPath("visualization-emam");
ZipFile zipFile = new ZipFile(mppZIP);
this.logger.info("Installing \"math-pretty-printer.zip\"...");
zipFile.extractAll(projectDirectory.toString());
}
@Override
public boolean isCleaned() {
File mppZIP = this.pathsService.getPathAsFile("math-pretty-printer.zip");
return !mppZIP.exists();
}
@Override
public void clean() throws IOException {
File mppZIP = this.pathsService.getPathAsFile("math-pretty-printer.zip");
this.logger.info("Deleting \"math-pretty-printer.zip\"...");
FileUtils.forceDelete(mppZIP);
} }
} }
...@@ -2,68 +2,24 @@ package de.monticore.lang.monticar.visualization.emam.dependencies; ...@@ -2,68 +2,24 @@ package de.monticore.lang.monticar.visualization.emam.dependencies;
import com.google.inject.Inject; import com.google.inject.Inject;
import de.monticore.lang.monticar.visualization.emam.paths.PathsService; import de.monticore.lang.monticar.visualization.emam.paths.PathsService;
import de.monticore.lang.monticar.visualization.emam.url.URLService; import de.monticore.lang.monticar.visualization.emam.resources.ResourcesService;
import net.lingala.zip4j.core.ZipFile;
import net.lingala.zip4j.exception.ZipException;
import org.apache.commons.io.FileUtils;
import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.net.URL;
import java.nio.file.Path;
import java.util.logging.Logger; import java.util.logging.Logger;
public class VisualizationDependency extends AbstractDependenciesContribution { public class VisualizationDependency extends AbstractDependenciesContribution {
@Inject @Inject
public VisualizationDependency(Logger logger, PathsService pathsService, URLService urlService) { public VisualizationDependency(Logger logger, PathsService pathsService, ResourcesService resourcesService) {
super(logger, pathsService, urlService); super(logger, pathsService, resourcesService);
} }
@Override @Override
public boolean isDownloaded() { public boolean isInstalled() throws Exception {
File visualizationZIP = this.pathsService.getPathAsFile("visualization.zip"); return super.isInstalled("visualization.jar");
return this.isInstalled() || visualizationZIP.exists();
}
@Override
public void download() throws IOException {
URL visualizationURL = this.urlService.getURL("visualization.zip");
Path visualizationZIP = this.pathsService.getPath("visualization.zip");
this.logger.info("Downloading \"visualization.zip\"...");
FileUtils.copyURLToFile(visualizationURL, visualizationZIP.toFile());
}
@Override
public boolean isInstalled() {
File visualizationJAR = this.pathsService.getPathAsFile("visualization.jar");
return visualizationJAR.exists();
} }
@Override @Override
public void install() throws ZipException { public void install() throws IOException {
File visualizationZIP = this.pathsService.getPathAsFile("visualization.zip"); super.install("visualization.jar");
Path projectDirectory = this.pathsService.getPath("visualization-emam");
ZipFile zipFile = new ZipFile(visualizationZIP);
this.logger.info("Installing \"visualization.zip\"...");
zipFile.extractAll(projectDirectory.toString());
}
@Override
public boolean isCleaned() {
File visualizationZIP = this.pathsService.getPathAsFile("visualization.zip");
return !visualizationZIP.exists();
}
@Override
public void clean() throws IOException {
File visualizationZIP = this.pathsService.getPathAsFile("visualization.zip");