PortablePreconditions.checkNotNull( "resource",
resource );
//Only files can be processed
if ( !Files.isRegularFile( resource ) ) {
return new IncrementalBuildResults();
}
//Check a full build has been performed
if ( !isBuilt() ) {
throw new IllegalStateException( "A full build needs to be performed before any incremental operations." );
}
//Add new resource
final String destinationPath = resource.toUri().toString().substring( projectPrefix.length() + 1 );
final InputStream is = ioService.newInputStream( resource );
final BufferedInputStream bis = new BufferedInputStream( is );
kieFileSystem.write( destinationPath,
KieServices.Factory.get().getResources().newInputStreamResource( bis ) );
addJavaClass( resource );
handles.put( destinationPath,
paths.convert( resource ) );
//Incremental build
final IncrementalResults incrementalResults = ( (InternalKieBuilder) kieBuilder ).createFileSet( destinationPath ).build();
//Messages from incremental build
final IncrementalBuildResults results = convertMessages( incrementalResults );
//Tidy-up removed message handles
for ( Message message : incrementalResults.getRemovedMessages() ) {
handles.remove( RESOURCE_PATH + "/" + message.getPath() );
}