当前位置: 首页 > 知识库问答 >
问题:

Eclipse WTP+Gradle Buildship未部署所有项目依赖项

艾才良
2023-03-14
    null

hibernate等的所有其他依赖项似乎都正确地部署到上面的相同dir中。

当我将eclipse更改为使用BuildShip时,这个问题就被打破了。以前我使用过Eclipse STS(Spring)插件,它工作得很好。

以下是web项目(WebApp)build.gradle:

apply plugin: 'war'
apply plugin: 'eclipse-wtp'

dependencies {
    compile project(":Common")
    compile project(":Model")
    compile project(":CommonServer")
    compile project(":CaBridge")
    ...
}

eclipse {
    wtp {
        component {
            // Configure the <Context path="..."/> in server.xml
            contextPath = '/console'

            // dependencies to mark as deployable with lib folder deploy path
            libConfigurations += [ project(":MagniCompCommon").configurations.runtime ]
        }
    }
}
apply plugin: 'eclipse-wtp'

dependencies {
    compile project(":MagniCompCommon")
}

以下是用于Common(未部署)的build.gradle:

apply plugin: 'eclipse-wtp'

dependencies {
    //compile project(":MagniCompCommon")
    compile project(":Model")

    compile("org.glassfish.jersey.containers:jersey-container-servlet:$jerseyGlassfishVersion")
    // Required for JAX-RS Client
    compile("org.glassfish.jersey.core:jersey-client:$jerseyGlassfishVersion")
}

下面是顶层项目(CmbProject)的build.gradle:

apply plugin: 'java'

subprojects {

    apply plugin: 'java'
    apply plugin: 'nebula.provided-base'
    apply plugin: 'nebula.optional-base'

    sourceCompatibility = JavaVersion.VERSION_1_8
    javadoc.enabled = false

    sourceSets {
        main {
            java {
                // Define all source dirs - Purpose is to add "src-gen"
                srcDirs = ["src/main/java", "src-gen"]
            }
        }
    }

    /*
     * Repositories used by each subproject must be given below.
     * Because each subproject resolves dependencies of other
     * subprojects, all subprojects must know all repos.
     * In other words, if projectA needs repo "foo.org" and projectB
     * depends upon projectA, then projectB needs repo "foo.org" as
     * well.
     */
    repositories {
        maven {
            // Local repo for annovention
            url uri("$rootDir/MagniCompCommon/repo")
        }

        mavenCentral()
        maven {
            url "http://download.java.net/maven/2"
        }
        maven {
            // Texo/EMF
            url "https://oss.sonatype.org/content/groups/public/org/eclipse/emf"
        }
        maven {
            // Eclipse
            url "https://oss.sonatype.org/content/repositories/public/eclipse"
        }
        maven {
            url "https://repository.jboss.org/nexus/content/groups/public-jboss"
        }
        maven {
            url "http://maven.vaadin.com/vaadin-addons"
        }
        maven {
            url "http://oss.sonatype.org/content/repositories/vaadin-snapshots"
        }
        maven {
            url("http://maven.clapper.org")
        }
        /*
         * -ADD LAST- so that it doesn' override any others
         * DynamicReports depends upon JasperReports which lists their own
         * bug fixed versions of packages like "com.lowagie:itext:2.1.7.js2"
         * This repo provides such patched packages.
         */
        maven {
            url("http://jasperreports.sourceforge.net/maven2")
        }
    }

    /*
     * Variables local to this file
     */
    def bouncycastleVersion = "1.54" // Was 1.51
    def slf4jVersion = "1.7.19"
    def hibernateVersion = "4.3.11.Final"
    def texoVersion = "0.9.0-v201501182340"
    def emfVersion = "2.11.0-v20150123-0347"
    def jnaVersion = "4.1.0"

    ext {
        /*
         * Variables here are used by subprojects
         */
        vaadinVersion = "7.6.8" // was 7.6.4
        vaadinIconsVersion = "1.0.1"
        jerseyGlassfishVersion = "2.23.2" // was 2.22.2
    }

    dependencies {

        /*
         * PRODUCT SPECIFIC
         */
        compile("org.bouncycastle:bcprov-jdk15on:$bouncycastleVersion")
        compile("org.bouncycastle:bcprov-ext-jdk15on:$bouncycastleVersion")
        compile("org.bouncycastle:bcpkix-jdk15on:$bouncycastleVersion")

        compile("com.h2database:h2:1.3.176")

        testCompile("org.testng:testng:6.9.4")

        /*
         * MagniComp common and product
         */
        compile("org.simpleframework:simple-xml:2.6.9")
        // Logging slf4j API
        compile("org.slf4j:slf4j-api:$slf4jVersion")
        // Send JCL to slf4j
        compile("org.slf4j:jcl-over-slf4j:$slf4jVersion")
        // Anything using JUL should defer to slf4j
        compile("org.slf4j:jul-to-slf4j:$slf4jVersion")
        // Send slf4j to log4j 1.2 for those JARs which use slf4j
        compile("org.slf4j:slf4j-log4j12:$slf4jVersion")
        // Log4j itself
        compile("log4j:log4j:1.2.17")
        // Hibernate
        // Do not include "hibernate-core" explicitly as hibernate-entitymanager will take care of it
        compile("org.hibernate:hibernate-entitymanager:$hibernateVersion")
        compile("org.hibernate:hibernate-c3p0:$hibernateVersion")

        compile("mysql:mysql-connector-java:5.1.38")

        // Texo
        compile("org.eclipse.emf:org.eclipse.emf.texo:$texoVersion")
        compile("org.eclipse.emf:org.eclipse.emf.texo.server:$texoVersion")
        compile("org.eclipse.emf:org.eclipse.emf.texo.xml:$texoVersion")
        // Texo dependencies (not automaticly added by texo)
        compile("org.eclipse.emf:org.eclipse.emf.common:$emfVersion")
        compile("org.eclipse.emf:org.eclipse.emf.ecore:$emfVersion")
        compile("org.eclipse.emf:org.eclipse.emf.ecore.xmi:$emfVersion")
        // Required by org.eclipse.emf
        // Disable because it's causing: 
        //   java.lang.SecurityException: class "org.osgi.framework.BundleReference"'s signer information does not match signer information of other classes in the same package
        //compile("org.eclipse.core:org.eclipse.core.runtime:3.7.0")

        compile("org.jsoup:jsoup:1.7.2")

        // Apache HTTP client
        compile("org.apache.httpcomponents:httpclient:4.3.5")
        // EventBus and more
        compile("com.google.guava:guava:18.0")

        // Quartz scheduler
        compile("org.quartz-scheduler:quartz:2.2.2") {
            exclude group: "c3p0", module: "c3p0"
        }
        // Java Mail
        compile("javax.mail:mail:1.4.5")

        // JNA for Common and CaBridge
        compile("net.java.dev.jna:jna:$jnaVersion")
        compile("net.java.dev.jna:jna-platform:$jnaVersion")

        // This package provided by Tomcat or Servlet container
        provided("javax.servlet:javax.servlet-api:3.1.0")

    }
}

共有1个答案

姬烨磊
2023-03-14

多亏了gradle论坛的一些帮助,我找到了解决办法。

作为WTP项目的依赖项的每个项目必须各自具备:

apply plugin: 'eclipse-wtp'

仅在WTP项目中拥有这一点是不够的。

 类似资料:
  • 问题内容: 我试图将我的Maven项目部署到Glassfish 4,但部署失败时出现以下异常: 也许值得一提的是它的构建还不错。.我不知道它要寻找的依赖项,对我来说有点神秘。任何帮助将不胜感激。 编辑-根据要求,我的POM文件: http://maven.apache.org/xsd/maven-4.0.0.xsd“> 4.0.0 问题答案: 该问题是由WAR文件中包含的lib 引起的。该lib已

  • 我使用的是Eclipse Luna、Maven3和Websphere Liberty 8.5.5。我在Eclipse中添加了websphere liberty server。部署在liberty中的EAR/WAR项目不包括WAR的WEB-INF/lib中的maven依赖项。如果导出EAR或WAR,则导出的文件包含所有依赖项。会出什么问题?

  • 我是maven的新手。(我已经搜索了几个小时的答案,但没有运气。mvn依赖:复制依赖不能解决我的问题)我需要复制项目的所有依赖项(以jar的形式),如果我的一个jar依赖于另一个工件,也复制该工件。 示例project1 pom。xml: “project1”依赖于project2。人工制品罐子当我使用“mvn依赖项:复制依赖项”时,我得到了project2。人工制品但我没有得到project3。

  • 我试图将我的maven项目部署到Glassfish 4,但当它部署失败时,我遇到以下异常: http://maven.apache.org/xsd/maven-4.0.0.xsd“>4.0.0

  • 我与Intellij合作过一个java spring项目 当我构建并运行项目时,这些错误会出现在我身上: 无法解析符号“springframework” 错误:(32,48)java:-source 1.5中不支持菱形运算符(使用-source 7或更高版本启用菱形运算符) 错误:(33,55)java:方法引用在-source 1.5中不受支持(使用-source 8或更高版本来启用方法引用)

  • 在实际使用之前,我试图从maven项目下载所有插件依赖项。 我试过跑步: 这成功地下载了它的插件及其部分依赖项。例如,对于exec插件,我得到: 但是,当您实际使用插件时,例如: 事实证明,它的依赖项尚未完全下载。 这是出乎意料的,因为根据文档,excludeTransitive属性在默认情况下为false(显式设置它没有帮助)。在我看来,它只是从定义的插件下载了一个级别的可传递依赖项。 有没有办