Может ли корневой проект содержать один jar (с одним манифестом) для всех модулей? - PullRequest
0 голосов
/ 27 декабря 2018

Здравствуйте, в основном, есть 5 модулей с зависимостями от проектов, а также от jar, поэтому я создаю один jar-файл в корневом проекте с исходным кодом, но не могу заполнить файл манифеста одного (объединенного) jar с зависимостями модулей,

перепробовал много ответов, сегменты кода ничего не работают.

apply plugin: 'base'
    apply plugin: 'application'
    mainClassName = "sample.Sample"
    def mainProjects = [':module-1',':module-2',':module-3',':module-4',':module-5',':module-6',':module-7',':module-8']
    allprojects {
        apply plugin: 'java'
        sourceCompatibility = 1.8
        targetCompatibility = 1.8
        repositories {
        mavenCentral()
    }
    dependencies {
            compile fileTree(dir: '../lib', include: ['test1.jar'])
            compile fileTree(dir: '../lib', include: ['test-1.0.4.jar'])
            compile fileTree(dir: '../lib', include: ['test2.jar'])
            compile fileTree(dir: '../lib', include: ['test-0.7.12.jar'])
            compile fileTree(dir: '../lib', include: ['mssql-jdbc-6.4.0.jre8.jar'])
            compile fileTree(dir: '../lib', include: ['ojdbc6.jar'])
            compile fileTree(dir: '../lib', include: ['ojdbc14.jar'])
            testCompile group: 'junit', name: 'junit', version: '4.12'
            compile group: 'log4j', name: 'log4j', version: '1.2.17'
            compile group: 'org.slf4j', name: 'slf4j-api', version: '1.7.7'
            compile group: 'org.slf4j', name: 'slf4j-log4j12', version: '1.7.7'
        }
        task collectJars {
            doLast {
                copy{
                    into "../build/libs/"
                    from configurations.runtime
                    exclude('module-*.jar')
                }
            }
        }
        tasks.withType(Jar) {
            manifest {
                attributes(
                        'Implementation-Title': 'sample-jar',
                        'Implementation-Version': version,
                        'Provider' : "Test Technologies",
                        'Build-Timestamp': new java.text.SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ").format(new Date()),
                        'Build-Jdk'      : "${System.properties['java.version']} (${System.properties['java.vendor']} ${System.properties['java.vm.version']})",
                        'Build-OS'       : "${System.properties['os.name']} ${System.properties['os.arch']} ${System.properties['os.version']}",
                        'Main-Class': 'sample.Sample',
                        'Class-Path': configurations.runtimeClasspath.files.collect { it.getName() }.join(' ')    )
            }
        }   build.dependsOn(collectJars)
    }
    task oneJar( type: Jar , dependsOn: mainProjects.collect{ it+":compileJava"})baseName = 'sample-jar' from files(mainProjects.collect{ project(it).sourceSets.main.output })
    }
build.dependsOn(oneJar)

Я попробовал все эти операторы с помощью compile, runTimeClassPath, compileOnly, runtime и т. Д. В следующем выражении

 configurations.runtimeClasspath.files.collect { it.getName() }.join(' ')
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...