Commit 42d472a2 authored by Jean Meurice's avatar Jean Meurice Committed by Evgeny Kusmenko

Library service update

parent 3e8747d2
......@@ -5,6 +5,7 @@
# can be found under https://github.com/MontiCore/monticore.
#
stages:
- windows
- linux
......
# (c) https://github.com/MontiCore/monticore
script:
- git checkout ${TRAVIS_BRANCH}
- mvn -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn -B clean install cobertura:cobertura org.eluder.coveralls:coveralls-maven-plugin:report --settings "settings.xml"
......
<!-- (c) https://github.com/MontiCore/monticore -->
<a href="https://codeclimate.com/github/MontiSim/commons/maintainability"><img src="https://api.codeclimate.com/v1/badges/1fee5e810477b6a2a432/maintainability" /></a> [![Build Status](https://travis-ci.org/MontiSim/commons.svg?branch=master)](https://travis-ci.org/MontiSim/commons) [![Coverage Status](https://coveralls.io/repos/github/MontiSim/commons/badge.svg?branch=master)](https://coveralls.io/github/MontiSim/commons?branch=master)
# Commons
......
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0" encoding="UTF-8" ?>
<!--
(c) https://github.com/MontiCore/monticore
......@@ -7,13 +7,12 @@
can be found under https://github.com/MontiCore/monticore.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>montisim</groupId>
<artifactId>commons</artifactId>
<version>1.0.9</version>
<version>1.0.10</version>
<properties>
......@@ -36,8 +35,8 @@
</dependency>
</dependencies>
<!-- == PROJECT BUILD SETTINGS =========================================== -->
<!-- == PROJECT BUILD SETTINGS =========================================== -->
<build>
<plugins>
......@@ -46,7 +45,7 @@
<version>2.8.1</version>
</plugin>
<!-- Other Configuration -->
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
......@@ -80,6 +79,7 @@
</execution>
</executions>
</plugin>
<!-- to add copyright information automatically-->
<plugin>
<groupId>com.mycila</groupId>
......@@ -87,10 +87,6 @@
<version>3.0</version>
<configuration>
<header>${project.baseUri}/src/license/se/license.txt</header>
<properties>
<owner>Michael von Wenckstern</owner>
<email>vonwenckstern@se-rwth.de</email>
</properties>
<excludes>
<exclude>**/README</exclude>
<exclude>src/test/resources/**</exclude>
......@@ -107,19 +103,18 @@
</execution>
</executions>
</plugin>
<plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19.1</version>
<configuration>
</configuration>
<configuration></configuration>
</plugin>
<plugin>
<groupId>org.eluder.coveralls</groupId>
<artifactId>coveralls-maven-plugin</artifactId>
<version>4.3.0</version>
<configuration>
</configuration>
<configuration></configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
......@@ -131,21 +126,21 @@
<!-- aggregated reports for multi-module projects -->
<aggregate>true</aggregate>
</configuration>
</plugin>
</plugin>
</plugins>
</build>
<!-- == DISTRIBUTION ==================================================== -->
<!-- == DISTRIBUTION ==================================================== -->
<distributionManagement>
<repository>
<id>se-nexus</id>
<url>https://nexus.se.rwth-aachen.de/content/repositories/embeddedmontiarc-releases/</url>
</repository>
<snapshotRepository>
<id>se-nexus</id>
<url>https://nexus.se.rwth-aachen.de/content/repositories/embeddedmontiarc-snapshots/</url>
</snapshotRepository>
</distributionManagement>
<distributionManagement>
<repository>
<id>se-nexus</id>
<url>https://nexus.se.rwth-aachen.de/content/repositories/embeddedmontiarc-releases/</url>
</repository>
<snapshotRepository>
<id>se-nexus</id>
<url>https://nexus.se.rwth-aachen.de/content/repositories/embeddedmontiarc-snapshots/</url>
</snapshotRepository>
</distributionManagement>
</project>
</project>
\ No newline at end of file
(c) https://github.com/MontiCore/monticore
The license generally applicable for this project
can be found under https://github.com/MontiCore/monticore.
can be found under https://github.com/MontiCore/monticore.
\ No newline at end of file
......@@ -27,9 +27,12 @@ public class LibraryService {
if (OS.contains("win")){
systemName = "windows";
libraryExtension = ".dll";
} else if (OS.contains("nix")|| OS.contains("nux")|| OS.contains("aix")|| OS.contains("mac")){
} else if (OS.contains("nix") || OS.contains("nux") || OS.contains("aix") ){
systemName = "linux";
libraryExtension = ".so";
} else if (OS.contains("mac")){
systemName = "mac";
libraryExtension = ".dylib";
}
else throw new ExceptionInInitializerError(new LibraryException(LibraryExceptionType.OS_RESOLVE, OS));
}
......@@ -74,11 +77,11 @@ public class LibraryService {
}
/*
Prepares a system dependent library:
It is under windows/lib_name or linux/lib_name in the resources.
(lib_name can contain a relative path plus the library name).
Exports a resource as file.
If system_dependent is true it will lookup "lib_name" under "windows", "linux" or "mac" depending on the system.
(lib_name can contain a relative path plus the library name. The file will have the same relative path to the working directory.)
*/
public static void prepareLibrary(String lib_name) throws LibraryException {
public static void prepareLibrary(String lib_name, boolean system_dependent) throws LibraryException {
String lib_path = getWorkingDirectory()+lib_name;
//System.out.println("lib_path: " + lib_path);
File target_file = new File(lib_path);
......@@ -87,7 +90,8 @@ public class LibraryService {
}
//Write library to disk
try {
InputStream res = LibraryService.class.getResourceAsStream("/"+getSystemName()+"/"+lib_name);
String path_to_resource = system_dependent ? "/"+getSystemName()+"/"+lib_name : "/"+lib_name;
InputStream res = LibraryService.class.getResourceAsStream(path_to_resource);
target_file.getParentFile().mkdirs();
FileOutputStream fout= new FileOutputStream(target_file);
BufferedOutputStream out = new BufferedOutputStream(fout);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment