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

Consider to provide a doc to teach users how to do LMP copyDependencies #804

Open
gkwan-ibm opened this issue Mar 23, 2023 · 4 comments
Open

Comments

@gkwan-ibm
Copy link
Member

I suggest to create a doc to tell users how to do LMP copyDependencies as this comment.

Although there is no copyDependencies for LGP, users may want to know how do that.

@gkwan-ibm
Copy link
Member Author

example:

configurations {
    jdbcLib
}

dependencies {
    // provided dependencies
    ...
    jdbcLib 'org.postgresql:postgresql:42.3.8'
}

...

task copyJdbcLibs(type: Copy) {
    from configurations.jdbcLib
    into "${buildDir}/wlp/usr/shared/resources"
}

deploy.dependsOn 'copyJdbcLibs'
...

@sreich
Copy link

sreich commented Apr 28, 2023

i have an issue i believe is related to this ask, lemme know if you prefer me to resubmit as a diff ticket...

trying to get this working using following these docs http://openliberty.io/docs/latest/relational-database-connections-JDBC.html and also your comment here...

seems with a gradle kts configuration (which is now Gradle's default, over the groovy syntax), it gets confused by the jdbcLib syntax. so far, what i've come up with is this...but it is actually failing the build right now

dependencies {
    jdbcLib("com.oracle.database.jdbc:ojdbc8:23.2.0.0")
}

val jdbcLib by configurations.creating

val copyJdbcTask = tasks.register<Copy>("copyJdbcLibForOpenLiberty") {
    from(jdbcLib) {
        into("$buildDir/wlp/usr/servers/${liberty.server.name}/jdbc")
        include("*.jar")
    }
}

tasks {
    deploy {
        dependsOn(copyJdbcTask)
    }
}

but..it does not like it,... within the from() scope, jdbclib is null for some reason...

suggestions?

@cherylking
Copy link
Member

@sreich I have not worked with gradle kts configuration, but are you sure the from(jdbcLib) should have curly braces separating it from the into and include properties? I found the following example for registering a Copy task:

tasks.register<Copy>("copy") {
   from("resources")
   into("target")
   include("**/*.txt", "**/*.xml", "**/*.properties")
}

@sreich
Copy link

sreich commented May 1, 2023

@cherylking it should be valid syntax, just wrapping it in a closure...removing them did not change anything. I believe the issue has to do with the delegate and it trying to use from(jdbclib) which seems to be null

...i just found the issue now, it looks like the delegate assignment ( val jdbcLib by configurations.creating ) needs to be listed above the dependency it is used in. Moving it below the dependency block reproduces the issue again. I didn't expect the compiler to get confused by that, since it's a class level field...

my problem is now fixed, thank you

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