Skip to content

Commit

Permalink
Improved Maven POM and ConfigurationBuilder
Browse files Browse the repository at this point in the history
Some errors have been fixed in the Maven POM: Minimization has been
turned off for the shaded full jar, as it leads to missing classes. The
main class now is specified correctly, too.

ConfigurationBuilder has been modified such that command line arguments
override config file arguments. I think this makes more sense than the
other way around.
  • Loading branch information
thomasWeise committed May 27, 2015
1 parent 2afc340 commit fb72bcf
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 6 deletions.
9 changes: 3 additions & 6 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@
<manifest>
<addDefaultImplementationEntries />
<addDefaultSpecificationEntries />
<mainClass>org.optimizationBenchmarking.experimentation.evaluation.system.Main</mainClass>
<mainClass>org.optimizationBenchmarking.experimentation.evaluation.Main</mainClass>
</manifest>
</archive>
</configuration>
Expand All @@ -280,11 +280,8 @@

<createSourcesJar>true</createSourcesJar>
<shadeTestJar>true</shadeTestJar>

<minimizeJar>true</minimizeJar>

<minimizeJar>false</minimizeJar>
<shadedArtifactAttached>true</shadedArtifactAttached>

<createDependencyReducedPom>false</createDependencyReducedPom>

<shadedClassifierName>full</shadedClassifierName>
Expand All @@ -304,7 +301,7 @@
<transformers>
<transformer
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>org.optimizationBenchmarking.experimentation.evaluation.system.Main</mainClass>
<mainClass>org.optimizationBenchmarking.experimentation.evaluation.Main</mainClass>
</transformer>
<transformer
implementation="org.apache.maven.plugins.shade.resource.ApacheLicenseResourceTransformer" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import java.io.File;
import java.io.IOException;
import java.nio.file.Path;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;

Expand Down Expand Up @@ -235,22 +236,31 @@ public synchronized final void putProperties(final Properties prop) {
*/
synchronized final void _configure(final String[] args)
throws IOException {
final _ConfigMap map;
Path configFile;
ConfigurationPropertiesInput propertiesInput;
ConfigurationXMLInput xmlInput;
HashMap<String, Object> copy;
String param;

this.fsmFlagsAssertAndUpdate(FSM.FLAG_NOTHING,
ConfigurationBuilder.FLAG_HAS_BEEN_CONFIGURED,
ConfigurationBuilder.FLAG_HAS_BEEN_CONFIGURED, FSM.FLAG_NOTHING);

this.putCommandLine(args);

map = this.m_data.m_data;
copy = null;

// load a potential properties file
configFile = this.m_data._get(Configuration.PARAM_PROPERTY_FILE,
PathParser.INSTANCE, null, false);
if (configFile != null) {
propertiesInput = ConfigurationPropertiesInput.getInstance();
if (propertiesInput.canUse()) {
copy = new HashMap<>(map.size());
copy.putAll(map);

propertiesInput.use().addPath(configFile).setDestination(this)
.create().call();
}
Expand All @@ -262,10 +272,28 @@ synchronized final void _configure(final String[] args)
if (configFile != null) {
xmlInput = ConfigurationXMLInput.getInstance();
if (xmlInput.canUse()) {

if (copy == null) {
copy = new HashMap<>(map.size());
copy.putAll(map);
}

xmlInput.use().addPath(configFile).setDestination(this).create()
.call();
}
}

// restore command line arguments: overwrite config file
if (copy != null) {
for (final Map.Entry<String, Object> entry : copy.entrySet()) {
param = entry.getKey();
if (Configuration.PARAM_XML_FILE.equalsIgnoreCase(param) || //
Configuration.PARAM_PROPERTY_FILE.equalsIgnoreCase(param)) {
continue;
}
map.getEntry(param, false).setValue(entry.getValue());
}
}
}

/** {@inheritDoc} */
Expand Down

0 comments on commit fb72bcf

Please sign in to comment.