Skip to content
This repository has been archived by the owner on Oct 26, 2022. It is now read-only.

Commit

Permalink
Added GwtIdeaPlugin class
Browse files Browse the repository at this point in the history
  • Loading branch information
Turbo87 authored and steffenschaefer committed Jun 2, 2015
1 parent 0173530 commit 21a3a3b
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import org.gradle.api.tasks.SourceSet;
import org.gradle.api.tasks.testing.Test;
import org.gradle.plugins.ide.eclipse.EclipsePlugin;
import org.gradle.plugins.ide.idea.IdeaPlugin;

public class GwtBasePlugin implements Plugin<Project> {
public static final String GWT_TASK_GROUP = "GWT";
Expand Down Expand Up @@ -159,6 +160,14 @@ public void execute(EclipsePlugin eclipsePlugin) {
new GwtEclipsePlugin().apply(project, GwtBasePlugin.this);
}
});

project.getPlugins().withType(IdeaPlugin.class,
new Action<IdeaPlugin>() {
@Override
public void execute(IdeaPlugin ideaPlugin) {
new GwtIdeaPlugin().apply(project, GwtBasePlugin.this);
}
});
}

private String gwtDependency(final String artifactId, final String gwtVersion) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/**
* Copyright (C) 2013 Steffen Schaefer
*
* 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 de.richsource.gradle.plugins.gwt;

import org.gradle.api.Action;
import org.gradle.api.Project;
import org.gradle.api.artifacts.Configuration;
import org.gradle.api.logging.Logger;
import org.gradle.api.logging.Logging;
import org.gradle.plugins.ide.eclipse.EclipsePlugin;
import org.gradle.plugins.ide.eclipse.model.EclipseModel;
import org.gradle.plugins.ide.idea.IdeaPlugin;
import org.gradle.plugins.ide.idea.model.IdeaModel;

import java.util.Collection;

/**
* This "plugin" improves the IntelliJ IDEA integration by adding
* the gwt dependencies to the project.
*
* idea {
* module {
* scopes.PROVIDED.plus += configurations.gwtSdk
* scopes.PROVIDED.plus += configurations.gwt
* }
* }
*/
public class GwtIdeaPlugin {

private static final String SCOPE_PROVIDED = "PROVIDED";
private static final String KEY_PLUS = "plus";

public void apply(final Project project, final GwtBasePlugin gwtBasePlugin) {
project.getPlugins().apply(IdeaPlugin.class);

project.afterEvaluate(new Action<Project>() {
@Override
public void execute(final Project project) {
IdeaModel ideaModel = project.getExtensions().getByType(IdeaModel.class);
Collection<Configuration> configurations =
ideaModel.getModule().getScopes().get(SCOPE_PROVIDED).get(KEY_PLUS);

Configuration gwtSdkConfiguration = gwtBasePlugin.getGwtSdkConfiguration();
Configuration gwtConfiguration = gwtBasePlugin.getGwtConfiguration();

configurations.add(gwtSdkConfiguration);
configurations.add(gwtConfiguration);
}
});
}
}

0 comments on commit 21a3a3b

Please sign in to comment.