Skip to content

Commit

Permalink
remove last remains of old build system
Browse files Browse the repository at this point in the history
  • Loading branch information
graemerocher committed Oct 9, 2014
1 parent 6458e8e commit 02cc333
Show file tree
Hide file tree
Showing 289 changed files with 248 additions and 30,442 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
package org.grails.dependency.resolution.maven.aether

import grails.build.logging.GrailsConsole
import grails.util.BuildSettings
import groovy.transform.CompileStatic
import groovy.transform.TypeCheckingMode
import groovy.util.slurpersupport.GPathResult
Expand Down Expand Up @@ -198,7 +197,7 @@ class AetherDependencyManager implements DependencyManager {
}

void produceReport(String scope) {
final desc = BuildSettings.SCOPE_TO_DESC[scope]
final desc = SCOPE_TO_DESC[scope]
if (desc) {
reportOnScope(scope, desc)
} else {
Expand Down Expand Up @@ -241,15 +240,15 @@ class AetherDependencyManager implements DependencyManager {

void produceReport() {
// build scope
reportOnScope(BuildSettings.BUILD_SCOPE, BuildSettings.BUILD_SCOPE_DESC)
reportOnScope(BUILD_SCOPE, BUILD_SCOPE_DESC)
// provided scope
reportOnScope(BuildSettings.PROVIDED_SCOPE, BuildSettings.PROVIDED_SCOPE_DESC)
reportOnScope(PROVIDED_SCOPE, PROVIDED_SCOPE_DESC)
// compile scope
reportOnScope(BuildSettings.COMPILE_SCOPE, BuildSettings.COMPILE_SCOPE_DESC)
reportOnScope(COMPILE_SCOPE, COMPILE_SCOPE_DESC)
// runtime scope
reportOnScope(BuildSettings.RUNTIME_SCOPE, BuildSettings.RUNTIME_SCOPE_DESC)
reportOnScope(RUNTIME_SCOPE, RUNTIME_SCOPE_DESC)
// test scope
reportOnScope(BuildSettings.TEST_SCOPE, BuildSettings.TEST_SCOPE_DESC)
reportOnScope(TEST_SCOPE, TEST_SCOPE_DESC)
}

protected void reportOnScope(String scope, String desc) {
Expand Down Expand Up @@ -669,7 +668,7 @@ class AetherDependencyManager implements DependencyManager {
dependency.group == 'org.grails.plugins' || dependency.extension == 'zip'
}

DependencyManager createCopy(BuildSettings buildSettings = null) {
DependencyManager createCopy() {
AetherDependencyManager dependencyManager = new AetherDependencyManager()
dependencyManager.repositories = this.repositories
dependencyManager.settings = this.settings
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,9 @@
import jline.internal.TerminalLineSettings;

import org.apache.tools.ant.BuildException;
import org.codehaus.groovy.grails.cli.ScriptExitException;
import org.codehaus.groovy.grails.cli.interactive.CandidateListCompletionHandler;
import org.codehaus.groovy.grails.cli.logging.GrailsConsoleErrorPrintStream;
import org.codehaus.groovy.grails.cli.logging.GrailsConsolePrintStream;
import org.grails.build.interactive.CandidateListCompletionHandler;
import org.grails.build.logging.GrailsConsoleErrorPrintStream;
import org.grails.build.logging.GrailsConsolePrintStream;
import org.codehaus.groovy.runtime.DefaultGroovyMethods;
import org.codehaus.groovy.runtime.StackTraceUtils;
import org.codehaus.groovy.runtime.typehandling.NumberMath;
Expand Down Expand Up @@ -679,10 +678,6 @@ public void error(Throwable error) {
}

private void printStackTrace(String message, Throwable error) {
if (error instanceof ScriptExitException) {
return; // don't bother with exit exceptions
}

if ((error instanceof BuildException) && error.getCause() != null) {
error = error.getCause();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.codehaus.groovy.grails.cli.support;
package grails.build.support;

import groovy.lang.ExpandoMetaClass;
import groovy.lang.GroovySystem;
Expand Down
71 changes: 65 additions & 6 deletions grails-bootstrap/src/main/groovy/grails/config/ConfigMap.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@ import org.codehaus.groovy.runtime.DefaultGroovyMethods
class ConfigMap implements Map<String, Object> {
final ConfigMap rootConfig
final List<String> path
@Delegate
final Map<String, Object> delegateMap

public ConfigMap() {
rootConfig = this
path = []
Expand All @@ -25,7 +24,67 @@ class ConfigMap implements Map<String, Object> {
this.path = path
delegateMap = [:]
}


@Override
int size() {
delegateMap.size()
}

@Override
boolean isEmpty() {
delegateMap.isEmpty()
}

@Override
boolean containsKey(Object key) {
delegateMap.containsKey key
}

@Override
boolean containsValue(Object value) {
delegateMap.containsValue value
}

@Override
Object get(Object key) {
delegateMap.get(key)
}

@Override
Object put(String key, Object value) {
delegateMap.put(key, value)
}

@Override
Object remove(Object key) {
delegateMap.remove key
}

@Override
void putAll(Map<? extends String, ?> m) {
delegateMap.putAll m
}

@Override
void clear() {
delegateMap.clear()
}

@Override
Set<String> keySet() {
delegateMap.keySet()
}

@Override
Collection<Object> values() {
delegateMap.values()
}

@Override
Set<Map.Entry<String, Object>> entrySet() {
delegateMap.entrySet()
}

public void merge(Map sourceMap, boolean parseFlatKeys=false) {
mergeMaps(this, sourceMap, parseFlatKeys)
}
Expand Down Expand Up @@ -53,7 +112,7 @@ class ConfigMap implements Map<String, Object> {
Object currentValue = targetMap.containsKey(sourceKey) ? targetMap.get(sourceKey) : null
Object newValue
if(sourceValue instanceof Map) {
ConfigMap subMap = new ConfigMap(targetMap.rootConfig, ((targetMap.path + [sourceKey]) as List<String>).asImmutable())
ConfigMap subMap = new ConfigMap( (ConfigMap)targetMap.rootConfig, ((targetMap.path + [sourceKey]) as List<String>).asImmutable())
if(currentValue instanceof Map) {
subMap.putAll((Map)currentValue)
}
Expand Down Expand Up @@ -110,7 +169,7 @@ class ConfigMap implements Map<String, Object> {
if(currentItem instanceof ConfigMap) {
currentMap = (ConfigMap)currentItem
} else if (createMissing) {
Map<String, Object> newMap = new ConfigMap(currentMap.rootConfig, ((currentMap.path + [pathElement]) as List<String>).asImmutable())
Map<String, Object> newMap = new ConfigMap( (ConfigMap)currentMap.rootConfig, ((currentMap.path + [pathElement]) as List<String>).asImmutable())
currentMap.put(pathElement, newMap)
currentMap = newMap
} else {
Expand Down Expand Up @@ -166,7 +225,7 @@ class ConfigMap implements Map<String, Object> {
}

@CompileStatic
private static class NullSafeNavigator {
static class NullSafeNavigator {
final ConfigMap parent
final List<String> path

Expand Down
34 changes: 25 additions & 9 deletions grails-bootstrap/src/main/groovy/grails/config/GrailsConfig.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -7,43 +7,46 @@ import org.yaml.snakeyaml.Yaml

@CompileStatic
@Canonical
public class GrailsConfig implements Cloneable {
class GrailsConfig implements Cloneable {
final ConfigMap configMap

public GrailsConfig() {
GrailsConfig() {
configMap = new ConfigMap()
}

public GrailsConfig(GrailsConfig copyOf) {
GrailsConfig(GrailsConfig copyOf) {
this(copyOf.@configMap)
}

public GrailsConfig(Map copyOf) {
GrailsConfig(Map copyOf) {
this()
mergeMap(copyOf)
}

public GrailsConfig clone() {
GrailsConfig clone() {
new GrailsConfig(this)
}

public void loadYml(File ymlFile) {
void loadYml(File ymlFile) {
ymlFile.withInputStream { InputStream input ->
loadYml(input)
}
}

@groovy.transform.CompileDynamic // fails with CompileStatic!
public void loadYml(InputStream input) {
void loadYml(InputStream input) {
Yaml yaml = new Yaml()
for(Object yamlObject : yaml.loadAll(input)) {
if(yamlObject instanceof Map) { // problem here with CompileStatic
mergeMap((Map)yamlObject)
}
}

def flatConfig = configMap.toFlatConfig()
configMap.putAll(flatConfig)
}

public void mergeMap(Map sourceMap, boolean parseFlatKeys=false) {
void mergeMap(Map sourceMap, boolean parseFlatKeys=false) {
configMap.merge(sourceMap, parseFlatKeys)
}

Expand All @@ -56,7 +59,10 @@ public class GrailsConfig implements Cloneable {
}

protected <T> T convertToType(Object value, Class<T> requiredType) {
if(requiredType.isInstance(value)) {
if(value instanceof ConfigMap.NullSafeNavigator) {
return null
}
else if(requiredType.isInstance(value)) {
return (T)value
}
if(requiredType==String.class) {
Expand Down Expand Up @@ -132,6 +138,16 @@ public class GrailsConfig implements Cloneable {
return this.configMap
return configMap.getProperty(name)
}

public Object get(String name) {
if ("configMap".equals(name))
return this.configMap
return configMap.getProperty(name)
}

public <T> T getProperty(String name, Class<T> requiredType) {
return convertToType( configMap.getProperty(name), requiredType )
}

public void setProperty(String name, Object value) {
configMap.setProperty(name, value)
Expand Down

This file was deleted.

Loading

0 comments on commit 02cc333

Please sign in to comment.