I have two Gradle projects, A and B. B is a simple Java application and is consumed by A as a compile project dependency. A is a web application.
Both A and B apply the java plugin, A applies the war plugin as well.
When building A, I get the following error:
FAILURE: Build failed with an exception.
* What went wrong:
Could not determine the dependencies of task ':war'.
> Configuration with name 'default' not found.
When separately building B I get no errors. When building from root, I get no errors either. The issue shows up only when building A.
I've also tried copying the B.jar to the lib folder of A and setting a dependency:
compile files("lib/B.jar")
The build in this case works fine.
What configurations do I need to include to avoid the error?
It's possible, when one subproject doesn't see another, if settings.gradle file is not on the parent directory for both subprojects and the subprojects in it are included via includeFlat. In this case you can call any task from your parent projects and all subprojects will know about each other, but it'll be unable to build separate subproject.
Any way, you need to show your project structure and build/settings files as well, to find out the problem.
Related
I have a multi-project setup and I am defining a project as a dependency in the build.gradle file. But that project is being replaced by another project in the same hierarchy. How do I stop this from happening?
Consider the project structure as:
A/B/C1/D/src
A/B/C2/D/src
In the build.gradle file inside C1/D, I have defined the project C2/D as a dependency. But then on calling the build task, the dependency C2/D gets replaced by C1/D which is resulting in the following error:
Circular dependency between the following tasks:
:B:C1:D:compileJava
\--- :B:C1:D:compileJava (*)
The build runs fine if I call :C1:build but on calling the build task the error appears.
On running the :B:C1:D:dependencies I can see the following:
+--- project :B:C2:D -> project :B:C1:D (*)
How can I stop this from happening?
Since the signatures (class names with packages) are the same, gradle takes code from the same project in build task. I would suggest using different names for the code in both projects (for example impl infix).
Otherwise you need to have a lot of resources (time and willingness) and use separate classloaders for the resources explicitly.
I have following structure:
ProjectA -> depends on ProjectB
ProjectB -> depends on ProjectC
compiling projectB everything works:
ProjectB/build.gradle:
dependencies {
compile project(':ProjectC')
}
ProjectB/settings.gradle:
include ':ProjectC'
project(':ProjectC').projectDir = new File(settingsDir, '../ProjectC')
However, compiling ProjectA it says it can not find ProjectC
ProjectA/build.gradle:
dependencies {
compile project(':ProjectB')
}
ProjectA/settings.gradle:
include ':ProjectB'
project(':ProjectB').projectDir = new File(settingsDir, '../ProjectB')
This will show following error:
Where:
Build file ProjectB\build.gradle
What went wrong:
A problem occurred evaluating project ':ProjectB'.
Project with path ':ProjectC' could not be found in project ':ProjectB'.
I Could only make it work including ProjectC in ProjectA. But this is not what I want.
I also tried to exclude on ProjectA but didnt work
ProjectA/build.gradle:
dependencies {
compile (project (':ProjectB')) {
exclude module: ':ProjectC'
}
}
But shows same error.
How can I fix this?
Multi-Project builds are not cascadable. You can have either one or no settings.gradle file in a multi-project build, but not multiple.
Besides that it is not working as expected, it can even get more confusing if you call Gradle from different directories. Gradle looks up (and to the side into directories called master) to find the nearest settings.gradle if none is specified. Then it evaluates the settings.gradle and checks whether the project in which your working directory is, is part of the multi-project build defined in that settings.gradle file. If so, it is executed in the context of the multi-project build, if not, it is executed as standalone build.
This means, if you call Gradle from inside ProjectA, you have a completely different build that probably als is configured differently, than if you call Gradle from inside ProjectB.
If you want to compose multiple multi-project builds into one build, you should instead use GradleBuild tasks or composite builds. In both cases the sub-build is completely independent and can itself be a multi-project build. Which one to use depends on the exact use-case.
With gradle you should be using only a single settings.gradle file. See Multiple settings gradle files for multiple projects building
Also just follow gradle multiproject documentation.
I'm attempting to build two Maven projects from Eclipse. One project constitutes a set of dependencies and libraries to be used for the other project which contains all of my source code. Both are configured as Maven projects using Tycho 1.0.0 .
I have a parent POM file that contains three modules: a folder containing my target file, the plugin containing the dependencies and the plugin that contains the source code. When trying to maven build on the parent POM, I get the following error:
Failed to execute goal org.eclipse.tycho:tycho-compiler-plugin:1.0.0:compile (default-compile) on project com.ericsson.cd-editor.ui: Execution default-compile of goal org.eclipse.tycho:tycho-compiler-plugin:1.0.0:compile failed: A required class was missing while executing org.eclipse.tycho:tycho-compiler-plugin:1.0.0:compile: freemarker/template/Configuration
Gonna post the full error log in pastebin since it's diffcult to read in a Stack Overflow post:
http://pastebin.com/EYnsqvpJ
Here is my parent POM file:
http://pastebin.com/wSAtwspV
I've been told by a colleague of mine that the reason this might be happening is that this dependency might be used by Tycho and cannot be found. The freemarker package is however available in my .m2/repository/.
It's really hard to tell where the error might be.
First, make sure the jar you have in your m2 archive actually contains the class the compiler is looking for.
You could check whether you dependencies are in the central maven repository, instead of making a project containing them.
Does the project that needs all the dependencies state them explicitly, e.g., in feature.xml or Manifest.mf? Otherwise tycho will not load them, even if they are accessible to maven.
Posting the pom.xml files for the modules might be helpful. Hope you'll figure it out :)
I have 2 projects, Project A and Project B. Project A is a Play2 App that depends on Project B (which is a client library.) Currently Project B is pulled from our artifactory with SBT. I would like to set up IntelliJ such that Project B is pulled from the project source on my computer, rather than from the artifactory that is specified in.
I have added Project B as a module of Project A and added Module B to the dependencies of Module A. I then ordered Module B to be at the very top of the dependency list. The static analysis of the code seems to be working fine, there's not compilation errors showing when I updated Project A's code to use a new method signature that I've updated in Project B. However, when I run the Play App I get a compilation error stating that the method signature is incorrect.
Is there a way to override the module used at runtime for SBT and the Play App?
You can do this via sbt. In your build.sbt, for example:
val localDep = ProjectRef(file("/Users/me/projects/b"), "b")
dependsOn(localDep)
IntelliJ will import this dependency as a module. You should remove the library dependency however, to avoid conflicting classpaths.
Naturally, this makes the project hard to share unless other developers have the project in the same location. In that case, I would create a multi-project build instead, which is usually the best choice for tightly coupled projects with individual resulting artifacts.
Another option is a git project dependency:
val projectDep = ProjectRef(uri("git://github.com/me/b"),"b")
I have a multi-module project with test dependencies between modules.
Layout:
main-module - has SpecialsTableQueryBuilderTest that depends on AbstractTestHelper from the generic-search module
generic-search - has AbstractTestHelper
The problem: is that when I run "Make project" the SpecialsTableQueryBuilderTest class it complains that it "cannot find symbol, symbol: class AbstractTestHelper".
I tried in the modules settings, for the main-module, dependencies tab to move the generic-search module up, but it didn't help.
Another thing I tried on the same dependencies tab, it was to add the folder output for test-classes ("/target/test-classes")from the generic-search module as dependencie
What can I do so my project setup to see the AbstractTestHelper class?
Instead of trying to build one project at a time, I suggest trying to run the test of interest. This will build that class and everything it depends on (often a few classes you didn't really need) but it does all this for you.
If you are trying to include a class from a test module into another test module, you need to export it as this is not how maven projects work by default. You can have maven also build it's tests into an additional jar which you can include as a dependency.
Here is instructions on how to build a test JAR http://maven.apache.org/plugins/maven-jar-plugin/examples/create-test-jar.html