如何在gradle项目中外部/手动添加jar文件?

时间:2016-02-22 04:41:45

标签: java gradle build.gradle

我在gradle Idea IDE中导入了IntelliJ项目。在我的个人WiFi中没有在构建中指定的所有jar。gradle已下载,我可以在外部libs文件夹中看到它们但是当我尝试在公司n / w下导入项目时,这些罐子没有得到下载。我想它的bcoz公司已经阻止了要下载的网站。我拥有所有那些jar文件,现在我想让它手动添加它。我试过了

File ->Project structure->Modules ->dependencies 

这里我添加了罐子库。但我仍然得到100多个编译时错误。我也在库中添加了罐子。 注意 - 我拥有的一堆罐子都有特定的文件夹结构。我的意思是每个jar都在文件夹内的文件夹中我直接添加了文件夹,因为很难只添加jar,所以需要添加的jar文件很多。 我的Build.Gradle文件 -

apply plugin: 'java'

sourceCompatibility = 1.7

def axis2Dir = '../apache-tomcat/webapps/axis2/'
def releaseDir = "R:/PepsiCo/release/"

repositories {
    mavenCentral()
}

dependencies {
    compile 'log4j:log4j:1.2.17',
            'commons-lang:commons-lang:2.6',
            'commons-httpclient:commons-httpclient:3.1',
            'commons-io:commons-io:1.4',
            'org.apache.commons:commons-email:1.3.3',
            'org.springframework:spring-jdbc:3.0.7.RELEASE',
            'org.springframework:spring-test:3.0.7.RELEASE',
            'org.apache.axis2:axis2:1.6.1',
            'org.flywaydb:flyway-core:3.0',
            'com.h2database:h2:1.3.176',
            'org.apache.ws.commons.axiom:axiom-api:1.2.12',
            'wsdl4j:wsdl4j:1.6.2',
            'org.apache.ws.commons.schema:XmlSchema:1.4.7',
            'org.apache.ws.commons.axiom:axiom-impl:1.2.12',
            'org.apache.neethi:neethi:3.0.1',
            'org.apache.axis2:axis2-transport-local:1.6.1',
            'org.apache.axis2:axis2-transport-http:1.6.1',
            'net.sf.ehcache:ehcache:2.9.0',
            'org.apache.chemistry.opencmis:chemistry-opencmis-client-impl:0.12.0',
    fileTree(dir: 'lib', include: '*.jar')
    testCompile 'junit:junit:4.11',
                'org.assertj:assertj-core:2.1.0'
}

task deployTws(type: Copy) {
    from libsDir
    into "$axis2Dir/WEB-INF/services/${project.name}/lib/"
    include '*.jar'
}

task undeployTws(type: Delete) {
    delete "$axis2Dir/WEB-INF/services/${project.name}"
}

task deployJar(type: Copy) {
    from libsDir
    into "$axis2Dir/WEB-INF/services/"
    include '*.jar'
}

// Remove hardcoding. See http://stackoverflow.com/questions/11428954/gradle-zip-packaging-copy-jar-file-from-repository.
task deployLib(type: Copy) {
    from "$buildDir/lib/"
    into "$axis2Dir/WEB-INF/lib/"
    include 'flyway-core-3.0.jar', 'h2-1.3.176.jar', 'commons-email-1.3.3.jar', 'ehcache-2.9.0.jar', 'pqppv-client.jar', 'pqpvcs-client.jar', 'pqpfds-client.jar', "chemistry-opencmis-commons-impl-0.12.0.jar", "chemistry-opencmis-client-api-0.12.0.jar", "chemistry-opencmis-client-bindings-0.12.0.jar", "chemistry-opencmis-client-impl-0.12.0.jar", "chemistry-opencmis-commons-api-0.12.0.jar"
    // 'rasapp.jar', 'rascore.jar', 'serialization.jar', 'logging.jar'
}

task deployFlyway(type: Copy) {
    from 'src/main/resources/db/migration/'
    into "$axis2Dir/WEB-INF/classes/db/migration/"
    include 'V*.sql'
    // include '**/*'
}

task deployResources(type: Copy) {
    from 'src/main/resources/'
    into "$axis2Dir/WEB-INF/classes/"
    include '*.conf', '*.properties', 'ehcache.xml'
}

task undeployJar(type: Delete) {
    delete "$axis2Dir/WEB-INF/services/$archivesBaseName-${version}.jar"
}

task deployTwsXml(type: Copy) {
    from 'src/main/resources/META-INF/'
    into "$axis2Dir/WEB-INF/services/${project.name}/META-INF/"
}

task copyLibs(type: Copy) {
    from configurations.runtime
    into "$buildDir/lib"
}

// Creates pqp-tws/build/distributions/pqp-tws.zip
task zipPackage(type: Zip) {
    from axis2Dir
    include 'WEB-INF/lib/flyway-core-3.0.jar',
            'WEB-INF/lib/h2-1.3.176.jar',
            'WEB-INF/lib/pqppv-client.jar',
            'WEB-INF/lib/pqpvcs-client.jar',
            'WEB-INF/lib/pqpfds-client.jar',
            'WEB-INF/lib/commons-email-1.3.3.jar',
            'WEB-INF/lib/ehcache-2.9.0.jar',
            'WEB-INF/lib/chemistry-opencmis-commons-impl-0.12.0.jar',
            'WEB-INF/lib/chemistry-opencmis-client-api-0.12.0.jar',
            'WEB-INF/lib/chemistry-opencmis-client-bindings-0.12.0.jar',
            'WEB-INF/lib/chemistry-opencmis-client-impl-0.12.0.jar',
            'WEB-INF/lib/chemistry-opencmis-commons-api-0.12.0.jar',
            'WEB-INF/services/pqp-tws.jar',
            'WEB-INF/classes/pqp-field.properties',
            'WEB-INF/classes/pqp-foundational.conf',
            'WEB-INF/classes/pqp-prescreen.conf',
            'WEB-INF/classes/ehcache.xml',
            'WEB-INF/classes/db/migration/*.sql'
             // 'WEB-INF/lib/rasapp.jar', 'WEB-INF/lib/rascore.jar', 'WEB-INF/lib/serialization.jar', 'WEB-INF/lib/logging.jar'
}

task releaseZip(type: Copy) {
    from "$buildDir/distributions/${project.name}.zip"
    into "$releaseDir"
}

task configlessJar(type: Jar) {
    from sourceSets.main.output
    exclude 'pqp.properties', 'pqp-field.properties', 'pqp-foundational.conf', 'pqp-prescreen.conf', 'ehcache.xml'
}

deployTws.dependsOn configlessJar, deployTwsXml

deployJar.dependsOn undeployJar, clean, configlessJar, copyLibs, deployLib, deployFlyway, deployResources

releaseZip {}.dependsOn deployJar, zipPackage

0 个答案:

没有答案