Package org.guvnor.common.services.project.builder.model

Examples of org.guvnor.common.services.project.builder.model.IncrementalBuildResults


                        final Project project = e.getKey();
                        final Map<Path, Collection<ResourceChange>> changes = e.getValue();

                        //Fall back to a Full Build in lieu of an Incremental Build if the Project has not been previously built
                        if ( buildService.isBuilt( project ) ) {
                            final IncrementalBuildResults results = buildService.applyBatchResourceChanges( project,
                                                                                                            changes );
                            incrementalBuildResultsEvent.fire( results );
                        } else {
                            final BuildResults results = buildService.build( project );
                            buildResultsEvent.fire( results );
View Full Code Here


    }

    @Override
    public IncrementalBuildResults addPackageResource( final Path resource ) {
        try {
            IncrementalBuildResults results = new IncrementalBuildResults();
            final Project project = projectService.resolveProject( resource );
            if ( project == null ) {
                return results;
            }
            final Builder builder = cache.assertBuilder( project );
View Full Code Here

    }

    @Override
    public IncrementalBuildResults deletePackageResource( final Path resource ) {
        try {
            IncrementalBuildResults results = new IncrementalBuildResults();
            final Project project = projectService.resolveProject( resource );
            if ( project == null ) {
                return results;
            }
            final Builder builder = cache.assertBuilder( project );
View Full Code Here

    }

    @Override
    public IncrementalBuildResults updatePackageResource( final Path resource ) {
        try {
            IncrementalBuildResults results = new IncrementalBuildResults();
            final Project project = projectService.resolveProject( resource );
            if ( project == null ) {
                return results;
            }
            final Builder builder = cache.assertBuilder( project );
View Full Code Here

    }

    @Override
    public IncrementalBuildResults applyBatchResourceChanges( final Project project,
                                                              final Map<Path, Collection<ResourceChange>> changes ) {
        IncrementalBuildResults results = new IncrementalBuildResults();
        try {
            if ( project == null ) {
                return results;
            }
            final Builder builder = cache.assertBuilder( project );
View Full Code Here

            checkNotNull( "resource",
                          resource );

            //Only files can be processed
            if ( !Files.isRegularFile( resource ) ) {
                return new IncrementalBuildResults( gav );
            }

            //Check a full build has been performed
            if ( !isBuilt() ) {
                throw new IllegalStateException( "A full build needs to be performed before any incremental operations." );
            }

            //Resource Type might require "external" validation (i.e. it's not covered by Kie)
            final IncrementalBuildResults results = new IncrementalBuildResults( gav );
            final BuildValidationHelper validator = getBuildValidationHelper( resource );
            if ( validator != null ) {
                final List<ValidationMessage> addedValidationMessages = validator.validate( Paths.convert( resource ) );

                if ( !( addedValidationMessages == null || addedValidationMessages.isEmpty() ) ) {
                    for ( ValidationMessage validationMessage : addedValidationMessages ) {
                        results.addAddedMessage( convertValidationMessage( validationMessage ) );
                    }
                }

                final List<ValidationMessage> removedValidationMessages = nonKieResourceValidationHelperMessages.remove( resource );
                if ( !( removedValidationMessages == null || removedValidationMessages.isEmpty() ) ) {
                    for ( ValidationMessage validationMessage : removedValidationMessages ) {
                        results.addRemovedMessage( convertValidationMessage( validationMessage ) );
                    }
                }
                nonKieResourceValidationHelpers.put( resource,
                                                     validator );
                nonKieResourceValidationHelperMessages.put( resource,
                                                            addedValidationMessages );
            }

            //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( getBaseFileName( destinationPath ),
                         Paths.convert( resource ) );

            //Incremental build
            try {
                final IncrementalResults incrementalResults = ( (InternalKieBuilder) kieBuilder ).createFileSet( destinationPath ).build();
                for ( final Message message : incrementalResults.getAddedMessages() ) {
                    results.addAddedMessage( convertMessage( message ) );
                }
                for ( final Message message : incrementalResults.getRemovedMessages() ) {
                    results.addRemovedMessage( convertMessage( message ) );
                }

                //Tidy-up removed message handles
                for ( Message message : incrementalResults.getRemovedMessages() ) {
                    handles.remove( RESOURCE_PATH + "/" + getBaseFileName( message.getPath() ) );
                }

            } catch ( LinkageError e ) {
                final String msg = MessageFormat.format( ERROR_CLASS_NOT_FOUND,
                                                         e.getLocalizedMessage() );
                logger.warn( msg, e );
                results.addAddedMessage( makeWarningMessage( msg ) );
            } catch ( Throwable e ) {
                final String msg = e.getLocalizedMessage();
                logger.error( msg, e );
                results.addAddedMessage( makeErrorMessage( msg ) );
            }

            return results;
        }
    }
View Full Code Here

            if ( !isBuilt() ) {
                throw new IllegalStateException( "A full build needs to be performed before any incremental operations." );
            }

            //Resource Type might have been validated "externally" (i.e. it's not covered by Kie). Clear any errors.
            final IncrementalBuildResults results = new IncrementalBuildResults( gav );
            final BuildValidationHelper validator = getBuildValidationHelper( resource );
            if ( validator != null ) {
                nonKieResourceValidationHelpers.remove( resource );
                final List<ValidationMessage> removedValidationMessages = nonKieResourceValidationHelperMessages.remove( resource );
                if ( !( removedValidationMessages == null || removedValidationMessages.isEmpty() ) ) {
                    for ( ValidationMessage validationMessage : removedValidationMessages ) {
                        results.addRemovedMessage( convertValidationMessage( validationMessage ) );
                    }
                }
            }

            //Delete resource
            final String destinationPath = resource.toUri().toString().substring( projectPrefix.length() + 1 );
            kieFileSystem.delete( destinationPath );
            removeJavaClass( resource );

            //Incremental build
            try {
                final IncrementalResults incrementalResults = ( (InternalKieBuilder) kieBuilder ).createFileSet( destinationPath ).build();
                for ( final Message message : incrementalResults.getAddedMessages() ) {
                    results.addAddedMessage( convertMessage( message ) );
                }
                for ( final Message message : incrementalResults.getRemovedMessages() ) {
                    results.addRemovedMessage( convertMessage( message ) );
                }

                //Tidy-up removed message handles
                for ( Message message : incrementalResults.getRemovedMessages() ) {
                    handles.remove( RESOURCE_PATH + "/" + getBaseFileName( message.getPath() ) );
                }

            } catch ( LinkageError e ) {
                final String msg = MessageFormat.format( ERROR_CLASS_NOT_FOUND,
                                                         e.getLocalizedMessage() );
                logger.warn( msg, e );
                results.addAddedMessage( makeWarningMessage( msg ) );
            } catch ( Throwable e ) {
                final String msg = e.getLocalizedMessage();
                logger.error( msg, e );
                results.addAddedMessage( makeErrorMessage( msg ) );
            }

            return results;
        }
    }
View Full Code Here

            final String[] kieBuilderPaths = new String[ changedFilesKieBuilderPaths.size() ];
            changedFilesKieBuilderPaths.toArray( kieBuilderPaths );

            //Messages from incremental build

            final IncrementalBuildResults results = new IncrementalBuildResults( gav );
            try {
                final IncrementalResults incrementalResults = ( (InternalKieBuilder) kieBuilder ).createFileSet( kieBuilderPaths ).build();
                for ( final Message message : incrementalResults.getAddedMessages() ) {
                    results.addAddedMessage( convertMessage( message ) );
                }
                for ( final Message message : incrementalResults.getRemovedMessages() ) {
                    results.addRemovedMessage( convertMessage( message ) );
                }

                //Tidy-up removed message handles
                for ( Message message : incrementalResults.getRemovedMessages() ) {
                    handles.remove( RESOURCE_PATH + "/" + getBaseFileName( message.getPath() ) );
                }

            } catch ( LinkageError e ) {
                final String msg = MessageFormat.format( ERROR_CLASS_NOT_FOUND,
                                                         e.getLocalizedMessage() );
                logger.warn( msg, e );
                results.addAddedMessage( makeWarningMessage( msg ) );
            } catch ( Throwable e ) {
                final String msg = e.getLocalizedMessage();
                logger.error( msg, e );
                results.addAddedMessage( makeErrorMessage( msg ) );
            }

            //Copy in BuildMessages for non-KIE resources
            for ( ValidationMessage addedValidationMessage : nonKieResourceValidatorAddedMessages ) {
                results.addAddedMessage( convertValidationMessage( addedValidationMessage ) );
            }
            for ( ValidationMessage removedValidationMessage : nonKieResourceValidatorRemovedMessages ) {
                results.addRemovedMessage( convertValidationMessage( removedValidationMessage ) );
            }

            return results;
        }
    }
View Full Code Here

        return results;
    }

    private IncrementalBuildResults convertMessages( final IncrementalResults kieIncrementalResults ) {
        final IncrementalBuildResults results = new IncrementalBuildResults();
        results.setArtifactID( artifactId );

        for ( final Message message : kieIncrementalResults.getAddedMessages() ) {
            results.addAddedMessage( convertMessage( message ) );
        }
        for ( final Message message : kieIncrementalResults.getRemovedMessages() ) {
            results.addRemovedMessage( convertMessage( message ) );
        }

        return results;
    }
View Full Code Here

            }
            final Builder builder = cache.assertBuilder( project );
            if ( !builder.isBuilt() ) {
                build( project );
            }
            final IncrementalBuildResults results = builder.addResource( paths.convert( resource ) );
            incrementalBuildResultsEvent.fire( results );

        } catch ( Exception e ) {
            throw ExceptionUtilities.handleException( e );
        }
View Full Code Here

TOP

Related Classes of org.guvnor.common.services.project.builder.model.IncrementalBuildResults

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.