org.netbeans.modules.groovy.grails.api.GrailsProjectConfig

Here are the examples of the java api org.netbeans.modules.groovy.grails.api.GrailsProjectConfig taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

16 Examples 7

19 Source : Utils.java
with Apache License 2.0
from apache

static ClreplacedPath createJDKSourcePath(Project nbproject) {
    GrailsProjectConfig config = nbproject.getLookup().lookup(GrailsProjectConfig.clreplaced);
    JavaPlatform jp = config.getJavaPlatform();
    if (jp == null) {
        jp = JavaPlatformManager.getDefault().getDefaultPlatform();
    }
    if (jp != null) {
        return jp.getSourceFolders();
    }
    return ClreplacedPathSupport.createClreplacedPath(new URL[0]);
}

19 Source : GrailsCommandSupport.java
with Apache License 2.0
from apache

public void refreshGrailsCommands() {
    Callable<Process> callable = // NOI18N
    ExecutionSupport.getInstance().createSimpleCommand(// NOI18N
    "help", GrailsProjectConfig.forProject(project));
    final HelpLineProcessor lineProcessor = new HelpLineProcessor();
    ExecutionDescriptor descriptor = new ExecutionDescriptor().inputOutput(InputOutput.NULL).outProcessorFactory(new ExecutionDescriptor.InputProcessorFactory() {

        public InputProcessor newInputProcessor(InputProcessor defaultProcessor) {
            // we are sure this will be invoked at most once
            return InputProcessors.bridge(lineProcessor);
        }
    });
    List<GrailsCommand> freshCommands = Collections.emptyList();
    // NOI18N
    ExecutionService service = ExecutionService.newService(callable, descriptor, "help");
    Future<Integer> task = service.run();
    try {
        if (task.get().intValue() == 0) {
            freshCommands = new ArrayList<GrailsCommand>();
            for (String command : lineProcessor.getCommands()) {
                // NOI18N
                freshCommands.add(new GrailsCommand(command, null, command));
            }
        }
    } catch (InterruptedException ex) {
        Thread.currentThread().interrupt();
    } catch (ExecutionException ex) {
        LOGGER.log(Level.INFO, null, ex);
    }
    synchronized (this) {
        if (buildConfigListener == null) {
            BuildConfig buildConfig = project.getBuildConfig();
            buildConfigListener = new BuildConfigListener();
            buildConfigListener.attachListeners(buildConfig);
            buildConfig.addPropertyChangeListener(WeakListeners.propertyChange(buildConfigListener, buildConfig));
        }
        if (projectConfigListener == null) {
            GrailsProjectConfig projectConfig = project.getLookup().lookup(GrailsProjectConfig.clreplaced);
            if (projectConfig != null) {
                projectConfigListener = new ProjectConfigListener();
                projectConfig.addPropertyChangeListener(WeakListeners.propertyChange(projectConfigListener, projectConfig));
            }
        }
        this.commands = freshCommands;
    }
}

19 Source : SourcePathImplementation.java
with Apache License 2.0
from apache

public static SourcePathImplementation forProject(GrailsProject project, SourceRoots sourceRoots) {
    GrailsProjectConfig config = GrailsProjectConfig.forProject(project);
    SourcePathImplementation impl = new SourcePathImplementation(sourceRoots);
    BuildConfig build = ((GrailsProject) config.getProject()).getBuildConfig();
    build.addPropertyChangeListener(WeakListeners.propertyChange(impl, config));
    return impl;
}

19 Source : ProjectClassPathImplementation.java
with Apache License 2.0
from apache

public static ProjectClreplacedPathImplementation forProject(Project project) {
    GrailsProjectConfig config = GrailsProjectConfig.forProject(project);
    ProjectClreplacedPathImplementation impl = new ProjectClreplacedPathImplementation(config);
    BuildConfig build = ((GrailsProject) config.getProject()).getBuildConfig();
    build.addPropertyChangeListener(WeakListeners.propertyChange(impl.buildConfigListener, build));
    config.addPropertyChangeListener(WeakListeners.propertyChange(impl.projectConfigListener, config));
    return impl;
}

19 Source : BootClassPathImplementation.java
with Apache License 2.0
from apache

public static BootClreplacedPathImplementation forProject(Project project) {
    GrailsProjectConfig config = GrailsProjectConfig.forProject(project);
    BootClreplacedPathImplementation impl = new BootClreplacedPathImplementation(config);
    config.addPropertyChangeListener(WeakListeners.propertyChange(impl.projectConfigListener, config));
    return impl;
}

18 Source : GrailsProjectProperties.java
with Apache License 2.0
from apache

/**
 * @author Petr Hejl
 */
public clreplaced GrailsProjectProperties {

    private final GrailsProject project;

    private final GrailsProjectConfig config;

    private ComboBoxModel environmentModel;

    private ComboBoxModel javaPlatformModel;

    private ButtonModel displayBrowserModel;

    private ListCellRenderer javaPlatformRenderer;

    private String port;

    private String debugBrowser;

    private String vmOptions;

    public GrailsProjectProperties(Project project) {
        replacedert project instanceof GrailsProject;
        this.project = (GrailsProject) project;
        this.config = GrailsProjectConfig.forProject(project);
    }

    public GrailsProject getProject() {
        return project;
    }

    public ComboBoxModel getEnvironmentModel() {
        if (environmentModel == null) {
            GrailsEnvironment[] envs = GrailsEnvironment.standardValues();
            Object[] values = new Object[envs.length];
            for (int i = 0; i < envs.length; i++) {
                values[i] = new Environmenreplacedem(envs[i]);
            }
            environmentModel = new DefaultComboBoxModel(values);
            GrailsEnvironment env = config.getEnvironment();
            if (env != null) {
                environmentModel.setSelectedItem(new Environmenreplacedem(env));
            }
        }
        return environmentModel;
    }

    public ComboBoxModel getJavaPlatformModel() {
        if (javaPlatformModel == null) {
            javaPlatformModel = PlatformUiSupport.createPlatformComboBoxModel(// NOI18N
            config.getJavaPlatform().getProperties().get("platform.ant.name"));
        }
        return javaPlatformModel;
    }

    public ButtonModel getDisplayBrowserModel() {
        if (displayBrowserModel == null) {
            displayBrowserModel = new JToggleButton.ToggleButtonModel();
            displayBrowserModel.setSelected(config.getDisplayBrowser());
        }
        return displayBrowserModel;
    }

    public ListCellRenderer getJavaPlatformRenderer() {
        if (javaPlatformRenderer == null) {
            javaPlatformRenderer = PlatformUiSupport.createPlatformListCellRenderer();
        }
        return javaPlatformRenderer;
    }

    public String getPort() {
        if (port == null) {
            port = config.getPort();
        }
        return port;
    }

    public void setPort(String port) {
        this.port = port;
    }

    public String getVmOptions() {
        if (vmOptions == null) {
            vmOptions = config.getVmOptions();
        }
        return vmOptions;
    }

    public void setVmOptions(String vmOptions) {
        this.vmOptions = vmOptions;
    }

    public String getDebugBrowser() {
        if (debugBrowser == null) {
            debugBrowser = config.getDebugBrowser();
        }
        return debugBrowser;
    }

    public void setDebugBrowser(String debugBrowser) {
        this.debugBrowser = debugBrowser;
    }

    public void save() {
        try {
            // store properties
            ProjectManager.mutex().writeAccess(new Mutex.ExceptionAction<Void>() {

                public Void run() throws IOException {
                    saveProperties();
                    return null;
                }
            });
            ProjectManager.getDefault().saveProject(project);
        } catch (MutexException e) {
            Exceptions.printStackTrace((IOException) e.getException());
        } catch (IOException ex) {
            Exceptions.printStackTrace(ex);
        }
    }

    private void saveProperties() throws IOException {
        if (debugBrowser != null) {
            config.setDebugBrowser(debugBrowser);
        }
        if (port != null) {
            config.setPort(port);
        }
        config.setVmOptions(vmOptions);
        Environmenreplacedem item = (Environmenreplacedem) getEnvironmentModel().getSelectedItem();
        if (item != null) {
            config.setEnvironment(item.getEnvironment());
        }
        Object platform = getJavaPlatformModel().getSelectedItem();
        if (platform != null) {
            config.setJavaPlatform(PlatformUiSupport.getPlatform(platform));
        }
        config.setDisplayBrowser(getDisplayBrowserModel().isSelected());
    }

    private static clreplaced Environmenreplacedem {

        private final GrailsEnvironment environment;

        public Environmenreplacedem(GrailsEnvironment environment) {
            this.environment = environment;
        }

        public GrailsEnvironment getEnvironment() {
            return environment;
        }

        @Override
        public String toString() {
            return NbBundle.getMessage(GeneralCustomizerPanel.clreplaced, "GeneralCustomizerPanel." + environment.toString());
        }

        @Override
        public boolean equals(Object obj) {
            if (obj == null) {
                return false;
            }
            if (getClreplaced() != obj.getClreplaced()) {
                return false;
            }
            final Environmenreplacedem other = (Environmenreplacedem) obj;
            if (this.environment != other.environment) {
                return false;
            }
            return true;
        }

        @Override
        public int hashCode() {
            int hash = 5;
            hash = 37 * hash + (this.environment != null ? this.environment.hashCode() : 0);
            return hash;
        }
    }
}

18 Source : GrailsPluginSupport.java
with Apache License 2.0
from apache

public FolderFilter getProjectPluginFilter() {
    GrailsProjectConfig projectConfig = project.getLookup().lookup(GrailsProjectConfig.clreplaced);
    if (projectConfig != null) {
        if (GrailsPlatform.Version.VERSION_1_1.compareTo(projectConfig.getGrailsPlatform().getVersion()) <= 0) {
            List<GrailsPlugin> plugins = loadInstalledPlugins11();
            final Set<String> pluginDirs = new HashSet<String>();
            for (GrailsPlugin plugin : plugins) {
                pluginDirs.add(plugin.getDirName());
            }
            return new FolderFilter() {

                @Override
                public boolean accept(String folderName) {
                    return pluginDirs.contains(folderName);
                }
            };
        }
    }
    return new FolderFilter() {

        @Override
        public boolean accept(String folderName) {
            return true;
        }
    };
}

18 Source : GrailsProject.java
with Apache License 2.0
from apache

@Override
public Lookup getLookup() {
    if (lookup == null) {
        GrailsProjectConfig config = new GrailsProjectConfig(this);
        config.initListeners();
        lookup = Lookups.fixed(// project spec requires a project be in its own lookup
        this, // allow outside code to mark the project as needing saving
        projectState, // Project information implementation
        new Info(), new GrailsActionProvider(this), GrailsSources.create(this), new GrailsServerState(this), new GrailsProjectCustomizerProvider(this), new GrailsProjectOperations(this), new GrailsProjectEncodingQueryImpl(), new OpenHook(), new AuxiliaryConfigurationImpl(), new RecommendedTemplatesImpl(), new GroovyExtenderImpl(), new ControllerCompletionProvider(), new DomainCompletionProvider(), // Logical view of project implementation
        logicalView, cpProvider, config, new GrailsDebugger(this));
    }
    return lookup;
}

18 Source : BuildConfig.java
with Apache License 2.0
from apache

private synchronized void loadProjectPluginsDirDefault() {
    if (GrailsPlatform.Version.VERSION_1_1.compareTo(GrailsProjectConfig.forProject(project).getGrailsPlatform().getVersion()) <= 0) {
        GrailsProjectConfig config = GrailsProjectConfig.forProject(project);
        File cached = config.getProjectPluginsDir();
        if (cached != null && isBuildConfigPresent()) {
            projectPluginsDir = FileUtil.normalizeFile(cached);
        } else {
            projectPluginsDir = getProjectPluginsDirDefault11();
        }
    } else {
        projectPluginsDir = getProjectPluginsDir10();
    }
}

18 Source : BuildConfig.java
with Apache License 2.0
from apache

private synchronized void loadGlobalPluginsDirDefault() {
    if (GrailsPlatform.Version.VERSION_1_1.compareTo(GrailsProjectConfig.forProject(project).getGrailsPlatform().getVersion()) <= 0) {
        GrailsProjectConfig config = GrailsProjectConfig.forProject(project);
        File cached = config.getGlobalPluginsDir();
        if (cached != null && isBuildConfigPresent()) {
            globalPluginsDir = FileUtil.normalizeFile(cached);
        } else {
            globalPluginsDir = getGlobalPluginsDirDefault11();
        }
    } else {
        globalPluginsDir = getGlobalPluginsDir10();
    }
}

18 Source : ProjectClassPathImplementation.java
with Apache License 2.0
from apache

final clreplaced ProjectClreplacedPathImplementation implements ClreplacedPathImplementation {

    private static final Logger LOGGER = Logger.getLogger(ProjectClreplacedPathImplementation.clreplaced.getName());

    private final PropertyChangeSupport support = new PropertyChangeSupport(this);

    private final ProjectConfigListener projectConfigListener = new ProjectConfigListener();

    private final BuildConfigListener buildConfigListener = new BuildConfigListener();

    private final GrailsProjectConfig projectConfig;

    private final File projectRoot;

    private final SourceCategoriesFactory sourceCategoriesFactory;

    private List<PathResourceImplementation> resources;

    private GrailsPlatform.Version version;

    private File pluginsDir;

    private File globalPluginsDir;

    private PluginsLibListener listenerPluginsLib;

    private ProjectClreplacedPathImplementation(GrailsProjectConfig projectConfig) {
        this.projectConfig = projectConfig;
        this.projectRoot = FileUtil.toFile(projectConfig.getProject().getProjectDirectory());
        this.version = projectConfig.getGrailsPlatform().getVersion();
        // TODO: would be nice to reuse the project source categories factory here:
        this.sourceCategoriesFactory = new SourceCategoriesFactory();
    }

    public static ProjectClreplacedPathImplementation forProject(Project project) {
        GrailsProjectConfig config = GrailsProjectConfig.forProject(project);
        ProjectClreplacedPathImplementation impl = new ProjectClreplacedPathImplementation(config);
        BuildConfig build = ((GrailsProject) config.getProject()).getBuildConfig();
        build.addPropertyChangeListener(WeakListeners.propertyChange(impl.buildConfigListener, build));
        config.addPropertyChangeListener(WeakListeners.propertyChange(impl.projectConfigListener, config));
        return impl;
    }

    @Override
    public synchronized List<PathResourceImplementation> getResources() {
        if (this.resources == null) {
            this.resources = this.getPath();
        }
        return this.resources;
    }

    private List<PathResourceImplementation> getPath() {
        replacedert Thread.holdsLock(this);
        BuildConfig buildConfig = ((GrailsProject) projectConfig.getProject()).getBuildConfig();
        List<PathResourceImplementation> result = new ArrayList<>();
        // lib directory from project root
        addLibs(projectRoot, result);
        // compile dependencies
        List<File> compileDeps = buildConfig.getCompileDependencies();
        addJars(compileDeps.toArray(new File[compileDeps.size()]), result, false);
        // FIXME move this to plugin specific support
        // http://grails.org/GWT+Plugin
        GrailsPluginSupport pluginSupport = GrailsPluginSupport.forProject(projectConfig.getProject());
        if (pluginSupport != null && pluginSupport.usesPlugin("gwt")) {
            // NOI18N
            // NOI18N
            File gwtDir = new File(new File(projectRoot, sourceCategoriesFactory.getSourceCategory(SourceCategoryType.LIB).getRelativePath()), "gwt");
            if (gwtDir.exists() && gwtDir.isDirectory()) {
                addJars(gwtDir, result, false);
            }
        }
        // FIXME move this to plugin specific support
        // http://grails.org/plugin/app-engine
        if (pluginSupport != null && pluginSupport.usesPlugin("app-engine")) {
            // NOI18N
            // FIXME BuilConfig defined value
            // NOI18N
            String value = System.getenv("APPENGINE_HOME");
            if (value != null) {
                // NOI18N
                File appEngineLib = new File(new File(value), "lib");
                // http://code.google.com/intl/cs/appengine/docs/java/tools/ant.html - clreplacedpath
                // NOI18N
                File lib = new File(appEngineLib, "shared");
                if (lib.exists() && lib.isDirectory()) {
                    addJars(lib, result, true);
                }
                // not sure about this
                // NOI18N
                lib = new File(appEngineLib, "user");
                if (lib.exists() && lib.isDirectory()) {
                    addJars(lib, result, true);
                }
            }
        }
        // in-place plugins
        List<GrailsPlugin> localPlugins = buildConfig.getLocalPlugins();
        for (GrailsPlugin plugin : localPlugins) {
            if (plugin.getPath() != null) {
                addLibs(plugin.getPath(), result);
            }
        }
        // TODO listeners ?
        // project plugins
        File oldPluginsDir = pluginsDir;
        File currentPluginsDir = buildConfig.getProjectPluginsDir();
        if (pluginsDir == null || !pluginsDir.equals(currentPluginsDir)) {
            LOGGER.log(Level.FINE, "Project plugins dir changed from {0} to {1}", new Object[] { pluginsDir, currentPluginsDir });
            this.pluginsDir = currentPluginsDir;
        }
        if (pluginSupport != null && pluginsDir.isDirectory()) {
            addPlugins(pluginsDir, result, pluginSupport.getProjectPluginFilter());
        }
        // global plugins
        // TODO philosophical question: Is the global plugin boot or compile clreplacedpath?
        File oldGlobalPluginsDir = globalPluginsDir;
        File currentGlobalPluginsDir = buildConfig.getGlobalPluginsDir();
        if (globalPluginsDir == null || !globalPluginsDir.equals(currentGlobalPluginsDir)) {
            LOGGER.log(Level.FINE, "Project plugins dir changed from {0} to {1}", new Object[] { pluginsDir, currentPluginsDir });
            this.globalPluginsDir = currentGlobalPluginsDir;
        }
        if (globalPluginsDir != null && globalPluginsDir.isDirectory()) {
            addPlugins(globalPluginsDir, result, null);
        }
        // Adding jars from Ivy cache - hopefully it won't hurt start-up performance
        addJars(buildConfig.getIvyCacheDir(), result, true);
        if (listenerPluginsLib == null) {
            // NOI18N
            File libDir = FileUtil.normalizeFile(new File(projectRoot, "lib"));
            listenerPluginsLib = new PluginsLibListener(this);
            FileUtil.addFileChangeListener(listenerPluginsLib, libDir);
        }
        // project plugins listener
        updateListener(listenerPluginsLib, oldPluginsDir, currentPluginsDir);
        // global plugins listener
        updateListener(listenerPluginsLib, oldGlobalPluginsDir, currentGlobalPluginsDir);
        return Collections.unmodifiableList(result);
    }

    private void updateListener(FileChangeListener listener, File oldDir, File newDir) {
        if (oldDir == null || !oldDir.equals(newDir)) {
            if (oldDir != null) {
                FileUtil.removeFileChangeListener(listener, oldDir);
            }
            if (newDir != null) {
                FileUtil.addFileChangeListener(listener, newDir);
            }
        }
    }

    private void addPlugins(File dir, List<PathResourceImplementation> result, GrailsPluginSupport.FolderFilter filter) {
        for (String name : dir.list()) {
            File file = new File(dir, name);
            if (file.isDirectory() && (filter == null || filter.accept(name))) {
                // lib directories of installed plugins
                addLibs(file, result);
            }
        }
    }

    private void addLibs(File root, List<PathResourceImplementation> result) {
        if (!root.exists() || !root.isDirectory()) {
            return;
        }
        File libDir = new File(root, sourceCategoriesFactory.getSourceCategory(SourceCategoryType.LIB).getRelativePath());
        if (!libDir.exists() || !libDir.isDirectory()) {
            return;
        }
        addJars(libDir, result, false);
    }

    private static void addJars(File dir, List<PathResourceImplementation> result, boolean recurse) {
        addJars(dir.listFiles(), result, recurse);
    }

    private static void addJars(File[] jars, List<PathResourceImplementation> result, boolean recurse) {
        if (jars != null) {
            for (File f : jars) {
                try {
                    if (f.isFile()) {
                        URL entry = Utilities.toURI(f).normalize().toURL();
                        if (FileUtil.isArchiveFile(entry)) {
                            entry = FileUtil.getArchiveRoot(entry);
                            result.add(ClreplacedPathSupport.createResource(entry));
                        }
                    } else if (recurse && f.isDirectory()) {
                        addJars(f, result, recurse);
                    }
                } catch (MalformedURLException mue) {
                    replacedert false : mue;
                }
            }
        }
    }

    @Override
    public void addPropertyChangeListener(PropertyChangeListener listener) {
        support.addPropertyChangeListener(listener);
    }

    @Override
    public void removePropertyChangeListener(PropertyChangeListener listener) {
        support.removePropertyChangeListener(listener);
    }

    private clreplaced ProjectConfigListener implements PropertyChangeListener {

        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            if (GrailsProjectConfig.GRAILS_PLATFORM_PROPERTY.equals(evt.getPropertyName())) {
                GrailsPlatform platform = ((GrailsProjectConfig) evt.getSource()).getGrailsPlatform();
                GrailsPlatform.Version currentVersion = platform.getVersion();
                if ((// 1.1 or above
                GrailsPlatform.Version.VERSION_1_1.compareTo(currentVersion) <= 0 && // lower than 1.1
                GrailsPlatform.Version.VERSION_1_1.compareTo(version) > 0) || (// lower than 1.1
                GrailsPlatform.Version.VERSION_1_1.compareTo(currentVersion) > 0 && GrailsPlatform.Version.VERSION_1_1.compareTo(version) <= 0)) {
                    // 1.1 or above
                    LOGGER.log(Level.INFO, "Project clreplacedpath changed due to change in {0}", evt.getPropertyName());
                    synchronized (ProjectClreplacedPathImplementation.this) {
                        resources = null;
                    }
                    support.firePropertyChange(ClreplacedPathImplementation.PROP_RESOURCES, null, null);
                }
                version = currentVersion;
            }
        }
    }

    private clreplaced BuildConfigListener implements PropertyChangeListener {

        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            if (BuildConfig.BUILD_CONFIG_PLUGINS.equals(evt.getPropertyName())) {
                LOGGER.log(Level.INFO, "Project clreplacedpath changed due to change in {0}", evt.getPropertyName());
                synchronized (ProjectClreplacedPathImplementation.this) {
                    resources = null;
                }
                support.firePropertyChange(ClreplacedPathImplementation.PROP_RESOURCES, null, null);
            }
        }
    }

    private static clreplaced PluginsLibListener implements FileChangeListener {

        private final ProjectClreplacedPathImplementation impl;

        public PluginsLibListener(ProjectClreplacedPathImplementation impl) {
            this.impl = impl;
        }

        @Override
        public void fileAttributeChanged(FileAttributeEvent fe) {
        }

        @Override
        public void fileChanged(FileEvent fe) {
            fireChange();
        }

        @Override
        public void fileDataCreated(FileEvent fe) {
            fireChange();
        }

        @Override
        public void fileDeleted(FileEvent fe) {
            fireChange();
        }

        @Override
        public void fileFolderCreated(FileEvent fe) {
            fireChange();
        }

        @Override
        public void fileRenamed(FileRenameEvent fe) {
            fireChange();
        }

        private void fireChange() {
            synchronized (impl) {
                impl.resources = null;
            }
            impl.support.firePropertyChange(ClreplacedPathImplementation.PROP_RESOURCES, null, null);
        }
    }
}

18 Source : BootClassPathImplementation.java
with Apache License 2.0
from apache

final clreplaced BootClreplacedPathImplementation implements ClreplacedPathImplementation {

    private static final Logger LOGGER = Logger.getLogger(BootClreplacedPathImplementation.clreplaced.getName());

    private final PropertyChangeSupport support = new PropertyChangeSupport(this);

    private final ProjectConfigListener projectConfigListener = new ProjectConfigListener();

    private final GrailsProjectConfig config;

    private List<PathResourceImplementation> resourcesCache;

    private long eventId;

    private BootClreplacedPathImplementation(GrailsProjectConfig config) {
        this.config = config;
    }

    public static BootClreplacedPathImplementation forProject(Project project) {
        GrailsProjectConfig config = GrailsProjectConfig.forProject(project);
        BootClreplacedPathImplementation impl = new BootClreplacedPathImplementation(config);
        config.addPropertyChangeListener(WeakListeners.propertyChange(impl.projectConfigListener, config));
        return impl;
    }

    public List<PathResourceImplementation> getResources() {
        long currentId;
        synchronized (this) {
            if (resourcesCache != null) {
                return resourcesCache;
            }
            currentId = eventId;
        }
        JavaPlatform jp = config.getJavaPlatform();
        final List<PathResourceImplementation> result = new ArrayList<PathResourceImplementation>();
        if (jp != null) {
            // TODO: May also listen on CP, but from Platform it should be fixed.
            final ClreplacedPath cp = jp.getBootstrapLibraries();
            replacedert cp != null : jp;
            for (ClreplacedPath.Entry entry : cp.entries()) {
                result.add(ClreplacedPathSupport.createResource(entry.getURL()));
            }
        }
        GrailsPlatform gp = config.getGrailsPlatform();
        if (gp != null) {
            final ClreplacedPath cp = gp.getClreplacedPath();
            replacedert cp != null : gp;
            for (ClreplacedPath.Entry entry : cp.entries()) {
                result.add(ClreplacedPathSupport.createResource(entry.getURL()));
            }
        }
        synchronized (this) {
            if (currentId == eventId) {
                if (resourcesCache == null) {
                    resourcesCache = Collections.unmodifiableList(result);
                }
                return resourcesCache;
            }
            return Collections.unmodifiableList(result);
        }
    }

    public void addPropertyChangeListener(PropertyChangeListener listener) {
        this.support.addPropertyChangeListener(listener);
    }

    public void removePropertyChangeListener(PropertyChangeListener listener) {
        this.support.removePropertyChangeListener(listener);
    }

    private clreplaced ProjectConfigListener implements PropertyChangeListener {

        public void propertyChange(PropertyChangeEvent evt) {
            if (GrailsProjectConfig.GRAILS_JAVA_PLATFORM_PROPERTY.equals(evt.getPropertyName()) || GrailsProjectConfig.GRAILS_PLATFORM_PROPERTY.equals(evt.getPropertyName())) {
                LOGGER.log(Level.FINE, "Boot clreplacedpath changed due to change in {0}", evt.getPropertyName());
                synchronized (BootClreplacedPathImplementation.this) {
                    resourcesCache = null;
                    eventId++;
                }
                support.firePropertyChange(ClreplacedPathImplementation.PROP_RESOURCES, null, null);
            }
        }
    }
}

17 Source : BuildConfig.java
with Apache License 2.0
from apache

private File getGlobalPluginsDir11() {
    replacedert Thread.holdsLock(this);
    try {
        if (buildSettingsInstance != null) {
            Method getGlobalPluginsDirMethod = // NOI18N
            buildSettingsInstance.getClreplaced().getMethod(// NOI18N
            "getGlobalPluginsDir", new Clreplaced[] {});
            Object value = getGlobalPluginsDirMethod.invoke(buildSettingsInstance, new Object[] {});
            if (value instanceof File) {
                File file = (File) value;
                if (!file.isAbsolute()) {
                    file = new File(projectRoot, file.getPath());
                }
                return FileUtil.normalizeFile(file);
            }
        }
    } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException ex) {
        LOGGER.log(Level.FINE, null, ex);
    }
    GrailsProjectConfig config = GrailsProjectConfig.forProject(project);
    GrailsPlatform platform = config.getGrailsPlatform();
    if (platform.isConfigured()) {
        return FileUtil.normalizeFile(new File(System.getProperty("user.home"), // NOI18N
        ".grails" + File.separator + config.getGrailsPlatform().getVersion().toString() + File.separator + // NOI18N
        "global-plugins"));
    }
    return null;
}

17 Source : BuildConfig.java
with Apache License 2.0
from apache

private File getProjectPluginsDir11() {
    replacedert Thread.holdsLock(this);
    try {
        if (buildSettingsInstance != null) {
            Method getProjectPluginsDirMethod = // NOI18N
            buildSettingsInstance.getClreplaced().getMethod(// NOI18N
            "getProjectPluginsDir", new Clreplaced[] {});
            Object value = getProjectPluginsDirMethod.invoke(buildSettingsInstance, new Object[] {});
            if (value instanceof File) {
                File file = (File) value;
                if (!file.isAbsolute()) {
                    file = new File(projectRoot, file.getPath());
                }
                return FileUtil.normalizeFile(file);
            }
        }
    } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException ex) {
        LOGGER.log(Level.FINE, null, ex);
    }
    GrailsProjectConfig config = GrailsProjectConfig.forProject(project);
    GrailsPlatform platform = config.getGrailsPlatform();
    if (platform.isConfigured()) {
        return FileUtil.normalizeFile(new File(System.getProperty("user.home"), // NOI18N
        ".grails" + File.separator + config.getGrailsPlatform().getVersion().toString() + File.separator + "projects" + File.separator + projectRoot.getName() + File.separator + // NOI18N
        "plugins"));
    }
    return null;
}

15 Source : BuildConfig.java
with Apache License 2.0
from apache

private synchronized void loadLocalPluginsDefault() {
    if (GrailsPlatform.Version.VERSION_1_1.compareTo(GrailsProjectConfig.forProject(project).getGrailsPlatform().getVersion()) <= 0) {
        GrailsProjectConfig config = GrailsProjectConfig.forProject(project);
        Map<String, File> cached = config.getLocalPlugins();
        if (cached != null && isBuildConfigPresent()) {
            localPlugins = new ArrayList<>();
            for (Map.Entry<String, File> entry : cached.entrySet()) {
                localPlugins.add(new GrailsPlugin(entry.getKey(), null, null, entry.getValue()));
            }
        } else {
            localPlugins = Collections.emptyList();
        }
    } else {
        localPlugins = Collections.emptyList();
    }
}

11 Source : BuildConfig.java
with Apache License 2.0
from apache

public void reload() {
    long start = System.currentTimeMillis();
    File currentProjectPluginsDir;
    File currentGlobalPluginsDir;
    List<GrailsPlugin> currentLocalPlugins;
    synchronized (this) {
        File newProjectRoot = FileUtil.toFile(project.getProjectDirectory());
        replacedert newProjectRoot != null;
        if (!newProjectRoot.equals(projectRoot)) {
            projectRoot = newProjectRoot;
        }
        buildSettingsInstance = loadBuildSettings();
        LOGGER.log(Level.FINE, "Took {0} ms to load BuildSettings for {1}", new Object[] { (System.currentTimeMillis() - start), project.getProjectDirectory().getNameExt() });
        currentLocalPlugins = loadLocalPlugins();
        currentProjectPluginsDir = loadProjectPluginsDir();
        currentGlobalPluginsDir = loadGlobalPluginsDir();
    }
    if (GrailsPlatform.Version.VERSION_1_1.compareTo(GrailsProjectConfig.forProject(project).getGrailsPlatform().getVersion()) <= 0) {
        GrailsProjectConfig config = project.getLookup().lookup(GrailsProjectConfig.clreplaced);
        if (config != null) {
            ProjectConfigListener listener = new ProjectConfigListener();
            config.addPropertyChangeListener(listener);
            try {
                config.setProjectPluginsDir(FileUtil.normalizeFile(currentProjectPluginsDir));
                config.setGlobalPluginsDir(FileUtil.normalizeFile(currentGlobalPluginsDir));
                Map<String, File> prepared = new HashMap<>();
                for (GrailsPlugin plugin : currentLocalPlugins) {
                    prepared.put(plugin.getName(), plugin.getPath());
                }
                config.setLocalPlugins(prepared);
            } finally {
                config.removePropertyChangeListener(listener);
            }
            if (listener.isChanged()) {
                propertySupport.firePropertyChange(BUILD_CONFIG_PLUGINS, null, null);
            }
        }
    }
}