IntelliJ Plugin-Gradle 配置

柯良骏
2023-12-01

Step 1: 使用Gradle构建IntelliJ plugin工程。

Step 2: 调整配置信息:

//plugins {
//    id 'java'
//    id 'org.jetbrains.intellij' version '0.4.8'
//}
//
//group 'xxx'
//version '1.0-SNAPSHOT'
//
//sourceCompatibility = 1.8
//
//intellij {
//    sandboxDirectory = "$project.buildDir/xxx"
//}
//
//repositories {
//    mavenCentral()
//}
//
//
//apply plugin: 'idea'
//apply plugin: 'org.jetbrains.intellij'
//apply plugin: 'java'
//
//intellij {
//    version 'IC-2016.3' //IntelliJ IDEA 2016.3 dependency; for a full list of IntelliJ IDEA releases please see https://www.jetbrains.com/intellij-repository/releases
//    plugins 'coverage' //Bundled plugin dependencies
//    pluginName 'unittest_bot'
//}
//
//dependencies {
//    testCompile group: 'junit', name: 'junit', version: '4.12'
    classpath "org.jetbrains.intellij.plugins:gradle-intellij-plugin:0.5.0-SNAPSHOT"
//}
//
 See https://github.com/JetBrains/gradle-intellij-plugin/
//intellij {
//    version '2019.1.1'
//}
//patchPluginXml {
//    changeNotes """
//      Add change notes here.<br>
//      <em>most HTML tags may be used</em>"""
//}

//buildscript {
//    repositories {
//        mavenCentral()
//    }
//}
buildscript {
    //仓库地址配置
    repositories {
        mavenCentral()
        maven {
            url "https://oss.sonatype.org/content/repositories/snapshots/"
        }
        maven {
            url 'http://dl.bintray.com/jetbrains/intellij-plugin-service'
        }
//        maven {
//            url 'http://repo1.maven.org/maven2/org/json/'
//        }
    }
    dependencies {
//        classpath "org.jetbrains.intellij.plugins:gradle-intellij-plugin:0.5.0-SNAPSHOT"
//        compile fileTree(dir: 'libs', include: '*.jar')
    }
}

plugins {
    id 'java'
    id "org.jetbrains.intellij" version "0.4.8"
}

apply plugin: 'idea'
apply plugin: 'org.jetbrains.intellij'
apply plugin: 'java'

repositories {
    mavenCentral()
}

dependencies {
    // Your might already have other librarires/dependencies here you should leave them
    compile fileTree(dir: 'libs', include: '*.jar')
    compile 'org.json:json:20171018'
}

intellij {
    version 'IC-2016.3' //IntelliJ IDEA 2016.3 dependency; for a full list of IntelliJ IDEA releases please see https://www.jetbrains.com/intellij-repository/releases
    plugins 'coverage' //Bundled plugin dependencies
    pluginName 'XXX'
}
intellij {
    sandboxDirectory = "$project.buildDir/your plugin"
}
intellij {
    version '2019.1.1'
}
//group 'org.jetbrains'
//version '1.2' // Plugin version

publishPlugin {
    username intellijPublishUsername
    password intellijPublishPassword
}

group 'XXX'
version '1.0-SNAPSHOT'

step 3 : 修改plugin.xml

step 4: build plugin.

 

关于依赖项:

对于本地依赖,可以在plugin根目录下libs文件夹下添加,build时会整体打包。

对于外部依赖,需要手动添加依赖版本。

dependencies {
    // Your might already have other librarires/dependencies here you should leave them
    compile fileTree(dir: 'libs', include: '*.jar')
    compile 'org.json:json:20171018'
}

编译后,打包的plugin位置为:build/distributions

 

转载于:https://my.oschina.net/slightScenery/blog/3053654

 类似资料: