source-sets

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

纵然是瞬间 提交于 2020-02-25 02:08:13
问题 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 however: we cannot access classes or methods with visibility internal from within test classes. The reason for this is that the Kotlin compiler places every source set in its own "module": $ find . -name '*.kotlin_module' ./classes/kotlin/domain/META

Android gradle buildTypes: Duplicate class

痞子三分冷 提交于 2020-02-12 08:24:46
问题 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 src/release/java/my/package/name/Constants.java . When I try to build this, gradle tells me the build failed on the Constants file in my release buildtype, with the error that it's a duplicate class. I also tried adding a different sourceSet for this in my build.gradle like this:

Gradle with non-standard named source sets - how do I make them available to the test classes?

南楼画角 提交于 2020-01-16 01:11:16
问题 I have a (legacy) Java project which I'm re-configuring to build with Gradle. The build should, eventually, output a number of jar archives, so I've divided to split up the source into source sets that correspond to the subdivision of the output into archives. The file tree looks something like this: - project root - src - setOne - java - ... - resources - ... - setTwo - java - ... - setThree - java - ... - resources - ... - test - java - ... - build.gradle and in build.gradle I have the

Gradle sourceSet depends on another sourceSet

点点圈 提交于 2019-12-23 09:58:01
问题 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 testenvCompile configuration. sourceSets { testenv } dependencies { testenvCompile sourceSets.main } This does not work, because you cannot directly add sourceSets as dependencies. The recommended way to do this is: sourceSets { testenv } dependencies {

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

半世苍凉 提交于 2019-12-17 10:24:08
问题 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 +- acitonbarsherlock +- facebook +- myLib1 +- myProject +- src +- commonFiles +- flavor1 +- flavor2 +- res +- flavor1 +- flavor2 The innards of the myProject gradle file android closure looks like this: android { compileSdkVersion 17 buildToolsVersion "18.0.1"

Get compiled .class output directory in Android Gradle task

半世苍凉 提交于 2019-12-12 20:09:11
问题 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 will give me this path, but when I try to use it, I get the error Could not find property 'output' on source set main . This happens even when I create a new, minimal project, with the following build.gradle : buildscript { repositories {

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

一笑奈何 提交于 2019-12-10 00:58:46
问题 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 of this source set's code compilation available at compile and run time for main and test source sets. What's the right semantic way to do it in Gradle? UPDATE: As suggested here: How do I add a new sourceset to Gradle? doesn't work for me, I still get java.lang

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

廉价感情. 提交于 2019-12-04 03:31:03
问题 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 project config: sourceSets { // This lets us write test utility code that can be used by both unit tests and android tests commonTest { java } test { java.srcDirs += commonTest.java.srcDirs } androidTest { java.srcDirs += commonTest.java.srcDirs }

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

非 Y 不嫁゛ 提交于 2019-11-27 11:18:42
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 +- acitonbarsherlock +- facebook +- myLib1 +- myProject +- src +- commonFiles +- flavor1 +- flavor2 +- res +- flavor1 +- flavor2 The innards of the myProject gradle file android closure looks like this: android { compileSdkVersion 17 buildToolsVersion "18.0.1" signingConfigs { ... } productFlavors { flavor2 { } flavor1 { } } sourceSets{ main { manifest.srcFile

How do I add a new sourceset to Gradle?

a 夏天 提交于 2019-11-26 19:36:22
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 my main source set. How do I make this happen? This took me a while to figure out and the online resources weren't great. So I wanted to document my solution. This is a simple gradle build script that has an intTest source set in addition to the main and test source sets: apply plugin: "java" sourceSets { // Note that just declaring this sourceset