Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

additionalDir Doesn't seem to work #22

Open
sirhallt opened this issue Jul 14, 2015 · 2 comments
Open

additionalDir Doesn't seem to work #22

sirhallt opened this issue Jul 14, 2015 · 2 comments

Comments

@sirhallt
Copy link

I have a gradle file defined as:

apply plugin: 'gradle-one-jar'

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.github.rholder:gradle-one-jar:1.0.4'
    }
}

task fullJar(type: OneJar) {
    mainClass = 'com.mycompany.MyApp'
    additionalDir = file('lib')
}

uploadArchives {
    repositories {
       flatDir {
           dirs 'repos'
       }
    }
}

In the lib directory is Oracle JDBC driver ojdbc7.jar, but this jar never makes it anywhere into the final OneJar. Thank you

@aholzer-torres-ln
Copy link

I have a workaround for this working on my local. My (somewhat redacted) build.gradle looks like this:


apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'application'
apply plugin: 'gradle-one-jar'

mainClassName = "com.company.package.App"

applicationDefaultJvmArgs = ["server","src/main/resources/app.yml"]

buildscript {
    repositories {
        mavenCentral()
    }

    dependencies {
        classpath 'com.github.rholder:gradle-one-jar:1.0.4'
    }
}

project.ext {
    dropwizardVersion = '0.8.0'
}

//For some reason this is not sufficient to get a runnable jar. Had to go with a different implementation
jar {
  manifest {
    attributes ("Manifest-Version": "1.0",
                'Main-Class': 'com.company.package.App',
                "Class-Path" : '.'
                ) 
  }

/* This would be to add all the jars to the file
  doFirst {
    from (configurations.compile.resolve().collect { it }) {
      exclude 'META-INF/MANIFEST.MF'
      exclude 'META-INF/*.SF'
      exclude 'META-INF/*.DSA'
      exclude 'META-INF/*.RSA'
    }
  }
*/

  //Adds the assets to the jar
  //from("$projectDir/src/main/resources")
}

repositories {
  mavenCentral()
  maven { url "http://repository.pentaho.org/artifactory/repo/" }
}

dependencies {
  compile (
    //dropwizard
    ['io.dropwizard:dropwizard-core:'       + dropwizardVersion],
    ['io.dropwizard:dropwizard-db:'         + dropwizardVersion],
    ['io.dropwizard:dropwizard-jdbi:'       + dropwizardVersion],
    ['io.dropwizard:dropwizard-testing:'    + dropwizardVersion],
    ['io.dropwizard:dropwizard-assets:'     + dropwizardVersion],

    //hibernate
    [group: 'org.hibernate', name: 'hibernate-core', version: '4.3.11.Final'],

    //olap4j
    [group: 'org.olap4j', name: 'olap4j', version: '1.2.0'],
    [group: 'org.olap4j', name: 'olap4j-xmla', version: '1.2.0'],

    //jdbc drivers
    [group: 'org.postgresql', name: 'postgresql', version: '9.4-1201-jdbc41'],
    [group: 'pentaho', name: 'mondrian', version: '3.10.0.1-130']

  )

  testCompile 'junit:junit:4.11'

}

run {
    args 'server', './src/main/resources/app.yml'
}

task fullJar(type: OneJar, dependsOn: 'build') {
    mainClass = 'com.company.package.App'
    archiveName 'app-dependencies.jar'
}

// This adds the assets to the jar so we can run from wherever
task enrichedJar(type: Jar, dependsOn: "fullJar") { 
    // Manually duplicating the OneJar manifest so that we can run.
    manifest{
      attributes(
                "Manifest-Version": "1.0",
                "Ant-Version": "Apache Ant 1.9.3",
                "Created-By": "1.8.0_51-b16 (Oracle Corporation)",
                "Main-Class": "com.simontuffs.onejar.Boot",
                "One-Jar-Main-Class": "com.company.package.App",
                "One-Jar-Show-Expand": "false",
                "One-Jar-Confirm-Expand": "false"
                )
    }
    baseName 'app'
    appendix "enriched" 
    from zipTree('build/libs/app-dependencies.jar') // add original content 
    from file("src/main/resources")    // add new content  
} 

@MichaelBeausoleil
Copy link

It looks like you have to set the additionalDir property to an absolute path for it to work.

So instead of:

additionalDir = file('lib')

try something like:

additionalDir = file('${buildDir}/lib/')

or:

additionalDir = file(sourceSets.main.output.resourcesDir.getAbsolutePath() + '/lib')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants