Gradle Module Execution Order - module

I have a gradle project with two modules.
The first module (A) produces an archive that the second module (B) makes use of. I've defined the settings.gradle file so that A is seen before B.
At the end of A, there is an install task that is called which will make the archive available for B, however the install task won't execute until all modules build.
When I use A's build file, or set the build command -p it will still try to find dependencies for project B. I don't want to do this!
How can I set this up so that module B will wait completely for module A to finish?

I've defined the settings.gradle file so that A is seen before B.
Order doesn't matter here.
At the end of A, there is an install task that is called which will make the archive available for B
The correct way to handle this is to make the outputs of A available to B via a project dependency. In the simplest case, B's build.gradle will contain the following:
dependencies {
compile project(":A") // could be something other than 'compile'
}
When I use A's build file, or set the build command -p it will still try to find dependencies for project B.
Most likely there is a problem with one of your build scripts, namely that it does work in the configuration phase that should be done in the execution phase.
How can I set this up so that module B will wait completely for module A to finish?
There is no good way. Gradle executes a graph of tasks, not a list of projects. As long as task dependencies are correct, the former will have no drawbacks, only advantages. Often, Gradle can figure out task dependencies automatically (especially between projects).

Related

How to print all dependencies in meson?

I checked out a gtk project inside a docker and during meson build found many dependencies are missing eg. libwayland-dev, libxrandr-dev...
Because meson fails at the first missing dependency, I had to redo this over and over to get install the entire list of dependencies that will be looked for using pkg-config. And, in projects with multiple git submodules, this becomes a lengthy process.
Wondering if I'm doing this whole thing wrong or if there is a way to get to the complete list of dependencies.
To get dependencies for your project, from build directory run:
meson introspect --dependencies

Listing app's Android dependencies from within a Gradle task

I am building a Gradle plugin that checks the dependencies of an app for a particular version of my library, and downloads a configuration file specific to that version.
Question: How can a plugin get all/some dependencies' versions of the project into a string?
In a way, I want to have a task which consumes (and then parses) the screen output of the androidDependencies task.
What have I tried:
Read the project's dependencies as they are. Didn't work as I could only get the dependencies before they are resolved into actual versions (the '+' version, or some other resolve strategy the app might exhibit).
Reverse-engineered the androidDependencies task to see how I could do the same, and instead of println, append to a string. Too time-consuming, and didn't feel like the right approach anyway.
From within a task in my plugin, spawn a process that executes ./gradlew dependencies and directs the output of that process into a string. This works but launching a new gradle daemon takes time, and the task finishes in about 5 seconds instead of what should be instantaneous.
Is there a better solution?

Multiple Project Gradle Setup with Intellij

I have two gradle projects. Project A includes Project B as a dependency. I have them both imported into intellij, With the same setup using maven, I could update project B and run Project A would immediately see the changes. With gradle I must run gradle build on project B and then refresh project A in intellij. Is there a trick to make this more dynamic?
If A and B were part of the same multi-project build, you could have A import B in this way:
dependencies {
compile project(':B')
}
Then, changes to B should immediately be visible to A. In other words, a change in B might cause a failed build in A as soon as IntelliJ detects that A is out of date and builds it.
However, it sounds like this is not the case, so A is actually importing B from some remote repo?
dependencies {
compile "com.stackoverflow.example:B:1.12"
}
In the later case, when Gradle (or IntelliJ) compiles project A, it actually uses the version of B which is in your local gradle cache, or towards the remote repo. Either way, Gradle won't see changes made in B until those changes are built and published to the repo.

How can I tell Hudson to build the modules instead of the jobs?

I have a alot of jobs on Hudson, most of which are really small and consist of just a few modules. But one is big and consist of several modules.
When ever I make a commit to our subversion repository for any of those several modules in that big job, Hudson builds the entire job instead of just the module that have changed.
It doesn't matter if I just scm-polling or a subversion hook, the result is the same.
It seems to me like it would be better if the modules where built instead of the jobs since the other modules in other jobs have dependencies to the modules and not to the jobs.
Can this be configured or do I have to create several jobs instead of the big one? And if so, can I configure the big job to never build when any of it's modules are being triggered but still build when it's own pom.xml is changed?
Thanks.
Hudson has an "Incremental Build" option in the Maven area of the job configuration.
It's hidden in the "Advanced" area.
You could make use of the reactor plugin. For example:
mvn reactor:make-scm-changes
This will only build those modules that have been changed in the SCM. Follow the link for other examples.
Doesn't your compiler offers you the incremental compile option? The java 1.6 compiler usually searches for class and source files and decides using the timestamp to determine whether to use the source or class file. Just leave out the clean goal when building your code.
Another option would be to first run a batch/shell script to determine what files changed and delete the corresponding class files so that the compiler incrementally builds the class files that are missing.

Maven dependency

Hi i have a quite simple question about maven dependency. I have 2 modules of one project. So first module is dependent on second. Second module has dependencies on some libs. Second module can be itself installed as standalone app. So when i build the project the first war will contain packaged second module as well as all libs that second module depends on.
I need that when i package first module the second module should be included without it's dependencies. How it is possible to manage?
Thx
I need that when i package first module the second module should be included without it's dependencies. How it is possible to manage?
Somehow, this is an hint that the dependencies of the 2nd module are provided when it gets packaged inside the war. IOW, declaring the dependencies of the 2nd module with a provided scope would do it, they wouldn't get pulled transitively.
Depending on how you create the standalone distribution of the 2nd module, you might need to combine dependencies scope with profiles, or not. Can't say since you didn't say anything about this :)
References
Dependency Scope