我正在将 Eclipse 中的 Java(EJB 项目)和动态 Web 项目迁移到 Gradle。我正在使用 Buildship。我的项目有一个 Eclipse 库配置,维护起来很痛苦。有了等级,这很棒,因为我只是将那些“依赖项”添加到 build.gradle 文件......等等。你知道的。没关系。
我的问题是我是否可以使用 Gradle 中的 Eclipse 插件来重新配置 Eclipse 中项目的构建路径并删除旧的 Eclipse 库并让 Eclipse 中的项目基于 Gradle 下载的相同 jar 作为依赖项构建,所以如果我更改其中一个依赖项的版本,Eclipse 编译器还将基于该新的 jar 依赖项编译代码。谢谢。
我编辑添加文件:
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>ElizaTourismEJB</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.wst.common.project.facet.core.builder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.jboss.tools.jst.web.kb.kbbuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.jboss.tools.cdi.core.cdibuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.wst.validation.validationbuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.hibernate.eclipse.console.hibernateBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.buildship.core.gradleprojectbuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jem.workbench.JavaEMFNature</nature>
<nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>
<nature>org.eclipse.wst.common.project.facet.core.nature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.jboss.tools.jst.web.kb.kbnature</nature>
<nature>org.jboss.tools.cdi.core.cdinature</nature>
<nature>org.hibernate.eclipse.console.hibernateNature</nature>
<nature>org.eclipse.buildship.core.gradleprojectnature</nature>
</natures>
</projectDescription>
.类路径:
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src/main/java">
<attributes>
<attribute name="FROM_GRADLE_MODEL" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" path="src/test/java">
<attributes>
<attribute name="FROM_GRADLE_MODEL" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8/"/>
<classpathentry kind="con" path="org.eclipse.buildship.core.gradleclasspathcontainer">
<attributes>
<attribute name="org.eclipse.jst.component.nondependency" value=""/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.module.container"/>
<classpathentry kind="con" path="org.eclipse.jdt.USER_LIBRARY/Jackson2"/>
<classpathentry kind="lib" path="commons-collections4-4.1.jar"/>
<classpathentry kind="lib" path="/ElizaTourismREST/WebContent/WEB-INF/lib/freemarker.jar"/>
<classpathentry kind="con" path="org.eclipse.jdt.USER_LIBRARY/Redis"/>
<classpathentry kind="con" path="org.eclipse.jst.server.core.container/com.ibm.ws.st.core.runtimeClasspathProvider/WebSphere Application Server Liberty Profile 16003">
<attributes>
<attribute name="owner.project.facets" value="jst.ejb;jpt.jpa"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="/Developer/java-lib/aspirin-0.11.01.jar"/>
<classpathentry kind="src" path=".apt_generated">
<attributes>
<attribute name="optional" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/bin"/>
</classpath>
构建.gradle:
apply plugin: 'java'
apply plugin: 'eclipse'
sourceCompatibility = 1.8
targetCompatibility = 1.8
repositories {
jcenter()
mavenCentral()
}
ext {
swagger_annotations_version = "1.5.9"
}
dependencies {
compile 'org.slf4j:slf4j-api:1.7.21'
testCompile 'junit:junit:4.12'
compile group: 'javax', name: 'javaee-api', version:'7.0'
compile "io.swagger:swagger-annotations:$swagger_annotations_version"
compile group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.5.4'
compile group: 'com.fasterxml.jackson.module', name: 'jackson-module-jaxb-annotations', version: '2.5.4'
compile group: 'biz.paluch.redis', name: 'lettuce', version: '4.3.0.Final'
compile group: 'org.masukomi', name: 'aspirin', version: '0.11.01'
compile group: 'org.freemarker', name: 'freemarker', version: '2.3.23'
}