In the gradle documentation says:
Builds which utilize a buildSrc directory will generate a second
profile report for buildSrc in the buildSrc/build directory.
How can we do that (utilize build/Src) via the gradle sript, couldn't you help me?
You may put your helper scripts/classes to various places. One of them is buildSrc directory.
See below quote from gradle documentation.
When you run Gradle, it checks for the existence of a directory called
buildSrc. Gradle then automatically compiles and tests this code and
puts it in the classpath of your build script. You don't need to
provide any further instruction. This can be a good place to add your
custom tasks and plugins.
Your qoute only tells that if you use buildSrc directory, you will have second profile report.
Related
Running ./gradlew quarkusGenerateCode works well, however the generated sources fall under the build directory:
I wouldn't like to set this path as a Gradle SourcesSet, "Mark Directory As" Generated Sources Root in Intellij, and so on as it's under the build directory.
Is there a way to set the output dir to something such as src/quarkus-generated-sources? The Quarkus user guides and the gradle plugin documentation are not too informative regarding that subject.
There's the build.gradle, nothing much special about it
plugins {
id 'io.quarkus'
}
dependencies {
implementation enforcedPlatform("${quarkusPlatformGroupId}:${quarkusPlatformArtifactId}:${quarkusPlatformVersion}")
implementation 'io.quarkus:quarkus-grpc'
...
}
There is no way to specify an alternative path for the built-in code generation mechanism.
The classes generated by Quarkus from your *.proto files may change quite often. If you run Quarkus in the development mode, they will be regenerated on each change (in the *.proto files). In such a set up this is an outcome of the build rather than a source, that's why I put it in build.
I think you could use Gradle protobuf plugin to generate the java files. It has an option to specify the output directory. Don't forget to register quarkus-grpc-protoc-plugin similarly to Maven protobuf plugin configuration.
The drawback of switching to it is that you won't be able to use the full power of the development mode when modifying the *.proto files.
I am trying to create a gradle plugin. I want it to run after all java class-files were created. Therefore, I call task.dependsOn("classes").
During configuration phase, Gradle says Task with path 'classes' not found in root project. even tough I can just run the task via gradlew classes
How can that be? How can I create the dependency I need?
According to documentation:
Classes from buildSrc are no longer visible to settings scripts
Previously, the buildSrc project was built before applying the
project’s settings script and its classes were visible within the
script. Now, buildSrc is built after the settings script and its
classes are not visible to it. The buildSrc classes remain visible to
project build scripts and script plugins.
I'm trying to figure out, what Gradle does with the files, which are located in src/main/resources directory.
The processResources task, added by the java plugin to the project, copies them to the build/resources/main directory.
The content of this directory is bundled into the jar file created by the jar task that is also added by the java plugin, and the resources can thus be loaded, at runtime, by the ClassLoader.
See the documentation of the java plugin.
it might do nothing with them, but ignore them - per default (with the Android plugin) that directory is called res, only the Java plugin would take the resources directory into account (the question does not indicate which plugin is used). otherwise it would run a processResources task on them; only res/raw is not being processed (copied 1:1).
I have a largish Maven multiproject build. I'm scanning the codebase with SonarQube (5.6.5). For background, I successfully integrated the various JaCoCo exec files into SonarQube by using the "jacoco:merge" goal, to produce a single exec file. The SonarQube property that alleges to allow specifying a list of JaCoCo exec files doesn't work in our version of SonarQube, but specifying a single one does work.
I'm now trying to integrate the numerous "TEST-*" files in "target/surefire-reports" in each of the subprojects. The "sonar.junit.reportsPath" property expects a single directory, so I can't specify a list of them.
That means I'm going to have to do something as part of the build to merge the entire contents of all of the "target/surefire-reports" directories into a single directory, so I can specify that directory.
I already have a pom that does nothing but merge JaCoCo data. This seems like a logical place to store the surefire reports.
How can I do this sort of thing with Maven? Would this be an application of the "maven-resources-plugin", or something else?
Ok, well, I guess I answered my own question. I was able to get this to work with the resources plugin, specifying every one of my modules as resource directories. I now have one ridiculous-looking POM that has three lists of all of the modules in my multiproject build, for three tasks that require me to list all of the modules to process. The Gradle version would be amazingly short.
I am building and running some unit tests from within a gradle build script. The tests need to access some resources located in gradle_project_dir/src/test/resources/fixtures which in gradle.build logic can be expressed as
apply plugin: 'java'
// ...
File fixturesDir = new File(sourceSets.test.resources.srcDirs[0], "fixtures")
What is the best way of pointing the test source to the file as seen in build.gradle?
I want to avoid hard-coding the path in the tests to keep them DRY.
The cleanest solution that currently comes to my mind is to make the gradle build script first build some .jar with BuildConstants class or similar which will contain the fixturesDir file and make the tests source depend on it.
Another option is to make both the build script and the tests depend on some external .jar (possibly built with yet another gradle build script).
Something tells me there should be a simpler way, though.