Skip to content

Commit

Permalink
committing broken code to demonstrate VerifierError with @CompileStatic
Browse files Browse the repository at this point in the history
  • Loading branch information
graemerocher committed Jan 17, 2013
1 parent 8669e68 commit 24434f6
Show file tree
Hide file tree
Showing 8 changed files with 124 additions and 30 deletions.
Expand Up @@ -25,6 +25,7 @@ import org.apache.maven.settings.Settings
import org.apache.maven.settings.building.DefaultSettingsBuildingRequest
import org.apache.maven.settings.building.SettingsBuilder
import org.apache.maven.settings.building.SettingsBuildingResult
import org.codehaus.groovy.grails.resolve.AbstractDependencyManager
import org.codehaus.groovy.grails.resolve.DependencyManager
import org.codehaus.groovy.grails.resolve.maven.aether.config.AetherDsl
import org.codehaus.groovy.grails.resolve.maven.aether.support.GrailsConsoleLoggerManager
Expand Down Expand Up @@ -65,7 +66,7 @@ import org.sonatype.aether.util.repository.DefaultProxySelector
* @since 2.3
*/
@CompileStatic
class AetherDependencyManager implements DependencyManager{
class AetherDependencyManager extends AbstractDependencyManager{

static final String DEFAULT_CACHE = "${System.getProperty('user.home')}/.m2/repository"
static final Map<String, List<String>> SCOPE_MAPPINGS = [compile:['compile'],
Expand Down
@@ -0,0 +1,80 @@
/* Copyright 2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.codehaus.groovy.grails.resolve

import groovy.transform.CompileStatic
import groovy.util.slurpersupport.GPathResult
import org.xml.sax.ErrorHandler
import org.xml.sax.SAXException
import org.xml.sax.SAXParseException

import javax.xml.parsers.ParserConfigurationException
import java.util.concurrent.ConcurrentHashMap

/**
* Abstract implementation of DependencyManager interface
*
* @author Graeme Rocher
* @since 2.3
*/
//@CompileStatic
abstract class AbstractDependencyManager implements DependencyManager{

private Map<File,GPathResult> parsedXmlCache = new ConcurrentHashMap<File, GPathResult>();

GPathResult downloadPluginList(File localFile) {
GPathResult parsedXml = parsedXmlCache[localFile]
if (!parsedXml) {
try {
URL url = new URL(GRAILS_CENTRAL_PLUGIN_LIST)

if (localFile.lastModified() < url.openConnection().lastModified ) {
localFile.withOutputStream { OutputStream os ->
url.withInputStream { InputStream is ->
os << is
}
}
}

def xmlSlurper = new XmlSlurper()
xmlSlurper.setErrorHandler(new ErrorHandler() {
public void warning(SAXParseException e) throws SAXException {
// noop
}

public void error(SAXParseException e) throws SAXException {
// noop
}

public void fatalError(SAXParseException e) throws SAXException {
// noop
}
});
parsedXml = xmlSlurper.parse(localFile)
parsedXmlCache.put(localFile, parsedXml)
}
catch (IOException e) {
// ignore
}
catch (SAXException e) {
// ignore
}
catch (ParserConfigurationException e) {
// ignore
}
}
return parsedXml
}
}
Expand Up @@ -48,7 +48,7 @@
* @author Graeme Rocher
* @since 1.3
*/
public abstract class AbstractIvyDependencyManager {
public abstract class AbstractIvyDependencyManager extends AbstractDependencyManager{

public static final String SNAPSHOT_CHANGING_PATTERN = ".*SNAPSHOT";

Expand Down
Expand Up @@ -15,8 +15,11 @@
package org.codehaus.groovy.grails.resolve;

import grails.util.BuildSettings;
import groovy.util.slurpersupport.GPathResult;
import org.codehaus.groovy.grails.resolve.reporting.DependencyGraphRenderer;

import java.io.File;
import java.net.URL;
import java.util.Collection;

/**
Expand All @@ -28,6 +31,19 @@
*/
public interface DependencyManager {

/**
* URL to the central Grails plugin repository's global plugin list
*/
String GRAILS_CENTRAL_PLUGIN_LIST = "http://grails.org/plugins/.plugin-meta/plugins-list.xml";


/**
* Downloads the Grails central plugin list and saves it to the given file. The file is then parsed and the resulting XML returned
*
* @param localFile The local file
* @return The parsed XML
*/
public GPathResult downloadPluginList(File localFile);
/**
* Outputs the dependency graph to System.out
*/
Expand Down
Expand Up @@ -22,6 +22,7 @@ import groovy.transform.CompileStatic
import groovy.transform.TypeCheckingMode;
import groovy.util.XmlSlurper;
import groovy.util.slurpersupport.GPathResult
import org.codehaus.groovy.grails.resolve.DependencyManager
import org.codehaus.groovy.tools.LoaderConfiguration;

import java.io.File;
Expand Down Expand Up @@ -126,7 +127,7 @@ Enter Y or N:"""
uaaService.registerProductUsage(product)


URL centralURL = new URL("http://grails.org/plugins/.plugin-meta/plugins-list.xml");
URL centralURL = new URL(DependencyManager.GRAILS_CENTRAL_PLUGIN_LIST);

InputStream input = null;

Expand Down
10 changes: 5 additions & 5 deletions grails-resources/src/grails/grails-app/conf/BuildConfig.groovy
Expand Up @@ -7,11 +7,11 @@ grails.project.source.level = 1.6
//grails.project.war.file = "target/${appName}-${appVersion}.war"

// uncomment (and adjust settings) to fork the JVM to isolate classpaths
//grails.project.fork = [
// run: [maxMemory:1024, minMemory:64, debug:false, maxPerm:256],
// war: [maxMemory:1024, minMemory:64, debug:false, maxPerm:256],
// console: [maxMemory:1024, minMemory:64, debug:false, maxPerm:256]
//]
grails.project.fork = [
run: [maxMemory:1024, minMemory:64, debug:false, maxPerm:256],
war: [maxMemory:1024, minMemory:64, debug:false, maxPerm:256],
console: [maxMemory:1024, minMemory:64, debug:false, maxPerm:256]
]

grails.project.dependency.resolver = "maven" // or ivy
grails.project.dependency.resolution = {
Expand Down
16 changes: 2 additions & 14 deletions scripts/ListPlugins_.groovy
Expand Up @@ -31,23 +31,11 @@ includeTargets << grailsScript("_GrailsPlugins")
target(listPlugins: "Implementation target") {
depends(parseArguments,configureProxy)

def repository = argsMap.repository
if (repository) {
eachRepository { name, url ->
if (name == repository) {
printRemotePluginList(repository)
printInstalledPlugins()
}
}
}
else if (argsMap.installed) {
if (argsMap.installed) {
printInstalledPlugins()
}
else {
eachRepository { name, url ->
printRemotePluginList(name)
return true
}
pluginsList = grailsSettings.dependencyManager.downloadPluginList(new File("$grailsWorkDir/plugins-list-grailsCentral.xml"))
printInstalledPlugins()
}

Expand Down
24 changes: 16 additions & 8 deletions scripts/_PluginDependencies.groovy
Expand Up @@ -184,17 +184,25 @@ doInstallPlugin = { pluginName, pluginVersion = null ->
}

eachRepository = { Closure callable ->
IvyDependencyManager dependencyManager = grailsSettings.dependencyManager
for (resolver in dependencyManager.chainResolver.resolvers) {
if (resolver instanceof GrailsRepoResolver) {
pluginsList = resolver.getPluginList(new File("${grailsWorkDir}/plugins-list-${resolver.name}.xml"))
if (pluginsList != null) {
callable(resolver.name, resolver.repositoryRoot)
} else {
grailsConsole.error "An error occurred resolving plugin list from resolver [${resolver.name} - ${resolver.repositoryRoot}]."
def dependencyManager = grailsSettings.dependencyManager
if(dependencyManager instanceof IvyDependencyManager) {
for (resolver in dependencyManager.chainResolver.resolvers) {
if (resolver instanceof GrailsRepoResolver) {
pluginsList = resolver.getPluginList(new File("${grailsWorkDir}/plugins-list-${resolver.name}.xml"))
if (pluginsList != null) {
callable(resolver.name, resolver.repositoryRoot)
} else {
grailsConsole.error "An error occurred resolving plugin list from resolver [${resolver.name} - ${resolver.repositoryRoot}]."
}
}
}
}
else {
dependencyManager.repositories.each { r ->
callable.call(r.id, r.url)
}
}

}

private withPluginInstall(Closure callable) {
Expand Down

0 comments on commit 24434f6

Please sign in to comment.