Not able to download Dynamodb local dependency - spring

testImplementation 'com.amazonaws:DynamoDBLocal:1.11.477'
we are not able to download this dependency
https://s3-us-west-2.amazonaws.com/dynamodb-local/release/com/amazonaws/DynamoDBLocal/1.15.0
<Error>
<Code>NoSuchKey</Code>
<Message>The specified key does not exist.</Message>
<Key>release/com/amazonaws/DynamoDBLocal/1.15.0</Key>
<RequestId>YXQZXNMTZN9W6YWS</RequestId>
<HostId>ET+U1aEJdzn4DJkDvCrZu45NaP+ObdB/PETMiakVu3ywln8jGpRDSC6BwGbSmyBLao465SKgsWs=</HostId>
</Error>
https://mvnrepository.com/artifact/com.amazonaws/DynamoDBLocal
None of the version working.

You can try this (updated to v1.15.0):
maven {
url 'https://s3-us-west-2.amazonaws.com/dynamodb-local/release/'
}
configurations {
dynamodb
}
dependencies {
testImplementation group: 'com.amazonaws', name: 'DynamoDBLocal', version: '1.15.0'
dynamodb fileTree (dir: 'lib', include: ["*.dylib", "*.so", "*.dll"])
dynamodb 'com.amazonaws:DynamoDBLocal:1.15.0'
}
task copyNativeDeps(type: Copy) {
from configurations.dynamodb
into "$project.buildDir/libs/"
}
test.dependsOn copyNativeDeps
test.doFirst {
systemProperty "java.library.path", 'build/libs'
}
Ref: https://stackoverflow.com/a/55281942/1471293

Related

Groovy compilation fails: Unable to load class 'org.grails.io.support.Resource'

I'm developing a JavaFX application written in Groovy and using Gradle. When I started up my application in IntelliJ recently, it seemingly from out of the blue started failing to compile with the error:
Unable to load class 'org.grails.io.support.Resource'.
This is an unexpected error. Please file a bug containing the idea.log file.
This is from running the "run" gradle task.
This is my build file:
plugins {
id 'groovy'
id 'application'
id 'org.openjfx.javafxplugin' version '0.0.7'
}
group 'redacted'
version '1.0-SNAPSHOT'
repositories {
mavenCentral()
maven { url "https://m2proxy.atlassian.com/repository/public" } // Atlassian repository
maven { url "https://maven.atlassian.com/content/repositories/atlassian-public/"} // Atlassian public
maven { url "https://download.java.net/maven/2/"}
}
dependencies {
implementation 'org.codehaus.groovy:groovy-all:3.0.5'
// Logback log-annotation
implementation group: 'ch.qos.logback', name: 'logback-classic', version: '1.2.6'
// https://mvnrepository.com/artifact/org.controlsfx/controlsfx
implementation group: 'org.controlsfx', name: 'controlsfx', version: '11.1.0'
testImplementation 'org.spockframework:spock-core:2.0-groovy-3.0'
// ---- GPars concurrency lib ----
// https://mvnrepository.com/artifact/org.codehaus.gpars/gpars
implementation group: 'org.codehaus.gpars', name: 'gpars', version: '1.2.1'
// ---- Jira Client ----
// https://mvnrepository.com/artifact/com.atlassian.jira/jira-rest-java-client-app
implementation group: 'com.atlassian.jira', name: 'jira-rest-java-client-app', version: '5.2.0'
// https://mvnrepository.com/artifact/com.atlassian.jira/jira-rest-java-client-api
implementation group: 'com.atlassian.jira', name: 'jira-rest-java-client-api', version: '5.2.0'
// ---- Misc ----
// https://mvnrepository.com/artifact/io.github.cdimascio/java-dotenv
implementation group: 'io.github.cdimascio', name: 'java-dotenv', version: '5.2.2'
// https://mvnrepository.com/artifact/org.jsoup/jsoup
implementation group: 'org.jsoup', name: 'jsoup', version: '1.14.3'
// ---- REST ----
// https://mvnrepository.com/artifact/org.springframework/spring-web
implementation group: 'org.springframework', name: 'spring-web', version: '3.0.2.RELEASE'
// https://mvnrepository.com/artifact/org.grails/grails-datastore-rest-client
implementation group: 'org.grails', name: 'grails-datastore-rest-client', version: '6.1.9.RELEASE'
// https://mvnrepository.com/artifact/javax.servlet/javax.servlet-api
implementation group: 'javax.servlet', name: 'javax.servlet-api', version: '4.0.1'
// https://mvnrepository.com/artifact/net.dongliu/requests
implementation group: 'net.dongliu', name: 'requests', version: '5.0.8'
// https://mvnrepository.com/artifact/io.jsondb/jsondb-core
implementation group: 'io.jsondb', name: 'jsondb-core', version: '1.0.115-j11'
}
test {
useJUnitPlatform()
}
javafx {
modules = ['javafx.controls', 'javafx.fxml']
version = '11.0.2'
}
mainClassName = 'redacted'
Has anyone seen this before? The things I've tried:
Invalidating caches in IntelliJ
Clean + Rebuild
Rollback code to a point I know compiled.
Update gradlew to use gradle 7.4
UPDATE
I seem to have found the culprit. My company has recently changed stuff related to how we build our projects, which requires using a init.gradle file in the .gradle/ folder, which contains some standard repository definitions. This is the content (with company repositories redacted):
allprojects {
apply plugin: 'java'
apply plugin: 'maven-publish'
buildscript {
repositories {
maven {
url "https://<redacted>"
credentials {
username mavenUser
password mavenPassword
}
}
}
}
repositories {
mavenLocal()
maven {
url "https://<redacted>"
credentials {
username mavenUser
password mavenPassword
}
}
}
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
}
}
repositories {
maven {
credentials {
username mavenUser
password mavenPassword
}
url "https://<redacted>"
}
}
}
}
Removing it fixed the problem for the project in question, but will obviously not work for all the other work related projects. So the question remains...how does this cause such an error?
UPDATE 2
I have not exactly found the source of the error, but it seems to have something to do with the repositories being declared in a wrong way. To fix this, one can call clear() in the project build.gradle file at the top of the repositories definition, effectively ignoring what's declared in init.gradle. So, just update the repositories {} clause to:
repositories {
clear() // This is needed in order for init.gradle to not cause errors
mavenCentral()
maven { url "https://m2proxy.atlassian.com/repository/public" } // Atlassian repository
maven { url "https://maven.atlassian.com/content/repositories/atlassian-public/"} // Atlassian public
maven { url "https://download.java.net/maven/2/"}
}
I have not exactly found the source of the error, but it seems to have something to do with the repositories being declared in a wrong way. To fix this, one can call clear() in the project build.gradle file at the top of the repositories definition, effectively ignoring what's declared in init.gradle. So, just update the repositories closure to:
repositories {
clear() // This is needed in order for init.gradle to not cause errors
mavenCentral()
maven { url "https://m2proxy.atlassian.com/repository/public" } // Atlassian repository
maven { url "https://maven.atlassian.com/content/repositories/atlassian-public/"} // Atlassian public
maven { url "https://download.java.net/maven/2/"}
}

Gradle powermock codecoverage missed

How to configure gradle to produce code coverage for sonar when i'm using powermock in my tests? I found that jacoco don't support that. Is there any other codecoverage plugin to work with powermock?
Jacoco Offline Instrumentation is the solution for this.
see my gradle build file
Build and run tests:
Linux:
\$ ./gradlew
Windows:
\$ gradlew
------------------------------------------
"""
apply plugin: 'java'
apply plugin: 'org.sonarqube'
apply plugin: 'jacoco'
// Project group and version
group 'com.abcd.jacocoTest'
version '1.0.0'
// JDK version source compatibility
sourceCompatibility = 1.8
// JDK version target compatibility
targetCompatibility = 1.8
configurations {
jacocoAnt
jacocoRuntime
}
task wrapper(type: Wrapper) {
gradleVersion = "4.5.1"
}
defaultTasks 'clean', 'test'
buildscript {
repositories {
maven { url "https://plugins.gradle.org/m2/" }
}
dependencies {
classpath "org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:2.6.2"
}
}
repositories {
mavenCentral()
}
dependencies {
jacocoAnt group: 'org.jacoco', name: 'org.jacoco.ant', version: '0.8.1'
jacocoAgent group: 'org.jacoco', name: 'org.jacoco.agent', version: '0.8.1'
testCompile group: 'junit', name: 'junit', version: '4.12'
testCompile group: 'org.mockito', name: 'mockito-core', version: '2.8.9'
testCompile group: 'org.powermock', name: 'powermock-module-junit4', version: '1.7.4'
testCompile group: 'org.powermock', name: 'powermock-api-mockito2', version: '1.7.4'
testCompile group: 'org.powermock', name: 'powermock-api-easymock', version: '1.7.4'
}
test {
testLogging {
afterSuite { desc, result ->
if (!desc.parent) { // will match the outermost suite
println "Unit Tests: ${result.resultType} (${result.testCount} tests, ${result.successfulTestCount} successes, ${result.failedTestCount} failures, ${result.skippedTestCount} skipped)"
}
}
}
jacoco {
append = "false"
destinationFile = file("$buildDir/reports/jacoco/jacoco-sonar/jacoco-coverage.exec")
}
}
jacoco {
toolVersion = "0.8.0"
}
jacocoTestReport {
reports {
html.destination file("${buildDir}/reports/jacoco/jacocoHtml")
}
}
sonarqube {
properties {
property "sonar.projectName", 'JacocoTest'
property "sonar.host.url", "http://localhost:9000"
property "sonar.java.binaries", "${buildDir}/classes"
property "sonar.java.libraries", "**/*.jar"
property "sonar.dynamicAnalysis", "reuseReports"
property "sonar.jacoco.reportPaths", "${buildDir}/reports/jacoco/jacoco-sonar/jacoco-coverage.exec"
}
}
task instrument(dependsOn: ['classes']) {
ext.outputDir = buildDir.path + '/reports/classes-instrumented'
doLast {
ant.taskdef(name: 'instrument',
classname: 'org.jacoco.ant.InstrumentTask',
classpath: configurations.jacocoAnt.asPath)
ant.instrument(destdir: outputDir) {
fileset(dir: sourceSets.main.output.classesDir)
}
}
}
gradle.taskGraph.whenReady { graph ->
if (graph.hasTask(instrument)) {
tasks.withType(Test) {
doFirst {
classpath = files(instrument.outputDir) + classpath + configurations.jacocoRuntime
}
}
}
}
task report(dependsOn: ['instrument', 'test']) {
doLast {
ant.taskdef(name: 'report',
classname: 'org.jacoco.ant.ReportTask',
classpath: configurations.jacocoAnt.asPath)
ant.report() {
executiondata {
ant.file(file: buildDir.path + '/reports/jacoco/jacoco-sonar/jacoco-coverage.exec')
}
structure(name: 'Example') {
classfiles {
fileset(dir: sourceSets.main.output.classesDir)
}
sourcefiles {
fileset(dir: 'src/main/java')
}
}
html(destdir: buildDir.path + '/reports/jacoco')
}
}
}
Here report task will create the offline instrumentation files of the project.
Finally, execute sonarqube task.
Then you can see the coverage of the powermocked classes also has included.
Execution command ./gradlew report sonarqube
Then go and see in your sonarqube host (localhost:9000).
You could try to use JaCoCo offline instrumentation instead of on-the-fly instrumentation as documented at https://github.com/powermock/powermock/wiki/Code-coverage-with-JaCoCo as long as https://github.com/powermock/powermock/issues/727 is not fixed which would make PowerMock compatible with JaCoCo on-the-fly instrumentation.
Alternatively you could use a different mocking framework, like e. g. JMockit. This is compatible with JaCoCo on-the-fly instrumentation as far as I remember.
I resigned to use gradle and jacoco. Now i'm using maven + cobertura + powermock and everything works without hacks. Why i'm using maven? Because i can't find how to produce xml code coverage report in cobertura using gradle.

How to use jOOQ code generation with Gradle?

I am reading this tutorial of jOOQ
It shows me how I can use jOOQ code-generation from inside Gradle.
Based on this tutorial I modified my build.gradle file and it looks like this:
group 'com.abhi'
version '1.0-SNAPSHOT'
apply plugin: 'java'
apply plugin: 'org.flywaydb.flyway'
sourceCompatibility = 1.8
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'org.flywaydb:flyway-gradle-plugin:3.2.1'
classpath 'org.jooq:jooq-codegen:3.7.1'
classpath 'com.h2database:h2:1.4.177'
}
}
repositories {
mavenCentral()
}
dependencies {
compile group: 'org.jooq', name: 'jooq', version: '3.7.1'
compile group: 'org.jooq', name: 'jooq-meta', version: '3.7.1'
compile group: 'org.jooq', name: 'jooq-codegen', version: '3.7.1'
runtime group: 'com.h2database', name: 'h2', version: '1.4.177'
}
flyway {
url = 'jdbc:h2:file:target/foobar'
user = 'sa'
}
But the part I am not able to understand is that the tutorial also provides some code:
def writer = new StringWriter()
def xml = new groovy.xml.MarkupBuilder(writer)
.configuration('xmlns': 'http://www.jooq.org/xsd/jooq-codegen-3.7.0.xsd') {
jdbc() {
driver('org.h2.Driver')
url('jdbc:h2:~/test-gradle')
user('sa')
password('')
}
generator() {
database() {
}
generate() {
}
target() {
packageName('org.jooq.example.gradle.db')
directory('src/main/java')
}
}
}
// Run the code generator
// ----------------------
org.jooq.util.GenerationTool.generate(
javax.xml.bind.JAXB.unmarshal(new StringReader(writer.toString()), org.jooq.util.jaxb.Configuration.class)
)
Where should I put this code and how shall I execute it?
This code looks like Groovy code but I am writing a Java project. So how and where does this fit into my project?
My objective is that every time I build the project, all the code generation is done by Gradle itself so that I don't have to run any tools manually.
Does it mean that I copy and paste this code inside of my build.gradle file?
You can e.g. add generate task that will be defined as follows:
task generate << {
def writer = new StringWriter()
def xml = new groovy.xml.MarkupBuilder(writer)
.configuration('xmlns': 'http://www.jooq.org/xsd/jooq-codegen-3.7.0.xsd') {
jdbc() {
driver('org.h2.Driver')
url('jdbc:h2:~/test-gradle')
user('sa')
password('')
}
generator() {
database() {
}
generate() {
}
target() {
packageName('org.jooq.example.gradle.db')
directory('src/main/java')
}
}
}
org.jooq.util.GenerationTool.generate(
javax.xml.bind.JAXB.unmarshal(new StringReader(writer.toString()), org.jooq.util.jaxb.Configuration.class)
)
}
You can create a task and use the org.jooq.meta.jaxb.Configuration class to configure code generation:
In your build.gradle file, you will want to place the following on the very top of the file (this will allow you to use the jOOQ classes (such as the org.jooq.meta.jaxb.Configuration class inside your Gradle file).
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath group: 'org.jooq', name: 'jooq', version: '3.13.4'
classpath group: 'org.jooq', name: 'jooq-meta', version: '3.13.4'
classpath group: 'org.jooq', name: 'jooq-codegen', version: '3.13.4'
classpath group: 'org.postgresql', name: 'postgresql', version: '42.2.16'
}
}
Next, create a new file (you can also do it inside build.gradle, but I like to separate it for better organization) called jooq.gradle, or whatever you would like to call it.
The following file is adapted from here with some minor modifications.
At the top of your program, you will want to add the following imports that will let us work with jOOQ (they may show up as red or invalid, but we'll fix that in just a bit):
import org.jooq.codegen.GenerationTool
import org.jooq.meta.jaxb.Database
import org.jooq.meta.jaxb.Generator
import org.jooq.meta.jaxb.Jdbc
import org.jooq.meta.jaxb.Target
Great!, now we can define some variables after this for better organization (not required):
ext.db = [
url: 'jdbc:postgresql://localhost:5432/postgres',
user: 'postgres',
password: 'postgres',
schema: 'public',
driver: 'org.postgresql.Driver',
jooqDbImpl: 'org.jooq.meta.postgres.PostgresDatabase',
packageName: 'samplepackage'
]
ext.genpath = new File("${projectDir}/build/generated-src/jooq/main")
For the above snippet, you will want to change the variables according to your configuration.
Next, we can add our buildscript again for this file:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath group: 'org.jooq', name: 'jooq', version: '3.13.4'
classpath group: 'org.jooq', name: 'jooq-meta', version: '3.13.4'
classpath group: 'org.jooq', name: 'jooq-codegen', version: '3.13.4'
classpath group: 'org.postgresql', name: 'postgresql', version: '42.2.16'
}
}
After this, we can add genPath as a Java source file:
sourceSets.main.java.srcDirs += genpath.toString()
And we can finally start our generateCode() task!
Create the function definition as such:
task generateCode() {
}
Inside you will want to put this snippet of code, which will configure the generator. Feel free to modify this according to your needs, but I will be putting a snippet that works for me:
org.jooq.meta.jaxb.Configuration configuration = new
org.jooq.meta.jaxb.Configuration()
.withJdbc(new Jdbc()
.withDriver(db.driver)
.withUrl(db.url)
.withUser(db.user)
.withPassword(db.password)
)
.withGenerator(new Generator()
.withDatabase(new Database()
.withName(db.jooqDbImpl)
.withIncludes(".*")
.withExcludes("")
.withInputSchema(db.schema)
)
.withTarget(new Target()
.withPackageName(db.packageName)
.withDirectory(genpath.toString())
)
);
Finally, after all the hard work, you can execute this function, which will create your code using the configuration above:
GenerationTool.generate(configuration);
If you would like to have a function to delete the generated code, you can use the following snippet:
task deleteGeneratedCode(type: Delete) {
delete genpath
}
And here is the following, completed jooq.gradle file:
import org.jooq.codegen.GenerationTool
import org.jooq.meta.jaxb.Database
import org.jooq.meta.jaxb.Generator
import org.jooq.meta.jaxb.Jdbc
import org.jooq.meta.jaxb.Target
ext.db = [
url: 'jdbc:postgresql://localhost:5432/postgres',
user: 'postgres',
password: 'postgres',
schema: 'limehrm',
driver: 'org.postgresql.Driver',
jooqDbImpl: 'org.jooq.meta.postgres.PostgresDatabase'
packageName: 'limehrm'
]
ext.genpath = new File("${projectDir}/build/generated/source/jooq/main")
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath group: 'org.jooq', name: 'jooq', version: '3.13.4'
classpath group: 'org.jooq', name: 'jooq-meta', version: '3.13.4'
classpath group: 'org.jooq', name: 'jooq-codegen', version: '3.13.4'
classpath group: 'org.postgresql', name: 'postgresql', version: '42.2.16'
}
}
sourceSets.main.java.srcDirs += genpath.toString()
task generateCode() {
if (!genpath.exists()) {
genpath.mkdirs()
}
org.jooq.meta.jaxb.Configuration configuration = new
org.jooq.meta.jaxb.Configuration()
.withJdbc(new Jdbc()
.withDriver(db.driver)
.withUrl(db.url)
.withUser(db.user)
.withPassword(db.password)
)
.withGenerator(new Generator()
.withDatabase(new Database()
.withName(db.jooqDbImpl)
.withIncludes(".*")
.withExcludes("")
.withInputSchema(db.schema)
)
.withTarget(new Target()
.withPackageName(db.packageName)
.withDirectory(genpath.toString())
)
);
GenerationTool.generate(configuration);
}
task deleteGeneratedCode(type: Delete) {
delete genpath
}
#Opal's answer works great (thanks!) with a couple of tweaks. Thought I'd share to spare anyone the hassle with newer versions of jOOQ & Gradle.
The changes:
<< removed from the first line and doLast added.
jOOQ .xsd updated to 3.9.2
org.jooq.util.GenerationTool.generate(writer.toString()) to generate the code
task generate {
doLast {
def writer = new StringWriter()
def xml = new groovy.xml.MarkupBuilder(writer)
.configuration('xmlns': 'http://www.jooq.org/xsd/jooq-codegen-3.9.2.xsd') {
jdbc() {
driver('org.h2.Driver')
url('jdbc:h2:~/test-gradle')
user('sa')
password('')
}
generator() {
database() {
}
generate() {
}
target() {
packageName('org.jooq.example.gradle.db')
directory('src/main/java')
}
}
}
org.jooq.util.GenerationTool.generate(writer.toString())
}
}

How to upload folder contents to FTP server using Gradle

I am new to gradle and I don't know how to upload my /bin folder contents to the FTP server. Tried to find solution in internet, but they didn't help to me.
My build.gradle file is as follows:
apply plugin: 'java'
sourceCompatibility = 1.6
version = '1.0'
repositories {
mavenCentral()
}
dependencies {
compile 'org.apache.httpcomponents:httpclient:4.3.3'
compile fileTree(dir: 'lib', include: '*.jar')
compile 'org.apache.directory.studio:org.dom4j.dom4j:1.6.1'
compile 'jaxen:jaxen:1.1.4'
testCompile group: 'junit', name: 'junit', version: '4.11'
}
build.doLast {
copy {
into 'bin'
from 'build/libs'
}
}
Now I want to write task which will upload /bin folder contents to the FTP server.
Any help would be appreciated. Thanks in advance
ftpAntTask is fairly simple to use.
buildscript {
repositories {
mavenCentral()
}
}
repositories{
mavenCentral()
}
configurations {
ftpAntTask
}
dependencies {
ftpAntTask("org.apache.ant:ant-commons-net:1.8.4") {
module("commons-net:commons-net:1.4.1") {
dependencies "oro:oro:2.0.8:jar"
}
}
}
task ftp << {
ant {
taskdef(name: 'ftp',
classname: 'org.apache.tools.ant.taskdefs.optional.net.FTP',
classpath: configurations.ftpAntTask.asPath)
ftp(server: "(removed)", userid: "(removed)", password: "(removed)", remoteDir: "(removed)") {
fileset(dir: "(removed)") {
include(name: "(removed)")
}
}
}
}
(This example was made from How to FTP a file from an Android Gradle build?)
Use apache commons net library. There's an example of FTPClient usage.
You also need to configure dependencies for the build script itself. Following code does it:
import org.apache.commons.net.ftp.FTPClient
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'commons-net:commons-net:3.3'
}
}
task upload << {
def ftp = new FTPClient()
//following logic..
}

tasks.setupAll.dependsOn(copyJars) does not work in gradle?

I tried following the answer here
how to override a task making it depend on one of mine in gradle
but it fails with
Could not find property 'setupAll' on task set.
I have tried a few things
Make the task in subprojects section depend on master:copyJars but that fails
The below solution
stripped off the tasks which didn't work.
I have only ONE build.gradle file and the settings.gradle file. The settings gradle file is
include 'master', 'toneserver','webserver'
The master build.gradle file is(SPECIFICALLY, search for the two instances of setupAll as somehow there is something wrong with that)
//NOTE: Currently this file is for dependency management only but we would like
// to convert all of the build to gradle from the ant files. We needed to add dependency
// management so did so with gradle first as a first step in the process of evolution
allprojects {
apply plugin: 'java'
apply plugin: 'eclipse'
buildDir = 'output'
task hello << { task -> println "I'm $task.project.name" }
build << { task -> println "MASTER: I'm building now classpath=$sourceSets.main.compileClasspath.files" }
}
project(':toneserver') {
dependencies {
compile fileTree(dir: 'play-1.2.4/framework/lib', include: '*.jar')
compile fileTree(dir: 'play-1.2.4/framework', include: '*.jar')
compile project(':master')
compile project(':webserver')
}
task eclipse(overwrite: true) {
}
}
project(':webserver') {
dependencies {
compile fileTree(dir: 'play-1.2.4/framework/lib', include: '*.jar')
compile fileTree(dir: 'play-1.2.4/framework', include: '*.jar')
compile project(':master')
}
//playframework has it's own generation of .classpath and .project fils so do not
//overwrite their versions
task eclipse(overwrite: true) {
}
}
project(':master') {
project.ext.genLibDir = file('lib')
project.ext.fixedLibDir = file('libother')
repositories {
mavenCentral()
}
dependencies {
compile group: 'org.hibernate', name: 'hibernate-entitymanager', version: '4.1.4.Final'
compile group: 'org.slf4j', name: 'slf4j-api', version: '1.6.6'
compile group: 'org.slf4j', name: 'log4j-over-slf4j', version: '1.6.6'
compile group: 'ch.qos.logback', name: 'logback-core', version: '1.0.6'
compile group: 'joda-time', name: 'joda-time', version: '2.1'
compile group: 'com.google.inject',name: 'guice', version: '3.0'
compile group: 'com.google.protobuf',name: 'protobuf-java', version: '2.4.1'
//to be erased soon
compile group: 'commons-configuration',name:'commons-configuration',version: '1.8'
compile group: 'org.jboss.netty', name: 'netty', version: '3.2.7.Final'
//compile group: 'org.asteriskjava',name: 'asterisk-java', version: '1.0.0.M3'
compile fileTree(dir: project.ext.fixedLibDir, include: '*.jar')
}
task('copyJars') {
ext.collection = files { genLibDir.listFiles() }
delete ext.collection
copy { from configurations.compile into genLibDir }
copy { from fixedLibDir into genLibDir }
}
tasks.setupAll.dependsOn(copyJars)
}
subprojects {
version = 'Developer-Build'
//configurations.compile {
// exclude group: 'javax.jms', module: 'jms'
// exclude group: 'com.sun.jdmk', module: 'jmxtools'
// exclude group: 'com.sun.jmx', module: 'jmxri'
//}
task('setupAll', dependsOn: ['eclipse']) {
description = 'Update jars from remote repositories and then fix eclipse classpath for master project'
}
hello << {println "- I depend on stserver"}
build << { println "subproject:source sets=$sourceSets.main.java.srcDirs" }
}
task release << { println "putting together release" }
//TODO: have a release task AND if version is null when running the release task
//throw an exception telling the user to pass in a version with "./build -Dversion=xxxx"
//The automated build will call the release task with a version number like that
gradle.taskGraph.whenReady {taskGraph ->
if (taskGraph.hasTask(release) && version == 'Developer-Build') {
throw new StopExecutionException("You must specify -Dversion=<some version> to run the release task")
} else {
version = '1.0-SNAPSHOT'
}
}
What is going on with this? Overriding tasks to depend on other stuff should work pretty easily I though(maybe that syntax is still wrong?)
thanks,
Dean
never mind, stupid mistake, forgot my task was in subprojects and should be outside and needed a : as well so new setupAll is outside subprojects and is
task('setupAll', dependsOn: [':master:copyJars', 'eclipse']) {
description = 'Update jars from remote repositories and then fix eclipse classpath for master project'
}

Resources