@Override public void write(int b) throws IOException { wholeTextBuilder.append((char) b); if (b == '\n') { LOG.lifecycle("[checker] {}", lineTextBuilder.toString()); processLine(lineTextBuilder.toString()); lineTextBuilder = new StringBuilder(); } else { lineTextBuilder.append((char) b); } }
if ( file.delete() ) { if ( !file.createNewFile() ) { logger.error( "Unable to recreate class file [" + file.getName() + "]" ); logger.error( "Unable to delete class file [" + file.getName() + "]" ); logger.warn( "Problem preparing class file for writing out enhancements [" + file.getName() + "]" );
private ClassLoader toClassLoader(FileCollection runtimeClasspath) { List<URL> urls = new ArrayList<URL>(); for ( File file : runtimeClasspath ) { try { urls.add( file.toURI().toURL() ); logger.debug( "Adding classpath entry for " + file.getAbsolutePath() ); } catch (MalformedURLException e) { throw new GradleException( "Unable to resolve classpath entry to URL : " + file.getAbsolutePath(), e ); } } return new URLClassLoader( urls.toArray( new URL[urls.size()] ), Enhancer.class.getClassLoader() ); }
@Override public void execute(Task task) { project.getLogger().debug( "Starting Hibernate enhancement on SourceSet.{}", sourceSet.getName() ); logger.warn("Extended enhancement is enabled. Classes other than entities may be modified. You should consider access the entities using getter/setter methods and disable this property. Use at your own risk." ); if ( enhancedBytecode != null ) { writeOutEnhancedClass( enhancedBytecode, file ); logger.info( "Successfully enhanced class [" + file + "]" ); logger.info( "Skipping class [" + file.getAbsolutePath() + "], not an entity nor embeddable" );
@TaskAction public void process() throws Throwable { Project project = getProject(); JoobyProject joobyProject = new JoobyProject(project); String mainClass = getMainClassName(); try (URLClassLoader loader = joobyProject.newClassLoader()) { getLogger().debug("Using classloader " + loader); Path srcdir = project.getProjectDir().toPath(); Path bindir = joobyProject.classes().toPath(); Path output = new ApiParser(srcdir) .with(loader) .export(bindir, mainClass); getLogger().info("API file: " + output); } }
LOG.info("Compiling Scala resource classes. Disabling pathing jar for " + taskName + " to avoid breaking Scala compilation"); return classpath;
@TaskAction public void checkFilesForChanges(IncrementalTaskInputs inputs) getLogger().lifecycle("Checking idl and snapshot files for changes..."); getLogger().info("idlFiles: " + idlFiles.getAsPath()); getLogger().info("snapshotFiles: " + snapshotFiles.getAsPath()); getLogger().lifecycle( "The following files have been removed, be sure to remove them from source control: {}", files); getLogger().lifecycle("The following files have been added, be sure to add them to source control: {}", files); getLogger().lifecycle( "The following files have been changed, be sure to commit the changes to source control: {}", files);
/** Makes it possible to remove a format which was created earlier. */ public void removeFormat(String name) { requireNonNull(name); FormatExtension toRemove = formats.remove(name); if (toRemove == null) { project.getLogger().warn("Called removeFormat('" + name + "') but there was no such format."); } }
private void applyEnhancement(final Project project, final HibernateExtension hibernateExtension) { if ( !hibernateExtension.enhance.shouldApply() ) { project.getLogger().warn( "Skipping Hibernate bytecode enhancement since no feature is enabled" ); return; project.getLogger().debug( "Applying Hibernate enhancement action to SourceSet.{}", sourceSet.getName() );
private void configureJoobyRun(final Project project) { project.getTasks() .withType(JoobyTask.class, joobyRun -> { ConventionMapping mapping = joobyRun.getConventionMapping(); mapping.map("classpath", () -> new JoobyProject(project).classpath()); mapping.map("src", () -> new JoobyProject(project).sources()); mapping.map("mainClassName", () -> project.getProperties().get("mainClassName")); mapping.map("srcExtensions", () -> Arrays.asList(".java", ".conf", ".properties", ".kt")); mapping.map("compiler", () -> { File eclipseClasspath = new File(project.getProjectDir(), ".classpath"); return eclipseClasspath.exists() ? "off" : "on"; }); Gradle gradle = project.getGradle(); mapping.map("block", () -> !gradle.getStartParameter().isContinuous()); mapping.map("logLevel", () -> gradle.getStartParameter().getLogLevel().name()); }); Map<String, Object> options = new HashMap<>(); options.put(Task.TASK_TYPE, JoobyTask.class); options.put(Task.TASK_DEPENDS_ON, "classes"); options.put(Task.TASK_NAME, "joobyRun"); options.put(Task.TASK_DESCRIPTION, "Run, debug and hot reload applications"); options.put(Task.TASK_GROUP, "jooby"); project.getTasks().create(options); }
output.mkdirs(); logger.debug("claspath: " + loader); logger.debug("assets.conf: " + assetConf.getConfig("assets")); CharSequence summary = compiler .summary(fileset, output.toPath(), env, end - start, " " + assemblyOutput, "Assets: " + distFile); logger.info(summary.toString()); .toFile(); to.getParentFile().mkdirs(); logger.debug("copying file to: " + to); Files.copy(from, to);
private void fixParserToTypescript() { if (this.prettierConfig == null) { this.prettierConfig = Collections.singletonMap("parser", "typescript"); } else { final Object replaced = this.prettierConfig.put("parser", "typescript"); if (replaced != null) { getProject().getLogger().warn("overriding parser option to 'typescript'. Was set to '{}'", replaced); } } } }
public void apply(Project project) { project.getPlugins().apply( "java" ); final HibernateExtension hibernateExtension = new HibernateExtension( project ); project.getLogger().debug( "Adding Hibernate extensions to the build [{}]", project.getName() ); project.getExtensions().add( "hibernate", hibernateExtension ); project.afterEvaluate( new Action<Project>() { @Override public void execute(Project project) { if ( hibernateExtension.enhance != null ) { applyEnhancement( project, hibernateExtension ); } } } ); }
@SuppressFBWarnings("NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE") static void check(SpotlessTask task, Formatter formatter, List<File> problemFiles) throws IOException { if (problemFiles.isEmpty()) { // if the first pass was successful, then paddedCell() mode is unnecessary task.getLogger().info(StringPrinter.buildStringFromLines( task.getName() + " is in paddedCell() mode, but it doesn't need to be.", "If you remove that option, spotless will run ~2x faster.", "For details see " + URL)); } File diagnoseDir = diagnoseDir(task); File rootDir = task.getProject().getRootDir(); List<File> stillFailing = PaddedCellBulk.check(rootDir, diagnoseDir, formatter, problemFiles); if (!stillFailing.isEmpty()) { throw task.formatViolationsFor(formatter, problemFiles); } } }
/** Method interface has been changed to * {@link GroovyExtension#importOrder(String...)}.*/ @Deprecated public void importOrder(List<String> importOrder) { getProject().getLogger().warn( StringPrinter.buildStringFromLines( "'importOrder([x, y, z])' is deprecated.", "Use 'importOrder x, y, z' instead.", "For details see https://github.com/diffplug/spotless/tree/master/plugin-gradle#applying-to-java-source")); importOrder(importOrder.toArray(new String[0])); }
private void runTask(final ProjectConnection connection, final Path path, final String task) { synchronized (LOCK) { Map<String, String> xml = new HashMap<>(); try { // clean jaxp XML_PROPS.forEach(p -> xml.put(p, (String) System.getProperties().remove(p))); try { connection.newBuild() .setStandardError(System.err) .setStandardOutput(System.out) .forTasks(task) .run(); } catch (Exception ex) { getLogger().debug("Execution of " + task + " resulted in exception", ex); } } finally { // restore jaxp xml.forEach((k, v) -> { if (v != null) { System.setProperty(k, v); } }); } } }
/** Use {@link #eclipse(String)} instead */ @Deprecated public void eclipseFormatFile(String eclipseVersion, Object eclipseFormatFile) { Objects.requireNonNull(eclipseVersion, "eclipseVersion"); Objects.requireNonNull(eclipseFormatFile, "eclipseFormatFile"); getProject().getLogger().warn( StringPrinter.buildStringFromLines( "'eclipseFormatFile [version] <file>' is deprecated.", "Use 'eclipse([version]).configFile(<file>)' instead.", "For details see https://github.com/diffplug/spotless/tree/master/plugin-gradle#applying-to-java-source")); eclipse(eclipseVersion).configFile(eclipseFormatFile); }
new UnionFileCollection(javaCompiler.getSource(), project.fileTree(destinationFolder)); javaCompiler.setSource(uft); logger.debug("Analyzing configuration: " + variantCompileClasspath.getFiles()); Set<String> targetActivities = new HashSet<>(); Streams.stream(variantCompileClasspath) .forEach( dependency -> { logger.debug("Detected dependency: {}", dependency.getAbsolutePath()); if (dependency.getName().endsWith(".jar")) { logger.debug("Detected navigation API dependency: {}", dependency.getName()); if (!dependency.exists()) { logger.debug("Dependency jar doesn't exist {}", dependency.getAbsolutePath()); } else { File file = dependency.getAbsoluteFile(); entry -> { if (entry.matches(".*__IntentBuilder.class")) { logger.debug("Detected intent builder: {}", entry); String targetActivityFQN = entry File generatedFile = getHensonNavigatorSourceFile(); try { logger.debug("Generating Henson navigator in " + generatedFile.getAbsolutePath()); logger.debug(hensonNavigator); Files.write(generatedFile.toPath(), singletonList(hensonNavigator)); } catch (IOException e) {
/** Method interface has been changed to * {@link JavaExtension#importOrder(String...)}.*/ @Deprecated public void importOrder(List<String> importOrder) { getProject().getLogger().warn( StringPrinter.buildStringFromLines( "'importOrder([x, y, z])' is deprecated.", "Use 'importOrder x, y, z' instead.", "For details see https://github.com/diffplug/spotless/tree/master/plugin-gradle#applying-to-java-source")); addStep(ImportOrderStep.createFromOrder(importOrder)); }