gpt4 book ai didi

build - Gradle:在构建中找不到软件包

转载 作者:行者123 更新时间:2023-12-03 04:46:23 31 4
gpt4 key购买 nike

我是Gradle的新手,但我有一个小问题。我正在尝试构建两个项目(称为“基础设施”和“域”),其中域从基础架构中导入了一些内容。

当我尝试构建两个项目时,Gradle无法编译我的域项目,因为他无法从基础结构中找到软件包。

这是我的build.gradle:

subprojects{
apply plugin: 'java'

springversion = '3.0.4.RELEASE'
hibernateversion = '3.4.0.GA'
jsfversion = '2.0.3'
projectid = 'com.companyName.projectName'
projectversion = '1.0.0-SNAPSHOT'

repositories {
mavenRepo urls: 'file:///C:/companyName/m2repo'
mavenCentral()
}

dependencies {
compile group: 'commons-configuration', name: 'commons-configuration', version: '1.6'
compile group: 'sample.plugin', name: 'hsqldb-maven-plugin', version: '1.0-SNAPSHOT'
testCompile group: 'junit', name: 'junit', version: '4.8.2'
testCompile group: 'org.mockito', name: 'mockito-core', version: '1.8.0'
testCompile group: 'org.springframework', name: 'spring-test', version: springversion

compile group: 'org.springframework', name: 'spring-context', version: springversion
compile group: 'org.springframework', name: 'spring-orm', version: springversion
compile group: 'org.springframework', name: 'spring-web', version: springversion
compile group: 'org.hibernate', name: 'hibernate-annotations', version: hibernateversion
compile group: 'org.hibernate', name: 'hibernate-entitymanager', version: hibernateversion
compile group: 'org.hibernate', name: 'ejb3-persistence', version: '1.0.2.GA'
compile group: 'javax.enterprise', name: 'cdi-api', version: '1.0-CR1'
compile group: 'com.sun.faces', name: 'jsf-api', version: jsfversion
compile group: 'commons-lang', name: 'commons-lang', version: '2.5'
runtime group: 'org.slf4j', name: 'slf4j-api', version: '1.5.6'
runtime group: 'org.slf4j', name: 'slf4j-jdk14', version: '1.5.6'
runtime group: 'org.hsqldb', name: 'hsqldb', version: '1.8.0.10'
runtime group: 'commons-dbcp', name: 'commons-dbcp', version: '1.2.2'
runtime group: 'org.aspectj', name: 'aspectjweaver', version: '1.6.2'
}

}

project (':infrastructure'){
task intTestJar(type: Jar) {
from sourceSets.main.classes
from sourceSets.test.classes
}
}

project(':domain'){
compileJava.dependsOn (':infrastructure:intTestJar')
}

在我的settings.gradle中,我声明了这一点:
include 'infrastructure', 'domain'

两个项目都应构建为.jar文件。

尝试构建项目时,如果他正在运行domain:compileTestJava,则会显示此错误。
package com.companyName.projectName.test does not exist

该软件包涉及我的基础设施项目。在eclipse中它可以工作,但是我不能用gradle来构建它。

任何帮助,将不胜感激。

问候,

瓦勒

最佳答案

这达到了目的:

subprojects{
apply plugin: 'java'
apply plugin: 'eclipse'

springversion = '3.0.4.RELEASE'
hibernateversion = '3.4.0.GA'
jsfversion = '2.0.3'
projectid = 'com.companyName.projectName'
projectversion = '1.0.0-SNAPSHOT'

repositories {
mavenRepo urls: 'file:///C:/companyName/m2repo'
mavenCentral()
}

dependencies {
compile group: 'commons-configuration', name: 'commons-configuration', version: '1.6'
compile group: 'sample.plugin', name: 'hsqldb-maven-plugin', version: '1.0-SNAPSHOT'
testCompile group: 'junit', name: 'junit', version: '4.8.2'
testCompile group: 'org.mockito', name: 'mockito-core', version: '1.8.0'
testCompile group: 'org.springframework', name: 'spring-test', version: springversion

compile group: projectid, name: 'infrastructure', version: projectversion
compile group: projectid, name: 'domain', version: projectversion
compile group: 'org.springframework', name: 'spring-context', version: springversion
compile group: 'org.springframework', name: 'spring-orm', version: springversion
compile group: 'org.springframework', name: 'spring-web', version: springversion
compile group: 'org.hibernate', name: 'hibernate-annotations', version: hibernateversion
compile group: 'org.hibernate', name: 'hibernate-entitymanager', version: hibernateversion
compile group: 'org.hibernate', name: 'ejb3-persistence', version: '1.0.2.GA'
compile group: 'javax.enterprise', name: 'cdi-api', version: '1.0-CR1'
compile group: 'com.sun.faces', name: 'jsf-api', version: jsfversion
compile group: 'commons-lang', name: 'commons-lang', version: '2.5'
runtime group: 'org.slf4j', name: 'slf4j-api', version: '1.5.6'
runtime group: 'org.slf4j', name: 'slf4j-jdk14', version: '1.5.6'
runtime group: 'org.hsqldb', name: 'hsqldb', version: '1.8.0.10'
runtime group: 'commons-dbcp', name: 'commons-dbcp', version: '1.2.2'
runtime group: 'org.aspectj', name: 'aspectjweaver', version: '1.6.2'
}
test{
maxParallelForks=2
}
}

project(':infrastructure'){
task infrastructureTestJar(type: Jar) {
from sourceSets.main.classes
from sourceSets.test.classes
}
infrastructureTestJar.dependsOn(jar)
}

project(':domain'){
compileJava.dependsOn(':infrastructure:build')
dependencies{
compile files('../infrastructure/build/libs/infrastructure.jar')
}
task domainTestJar(type: Jar) {
from sourceSets.main.classes
from sourceSets.test.classes
}
domainTestJar.dependsOn(jar)
}

关于build - Gradle:在构建中找不到软件包,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6263532/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com