Skip to content

Commit

Permalink
switch to use Typesafe config for execution config (#56)
Browse files Browse the repository at this point in the history
- move to typesafe config and support across the modules to support that.
- support for multiple execution configs
- updated method for resolving and merging config
- generation of new config from old maven settings
  • Loading branch information
iantmoore committed Aug 14, 2017
1 parent 2b90e46 commit 044a40b
Show file tree
Hide file tree
Showing 83 changed files with 3,535 additions and 1,155 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ classes/
*.iml
_build/

/TODO.md
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ Requirements
------------
* Java 8

1.1.0
-----
* Moved substeps config to a single org.substeps hierarchy, existing overrides will still be used, but config should be updated
* Moved maven pom configuration to config files (multiple). Maven plugin will print out the new config from existing pom settings, see [1.1.0 Upgrade notes](1.1.0 Upgrade.md) for further details
* Added an exclusion filter to the config for the glossary builder under `org.substeps.config.glossary.excludeStepImplementationClassNames`

1.0.6
-----
* Redacted some of the output of the config
Expand Down
58 changes: 55 additions & 3 deletions api/pom.xml
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
<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>

<parent>
<groupId>org.substeps</groupId>
<artifactId>substeps-framework</artifactId>
<version>1.0.6-SNAPSHOT</version>
<version>1.1.0-SNAPSHOT</version>
</parent>

<artifactId>substeps-core-api</artifactId>
Expand All @@ -30,6 +29,17 @@
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-library</artifactId>
</dependency>

<dependency>
<groupId>org.scalatest</groupId>
<artifactId>scalatest_2.11</artifactId>
<scope>test</scope>
</dependency>


<dependency>
<groupId>com.google.guava</groupId>
Expand Down Expand Up @@ -57,6 +67,48 @@
</execution>
</executions>
</plugin>

<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>scala-maven-plugin</artifactId>
<executions>

<!-- Run scala compiler in the process-resources phase, so that dependencies on scala classes can be
resolved later in the (Java) compile phase -->
<execution>
<id>scala-compile-first</id>
<phase>process-resources</phase>
<goals>
<goal>add-source</goal>
<goal>compile</goal>
</goals>
</execution>

<!-- Run scala compiler in the process-test-resources phase, so that dependencies on scala classes can
be resolved later in the (Java) test-compile phase -->
<execution>
<id>scala-test-compile</id>
<phase>process-test-resources</phase>
<goals>
<goal>testCompile</goal>
</goals>
</execution>

</executions>
<configuration>
<sourceDir>src/main/scala</sourceDir>
<jvmArgs>
<jvmArg>-Xms64m</jvmArg>
<jvmArg>-Xmx1024m</jvmArg>
</jvmArgs>
<scalaVersion>${scala.version}</scalaVersion>
<!-- <args> <arg>-make:transitive</arg> <arg>dependenfile</arg> <arg>${project.build.directory}/.scala_dependencies</arg>
</args> -->
</configuration>

</plugin>


</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,13 @@ public interface SubstepsServerMBean extends SubstepsRunner {

byte[] prepareExecutionConfigAsBytes(final SubstepsExecutionConfig theConfig);

byte[] prepareExecutionConfigAsBytes(final String theConfig);

byte[] prepareRemoteExecutionConfig(final String mavenFallbackConfig, String featureFile, String scenarioName);


byte[] runAsBytes();

String getProjectSubstepsVersion();

}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import com.typesafe.config.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.substeps.runner.NewSubstepsExecutionConfig;

import java.net.URL;

Expand All @@ -32,21 +33,12 @@ public enum Configuration {

INSTANCE;

private transient final Logger logger;

private transient final Config config;

Configuration() {
logger = LoggerFactory.getLogger(Configuration.class);
final String resourceBundleName = resourceBundleName();


config = ConfigFactory.load(resourceBundleName);

public Config getSubstepsConfig(){
return NewSubstepsExecutionConfig.threadLocalConfig().getConfig("org.substeps.config");
}

public Config getConfig(){
return config;
return NewSubstepsExecutionConfig.threadLocalConfig();
}


Expand All @@ -63,62 +55,22 @@ public void addDefaultProperties(final URL url, final String name) {
}



public String getConfigurationInfo() {

ConfigRenderOptions options =
ConfigRenderOptions.defaults().setComments(false).setFormatted(true).setJson(false).setOriginComments(false);

return config
.withoutPath("java")
.withoutPath("sun")
.withoutPath("awt")
.withoutPath("idea")
.withoutPath("line.separator")
.withoutPath("os")
.withoutPath("path.separator")
.withValue("remote.token", ConfigValueFactory.fromAnyRef("******"))
.withValue("remote.username", ConfigValueFactory.fromAnyRef("******"))

.root().render(options);
}


private String resourceBundleName() {

String useProps = System.getProperty("substeps.use.dot.properties");
String ext;
if (useProps != null && Boolean.parseBoolean(useProps)){
logger.info("Using legacy properties for configuration, use .conf for greater functionality");
ext = ".properties";
}
else {
ext = ".conf";
}

String resourceBundle = System.getProperty("environment", "localhost") + ext;

System.out.println("loading config from resource bundle: " + resourceBundle);
return resourceBundle;
}


public String getString(final String key) {
return config.getString(key);
return getConfig().getString(key);
}


public int getInt(final String key) {
return config.getInt(key);
return getConfig().getInt(key);
}


public long getLong(final String key) {
return config.getLong(key);
return getConfig().getLong(key);
}


public boolean getBoolean(final String key) {
return config.getBoolean(key);
return getConfig().getBoolean(key);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.Arrays;
import java.util.EnumMap;
import java.util.HashMap;
import java.util.Map;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import com.google.common.base.Function;
import com.technophobia.substeps.execution.ExecutionResult;
import com.technophobia.substeps.execution.node.IExecutionNode;
import com.technophobia.substeps.execution.node.StepImplementationNode;

import java.io.Serializable;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
package com.technophobia.substeps.runner;

import com.technophobia.substeps.execution.node.RootNode;
import com.typesafe.config.Config;

import java.util.List;

Expand All @@ -27,7 +28,7 @@
*/
public interface SubstepsRunner {

RootNode prepareExecutionConfig(final SubstepsExecutionConfig theConfig);
RootNode prepareExecutionConfig(final Config theConfig);

RootNode run();

Expand Down
4 changes: 2 additions & 2 deletions api/src/main/java/org/substeps/report/IReportBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/
public interface IReportBuilder {

void buildFromDirectory(File sourceDataDir);
void buildFromDirectory(File sourceDataDir, File stepImplsJson);
void buildFromDirectory(File sourceDataDir, File reportDir);
void buildFromDirectory(File sourceDataDir, File reportDir, File stepImplsJson);

}

This file was deleted.

This file was deleted.

12 changes: 0 additions & 12 deletions api/src/main/resources/default-core-substeps.properties

This file was deleted.

Loading

0 comments on commit 044a40b

Please sign in to comment.