org.codehaus.mojo.groovy.tools.ProvidersMojo Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of groovy-maven-plugin Show documentation
Show all versions of groovy-maven-plugin Show documentation
Provides support for execution, compilation and other facets of Groovy development.
The newest version!
/*
* Copyright (C) 2006-2007 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.mojo.groovy.tools;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.Collection;
import java.util.Iterator;
import java.util.Map;
import org.codehaus.mojo.groovy.ProviderMojoSupport;
import org.codehaus.mojo.groovy.feature.Feature;
import org.codehaus.mojo.groovy.feature.Provider;
import org.codehaus.mojo.groovy.feature.ProviderManager;
import org.codehaus.mojo.groovy.feature.ProviderRegistry;
import org.codehaus.mojo.groovy.feature.ProviderSelector;
/**
* Displays information about the Groovy runtime providers which are configured and selected.
*
* @goal providers
* @requiresProject false
* @since 1.0-beta-3
*
* @author Jason Dillon
* @version $Id: ProvidersMojo.java 5524 2007-10-25 07:29:37Z user57 $
*/
public class ProvidersMojo
extends ProviderMojoSupport
{
protected void doExecute() throws Exception {
// logEnvironment();
ProviderManager manager = getProviderManager();
log.debug("Provider manager: {}", manager);
ProviderRegistry registry = manager.getRegistry();
log.debug("Provider registry: {}", registry);
ProviderSelector selector = manager.getSelector();
log.debug("Provider selector: {}", selector);
// Before we can get the list of registered providers, we need to select one first,
// so pick the default and save any failure for later inspection
Provider selected = null;
Throwable selectFailure = null;
try {
selected = provider();
log.debug("Selected: {}", selected);
}
catch (Throwable t) {
log.debug("Selection failure: " + t, t);
selectFailure = t;
}
log.info("");
log.info("Provider selection: {}", getProviderSelection());
log.info("");
Map providers = registry.providers();
if (providers == null || providers.isEmpty()) {
log.info("No providers registered");
}
else {
log.info("Found {} registered providers:", String.valueOf(providers.size()));
for (Iterator iter = providers.keySet().iterator(); iter.hasNext();) {
String key = (String) iter.next();
Provider provider = (Provider) providers.get(key);
logProvider(provider, " ");
log.info("");
}
if (selected != null) {
log.info("Selected provider:");
log.info(" {}", selected);
}
else if (selectFailure != null) {
log.info("No provider was selected; Failures occured while selecting: {}", selectFailure.toString());
}
else {
log.info("No provider was selected and no failure was detected; The gods must be crazy...");
}
}
log.info("");
}
protected void logEnvironment() {
URL[] urls = ((URLClassLoader)getClass().getClassLoader()).getURLs();
log.debug("ClassLoader Class-Path:");
for (int i=0; i
© 2015 - 2025 Weber Informatics LLC | Privacy Policy