Android – add source files to gradle project

Let's suppose I have a simple Android project that I will build by gradle

Can I add sources from any directory?

So I want to keep the main sourcesets unchanged just to add some java files in the source path

resolvent:

Just add the folder to java.srcdir. It's just a set of files, so you can add more files like any other set in groovy

An example of this is to add this snippet:

sourceSets {
    main{
        java {
            srcDir("path/to/source/folder")
        }
    }
}

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>