I try to generate apk from Netbeans 8 but I 'am getting an exeception.
Here is the content of my gradle file:
buildscript {
repositories {
maven {
url 'https://oss.sonatype.org/content/repositories/snapshots'
}
jcenter()
}
dependencies {
classpath 'org.javafxports:jfxmobile-plugin:1.3.0-SNAPSHOT'
}
}
apply plugin: 'org.javafxports.jfxmobile'
repositories {
jcenter()
maven {
url 'http://nexus.gluonhq.com/nexus/content/repositories/releases'
}
}
mainClassName = 'com.testgluon.TestGluonMob'
dependencies {
compile 'com.gluonhq:charm:4.2.0'
}
jfxmobile {
android {
manifest = 'src/android/AndroidManifest.xml'
compileSdkVersion = '25'
}
}
I have already installed :
multidex-1.0.1.aar
I saw this answer but no luck. it does n't help me.
Edit: the following is a part of stacktrace (using --info option from Netbeans):
:applyRetrolambda (Thread[Daemon worker Thread 3,5,main]) completed. Took 21.933 secs.
:mergeClassesIntoJar (Thread[Daemon worker Thread 3,5,main]) started.
:mergeClassesIntoJar
Putting task artifact state for task ':mergeClassesIntoJar' into context took 0.001 secs.
Task :mergeClassesIntoJar class loader hash: 83f3637f6805a7b149525a93c5faad58
Task :mergeClassesIntoJar actions class loader hash: fde60ab3b9776111ebd9bf87f24df716
Executing task ':mergeClassesIntoJar' (up-to-date check took 0.172 secs) due to:
Output property 'archivePath' file P:\javafxGluon\TestGluonMob\build\javafxports\tmp\android\multi-dex\allclasses.jar has changed.
:mergeClassesIntoJar (Thread[Daemon worker Thread 3,5,main]) completed. Took 3.91 secs.
:shrinkMultiDexComponents (Thread[Daemon worker Thread 3,5,main]) started.
:shrinkMultiDexComponents
Putting task artifact state for task ':shrinkMultiDexComponents' into context took 0.033 secs.
Task :shrinkMultiDexComponents class loader hash: c54ece983c65e20d963e3e8bb57cfcb0
Task :shrinkMultiDexComponents actions class loader hash: b6f3644e00f5f8abdc2639cc044bf52b
Executing task ':shrinkMultiDexComponents' (up-to-date check took 0.061 secs) due to:
Output property 'outJarFileCollection' file P:\javafxGluon\TestGluonMob\build\javafxports\tmp\android\multi-dex\componentClasses.jar has changed.
ProGuard, version 5.1
Reading program jar [P:\javafxGluon\TestGluonMob\build\javafxports\tmp\android\multi-dex\allclasses.jar]
Reading library jar [C:\Program Files\Android\android-sdk\build-tools\25.0.1\lib\shrinkedAndroid.jar]
Preparing output jar [P:\javafxGluon\TestGluonMob\build\javafxports\tmp\android\multi-dex\componentClasses.jar]
Copying resources from program jar [P:\javafxGluon\TestGluonMob\build\javafxports\tmp\android\multi-dex\allclasses.jar]
:shrinkMultiDexComponents (Thread[Daemon worker Thread 3,5,main]) completed. Took 7.079 secs.
:createMainDexList (Thread[Daemon worker Thread 3,5,main]) started.
:createMainDexList
Putting task artifact state for task ':createMainDexList' into context took 0.03 secs.
Task :createMainDexList class loader hash: c54ece983c65e20d963e3e8bb57cfcb0
Task :createMainDexList actions class loader hash: b6f3644e00f5f8abdc2639cc044bf52b
Executing task ':createMainDexList' (up-to-date check took 0.005 secs) due to:
Output property 'outputFile' file P:\javafxGluon\TestGluonMob\build\javafxports\tmp\android\multi-dex\maindexlist.txt has changed.
:createMainDexList (Thread[Daemon worker Thread 3,5,main]) completed. Took 3.276 secs.
:writeInputListFile (Thread[Daemon worker Thread 3,5,main]) started.
:writeInputListFile
Putting task artifact state for task ':writeInputListFile' into context took 0.029 secs.
Task :writeInputListFile class loader hash: c54ece983c65e20d963e3e8bb57cfcb0
Task :writeInputListFile actions class loader hash: b6f3644e00f5f8abdc2639cc044bf52b
Executing task ':writeInputListFile' (up-to-date check took 0.034 secs) due to:
Output property 'inputListFile' file P:\javafxGluon\TestGluonMob\build\javafxports\tmp\android\dex\inputList.txt has changed.
:writeInputListFile (Thread[Daemon worker Thread 3,5,main]) completed. Took 0.108 secs.
:dex (Thread[Daemon worker Thread 3,5,main]) started.
:dex
Putting task artifact state for task ':dex' into context took 0.034 secs.
Task :dex class loader hash: c54ece983c65e20d963e3e8bb57cfcb0
Task :dex actions class loader hash: b6f3644e00f5f8abdc2639cc044bf52b
Executing task ':dex' (up-to-date check took 0.002 secs) due to:
No history is available.
[ant:java] Java Result: 1
:dex FAILED
:dex (Thread[Daemon worker Thread 3,5,main]) completed. Took 0.246 secs.
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':dex'.
> org.gradle.api.GradleException (no error message)
* Try:
Run with --stacktrace option to get the stack trace. Run with --debug option to get more log output.
BUILD FAILED
Note:
I don't require 25. I can use older version.
When I delete compileSdkVersion = '25', I get the this exception:
Executing: gradle :android
Arguments: [--info]
The client will now receive all logging from the daemon (pid: 5056). The daemon log file: C:\Users\user\.gradle\daemon\3.2.1\daemon-5056.out.log
Starting 14th build in daemon [uptime: 1 hrs 0 mins 21.185 secs, performance: 100%, no major garbage collections]
Executing build with daemon context: DefaultDaemonContext[uid=42b5a162-e19a-4659-8796-8ca0d6e5684c,javaHome=C:\Program Files\Java\jdk1.8.0_60,daemonRegistryDir=C:\Users\user\.gradle\daemon,pid=5056,idleTimeout=10800000,daemonOpts=-XX:MaxPermSize=256m,-XX:+HeapDumpOnOutOfMemoryError,-Xmx1024m,-Dfile.encoding=windows-1252,-Duser.country=FR,-Duser.language=fr,-Duser.variant]
Starting Build
Settings evaluated using settings file 'P:\master\settings.gradle'.
Projects loaded. Root project using build file 'P:\javafxGluon\TestGluonMob\build.gradle'.
Included projects: [root project 'TestGluonMob']
Evaluating root project 'TestGluonMob' using build file 'P:\javafxGluon\TestGluonMob\build.gradle'.
Android install directory: P:\javafxGluon\TestGluonMob\build\javafxports\android
Android temporary output directory: P:\javafxGluon\TestGluonMob\build\javafxports\tmp\android
Resources directory: P:\javafxGluon\TestGluonMob\build\javafxports\tmp\android\resources
Multi-dex output directory: P:\javafxGluon\TestGluonMob\build\javafxports\tmp\android\multi-dex
Dex output directory: P:\javafxGluon\TestGluonMob\build\javafxports\tmp\android\dex
iOS install directory: P:\javafxGluon\TestGluonMob\build\javafxports\ios
iOS temporary output directory: P:\javafxGluon\TestGluonMob\build\javafxports\tmp\ios
Adding C:\Program Files\Android\android-sdk\extras\android\m2repository to project repositories.
Adding C:\Program Files\Android\android-sdk\extras\google\m2repository to project repositories.
All projects evaluated.
Selected primary task ':android' from project :
Tasks to be executed: [task ':validateManifest', task ':collectMultiDexComponents', task ':compileJava', task ':processResources', task ':classes', task ':compileAndroidJava', task ':copyClassesForRetrolambda', task ':applyRetrolambda', task ':mergeClassesIntoJar', task ':shrinkMultiDexComponents', task ':createMainDexList', task ':writeInputListFile', task ':dex', task ':mergeAndroidAssets', task ':mergeAndroidResources', task ':processAndroidResources', task ':processAndroidResourcesDebug', task ':validateSigningDebug', task ':apkDebug', task ':zipalignDebug', task ':android']
Using javafxports version 8.60.8
Configuring Build for Android
Using javafxports dalvik sdk from location C:\Users\user\.gradle\caches\modules-2\files-2.1\org.javafxports\dalvik-sdk\8.60.8\6630ec66e4703c910ac3fd6151a8494c8b59186b\unpacked\dalvik-sdk
Using androidSdk from location: C:\Program Files\Android\android-sdk
There was no buildToolsVersion specified, looking for most recent installed version automatically
Using the following automatically detected buildToolsVersion: 25.0.1
FAILURE: Build failed with an exception.
* What went wrong:
Configured compileSdkVersion is invalid: 21 (C:\Program Files\Android\android-sdk/platforms/android-21
* Try:
Run with --stacktrace option to get the stack trace. Run with --debug option to get more log output.
BUILD FAILED
runnig gradle -v cammand give me :
------------------------------------------------------------
Gradle 3.2.1
------------------------------------------------------------
Build time: 2016-11-22 15:19:54 UTC
Revision: 83b485b914fd4f335ad0e66af9d14aad458d2cc5
Groovy: 2.4.7
Ant: Apache Ant(TM) version 1.9.6 compiled on June 29 2015
JVM: 1.8.0_60 (Oracle Corporation 25.60-b23)
OS: Windows Vista 6.0 x86
The link below show the Android SDK tools already installed:
Android SDK tools installed
jfxmobile {
downConfig {
version = '3.0.0'
plugins 'display', 'lifecycle', 'statusbar', 'storage'
}
android {
manifest = 'src/android/AndroidManifest.xml'
compileSdkVersion=25
buildToolsVersion = '25.0.0'
androidSdk='/Users/USERNAME/Library/Android/sdk'
}
ios {
infoPList = file('src/ios/Default-Info.plist')
forceLinkClasses = [
'com.gluonapplication.**.*',
'com.gluonhq.**.*',
'javax.annotations.**.*',
'javax.inject.**.*',
'javax.json.**.*',
'org.glassfish.json.**.*'
]
}
Please make sure to set your android sdk path as shown in the code above. if you do not have the android SDK, you can download it from here
https://developer.android.com/studio/index.html
in this case you will download android studio (which is fine). Download it and then install the desired version of the SDK you want.
Related
What happened when excute bootJar or run:
> Task :common:compileJava
> Task :common:processResources NO-SOURCE
> Task :common:classes
> Task :common:jar SKIPPED
> Task :api:compileJava FAILED
D:\workspace\IDEA\bootar\api\src\main\java\com\sample\Application.java:3:
����: �����com.sample.common������// looks like package or class not found.
import com.sample.common.CommonClazz;
^
D:\workspace\IDEA\bootar\api\src\main\java\com\sample\Application.java:23:
����: �Ҳ�������
public CommonClazz test() {
^
����: �� CommonClazz
�: �� Application
2 ������
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':api:compileJava'.
> Compilation failed; see the compiler error output for details.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 2s
2 actionable tasks: 2 executed
Actually, the project itself is very simple:
and the gradle files:
The IDE could find CommonClazz and import it into Application, but when I try to run or build the api module, it failed.
I'm using:
IntelliJ IDEA 2019.2 EAP (Ultimate Edition)
Build #IU-192.5587.17, built on July 3, 2019
Runtime version: 11.0.3+12-b304.10 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Windows 10 10.0
GC: G1 Young Generation, G1 Old Generation
Memory: 1270M
Cores: 4
Registry: debugger.watches.in.variables=false, git.explicit.commit.renames.prohibit.multiple.calls=false
Non-Bundled Plugins: Key Promoter X, Lombook Plugin, Property Sorter, cn.yiiguxing.plugin.translate, mobi.hsz.idea.gitignore, GradleDependenciesHelper, com.vladsch.idea.multimarkdown
spring-boot-gradle-plugin:2.1.6.RELEASE
springCloudVersion Greenwich.SR1
I've a Kotlin Spring Boot project here. It has some tests, which run just fine from IntelliJ, but when I run from command line, fail with the following errors.
BUILD FAILED in 1m 12s
7 actionable tasks: 7 executed
asarkar:license-report-kotlin$ ./gradlew clean test
> Task :compileKotlin
Using kotlin incremental compilation
> Task :compileTestKotlin
Using kotlin incremental compilation
> Task :test
2017-07-16 21:43:06.345 INFO 2956 --- [ Thread-13] s.c.a.AnnotationConfigApplicationContext : Closing org.springframework.context.annotation.AnnotationConfigApplicationContext#54fa5525: startup date [Sun Jul 16 21:42:04 PDT 2017]; root of context hierarchy
org.abhijitsarkar.ApplicationTest > testEndToEnd FAILED
java.lang.AssertionError at ApplicationTest.kt:83
org.abhijitsarkar.service.GradleAgentTest > initializationError FAILED
java.lang.ClassNotFoundException
org.abhijitsarkar.service.JGitAgentTest > initializationError FAILED
java.lang.ClassNotFoundException
org.abhijitsarkar.service.LinkVerifierTest > initializationError FAILED
java.lang.ClassNotFoundException
4 tests completed, 4 failed
FAILURE: Build failed with an exception.
What I've tried so far:
Went back and forth between the build.gradle and build.gradle.kts.
Added the Kotlin runtime to the jar kotlinOptions.includeRuntime = true.
Changed package level functions to functions in an object.
What I found weird:
An out directory is created in addition to the usual Gradle build directory.
Some classes/objects are compiled to class files with names ending in Kt. I've not found any rhyme or reason for this, but I'm still new to Kotlin, so I may be missing something.
Your tests (or the actual tested classes) does something strange: They delete somehow the content of the build folder which contains the test-classes.
To see this, try the following:
./gradlew clean testClasses
find build # You get a full list of all main and test classes
./gradlew clean testClasses test
find build # You get a very limited list of resources in the build-folder (must be somehow modified by your code)
If you deactivate all your tests and just add the following (just for testing purpose) in there:
import io.kotlintest.matchers.*
import io.kotlintest.specs.*
class MyTests : StringSpec() {
init {
"length should return size of string" {
"hello".length shouldBe 5
}
}
}
If you again gradle-test it,
./gradlew clean testClasses test
find build # all resources again available
Check your tests for the problem.
I have a task of type Javadoc like this:
class CreateJavadocsTask extends Javadoc{
#TaskAction
def action1()
{
project.source = project.android.sourceSets.main.java.srcDirs
options.linkSource true
classpath += project.files(project.android.getBootClasspath().join(File.pathSeparator))
failOnError false
}
}
This task gives an error that task is up to date as it has no source files:
Baloe is the stacktrace :
Using incremental javac compilation.
Incremental java compilation is an incubating feature.
Not using incremental javac compilation.
Using incremental javac compilation.
Not using incremental javac compilation.
Using incremental javac compilation.
All projects evaluated.
[buildinfo] Not using buildInfo properties file for this build.
Selected primary task 'createJavadocs12' from project :
Tasks to be executed: [task ':bluetooth:createJavadocs12']
:bluetooth:createJavadocs12 (Thread[main,5,main]) started.
:bluetooth:createJavadocs12
Skipping task ':bluetooth:createJavadocs12' as it has no source files.
:bluetooth:createJavadocs12 UP-TO-DATE
:bluetooth:createJavadocs12 (Thread[main,5,main]) completed. Took 0.034 secs.
You are assigning the inputs of the task during execution time. You will need to declare the inputs outside of the task action. Otherwise, Gradle won't be able to determine inputs/outputs of the task during configuration time and therefore mark it up-to-date.
The following part is a part of my build.gradle file:
project(":App") {
dependencies {
compile(project(':Shared'))
compile(project(':Subproject1'))
compile(project(':Subproject2'))
compile(project(':Subproject3'))
compile(project(':Subproject4'))
compile(project(':Subproject5'))
}
jar {
manifest {
attributes(
'Main-Class': 'com.my.App.Main',
)
}
}
// To run, use: $ gradle :App:fatJar
task fatJar(type: Jar) {
println "fatJarBuild(): 1"
manifest.from jar.manifest
println "fatJarBuild(): 2"
classifier = 'all'
println "fatJarBuild(): 3"
from {
configurations.runtime.collect {
println "fatJarBuild(): collect" + it.absolutePath
it.isDirectory() ? it : zipTree(it)
}
} {
exclude "META-INF/*.SF"
exclude "META-INF/*.DSA"
exclude "META-INF/*.RSA"
}
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
println "fatJarBuild(): 4"
with jar
}
}
Now, whenever I slightly modify a file in my codebase, it takes substantial time to finish fatJar task:
[... End of "./gradlew :App:fatJar --info" follows ... ]
:App:compileJava (Thread[Daemon worker Thread 13,5,main]) completed. Took 0.164 secs.
:App:processResources (Thread[Daemon worker Thread 13,5,main]) started.
:App:processResources
Skipping task ':App:processResources' as it is up-to-date (took 0.002 secs).
:App:processResources UP-TO-DATE
:App:processResources (Thread[Daemon worker Thread 13,5,main]) completed. Took 0.002 secs.
:App:classes (Thread[Daemon worker Thread 13,5,main]) started.
:App:classes
Skipping task ':App:classes' as it has no actions.
:App:classes (Thread[Daemon worker Thread 13,5,main]) completed. Took 0.0 secs.
:App:fatJar (Thread[Daemon worker Thread 13,5,main]) started.
:App:fatJar
Executing task ':App:fatJar' (up-to-date check took 0.003 secs) due to:
Input file /home/work/App/BrainThread.class has changed.
:App:fatJar (Thread[Daemon worker Thread 13,5,main]) completed. Took 5.993 secs.
BUILD SUCCESSFUL
Total time: 7.051 secs
Stopped 0 compiler daemon(s).
Received result Success[value=null] from daemon DaemonInfo{pid=30179, address=[c5e7f6f0-985b-48cc-88b0-ebc8aed7e75b port:33465, addresses:[/0:0:0:0:0:0:0:1%lo, /127.0.0.1]], idle=true, context=DefaultDaemonContext[uid=cc8b9da5-88b5-476a-9cf5-430af98f7f5a,javaHome=/usr/lib/jvm/java-8-openjdk-amd64,daemonRegistryDir=/home/user/.gradle/daemon,pid=30179,idleTimeout=10800000,daemonOpts=-XX:MaxPermSize=256m,-XX:+HeapDumpOnOutOfMemoryError,-Xmx1024m,-Dfile.encoding=UTF-8,-Duser.country=US,-Duser.language=en,-Duser.variant]} (build should be done).
You can see that BrainThread.class was modified and as an effect some heavy machinery started.
Can I make my build.gradle more time efficient?
Maybe someone else will come along and tell me I'm wrong, but IMO 5 seconds is not unreasonable time to build a fatjar. The task as defined
Unpacks the jar file of every single dependency,
Consolidates the unpacked files, along with your project class files and then
Repackages everything into a new jar.
Depending on how many dependencies you have, 5 seconds seems fairly ok to me. Unless the underlying Zip task is somehow optimized, I do not see this timing change.
A couple of things you can thing about though:
You could move the fatjar task out of your standard build cycle, which runs for every change. You could only run the fatjar task when you're doing a release. In most cases you should be able to test changes locally without having to build a fatjar as you have all the dependencies available anyway.
For a single file change, you're doing the unpack-repack dance with a whole lot of dependency jar. Maybe you can write an optimized fatjar task that unpacks the old fatjar, replaces the changed file and repacks it, reducing the number of file operations required.
EDIT: I just looked at the gradle shadow jar plugin, and realized that it does exactly what I described #2 above, makes incremental changes in place to the fatjar, which should give you palpable performance improvements.
Confused by ordering in Gradle. I'm a novice, previously used Ant for builds, having a play with Gradle which may explain some of this
Brief background (in case anyone would be asking "why would you do that").
We ship a Java WebStart app in a war file. Java 7 (-40 onwards) is prompting users about incorrectly formatted jar files with missing elements. I would like to automate a process that gets the war; extracts the jars for JavaWS from 'bin' folder; adds elements to the Manifest
Later I'll get to re-signing the jars and re-assembling the war, but for now I just want to get to adding the Manifest entries.
My problem is that I have defined tasks that have dependsOn elements but the tasks seem to run in the wrong order (see gradle file below).
What I expect is the tasks to run in sequence: delete dir; get war; unwar the war; add elements to the jar.
What I see (from log file) is: elements are added to jar, effectively this creates a new jar, the dir is deleted and the war is unwar'ed so I end up with the original war file contents.
I checked: Gradle Task To Call Other Tasks In Order however, I don't seem able to use mustRunAfter at all, could be related to version of gradle I have, but anyway I don't really want to control order of disparate tasks, I would prefer (in my Ant based thinking) that I can define the order I want by having tasks depend on each other.
Can anyone see the flaw in my build file?
NOTE: if I remove the "dependsOn" from the resignclientjars task and run it manually after running the other tasks, it all works fine and I get my jars with the new elements in the Manifest, so I have a workable workaround, but would prefer to know what I'm doing wrong here.
task (deletework, type: Delete) {
delete 'workYYY'
}
task (getlaganwar, type: Copy, dependsOn: deletework) {
from "d:/dev/v8-0-5/wars"
into "workYYY"
include 'lagan.war'
}
task (unwar, type: Copy, dependsOn: getlaganwar) {
from zipTree(file('workYYY/lagan.war'))
into file("workYYY/lagan")
}
task (resignclientjars, type: Copy, dependsOn: unwar) {
//task (resignclientjars, type: Copy) {
// mustRunAfter unwar
def workDir = file("workYYY/lagan")
def binDir = file(new File(workDir, "bin"))
def collection = files { binDir.listFiles() }
collection.each {
File jarFile = new File(binDir, it.name)
ant.echo(message: "updating:${jarFile.absolutePath}")
ant.jar(jarfile: jarFile, update: 'true') {
manifest {
attribute(name: 'Implementation-Title', value: 'Lagan Enterprise')
attribute(name: 'Implementation-Vendor', value: 'Lagan Enterprise')
attribute(name: 'Implementation-Version', value: 'Lagan Enterprise')
attribute(name: 'Application-Name', value: 'Lagan Enterprise')
attribute(name: 'Permissions', value: 'all-permissions')
}
}
}
}
//unwar.mustRunAfter getlaganwar
//getlaganwar.mustRunAfter deletework
//resignclientjars.mustRunAfter getlaganwar
Debug Output contains the following:
[sts] -----------------------------------------------------
[sts] Starting Gradle build for the following tasks:
[sts] :resignclientjars
[sts] -----------------------------------------------------
12:06:19.658 [WARN] [org.gradle.api.internal.project.ant.AntLoggingAdapter] [ant:echo] updating:D:\dev\util\java7-clientjars\workYYY\lagan\bin\DebugWinIEBrowser.jar
12:06:19.666 [WARN] [org.gradle.api.internal.project.ant.AntLoggingAdapter] [ant:echo] updating:D:\dev\util\java7-clientjars\workYYY\lagan\bin\DebugWinMSWord.jar
12:06:19.670 [WARN] [org.gradle.api.internal.project.ant.AntLoggingAdapter] [ant:echo] updating:D:\dev\util\java7-clientjars\workYYY\lagan\bin\WinIEBrowser.jar
12:06:19.674 [WARN] [org.gradle.api.internal.project.ant.AntLoggingAdapter] [ant:echo] updating:D:\dev\util\java7-clientjars\workYYY\lagan\bin\WinMSWord.jar
12:06:19.690 [INFO] [org.gradle.execution.TaskNameResolvingBuildConfigurationAction] Selected primary task ':resignclientjars'
12:06:19.692 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Waiting to acquire exclusive lock on task artifact state cache (D:\dev\util\java7-clientjars\.gradle\1.5\taskArtifacts).
12:06:19.692 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Lock acquired.
12:06:19.692 [INFO] [org.gradle.BuildLogger] Tasks to be executed: [task ':deletework', task ':getlaganwar', task ':unwar', task ':resignclientjars']
12:06:19.693 [DEBUG] [org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter] Starting to execute task ':deletework'
12:06:19.693 [DEBUG] [org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter] Determining if task ':deletework' is up-to-date
12:06:19.694 [INFO] [org.gradle.api.internal.changedetection.ShortCircuitTaskArtifactStateRepository] Task ':deletework' has not declared any outputs, assuming that it is out-of-date.
12:06:19.694 [DEBUG] [org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter] task ':deletework' is not up-to-date
12:06:19.695 [DEBUG] [org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter] Executing actions for task ':deletework'.
12:06:19.695 [DEBUG] [org.gradle.api.internal.file.copy.DeleteActionImpl] Deleting D:\dev\util\java7-clientjars\workYYY
12:06:19.934 [DEBUG] [org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter] Finished executing task ':deletework'
12:06:19.934 [LIFECYCLE] [org.gradle.TaskExecutionLogger] :getlaganwar
12:06:19.934 [DEBUG] [org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter] Starting to execute task ':getlaganwar'
12:06:19.936 [DEBUG] [org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter] Determining if task ':getlaganwar' is up-to-date
12:06:19.942 [INFO] [org.gradle.api.internal.changedetection.DefaultTaskArtifactStateRepository] Executing task ':getlaganwar' due to:
Output file D:\dev\util\java7-clientjars\workYYY for task ':getlaganwar' has changed.
Output file D:\dev\util\java7-clientjars\workYYY\lagan.war has been removed for task ':getlaganwar'.
12:06:19.942 [DEBUG] [org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter] task ':getlaganwar' is not up-to-date
12:06:19.944 [DEBUG] [org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter] Executing actions for task ':getlaganwar'.
12:06:20.564 [DEBUG] [org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter] Finished executing task ':getlaganwar'
12:06:20.565 [LIFECYCLE] [org.gradle.TaskExecutionLogger] :unwar
12:06:20.565 [DEBUG] [org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter] Starting to execute task ':unwar'
12:06:20.586 [DEBUG] [org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter] Determining if task ':unwar' is up-to-date
12:06:20.588 [DEBUG] [org.gradle.api.internal.changedetection.DefaultFileCacheListener] Can cache files for ZIP 'D:\dev\util\java7-clientjars\workYYY\lagan.war'
12:06:20.588 [DEBUG] [org.gradle.api.internal.changedetection.DefaultFileCacheListener] Can cache files for file 'D:\dev\util\java7-clientjars\workYYY\lagan'
12:06:24.096 [INFO] [org.gradle.api.internal.changedetection.DefaultTaskArtifactStateRepository] Executing task ':unwar' due to:
Output file D:\dev\util\java7-clientjars\workYYY\lagan for task ':unwar' has changed.
12:06:24.097 [DEBUG] [org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter] task ':unwar' is not up-to-date
12:06:24.100 [DEBUG] [org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter] Executing actions for task ':unwar'.
12:06:27.863 [DEBUG] [org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter] Finished executing task ':unwar'
12:06:27.863 [LIFECYCLE] [org.gradle.TaskExecutionLogger] :resignclientjars
12:06:27.864 [DEBUG] [org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter] Starting to execute task ':resignclientjars'
12:06:27.864 [INFO] [org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter] Skipping task ':resignclientjars' as it has no source files.
12:06:27.864 [DEBUG] [org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter] Finished executing task ':resignclientjars'
12:06:27.864 [LIFECYCLE] [org.gradle.TaskExecutionLogger] :resignclientjars UP-TO-DATE
12:06:27.865 [DEBUG] [org.gradle.execution.taskgraph.DefaultTaskGraphExecuter] Timing: Executing the DAG took 8.173 secs
12:06:27.865 [LIFECYCLE] [org.gradle.BuildResultLogger]
12:06:27.865 [LIFECYCLE] [org.gradle.BuildResultLogger] BUILD SUCCESSFUL
12:06:27.865 [LIFECYCLE] [org.gradle.BuildResultLogger]
12:06:27.866 [LIFECYCLE] [org.gradle.BuildResultLogger] Total time: 8.886 secs
The unpredictable dependency ordering in Gradle is really annoying.
Here is workaround for executing the dependent tasks in order:
task dist(type: Zip) {
def tasks = [clean, jar, test, docs]
for (int i = 0; i < tasks.size() - 1; i++) {
tasks[i + 1].mustRunAfter(tasks[i])
}
dependsOn(tasks)
//...other stuff
}
Probably this workaround could be extracted in reusable manner as strictDependsOn()...
You're using Gradle 1.5, and mustRunAfter dates from 1.6. The current version is 1.8.
dependsOn doesn't fix any order for the tasks. This has been discussed ad nauseam in various bug reports. The workaround is to use depencencies between indifidual tasks, or mustRunAfter.
The problem with your build script isn't the task dependencies, but that the task definition for resignclientjars is incorrect. It's doing its work in the configuration phase (i.e. for every build invocation whatsoever) instead of the execution phase. A correct task definition would look as follows:
task resignclientjars(dependsOn: unwar) {
doLast {
...
}
}
You can read up on configuration phase vs. execution phase in the Gradle User Guide or the Gradle forums.
For whatever reason gradle does guarantee order for dependsOn, after time they added mustRunAfter, which however you have to chain yourself like a idiot, so here is a utility:
task buildAppRelease() {
group = "build"
dependsOn ordered(":allClean", ":allTestReleaseUnitTest", ":app:assembleRelease")
}
def ordered(String... dependencyPaths) {
def dependencies = dependencyPaths.collect { tasks.getByPath(it) }
for (int i = 0; i < dependencies.size() - 1; i++) {
dependencies[i + 1].mustRunAfter(dependencies[i])
}
return dependencies
}
I found that it works if I use both dependsOn and mustRunAfter. Here is an example of running two tasks, one (custom registered "importUnicodeFiles" task) that is in "this" project and one (predefined "run" task) that is in a sibling project named ":unicode":
tasks.register("rebuildUnicodeFiles") {
description = "Force the rebuild of the `./src/main/resources/text` data"
val make = project(":unicode").tasks["run"]
val copy = tasks["importUnicodeFiles"]
dependsOn(make)
dependsOn(copy)
copy.mustRunAfter(make)
}
I have been able to use dependsOn and mustRunAfter as below to define order for the tasks. Note, here I want to run ktlintFormat first then run ktlint.
ktlint.mustRunAfter ktlintFormat
compileKotlin.dependsOn ktlintFormat,ktlint