我正在按照本教程构建语言服务器 https://www.eclipse.org/community/eclipse_newsletter/2017/may/article5.php
但是,当我尝试构建shadowJar时,却不断出现此错误:
D:\leaf\org.xtext.example.mydsl1.parent>gradle shadowJar
FAILURE: Build failed with an exception.
* Where:
Build file 'D:\leaf\org.xtext.example.mydsl1.parent\build.gradle' line: 25
* What went wrong:
A problem occurred evaluating root project 'org.xtext.example.mydsl1.parent'.
> Plugin with id 'org.xtext.xtend' not found.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 0s
下面是我的父脚本的build.gradle文件
buildscript {
repositories {
jcenter()
}
plugins {
id "org.xtext.xtend" version "2.0.1"
}
repositories {
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath 'com.github.jengelman.gradle.plugins:shadow:1.2.4'
classpath "org.xtext:xtext-gradle-plugin:2.0.1"
}
}
subprojects {
ext.xtextVersion = '2.16.0-SNAPSHOT'
repositories {
jcenter()
maven {
url 'https://oss.sonatype.org/content/repositories/snapshots'
}
}
apply plugin: 'java'
apply plugin: 'org.xtext.xtend'
apply plugin: 'com.github.johnrengelman.shadow'
apply from: "${rootDir}/gradle/source-layout.gradle"
apply from: "${rootDir}/gradle/maven-deployment.gradle"
apply plugin: 'eclipse'
group = 'org.xtext.example.mydsl1'
version = '1.0.0-SNAPSHOT'
sourceCompatibility = '1.8'
targetCompatibility = '1.8'
configurations.all {
exclude group: 'asm'
}
}
答案 0 :(得分:0)
我再次创建了项目,并使用了向导创建的代码。我将语言服务器的构建类型选择为“胖罐”,因为我的目标是创建一个。除此之外,我在自动生成的代码中添加了教程中给出的基本名称,分类器和版本。 Shadowjar(位于.ide文件夹的build.gradle文件中)是我更改的代码的唯一部分。因此,我的shadowjar代码如下所示:
shadowJar {
baseName = 'dsl-language-server'
classifier = null
version = null
from(project.convention.getPlugin(JavaPluginConvention).sourceSets.main.output)
configurations = [project.configurations.runtime]
exclude('META-INF/INDEX.LIST', 'META-INF/*.SF', 'META-INF/*.DSA', 'META-INF/*.RSA','schema/*',
'.options', '.api_description', '*.profile', '*.html', 'about.*', 'about_files/*',
'plugin.xml', 'modeling32.png', 'systembundle.properties', 'profile.list')
classifier = 'ls'
append('plugin.properties')
}
然后,我通过Windows PowerShell导航到项目的父文件夹,并使用“ gradle shadowjar”命令对其进行了构建。它建造得很好! 可以在.ide目录下的/ build / libs /中找到生成的jar文件。