There is a variant of JavaCore.newSourceEntry
that supports this:
public static IClasspathEntry newSourceEntry(IPath path, IPath[] inclusionPatterns,
IPath[] exclusionPatterns, IPath specificOutputLocation,
IClasspathAttribute[] extraAttributes)