Skip to content

Commit

Permalink
Turn 'ide' into pre-compiled script plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
jjohannes committed Jul 2, 2020
1 parent 6bba629 commit 79f2c79
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 64 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ dependencies {
constraints {
// Gradle Plugins
api("com.gradle.publish:plugin-publish-plugin:0.11.0")
api("gradle.plugin.org.jetbrains.gradle.plugin.idea-ext:gradle-idea-ext:0.7")
api("me.champeau.gradle:japicmp-gradle-plugin:0.2.9")
api("org.gradle:test-retry-gradle-plugin:1.1.6")
api("org.gradle.kotlin:gradle-kotlin-dsl-conventions:0.5.0")
Expand Down
11 changes: 1 addition & 10 deletions buildSrc/subprojects/ide/ide.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,14 +1,5 @@
dependencies {
implementation(project(":basics"))

implementation("gradle.plugin.org.jetbrains.gradle.plugin.idea-ext:gradle-idea-ext:0.7")
}

gradlePlugin {
plugins {
register("ide") {
id = "gradlebuild.ide"
implementationClass = "org.gradle.gradlebuild.ide.IdePlugin"
}
}
implementation("gradle.plugin.org.jetbrains.gradle.plugin.idea-ext:gradle-idea-ext")
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,17 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.gradle.gradlebuild.ide

import org.gradle.api.NamedDomainObjectContainer
import org.gradle.api.Plugin
import org.gradle.api.PolymorphicDomainObjectContainer
import org.gradle.api.Project
import org.gradle.api.plugins.ExtensionAware
import org.gradle.kotlin.dsl.*
import org.gradle.plugins.ide.idea.model.IdeaModel
package gradlebuild

import org.gradle.plugins.ide.idea.model.IdeaProject
import org.jetbrains.gradle.ext.CopyrightConfiguration
import org.jetbrains.gradle.ext.ProjectSettings
import org.jetbrains.gradle.ext.Remote
import org.jetbrains.gradle.ext.RunConfiguration

plugins {
id("org.jetbrains.gradle.plugin.idea-ext")
}

object GradleCopyright {
const val profileName = "ASL2"
Expand All @@ -48,62 +44,45 @@ See the License for the specific language governing permissions and
limitations under the License."""
}

tasks.idea.configure {
doFirst { throw RuntimeException("To import in IntelliJ, please follow the instructions here: https://github.com/gradle/gradle/blob/master/CONTRIBUTING.md#intellij") }
}

open class IdePlugin : Plugin<Project> {

override fun apply(project: Project): Unit = project.run {
configureIdeaForRootProject()
idea {
module {
excludeDirs = setOf(layout.projectDirectory.file("intTestHomeDir").asFile)
}

private
fun Project.configureIdeaForRootProject() {
apply(plugin = "org.jetbrains.gradle.plugin.idea-ext")
tasks.named("idea") {
doFirst { throw RuntimeException("To import in IntelliJ, please follow the instructions here: https://github.com/gradle/gradle/blob/master/CONTRIBUTING.md#intellij") }
}
with(the<IdeaModel>()) {
module {
excludeDirs = setOf(intTestHomeDir)
}
project {
settings {
configureCopyright()
configureRunConfigurations()
doNotDetectFrameworks("android", "web")
}
}
project {
settings {
configureCopyright()
configureRunConfigurations()
doNotDetectFrameworks("android", "web")
}
}
}

private
fun ProjectSettings.configureCopyright() {
copyright {
useDefault = GradleCopyright.profileName
profiles {
create(GradleCopyright.profileName) {
notice = GradleCopyright.notice
keyword = GradleCopyright.keyword
}
fun ProjectSettings.configureCopyright() {
copyright {
useDefault = GradleCopyright.profileName
profiles {
create(GradleCopyright.profileName) {
notice = GradleCopyright.notice
keyword = GradleCopyright.keyword
}
}
}
}

private
fun ProjectSettings.configureRunConfigurations() {
runConfigurations {
create<Remote>("Remote debug port 5005") {
mode = Remote.RemoteMode.ATTACH
transport = Remote.RemoteTransport.SOCKET
sharedMemoryAddress = "javadebug"
host = "localhost"
port = 5005
}
fun ProjectSettings.configureRunConfigurations() {
runConfigurations {
create<Remote>("Remote debug port 5005") {
mode = Remote.RemoteMode.ATTACH
transport = Remote.RemoteTransport.SOCKET
sharedMemoryAddress = "javadebug"
host = "localhost"
port = 5005
}
}

private
val Project.intTestHomeDir
get() = file("intTestHomeDir")
}


Expand Down

0 comments on commit 79f2c79

Please sign in to comment.