Is there a way to tell Gradle
"Hey, there's a build.gradle.kts in the directory some/subdir, but please act like it's not there and don't try to mess with it at all"?
I have to keep a non-Android Kotlin project in an Android repository with a build.gradle.kts-file in the repository root for ... reasons ... and it keeps breaking my build due to plugin version conflicts.
The hierarchy layout is as follows:
|-- build.gradle.kts
|-- settings.gradle.kts
|-- src/
|-- android_project_a/
|-- build.gradle.kts
|-- android_project_b/
|-- build.gradle.kts
|-- kotlin_project/
|-- build.gradle.kts // This is what I need to exclude
If you are using command line to build, You can execute subdir as following
gradle build -x kotlin_project:build
But this is not a nice way to have it done, I wanted to check your build.gradle and setting.gradle, As you can change that once and for all, If you change the sub-projects and implementation of your sub-projects.
This kotlin_project should be a part of your setting.gradle as its being build automatically when you trigger root dir build.
You can exclude it if you want, But you have to remove it as well from dependencies at your build.gradle
Related
I have a 2 root projects in gradle one main root project1 from where I invoke gradle build and has settings.gradle which includes subprojects to build
Another root project2 where I have settings.gradle which includes subprojects to build
Rootproject1
build.gradle
settings.gradle
Rootproject2
build.gradle
settings.gradle
I want to inlcude Rootproject2 in my Rootproject1 settings.gradle file so that from Rootproject1 (gradle build) should build Rootproject1 as well as Rootproject2
include/inlcudeFlat -- it is relative to rootproject
There should be one settings.gradle which will be placed inside the primary root folder and you will need to write:
include ':Rootproject1',
':Rootproject2'
Then, in the build.gradle file of Rootproject1, you will need to write:
dependencies {
implementation project(path: ':Rootproject2')
}
[Updated on Jan 23, 2019] Something like following:
Root
|------ Rootproject1
|
|------ Rootproject2
|
|------ settings.gradle
I am trying to use Maven Archetypes to create a basic directory structure for a new project that is just a parent to several child projects. The structure inside archetype-resources looks like this:
root
|--- pom.xml
|--- subproject1
| \--- foo.xml
|
\--- subproject2
\--- bar.xml
Instead of generating this structure, I get the following error:
Template 'subproject1/foo.xml' not in directory 'src/main/java'
Is there a way to tell Maven to not assume the archetype is generating a Maven Java project?
I have projects built by Maven and Gradle. Is there a way to define dependency versions in a text file, e.g.:
.
|-- dep-versions.properties
|
|-- proj-by-gradle
| |-- build.gradle
| `-- settings.gradle
|
`-- proj-by-maven
`-- pom.xml
Is there an easy way to specify in dep-versions.properties, something like:
com.google.guava:guava = 26.0-jre
org.apache.commons:commons-pool2 = 2.5.0
And then use these versions in both the pom.xml and build.gradle?
You can create a BOM pom (Bill of materials) and use it in both builds. Support for importing maven BOM files was added to Gradle in version 4.6: https://docs.gradle.org/4.6/release-notes.html#bom-import
i have a project layout like
sample/
A/
src/
main/
java/
A.java
res/
A.jpg
B/
src/
main/
java/
B.java
res/
B.jpg
build.gradle
settings.gradle
how to create two separate jar files(A.jar/B.jar)
A.jar includes A.java, A.jpg
B.jar includes B.java, B.jpg
Here you can find a sample project. Basically all configuration is put in build.gradle and settings.gradle files:
build.gradle
subprojects {
apply plugin: 'java'
}
settings.gradle
include 'A', 'B'
We have a (until now) small project, which consists of 4 eclipse projects. The main project consists of all the needed libs and an Ant script.
Now we want to convert this project(s) to Maven, while keeping the project stucture.
How it works:
Ant script compiles all projects (without main) to jar files
Ant script copies all those jar files into the lib folder of the main project
Ant script copies some static files (html, css, js, etc.) from the modules into some corresponding folders of the main project
Ant generates a war archive of the main project
The (maybe) problem with Maven:
All projects depend on main project
so I think it's not possible to use Maven's normal compiling behaviour
I read a bit about Maven's possibilities and it looks like the assembly plugin could solve the problem?! But I don't know how to get all that stuff working...
I thought of this project layout:
+ parent-pom (with packaging: pom)
- main-war (packaging: war)
- module1 (packaging: jar, depends on main-war)
- module2 (packaging: jar, depends on main-war)
- module3 (packaging: jar, depends on main-war and module1)
Now the parent-pom must have the <build> directive with the assembly plugin I think?
Please help me. Thank you :)
I would first suggest to change the structure of your project which means having the following folder layout:
+-- root (pom.xml packaging: pom)
+--- module1 (packaging: jar: depends on: module-common)
+--- module2 (packaging: jar: depends on: module-common)
+--- module3 (packaging: jar: depends on: module1, module-common)
+--- module-common (packaging: jar)
+--- module-war (packaging: war, depends on: module1, module2, module3)
The mentioned dependency to the war module does not make sense, cause usually you have a module which depends on an other but not on a war mdoule. So to solve that problem the simplest solution is to introduce a separate module-common which should take the code which is common for all modules. The war module has folders for html, static files etc. with a layout like the following:
.
|-- pom.xml
`-- src
`-- main
|-- java
| `-- com
| `-- example
| `-- projects
| `-- SampleAction.java
|-- resources
| `-- images
| `-- sampleimage.jpg
`-- webapp
|-- WEB-INF
| `-- web.xml
|-- index.html
`-- jsp
`-- websource.jsp
If you handle the things in a a structure like the above you don't need to use assembly plugin or what ever plugin to copy files etc. it will be handled by default. As a result you will get a war file which contains the things you need.