Permalink
Browse files

committing broken code to demonstrate VerifierError with @CompileStatic

  • Loading branch information...
1 parent 8669e68 commit 24434f68a890fcb295178c27c731daa80d471f15 @graemerocher graemerocher committed Jan 17, 2013
View
3 ...ain/groovy/org/codehaus/groovy/grails/resolve/maven/aether/AetherDependencyManager.groovy
@@ -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
@@ -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'],
View
80 ...strap/src/main/groovy/org/codehaus/groovy/grails/resolve/AbstractDependencyManager.groovy
@@ -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
+ }
+}
View
2 ...trap/src/main/groovy/org/codehaus/groovy/grails/resolve/AbstractIvyDependencyManager.java
@@ -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";
View
16 grails-bootstrap/src/main/groovy/org/codehaus/groovy/grails/resolve/DependencyManager.java
@@ -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;
/**
@@ -29,6 +32,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
*/
void produceReport();
View
3 grails-bootstrap/src/uaa/groovy/org/codehaus/groovy/grails/cli/support/UaaEnabler.groovy
@@ -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;
@@ -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;
View
10 grails-resources/src/grails/grails-app/conf/BuildConfig.groovy
@@ -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 = {
View
16 scripts/ListPlugins_.groovy
@@ -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()
}
View
24 scripts/_PluginDependencies.groovy
@@ -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) {

0 comments on commit 24434f6

Please sign in to comment.