Skip to content

Commit

Permalink
Ailibs/refactor/namespacing (#130)
Browse files Browse the repository at this point in the history
* Update README.md

* Updated Javadoc references

* Mlplan/bugfix/twophasehasco/wrongassert optimal solution (#128)

* Modified logging behavior of MCCV, commented out incorrect assert

* Removed .travis_push_javadoc.sh

* Updated dependency specification examples in readme

* Updated ML-Plan readme

* removed unnessary files from ML-Plan top level

* Update README.md

* Update readme.md

* Update readme.md

* Update readme.md

* Update readme.md

* Update readme.md

* Update readme.md

* Update readme.md

* Update readme.md

* Update readme.md

* Configured the projects correctly for mvn repository. (#129)

* Configured the projects correctly for mvn repository.

Moved resources to resource folder.
Relaxed python version check.
Included searchgraph stylesheet via resources.

* Added empty default values for ossrhUsername and ossrhPassword

* Removed signs from travis builds

* Added intteruptible meka and weka via maven central.

* Fixed typos in build.gradle files.

* Configured the projects correctly for mvn repository.

Moved resources to resource folder.
Relaxed python version check.
Included searchgraph stylesheet via resources.

* Added empty default values for ossrhUsername and ossrhPassword

* Removed signs from travis builds

* Added intteruptible meka and weka via maven central.

* Fixed typos in build.gradle files.

* Renaming search packages.

Fix for some resource loading issues.

Fix for some logging issues.

Fix for some search space configurations.

* Update readme.md

* Update README.md

* modified travis.yml and removed settings.gradle from ML-Plan
  • Loading branch information
fmohr authored and mwever committed May 13, 2019
1 parent 691e8b3 commit 23aefe6
Show file tree
Hide file tree
Showing 355 changed files with 12,152 additions and 15,870 deletions.
8 changes: 4 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
include:
- stage: compile
script:
- "./gradlew build -x test"
- "./gradlew build -x test -x signArchives"
- stage: analysis
addons:
sonarcloud:
Expand All @@ -33,9 +33,9 @@ jobs:
- ./gradlew compileJava
- ./gradlew testClasses
- ./gradlew sonarqube -x test
- stage: deploy
script:
- "./gradlew publish -PnexusBaseUrl=$nexusBaseUrl -PnexusUpRepo=$nexusUpRepo -PnexusUser=$nexusUser -PnexusPassword=$nexusPassword"
#- stage: deploy
#script:
#- "./gradlew publish -PnexusBaseUrl=$nexusBaseUrl -PnexusUpRepo=$nexusUpRepo -PnexusUser=$nexusUser -PnexusPassword=$nexusPassword"
env:
global:
- secure: FkCxTnMbWP3Whd61puUXI6VJhhhXTeFby0k2Rmq01dYZN8asZ1FCoQFw1dEOlcx7dWLYFvb1feSmi7YOW+u6WznrbORu41NWFpA5VvGJyPkrsrhNN6xaNy7PNfFCMjmhZqcOAUoCCDwGzyUe17qoip1NfjNiIIFa+G6HNATUaODeGBtDBYpKVw3tvzM/rz14cIx2U4wF1WphxaIME3X5pzBNm0JK0NsYOZOHpb96O5t0lVkQXFgsm2A7Q0yWV+fGENoqfHZlnKmuiXjd7VJDNl9VMPjCLbcgVeN7O7OSzOQ9Omb9YwesV2nMUPEX6g2/v9yzFOoDpghtKEU9jZaLpIfmHsRafCNx0jBdy482cjznfEYaowT4CG/lGi4tT8gMYxzJGsT8TAdHoyzX7ZZUJsY+LWqb0K45YTup51Ynbuz2xeGzWo6Ydm9kYeuBcmcMwEjXFcSubalobT3JGlKUIgW9abEUfTWZwuhAzsRJ6uzB2N7pVqC/MyGXvnDJcQNDObHlmeKA0pWqZ9yIWYxHqByuwWfs+Ac63XJOk1qboWBfRXQhTWI9qQPV1W1j0kHU4S+MA2vPS1P7evzcU+Ci/YdCDwONiZ8Df1mevV3U8uZPmMcb5rgJ2YQT7xlSahTE1n7St8SroP6vFdiCgKuj8RRAIn9IZM6uTBAN1dKyDxQ=
Expand Down
66 changes: 0 additions & 66 deletions .travis_push_javadoc.sh

This file was deleted.

11 changes: 7 additions & 4 deletions JAICore/jaicore-basic/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,15 @@ dependencies {
uploadArchives {
repositories {
mavenDeployer {
def ossrhUsername = project.hasProperty('ossrhUsername') ? project.property('ossrhUsername') : ""
def ossrhPassword = project.hasProperty('ossrhPassword') ? project.property('ossrhPassword') : ""

beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") {
authentication(userName: "${ossrhUsername}", password: "${ossrhPassword}")
authentication(userName: ossrhUsername, password: ossrhPassword)
}
snapshotRepository(url: "https://oss.sonatype.org/content/repositories/snapshots/") {
authentication(userName: "${ossrhUsername}", password: "${ossrhPassword}")
authentication(userName: ossrhUsername, password: ossrhPassword)
}

pom.project {
Expand Down Expand Up @@ -49,8 +52,8 @@ uploadArchives {
}
developer {
id 'ahetzer'
name 'Alexander Hetzer'
email 'alexander.hetzer@upb.de'
name 'Alexander Tornede'
email 'alexander.tornede@upb.de'
}
}
}
Expand Down
10 changes: 5 additions & 5 deletions JAICore/jaicore-basic/conf/log4j.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
</layout>
</appender>

<logger name="jaicore">
<logger name="ai.libs.jaicore">
<level value="warn" />
<appender-ref ref="console" />
<appender-ref ref="infoFileAppender" />
Expand All @@ -55,19 +55,19 @@
<appender-ref ref="traceFileAppender" />
</logger>

<logger name="jaicore.basic.algorithm.GeneralAlgorithmTester">
<logger name="ai.libs.jaicore.basic.algorithm.GeneralAlgorithmTester">
<level value="trace" />
</logger>

<logger name="jaicore.graphvisualizer">
<logger name="ai.libs.jaicore.graphvisualizer">
<level value="warn" />
</logger>

<logger name="jaicore.interrupt">
<logger name="ai.libs.jaicore.interrupt">
<level value="debug" />
</logger>

<logger name="jaicore.timing">
<logger name="ai.libs.jaicore.timing">
<level value="debug" />
</logger>

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Lorem ipsum dolor sit amet.
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,11 @@ private FileUtil() {
}

public static List<String> readFileAsList(final File file) throws IOException {
return readFileAsList(file.getAbsolutePath());
if (file instanceof ResourceFile) {
return ResourceUtil.readResourceFileToStringList((ResourceFile) file);
} else {
return readFileAsList(file.getAbsolutePath());
}
}

public static List<String> readFileAsList(final String filename) throws IOException {
Expand Down Expand Up @@ -180,6 +184,10 @@ public static Properties readPropertiesFile(final File propertiesFile) throws IO
*/
public static void requireFileExists(final File file) throws FileIsDirectoryException, FileNotFoundException {
Objects.requireNonNull(file);
if (file instanceof ResourceFile) {
return;
}

if (!file.exists()) {
throw new FileNotFoundException("File " + file.getAbsolutePath() + " does not exist");
}
Expand Down Expand Up @@ -207,6 +215,7 @@ public static File getExistingFileWithHighestPriority(final String resourcePath,
}
}
}

return ResourceUtil.getResourceAsFile(resourcePath);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package ai.libs.jaicore.basic;

public class LoadResourceAsFileFailedException extends RuntimeException {

public LoadResourceAsFileFailedException(final String msg) {
super(msg);
}

public LoadResourceAsFileFailedException(final String msg, final Throwable cause) {
super(msg, cause);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
package ai.libs.jaicore.basic;

import java.io.File;
import java.io.InputStream;
import java.util.LinkedList;
import java.util.List;

import ai.libs.jaicore.basic.sets.SetUtil;

public class ResourceFile extends File {

/**
*
*/
private static final long serialVersionUID = -404232145050366072L;
private final String pathName;

public ResourceFile(final String pathname) {
super(pathname);
this.pathName = pathname;
}

public ResourceFile(final ResourceFile baseFile, final String pathname) {
super(getPathName(baseFile, pathname));
this.pathName = getPathName(baseFile, pathname);
}

private static String getPathName(final ResourceFile baseFile, final String pathName) {
List<String> pathConstruct = new LinkedList<>();
List<String> concatPaths = new LinkedList<>();

concatPaths.addAll(SetUtil.explode(baseFile.getPathName(), "/"));
concatPaths.addAll(SetUtil.explode(pathName, "/"));

for (String pathElement : concatPaths) {
if (pathElement.equals(".")) {
continue;
} else if (pathElement.equals("..")) {
if (pathConstruct.isEmpty()) {
throw new IllegalArgumentException("Cannot construct path from " + baseFile.getPathName() + " and " + pathName);
} else {
pathConstruct.remove(pathConstruct.size() - 1);
}
} else {
pathConstruct.add(pathElement);
}
}

return SetUtil.implode(pathConstruct, "/");
}

public InputStream getInputStream() {
return this.getClass().getClassLoader().getResourceAsStream(this.pathName);
}

public final String getPathName() {
return this.pathName;
}

@Override
public final ResourceFile getParentFile() {
List<String> stringList = SetUtil.explode(this.pathName, "/");
if (stringList.size() >= 1) {
stringList.remove(stringList.size() - 1);
return new ResourceFile(SetUtil.implode(stringList, "/"));
} else {
return null;
}
}

@Override
public boolean exists() {
return true;
}

}
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
package ai.libs.jaicore.basic;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URL;
import java.util.LinkedList;
import java.util.List;

import ai.libs.jaicore.basic.sets.SetUtil;

/**
* Utils for handling resource access in a more convenient way.
*
Expand All @@ -27,14 +31,7 @@ private ResourceUtil() {
* @throws IOException Throws an IOException if the file could not be read.
*/
public static String readResourceFileToString(final String path) throws IOException {
StringBuilder sb = new StringBuilder();
try (BufferedReader br = new BufferedReader(new FileReader(getResourceAsFile(path)))) {
String line;
while ((line = br.readLine()) != null) {
sb.append(line + "\n");
}
}
return sb.toString();
return SetUtil.implode(readResourceFileToStringList(path), "\n");
}

/**
Expand All @@ -43,11 +40,10 @@ public static String readResourceFileToString(final String path) throws IOExcept
* @param path The path of the resource that shall be read.
* @return The contents of the resource parsed to a string.
* @throws IOException Throws an IOException if the file could not be read.
* @throws FileNotFoundException Thrown if the file could not be found.
*/
public static List<String> readResourceFileToStringList(final String path) throws IOException {
List<String> list = new LinkedList<>();
try (BufferedReader br = new BufferedReader(new FileReader(getResourceAsFile(path)))) {
try (BufferedReader br = new BufferedReader(new InputStreamReader(ResourceUtil.class.getClassLoader().getResourceAsStream(path)))) {
String line;
while ((line = br.readLine()) != null) {
list.add(line);
Expand All @@ -56,14 +52,55 @@ public static List<String> readResourceFileToStringList(final String path) throw
return list;
}

/**
* Reads the contents of a resource to a list of strings.
*
* @param resourceFile The resource file to read.
* @return The contents of the resource parsed to a string.
* @throws IOException Throws an IOException if the file could not be read.
*/
public static List<String> readResourceFileToStringList(final ResourceFile resourceFile) throws IOException {
return readResourceFileToStringList(resourceFile.getPathName());
}

/**
* Returns the file corresponding to the given path.
*
* @param path The path for which a resource shall be retrieved.
* @return The resource file corresponding to the given path.
* @throws IOException
*/
public static File getResourceAsFile(final String path) {
return new File(ResourceUtil.class.getClassLoader().getResource(path).getFile());
public static ResourceFile getResourceAsFile(final String path) {
return new ResourceFile(path);
}

/**
* Returns the file corresponding to the given path.
*
* @param path The path for which a resource shall be retrieved.
* @return The resource file corresponding to the given path.
* @throws IOException
*/
public static URL getResourceAsURL(final String path) {
return ResourceUtil.class.getClassLoader().getResource(path);
}

/**
* Creates a temporary file from the resource to load.
* @param resourcePath The path to the resource.
* @return The canonical path to the temporary file reflecting the contents of the resource.
*/
public static String getResourceAsTempFile(final String resourcePath) {
try {
File tempFile = File.createTempFile("ai.libs-", ".res");
tempFile.deleteOnExit();
try (BufferedWriter bw = new BufferedWriter(new FileWriter(tempFile))) {
bw.write(ResourceUtil.readResourceFileToString(resourcePath));
}
return tempFile.getCanonicalPath();
} catch (IOException e) {
throw new LoadResourceAsFileFailedException("Could not load resource as a temporary file", e);
}
}

}
Loading

0 comments on commit 23aefe6

Please sign in to comment.