How to tell Eclipse not use my custom sourceSets

I need to export api and impl to different jar, so I need to custom my sourceSets to the following:

sourceSets{
	
	api {
		java {
			srcDir "src/main/java"
			include "com/my/api/**"
			exclude "com/my/api/impl/**"
		}
	}
	
	core {
		java {
			srcDir "src/main/java"
			exclude "com/my/api/*.java"
			exclude "com/my/api/model/**"
		}
		resources {
			srcDir "src/main/resources"
			exclude "**/package-info.java"
		}
		
		compileClasspath = sourceSets.main.output + configurations.compile
	}
}

Notice that I don’t have main.java.srcDir settings.
When I make this to eclipse project, gradle generates lots source folder in classpath as following:

<classpathentry kind="src" path="src/main/java"/>
<classpathentry kind="src" path="src/main/resources"/>
<classpathentry kind="src" path="src/test/java"/>
<classpathentry kind="src" path="src/test/resources"/>
<classpathentry including="com/my/api/**" excluding="com/my/api/impl/**" kind="src" path="src/main/java"/>
<classpathentry excluding="com/my/api/*.java|com/my/api/model/**" kind="src" path="src/main/java"/>
<classpathentry excluding="**/package-info.java" kind="src" path="src/main/resources"/>

It’s fine that gradle create four classpath for me about maven/gradle convention: “src/main/java”, “src/main/resources”, “src/test/java”, and “src/test/resources”.
But I don’t want the other classpath entries in the last three rows about my setting in sourceSets.

I want to know how to tell Eclipse not use my custom sourceSets, or how to set the correct sourceSets, or any one can tell me any other suggestions?!

Thank you.

you can exclude sourceSets from your eclipse setup using the following snippet:

eclipse {
    classpath {
        sourceSets -= [sourceSets.api, sourceSets.core]	
    }	
 }

you might want to consider to use the java-base plugin and get rid of the main and the test sourceSet as you don’t really use them.

Great! It works.

Thank you very much :slight_smile: