@Test public void buildDetectsFilesWithSpecialCharacters() throws Exception { LRUPomModelCache pomModelCache = getReference(LRUPomModelCache.class); URL url = this.getClass().getResource("/ModuleBuildTestFileWithSpecialCharacter"); SimpleFileSystemProvider p = new SimpleFileSystemProvider(); org.uberfire.java.nio.file.Path path = p.getPath(url.toURI()); final Module module = moduleService.resolveModule(Paths.convert(path)); final Builder builder = new Builder(module, ioService, moduleService, importsService, new ArrayList<>(), dependenciesClassLoaderCache, pomModelCache, getPackageNameWhiteListService(), alwaysTrue); BuildResults buildResults = builder.build(); List<BuildMessage> errorMessages = buildResults.getErrorMessages(); assertEquals(2, errorMessages.size()); assertTrue(errorMessages.get(0).getText().contains("mismatched input 'Build' expecting one of the following tokens:")); }
public BuildResults build() { final BuildResults results = new BuildResults(projectGAV); synchronized (kieFileSystem) { kieBuilder = createKieBuilder(kieFileSystem); try { final Results kieResults = ((InternalKieBuilder) kieBuilder).buildAll(classFilter).getResults(); results.addAllBuildMessages(convertMessages(kieResults.getMessages(), handles)); } catch (LinkageError e) { final String msg = MessageFormat.format(ERROR_CLASS_NOT_FOUND, e.getLocalizedMessage()); logger.warn(msg); results.addBuildMessage(makeWarningMessage(msg)); } catch (Throwable e) { final String msg = e.getLocalizedMessage(); logger.error(msg, e); results.addBuildMessage(makeErrorMessage(msg)); } finally { final PomModel pomModel = ((KieBuilderImpl) kieBuilder).getPomModel(); if (pomModel != null) { pomModelCache.setEntry(project, pomModel); } } } for (Map.Entry<Path, BuildValidationHelper> e : nonKieResourceValidationHelpers.entrySet()) { final org.uberfire.backend.vfs.Path vfsPath = Paths.convert(e.getKey()); final List<ValidationMessage> validationMessages = e.getValue().validate(vfsPath); nonKieResourceValidationHelperMessages.put(e.getKey(), validationMessages); results.addAllBuildMessages(convertValidationMessages(validationMessages)); } final Path nioExternalImportsPath = projectRoot.resolve("project.imports"); if (Files.exists(nioExternalImportsPath)) { final org.uberfire.backend.vfs.Path externalImportsPath = Paths.convert(nioExternalImportsPath); final ProjectImports projectImports = importsService.load(externalImportsPath); final Imports imports = projectImports.getImports(); for (final Import item : imports.getImports()) { final String fullyQualifiedClassName = item.getType(); try { Class clazz = this.getClass().getClassLoader().loadClass(item.getType()); } catch (ClassNotFoundException cnfe) { logger.warn(cnfe.getMessage()); final String msg = MessageFormat.format(ERROR_CLASS_NOT_FOUND, fullyQualifiedClassName); results.addBuildMessage(makeWarningMessage(msg)); } } } final KieModuleMetaData kieModuleMetaData = KieModuleMetaData.Factory.newKieModuleMetaData(getKieModuleIgnoringErrors(), DependencyFilter.COMPILE_FILTER); updateDependenciesClassLoader(project, kieModuleMetaData); results.addAllBuildMessages(verifyClasses(kieModuleMetaData)); return results; }
Builder implements Serializable { public BuildResults build() { final BuildResults results = new BuildResults(projectGAV); synchronized (kieFileSystem) { kieBuilder = createKieBuilder(kieFileSystem); try { final Results kieResults = ((InternalKieBuilder) kieBuilder).buildAll(classFilter).getResults(); results.addAllBuildMessages(convertMessages(kieResults.getMessages(), handles)); } catch (LinkageError e) { final String msg = MessageFormat.format(ERROR_CLASS_NOT_FOUND, e.getLocalizedMessage()); logger.warn(msg); results.addBuildMessage(makeWarningMessage(msg)); } catch (Throwable e) { final String msg = e.getLocalizedMessage(); logger.error(msg, e); results.addBuildMessage(makeErrorMessage(msg)); } finally { final PomModel pomModel = ((KieBuilderImpl) kieBuilder).getPomModel(); if (pomModel != null) { pomModelCache.setEntry(project, pomModel); } } } for (Map.Entry<Path, BuildValidationHelper> e : nonKieResourceValidationHelpers.entrySet()) { final org.uberfire.backend.vfs.Path vfsPath = Paths.convert(e.getKey()); final List<ValidationMessage> validationMessages = e.getValue().validate(vfsPath); nonKieResourceValidationHelperMessages.put(e.getKey(), validationMessages); results.addAllBuildMessages(convertValidationMessages(validationMessages)); } final Path nioExternalImportsPath = projectRoot.resolve("project.imports"); if (Files.exists(nioExternalImportsPath)) { final org.uberfire.backend.vfs.Path externalImportsPath = Paths.convert(nioExternalImportsPath); final ProjectImports projectImports = importsService.load(externalImportsPath); final Imports imports = projectImports.getImports(); for (final Import item : imports.getImports()) { final String fullyQualifiedClassName = item.getType(); try { Class clazz = this.getClass().getClassLoader().loadClass(item.getType()); } catch (ClassNotFoundException cnfe) { logger.warn(cnfe.getMessage()); final String msg = MessageFormat.format(ERROR_CLASS_NOT_FOUND, fullyQualifiedClassName); results.addBuildMessage(makeWarningMessage(msg)); } } } final KieModuleMetaData kieModuleMetaData = KieModuleMetaData.Factory.newKieModuleMetaData(getKieModuleIgnoringErrors(), DependencyFilter.COMPILE_FILTER); updateDependenciesClassLoader(project, kieModuleMetaData); results.addAllBuildMessages(verifyClasses(kieModuleMetaData)); return results; } }
Builder implements Serializable { public BuildResults build() { final BuildResults results = new BuildResults(projectGAV); synchronized (kieFileSystem) { kieBuilder = createKieBuilder(kieFileSystem); try { final Results kieResults = ((InternalKieBuilder) kieBuilder).buildAll(classFilter).getResults(); results.addAllBuildMessages(convertMessages(kieResults.getMessages(), handles)); } catch (LinkageError e) { final String msg = MessageFormat.format(ERROR_CLASS_NOT_FOUND, e.getLocalizedMessage()); logger.warn(msg); results.addBuildMessage(makeWarningMessage(msg)); } catch (Throwable e) { final String msg = e.getLocalizedMessage(); logger.error(msg, e); results.addBuildMessage(makeErrorMessage(msg)); } finally { final PomModel pomModel = ((KieBuilderImpl) kieBuilder).getPomModel(); if (pomModel != null) { pomModelCache.setEntry(project, pomModel); } } } for (Map.Entry<Path, BuildValidationHelper> e : nonKieResourceValidationHelpers.entrySet()) { final org.uberfire.backend.vfs.Path vfsPath = Paths.convert(e.getKey()); final List<ValidationMessage> validationMessages = e.getValue().validate(vfsPath); nonKieResourceValidationHelperMessages.put(e.getKey(), validationMessages); results.addAllBuildMessages(convertValidationMessages(validationMessages)); } final Path nioExternalImportsPath = projectRoot.resolve("project.imports"); if (Files.exists(nioExternalImportsPath)) { final org.uberfire.backend.vfs.Path externalImportsPath = Paths.convert(nioExternalImportsPath); final ProjectImports projectImports = importsService.load(externalImportsPath); final Imports imports = projectImports.getImports(); for (final Import item : imports.getImports()) { final String fullyQualifiedClassName = item.getType(); try { Class clazz = this.getClass().getClassLoader().loadClass(item.getType()); } catch (ClassNotFoundException cnfe) { logger.warn(cnfe.getMessage()); final String msg = MessageFormat.format(ERROR_CLASS_NOT_FOUND, fullyQualifiedClassName); results.addBuildMessage(makeWarningMessage(msg)); } } } final KieModuleMetaData kieModuleMetaData = KieModuleMetaData.Factory.newKieModuleMetaData(getKieModuleIgnoringErrors(), DependencyFilter.COMPILE_FILTER); updateDependenciesClassLoader(project, kieModuleMetaData); results.addAllBuildMessages(verifyClasses(kieModuleMetaData)); return results; } Builder(final Module project,
                   final IOService ioService,
                   final KieModuleService moduleService,
                   final ProjectImportsService importsService,
                   final List<BuildValidationHelper> buildValidationHelpers,
                   final LRUModuleDependenciesClassLoaderCache dependenciesClassLoaderCache,
                   final LRUPomModelCache pomModelCache,
                   final PackageNameWhiteListService packageNameWhiteListService,
                   final Predicate<String> classFilter,
                   final KieBuilder kieBuilder,
                   final KieFileSystem kieFileSystem);  Builder(final Module project,
                   final IOService ioService,
                   final KieModuleService moduleService,
                   final ProjectImportsService importsService,
                   final List<BuildValidationHelper> buildValidationHelpers,
                   final LRUModuleDependenciesClassLoaderCache dependenciesClassLoaderCache,
                   final LRUPomModelCache pomModelCache,
                   final PackageNameWhiteListService packageNameWhiteListService,
                   final Predicate<String> classFilter); }
Builder implements Serializable { public BuildResults build() { final BuildResults results = new BuildResults(projectGAV); synchronized (kieFileSystem) { kieBuilder = createKieBuilder(kieFileSystem); try { final Results kieResults = ((InternalKieBuilder) kieBuilder).buildAll(classFilter).getResults(); results.addAllBuildMessages(convertMessages(kieResults.getMessages(), handles)); } catch (LinkageError e) { final String msg = MessageFormat.format(ERROR_CLASS_NOT_FOUND, e.getLocalizedMessage()); logger.warn(msg); results.addBuildMessage(makeWarningMessage(msg)); } catch (Throwable e) { final String msg = e.getLocalizedMessage(); logger.error(msg, e); results.addBuildMessage(makeErrorMessage(msg)); } finally { final PomModel pomModel = ((KieBuilderImpl) kieBuilder).getPomModel(); if (pomModel != null) { pomModelCache.setEntry(project, pomModel); } } } for (Map.Entry<Path, BuildValidationHelper> e : nonKieResourceValidationHelpers.entrySet()) { final org.uberfire.backend.vfs.Path vfsPath = Paths.convert(e.getKey()); final List<ValidationMessage> validationMessages = e.getValue().validate(vfsPath); nonKieResourceValidationHelperMessages.put(e.getKey(), validationMessages); results.addAllBuildMessages(convertValidationMessages(validationMessages)); } final Path nioExternalImportsPath = projectRoot.resolve("project.imports"); if (Files.exists(nioExternalImportsPath)) { final org.uberfire.backend.vfs.Path externalImportsPath = Paths.convert(nioExternalImportsPath); final ProjectImports projectImports = importsService.load(externalImportsPath); final Imports imports = projectImports.getImports(); for (final Import item : imports.getImports()) { final String fullyQualifiedClassName = item.getType(); try { Class clazz = this.getClass().getClassLoader().loadClass(item.getType()); } catch (ClassNotFoundException cnfe) { logger.warn(cnfe.getMessage()); final String msg = MessageFormat.format(ERROR_CLASS_NOT_FOUND, fullyQualifiedClassName); results.addBuildMessage(makeWarningMessage(msg)); } } } final KieModuleMetaData kieModuleMetaData = KieModuleMetaData.Factory.newKieModuleMetaData(getKieModuleIgnoringErrors(), DependencyFilter.COMPILE_FILTER); updateDependenciesClassLoader(project, kieModuleMetaData); results.addAllBuildMessages(verifyClasses(kieModuleMetaData)); return results; } Builder(final Module project,
                   final IOService ioService,
                   final KieModuleService moduleService,
                   final ProjectImportsService importsService,
                   final List<BuildValidationHelper> buildValidationHelpers,
                   final LRUModuleDependenciesClassLoaderCache dependenciesClassLoaderCache,
                   final LRUPomModelCache pomModelCache,
                   final PackageNameWhiteListService packageNameWhiteListService,
                   final Predicate<String> classFilter,
                   final KieBuilder kieBuilder,
                   final KieFileSystem kieFileSystem);  Builder(final Module project,
                   final IOService ioService,
                   final KieModuleService moduleService,
                   final ProjectImportsService importsService,
                   final List<BuildValidationHelper> buildValidationHelpers,
                   final LRUModuleDependenciesClassLoaderCache dependenciesClassLoaderCache,
                   final LRUPomModelCache pomModelCache,
                   final PackageNameWhiteListService packageNameWhiteListService,
                   final Predicate<String> classFilter); Builder clone(); BuildResults build(); BuildResults build(final Path resource,
                              final InputStream inputStream); IncrementalBuildResults addResource(final Path resource); IncrementalBuildResults deleteResource(final Path resource); IncrementalBuildResults updateResource(final Path resource); IncrementalBuildResults updateResource(final Path resource,
                                                  final InputStream inputStream); IncrementalBuildResults applyBatchResourceChanges(final Map<org.uberfire.backend.vfs.Path, Collection<ResourceChange>> changes); org.kie.api.builder.KieModule getKieModule(); org.kie.api.builder.KieModule getKieModuleIgnoringErrors(); KieModuleMetaData getKieModuleMetaDataIgnoringErrors(); TypeSourceResolver getTypeSourceResolver(KieModuleMetaData kieModuleMetaData); KieContainer getKieContainer(); boolean isBuilt(); }
Builder implements Serializable { public BuildResults build() { final BuildResults results = new BuildResults(projectGAV); synchronized (kieFileSystem) { kieBuilder = createKieBuilder(kieFileSystem); try { final Results kieResults = ((InternalKieBuilder) kieBuilder).buildAll(classFilter).getResults(); results.addAllBuildMessages(convertMessages(kieResults.getMessages(), handles)); } catch (LinkageError e) { final String msg = MessageFormat.format(ERROR_CLASS_NOT_FOUND, e.getLocalizedMessage()); logger.warn(msg); results.addBuildMessage(makeWarningMessage(msg)); } catch (Throwable e) { final String msg = e.getLocalizedMessage(); logger.error(msg, e); results.addBuildMessage(makeErrorMessage(msg)); } finally { final PomModel pomModel = ((KieBuilderImpl) kieBuilder).getPomModel(); if (pomModel != null) { pomModelCache.setEntry(project, pomModel); } } } for (Map.Entry<Path, BuildValidationHelper> e : nonKieResourceValidationHelpers.entrySet()) { final org.uberfire.backend.vfs.Path vfsPath = Paths.convert(e.getKey()); final List<ValidationMessage> validationMessages = e.getValue().validate(vfsPath); nonKieResourceValidationHelperMessages.put(e.getKey(), validationMessages); results.addAllBuildMessages(convertValidationMessages(validationMessages)); } final Path nioExternalImportsPath = projectRoot.resolve("project.imports"); if (Files.exists(nioExternalImportsPath)) { final org.uberfire.backend.vfs.Path externalImportsPath = Paths.convert(nioExternalImportsPath); final ProjectImports projectImports = importsService.load(externalImportsPath); final Imports imports = projectImports.getImports(); for (final Import item : imports.getImports()) { final String fullyQualifiedClassName = item.getType(); try { Class clazz = this.getClass().getClassLoader().loadClass(item.getType()); } catch (ClassNotFoundException cnfe) { logger.warn(cnfe.getMessage()); final String msg = MessageFormat.format(ERROR_CLASS_NOT_FOUND, fullyQualifiedClassName); results.addBuildMessage(makeWarningMessage(msg)); } } } final KieModuleMetaData kieModuleMetaData = KieModuleMetaData.Factory.newKieModuleMetaData(getKieModuleIgnoringErrors(), DependencyFilter.COMPILE_FILTER); updateDependenciesClassLoader(project, kieModuleMetaData); results.addAllBuildMessages(verifyClasses(kieModuleMetaData)); return results; } Builder(final Module project,
                   final IOService ioService,
                   final KieModuleService moduleService,
                   final ProjectImportsService importsService,
                   final List<BuildValidationHelper> buildValidationHelpers,
                   final LRUModuleDependenciesClassLoaderCache dependenciesClassLoaderCache,
                   final LRUPomModelCache pomModelCache,
                   final PackageNameWhiteListService packageNameWhiteListService,
                   final Predicate<String> classFilter,
                   final KieBuilder kieBuilder,
                   final KieFileSystem kieFileSystem);  Builder(final Module project,
                   final IOService ioService,
                   final KieModuleService moduleService,
                   final ProjectImportsService importsService,
                   final List<BuildValidationHelper> buildValidationHelpers,
                   final LRUModuleDependenciesClassLoaderCache dependenciesClassLoaderCache,
                   final LRUPomModelCache pomModelCache,
                   final PackageNameWhiteListService packageNameWhiteListService,
                   final Predicate<String> classFilter); Builder clone(); BuildResults build(); BuildResults build(final Path resource,
                              final InputStream inputStream); IncrementalBuildResults addResource(final Path resource); IncrementalBuildResults deleteResource(final Path resource); IncrementalBuildResults updateResource(final Path resource); IncrementalBuildResults updateResource(final Path resource,
                                                  final InputStream inputStream); IncrementalBuildResults applyBatchResourceChanges(final Map<org.uberfire.backend.vfs.Path, Collection<ResourceChange>> changes); org.kie.api.builder.KieModule getKieModule(); org.kie.api.builder.KieModule getKieModuleIgnoringErrors(); KieModuleMetaData getKieModuleMetaDataIgnoringErrors(); TypeSourceResolver getTypeSourceResolver(KieModuleMetaData kieModuleMetaData); KieContainer getKieContainer(); boolean isBuilt();  }