Questions tagged [source-sets]

A concept used by the Gradle build system, to divide the source code into parts for which the build process can be configured separately.

66 questions
109
votes
8 answers

How do I add a new sourceset to Gradle?

I want to add integration tests to my Gradle build (Version 1.0). They should run separately from my normal tests because they require a webapp to be deployed to localhost (they test that webapp). The tests should be able to use classes defined in…
Spina
  • 8,388
  • 7
  • 34
  • 35
54
votes
5 answers

Gradle flavors for android with custom source sets - what should the gradle files look like?

I've got an old eclipse project I've moved into android studio and setup to use flavors. It seemed to be working fine till I started trying to use different java files between my flavors. My project setup is this: ProjectRoot +-…
AdamWardVGP
  • 580
  • 1
  • 4
  • 11
34
votes
2 answers

Android gradle buildTypes: Duplicate class

I'm converting my app to use gradle, and I'm trying to use the buildTypes. I have a Constants class which I wish to modify for my release build. So I have a file at src/main/java/my/package/name/Constants.java and at…
Arne517
  • 805
  • 2
  • 8
  • 14
17
votes
1 answer

Gradle: custom source set as dependency for the main and test ones

I've created custom source set in Gradle project to keep all generated code: sourceSets { generated { java { srcDir 'src/generated/java' } resources { srcDir 'src/generated/resources' } } } I want to make the result…
Anton Moiseev
  • 2,766
  • 4
  • 21
  • 30
12
votes
3 answers

Kotlin: java.lang.NoSuchMethodError in tests

Is it possible to use Kotlin package functions and package properties in different sourcesets? When I try to do so, I have NoSuchMethodError thrown. Example I have Gradle project with Kotlin code and two sourcesets in it, main and test. In main, I…
hotkey
  • 111,884
  • 27
  • 298
  • 285
11
votes
1 answer

gradle get resources default output directory

Gradle: how to get default resources output dir? println sourceSets.main.resources.outputDir Error: Needs to set a non-null value before it can be retrieved
eastwater
  • 781
  • 1
  • 10
  • 28
8
votes
1 answer

Gradle: using resources in a dependency jar as a sourceset

Suppose I have a build.gradle thus: dependencies { compile 'com.group:some-app:1.0.1' compile 'com.group:some-app:1.0.1:sources' } sourceSets { main { other { srcDir 'src/main/other' } } } So…
Stewart
  • 17,139
  • 8
  • 45
  • 74
8
votes
1 answer

Gradle sourceSet depends on another sourceSet

This Question is similar to Make one source set dependent on another Besides the main SourceSet I also have a testenv SourceSet. The code in the testenv SourceSet references the main code, therefor I need to add the main SourceSet to the…
Adrodoc55
  • 486
  • 6
  • 18
6
votes
0 answers

The SourceSet 'commonTest' is not recognized by the Android Gradle Plugin. Perhaps you misspelled something?

Seemingly the same root cause as this question, but the answer there will not work for me. I have a custom source set called commonTest that I use for sharing certain test utility code across the test and androidTest source sets. Here is my relevant…
6
votes
1 answer

Get compiled .class output directory in Android Gradle task

I'm creating a Gradle task for my Android project that needs to know the path to the compiled .class files. How can I get this path? I've found suggestions (here and here; also see the Gradle docs for SourceSet) that sourceSets.main.output.classDir…
Dan Getz
  • 7,743
  • 6
  • 29
  • 60
5
votes
0 answers

Exclude assets from debug build on Flutter

I have 8000+ files named (1.txt, 2.txt, 3.txt, etc) on my /assets/files folder. However I don't need all of them for my debug build. I only need the first 30 of them. Indeed, if I leave all those files on the assets folder the build time is…
Daniel
  • 524
  • 1
  • 5
  • 12
5
votes
2 answers

Define a sourceset for all java sub-projects

I wonder if it is possible to define a source set in gradle (e.g. integrationTests) that can be applied to all sub-projects that use the 'java' plugin? Something like sourceSets { integTest { java.srcDir…
u6f6o
  • 1,728
  • 2
  • 23
  • 47
4
votes
0 answers

How to make Kotlin `internal` objects accessible to tests?

My project uses several Gradle source sets for its production code base instead of just main: domain dal rest test dbUnitTest This has proven very useful for limiting dependencies and enforcing separation of concern. It comes with one downside…
blubb
  • 8,562
  • 2
  • 36
  • 67
3
votes
0 answers

How can I add directories to a Gradle sourceset by wildcard pattern?

I would like to separate various source types into per-module areas without either: adding a separate Android module project (or build.gradle) for each or explicitly adding each module's source directories to appropriate source sets in build So…
user6519354
  • 139
  • 1
  • 6
3
votes
0 answers

Gradle multi-module project Source Sets is missing in a module on Intellij Idea

I have imported a multi module gradle project to intellij idea, where one module has dependency on other. Based on that I can able to use classes from any module as it got the dependency. But problem I am facing is, one of the modules is not…
Jet
  • 2,197
  • 2
  • 26
  • 43
1
2 3 4 5