This is an automated email from the ASF dual-hosted git repository. gnodet pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/camel.git
commit ca0ef2049ad36d20e90dfdbae5fa68cc37f4dad2 Author: Guillaume Nodet <[email protected]> AuthorDate: Mon Mar 8 16:39:01 2021 +0100 Use the standard formatter plugin and upgrade the impsort plugin --- .../resources/camel-eclipse-formatter-config.xml | 5 +- camel-dependencies/pom.xml | 3 +- catalog/pom.xml | 4 +- components/pom.xml | 4 +- core/pom.xml | 4 +- init/camel-format-plugin/README.md | 10 - init/camel-format-plugin/pom.xml | 91 --- .../net/revelc/code/formatter/FormatterMojo.java | 869 --------------------- .../net/revelc/code/formatter/ValidateMojo.java | 99 --- .../revelc/code/formatter/java/JavaFormatter.java | 98 --- .../src/main/resources/META-INF/LICENSE.txt | 203 ----- .../src/main/resources/META-INF/MANIFEST.MF | 0 .../src/main/resources/META-INF/NOTICE.txt | 14 - init/pom.xml | 1 - parent/pom.xml | 14 +- tests/pom.xml | 4 +- tooling/pom.xml | 4 +- 17 files changed, 21 insertions(+), 1406 deletions(-) diff --git a/buildingtools/src/main/resources/camel-eclipse-formatter-config.xml b/buildingtools/src/main/resources/camel-eclipse-formatter-config.xml index 0d3de6e..b382473 100644 --- a/buildingtools/src/main/resources/camel-eclipse-formatter-config.xml +++ b/buildingtools/src/main/resources/camel-eclipse-formatter-config.xml @@ -19,9 +19,6 @@ --> <profiles version="8"> <profile name="Camel Java Conventions" version="8" kind="CodeFormatterProfile"> - <setting id="org.apache.camel.formatter.java.exclusion_pattern" - value="\b((from|fromF)\([^;]*\.end[^;]*?\)|rest\([^;]*?\));"/> - <setting id="org.eclipse.jdt.core.formatter.align_assignment_statements_on_columns" value="false"/> <setting id="org.eclipse.jdt.core.formatter.align_fields_grouping_blank_lines" value="2147483647"/> <setting id="org.eclipse.jdt.core.formatter.align_type_members_on_columns" value="false"/> @@ -134,7 +131,7 @@ <setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_method" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_package" value="insert"/> - <setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter" value="insert"/> + <setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_type" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_label" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer" value="do not insert"/> diff --git a/camel-dependencies/pom.xml b/camel-dependencies/pom.xml index b6c13f5..a93b72d 100644 --- a/camel-dependencies/pom.xml +++ b/camel-dependencies/pom.xml @@ -201,6 +201,7 @@ <flatpack-version>4.0.4</flatpack-version> <flink-version>1.12.2</flink-version> <fop-version>2.6</fop-version> + <formatter-maven-plugin-version>2.14.0</formatter-maven-plugin-version> <freemarker-version>2.3.31</freemarker-version> <ftpserver-version>1.1.1</ftpserver-version> <geronimo-annotation-1.0-spec-version>1.1.1</geronimo-annotation-1.0-spec-version> @@ -272,7 +273,7 @@ <ical4j-version>1.0.7</ical4j-version> <icu4j-version>68.2</icu4j-version> <ignite-version>2.9.1</ignite-version> - <impsort-maven-plugin-version>1.5.0</impsort-maven-plugin-version> + <impsort-maven-plugin-version>1.6.0</impsort-maven-plugin-version> <infinispan-version>12.0.1.Final</infinispan-version> <influx-guava-version>20.0</influx-guava-version> <influx-java-driver-version>2.21</influx-java-driver-version> diff --git a/catalog/pom.xml b/catalog/pom.xml index 18762b1..b0b1f0c 100644 --- a/catalog/pom.xml +++ b/catalog/pom.xml @@ -76,8 +76,8 @@ </executions> </plugin> <plugin> - <groupId>org.apache.camel</groupId> - <artifactId>camel-format-plugin</artifactId> + <groupId>net.revelc.code.formatter</groupId> + <artifactId>formatter-maven-plugin</artifactId> </plugin> </plugins> </build> diff --git a/components/pom.xml b/components/pom.xml index e2422b3..8b55ab9 100644 --- a/components/pom.xml +++ b/components/pom.xml @@ -521,8 +521,8 @@ </executions> </plugin> <plugin> - <groupId>org.apache.camel</groupId> - <artifactId>camel-format-plugin</artifactId> + <groupId>net.revelc.code.formatter</groupId> + <artifactId>formatter-maven-plugin</artifactId> </plugin> </plugins> </build> diff --git a/core/pom.xml b/core/pom.xml index 3d87bc0..e184858 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -186,8 +186,8 @@ </executions> </plugin> <plugin> - <groupId>org.apache.camel</groupId> - <artifactId>camel-format-plugin</artifactId> + <groupId>net.revelc.code.formatter</groupId> + <artifactId>formatter-maven-plugin</artifactId> </plugin> </plugins> </build> diff --git a/init/camel-format-plugin/README.md b/init/camel-format-plugin/README.md deleted file mode 100644 index 173b41a..0000000 --- a/init/camel-format-plugin/README.md +++ /dev/null @@ -1,10 +0,0 @@ -# camel-format-plugin - -The plugin is used to reformat the source code at build time. It repackages -the `net.revelc.code.formatter:formatter-maven-plugin`, adding a way to exclude -portions of the source file from being formatted. This is useful to avoid -reformating inside the DSL which is usually indented with semantics. - -The only modified file is the `JavaFormatter` class. The two other `FormatterMojo` -and `ValidateMojo` classes are provided so that the maven plugin plugin can easily detect -the goals. diff --git a/init/camel-format-plugin/pom.xml b/init/camel-format-plugin/pom.xml deleted file mode 100644 index 7897df2..0000000 --- a/init/camel-format-plugin/pom.xml +++ /dev/null @@ -1,91 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - - Licensed to the Apache Software Foundation (ASF) under one or more - contributor license agreements. See the NOTICE file distributed with - this work for additional information regarding copyright ownership. - The ASF licenses this file to You under the Apache License, Version 2.0 - (the "License"); you may not use this file except in compliance with - the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - ---> -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - <modelVersion>4.0.0</modelVersion> - - <parent> - <groupId>org.apache.camel</groupId> - <artifactId>init</artifactId> - <version>3.9.0-SNAPSHOT</version> - <relativePath>..</relativePath> - </parent> - - <artifactId>camel-format-plugin</artifactId> - <packaging>maven-plugin</packaging> - - <name>Camel :: Maven Plugins :: Enhanced Formatter Plugin</name> - <description>Plugin to automatically reformat the code</description> - - <dependencies> - <dependency> - <groupId>net.revelc.code.formatter</groupId> - <artifactId>formatter-maven-plugin</artifactId> - <version>${formatter-maven-plugin.version}</version> - <scope>compile</scope> - </dependency> - <dependency> - <groupId>io.github.java-diff-utils</groupId> - <artifactId>java-diff-utils</artifactId> - <version>${java-diff-utils-version}</version> - <scope>compile</scope> - </dependency> - - <dependency> - <groupId>org.apache.maven</groupId> - <artifactId>maven-plugin-api</artifactId> - <version>3.6.3</version> - <scope>provided</scope> - </dependency> - <dependency> - <groupId>org.apache.maven.plugin-tools</groupId> - <artifactId>maven-plugin-annotations</artifactId> - <version>3.6.0</version> - <scope>provided</scope> - </dependency> - </dependencies> - - <build> - <plugins> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-shade-plugin</artifactId> - <version>3.2.4</version> - <executions> - <execution> - <phase>package</phase> - <goals> - <goal>shade</goal> - </goals> - <configuration> - <artifactSet> - <includes> - <include>net.revelc.code.formatter:formatter-maven-plugin</include> - </includes> - </artifactSet> - <promoteTransitiveDependencies>true</promoteTransitiveDependencies> - </configuration> - </execution> - </executions> - </plugin> - </plugins> - </build> - -</project> diff --git a/init/camel-format-plugin/src/main/java/net/revelc/code/formatter/FormatterMojo.java b/init/camel-format-plugin/src/main/java/net/revelc/code/formatter/FormatterMojo.java deleted file mode 100644 index 67a3908..0000000 --- a/init/camel-format-plugin/src/main/java/net/revelc/code/formatter/FormatterMojo.java +++ /dev/null @@ -1,869 +0,0 @@ -/* - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package net.revelc.code.formatter; - -import java.io.BufferedInputStream; -import java.io.BufferedOutputStream; -import java.io.BufferedReader; -import java.io.BufferedWriter; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.nio.charset.Charset; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Properties; - -import org.xml.sax.SAXException; - -import com.github.difflib.DiffUtils; -import com.github.difflib.patch.Patch; -import com.google.common.base.Strings; -import com.google.common.hash.Hashing; -import net.revelc.code.formatter.css.CssFormatter; -import net.revelc.code.formatter.html.HTMLFormatter; -import net.revelc.code.formatter.java.JavaFormatter; -import net.revelc.code.formatter.javascript.JavascriptFormatter; -import net.revelc.code.formatter.json.JsonFormatter; -import net.revelc.code.formatter.model.ConfigReadException; -import net.revelc.code.formatter.model.ConfigReader; -import net.revelc.code.formatter.xml.XMLFormatter; -import org.apache.maven.plugin.AbstractMojo; -import org.apache.maven.plugin.MojoExecutionException; -import org.apache.maven.plugin.MojoFailureException; -import org.apache.maven.plugin.logging.Log; -import org.apache.maven.plugins.annotations.Component; -import org.apache.maven.plugins.annotations.LifecyclePhase; -import org.apache.maven.plugins.annotations.Mojo; -import org.apache.maven.plugins.annotations.Parameter; -import org.codehaus.plexus.resource.ResourceManager; -import org.codehaus.plexus.resource.loader.FileResourceLoader; -import org.codehaus.plexus.resource.loader.ResourceNotFoundException; -import org.codehaus.plexus.util.DirectoryScanner; -import org.codehaus.plexus.util.ReaderFactory; -import org.codehaus.plexus.util.StringUtils; -import org.codehaus.plexus.util.WriterFactory; -import org.eclipse.jdt.core.JavaCore; -import org.eclipse.jdt.core.formatter.CodeFormatter; -import org.eclipse.jface.text.BadLocationException; -import org.eclipse.text.edits.MalformedTreeException; - -/** - * A Maven plugin mojo to format Java source code using the Eclipse code formatter. - * - * Mojo parameters allow customizing formatting by specifying the config XML file, line endings, compiler version, and - * source code locations. Reformatting source files is avoided using an sha512 hash of the content, comparing to the - * original hash to the hash after formatting and a cached hash. - * - * @author jecki - * @author Matt Blanchette - * @author marvin.froeder - */ -@Mojo(name = "format", defaultPhase = LifecyclePhase.PROCESS_SOURCES, requiresProject = true, threadSafe = true) -public class FormatterMojo extends AbstractMojo implements ConfigurationSource { - - private static final String FILE_S = " file(s)"; - - /** The Constant CACHE_PROPERTIES_FILENAME. */ - private static final String CACHE_PROPERTIES_FILENAME = "formatter-maven-cache.properties"; - - /** The Constant DEFAULT_INCLUDES. */ - private static final String[] DEFAULT_INCLUDES = new String[] { "**/*.css", "**/*.json", "**/*.html", "**/*.java", - "**/*.js", "**/*.xml" }; - - /** - * ResourceManager for retrieving the configFile resource. - */ - @Component(role = ResourceManager.class) - private ResourceManager resourceManager; - - /** - * Project's source directory as specified in the POM. - */ - @Parameter(defaultValue = "${project.build.sourceDirectory}", property = "sourceDirectory", required = true) - private File sourceDirectory; - - /** - * Project's test source directory as specified in the POM. - */ - @Parameter(defaultValue = "${project.build.testSourceDirectory}", property = "testSourceDirectory", required = true) - private File testSourceDirectory; - - /** - * Project's target directory as specified in the POM. - */ - @Parameter(defaultValue = "${project.build.directory}", readonly = true, required = true) - private File targetDirectory; - - /** - * Project's base directory. - */ - @Parameter(defaultValue = ".", property = "project.basedir", readonly = true, required = true) - private File basedir; - - /** - * Projects cache directory. - * - * <p> - * This file is a hash cache of the files in the project source. It can be preserved in source code such that it - * ensures builds are always fast by not unnecessarily writing files constantly. It can also be added to gitignore - * in case startup is not necessary. It further can be redirected to another location. - * - * <p> - * When stored in the repository, the cache if run on cross platforms will display the files multiple times due to - * line ending differences on the platform. - * - * <p> - * The cache itself has been part of formatter plugin for a long time but was hidden in target directory and did not - * survive clean phase when it should. This is not intended to be clean in that way as one would want as close to a - * no-op as possible when files are already all formatted and/or have not been otherwise touched. This is used based - * off the files in the project so it is as much part of the source as any other file is. - * - * @since 2.12.1 - */ - @Parameter(defaultValue = "${project.build.directory}", property = "formatter.cachedir") - private File cachedir; - - /** - * Location of the Java source files to format. Defaults to source main and test directories if not set. Deprecated - * in version 0.3. Reintroduced in 0.4. - * - * @since 0.4 - */ - @Parameter - private File[] directories; - - /** - * List of fileset patterns for Java source locations to include in formatting. Patterns are relative to the project - * source and test source directories. When not specified, the default include is <code>**/*.java</code> - * - * @since 0.3 - */ - @Parameter(property = "formatter.includes") - private String[] includes; - - /** - * List of fileset patterns for Java source locations to exclude from formatting. Patterns are relative to the - * project source and test source directories. When not specified, there is no default exclude. - * - * @since 0.3 - */ - @Parameter(property = "formatter.excludes") - private String[] excludes; - - /** - * Java compiler source version. - */ - @Parameter(defaultValue = "1.8", property = "maven.compiler.source", required = true) - private String compilerSource; - - /** - * Java compiler compliance version. - */ - @Parameter(defaultValue = "1.8", property = "maven.compiler.source", required = true) - private String compilerCompliance; - - /** - * Java compiler target version. - */ - @Parameter(defaultValue = "1.8", property = "maven.compiler.target", required = true) - private String compilerTargetPlatform; - - /** - * The file encoding used to read and write source files. When not specified and sourceEncoding also not set, - * default is platform file encoding. - * - * @since 0.3 - */ - @Parameter(property = "project.build.sourceEncoding", required = true) - private String encoding; - - /** - * Sets the line-ending of files after formatting. Valid values are: - * <ul> - * <li><b>"AUTO"</b> - Use line endings of current system</li> - * <li><b>"KEEP"</b> - Preserve line endings of files, default to AUTO if ambiguous</li> - * <li><b>"LF"</b> - Use Unix and Mac style line endings</li> - * <li><b>"CRLF"</b> - Use DOS and Windows style line endings</li> - * <li><b>"CR"</b> - Use early Mac style line endings</li> - * </ul> - * - * @since 0.2.0 - */ - @Parameter(defaultValue = "AUTO", property = "lineending", required = true) - private LineEnding lineEnding; - - /** - * File or classpath location of an Eclipse code formatter configuration xml file to use in formatting. - */ - @Parameter(defaultValue = "formatter-maven-plugin/eclipse/java.xml", property = "configfile", required = true) - private String configFile; - - /** - * File or classpath location of an Eclipse code formatter configuration xml file to use in formatting. - */ - @Parameter(defaultValue = "formatter-maven-plugin/eclipse/javascript.xml", property = "configjsfile", required = true) - private String configJsFile; - - /** - * File or classpath location of a properties file to use in html formatting. - */ - @Parameter(defaultValue = "formatter-maven-plugin/jsoup/html.properties", property = "confightmlfile", required = true) - private String configHtmlFile; - - /** - * File or classpath location of a properties file to use in xml formatting. - */ - @Parameter(defaultValue = "formatter-maven-plugin/eclipse/xml.properties", property = "configxmlfile", required = true) - private String configXmlFile; - - /** - * File or classpath location of a properties file to use in json formatting. - */ - @Parameter(defaultValue = "formatter-maven-plugin/jackson/json.properties", property = "configjsonfile", required = true) - private String configJsonFile; - - /** - * File or classpath location of a properties file to use in css formatting. - */ - @Parameter(defaultValue = "formatter-maven-plugin/ph-css/css.properties", property = "configcssfile", required = true) - private String configCssFile; - - /** - * Whether the java formatting is skipped. - */ - @Parameter(defaultValue = "false", property = "formatter.java.skip") - private boolean skipJavaFormatting; - - /** - * Whether the javascript formatting is skipped. - */ - @Parameter(defaultValue = "false", property = "formatter.js.skip") - private boolean skipJsFormatting; - - /** - * Whether the html formatting is skipped. - */ - @Parameter(defaultValue = "false", property = "formatter.html.skip") - private boolean skipHtmlFormatting; - - /** - * Whether the xml formatting is skipped. - */ - @Parameter(defaultValue = "false", property = "formatter.xml.skip") - private boolean skipXmlFormatting; - - /** - * Whether the json formatting is skipped. - */ - @Parameter(defaultValue = "false", property = "formatter.json.skip") - private boolean skipJsonFormatting; - - /** - * Whether the css formatting is skipped. - */ - @Parameter(defaultValue = "false", property = "formatter.css.skip") - private boolean skipCssFormatting; - - /** - * Whether the formatting is skipped. - * - * @since 0.5 - */ - @Parameter(defaultValue = "false", alias = "skip", property = "formatter.skip") - private boolean skipFormatting; - - /** - * Use eclipse defaults when set to true for java and javascript. - */ - @Parameter(defaultValue = "false", property = "formatter.useEclipseDefaults") - private boolean useEclipseDefaults; - - private JavaFormatter javaFormatter = new JavaFormatter(); - - private JavascriptFormatter jsFormatter = new JavascriptFormatter(); - - private HTMLFormatter htmlFormatter = new HTMLFormatter(); - - private XMLFormatter xmlFormatter = new XMLFormatter(); - - private JsonFormatter jsonFormatter = new JsonFormatter(); - - private CssFormatter cssFormatter = new CssFormatter(); - - private boolean hashCacheWritten; - - /** - * Execute. - * - * @throws MojoExecutionException - * the mojo execution exception - * @throws MojoFailureException - * the mojo failure exception - * - * @see AbstractMojo#execute() - */ - @Override - public void execute() throws MojoExecutionException, MojoFailureException { - if (this.skipFormatting) { - getLog().info("Formatting is skipped"); - return; - } - - long startClock = System.currentTimeMillis(); - - if (StringUtils.isEmpty(this.encoding)) { - this.encoding = ReaderFactory.FILE_ENCODING; - getLog().warn("File encoding has not been set, using platform encoding (" + this.encoding - + ") to format source files, i.e. build is platform dependent!"); - } else { - if (!Charset.isSupported(this.encoding)) { - throw new MojoExecutionException("Encoding '" + this.encoding + "' is not supported"); - } - getLog().info("Using '" + this.encoding + "' encoding to format source files."); - } - - List<File> files = new ArrayList<>(); - if (this.directories != null) { - for (File directory : this.directories) { - if (directory.exists() && directory.isDirectory()) { - files.addAll(addCollectionFiles(directory)); - } - } - } else { - // Using defaults of source main and test dirs - if (this.sourceDirectory != null && this.sourceDirectory.exists() && this.sourceDirectory.isDirectory()) { - files.addAll(addCollectionFiles(this.sourceDirectory)); - } - if (this.testSourceDirectory != null && this.testSourceDirectory.exists() - && this.testSourceDirectory.isDirectory()) { - files.addAll(addCollectionFiles(this.testSourceDirectory)); - } - } - - int numberOfFiles = files.size(); - Log log = getLog(); - log.info("Number of files to be formatted: " + numberOfFiles); - - if (numberOfFiles > 0) { - createCodeFormatter(); - ResultCollector rc = new ResultCollector(); - Properties hashCache = readFileHashCacheFile(); - - String basedirPath = getBasedirPath(); - for (int i = 0, n = files.size(); i < n; i++) { - File file = files.get(i); - if (file.exists()) { - if (file.canWrite()) { - formatFile(file, rc, hashCache, basedirPath); - } else { - rc.readOnlyCount++; - } - } else { - rc.failCount++; - } - } - - // Only store the cache if it changed during processing to avoid java properties timestamp writting for - // those that want to save the cache - if (hashCacheWritten) { - storeFileHashCache(hashCache); - } - - // only output if we formatted something - if (rc.successCount > 0) { - log.info("Successfully formatted: " + rc.successCount + FILE_S); - log.info("Fail to format: " + rc.failCount + FILE_S); - log.info("Skipped: " + rc.skippedCount + FILE_S); - log.info("Read only skipped: " + rc.readOnlyCount + FILE_S); - long endClock = System.currentTimeMillis(); - log.info("Approximate time taken: " + ((endClock - startClock) / 1000) + "s"); - } - } - } - - /** - * Add source files to the files list. - * - */ - List<File> addCollectionFiles(File newBasedir) { - final DirectoryScanner ds = new DirectoryScanner(); - ds.setBasedir(newBasedir); - if (this.includes != null && this.includes.length > 0) { - ds.setIncludes(this.includes); - } else { - ds.setIncludes(DEFAULT_INCLUDES); - } - - ds.setExcludes(this.excludes); - ds.addDefaultExcludes(); - ds.setCaseSensitive(false); - ds.setFollowSymlinks(false); - ds.scan(); - - List<File> foundFiles = new ArrayList<>(); - for (String filename : ds.getIncludedFiles()) { - foundFiles.add(new File(newBasedir, filename)); - } - return foundFiles; - } - - /** - * Gets the basedir path. - * - * @return the basedir path - */ - private String getBasedirPath() { - try { - return this.basedir.getCanonicalPath(); - } catch (IOException e) { - getLog().debug("", e); - return ""; - } - } - - /** - * Store file hash cache. - * - * @param props - * the props - */ - private void storeFileHashCache(Properties props) { - File cacheFile = new File(this.cachedir, CACHE_PROPERTIES_FILENAME); - try (OutputStream out = new BufferedOutputStream(new FileOutputStream(cacheFile))) { - props.store(out, null); - } catch (IOException e) { - getLog().warn("Cannot store file hash cache properties file", e); - } - } - - /** - * Read file hash cache file. - * - * @return the properties - */ - private Properties readFileHashCacheFile() { - Properties props = new Properties(); - Log log = getLog(); - if (!this.cachedir.exists()) { - this.cachedir.mkdirs(); - } else if (!this.cachedir.isDirectory()) { - log.warn("Something strange here as the '" + this.cachedir.getPath() - + "' supposedly cache directory is not a directory."); - return props; - } - - File cacheFile = new File(this.cachedir, CACHE_PROPERTIES_FILENAME); - if (!cacheFile.exists()) { - return props; - } - - try (BufferedInputStream stream = new BufferedInputStream(new FileInputStream(cacheFile))) { - props.load(stream); - } catch (IOException e) { - log.warn("Cannot load file hash cache properties file", e); - } - return props; - } - - /** - * Format file. - * - * @param file - * the file - * @param rc - * the rc - * @param hashCache - * the hash cache - * @param basedirPath - * the basedir path - * - * @throws MojoFailureException - * the mojo failure exception - * @throws MojoExecutionException - * the mojo execution exception - */ - private void formatFile(File file, ResultCollector rc, Properties hashCache, String basedirPath) - throws MojoFailureException, MojoExecutionException { - try { - doFormatFile(file, rc, hashCache, basedirPath, false); - } catch (IOException | MalformedTreeException | BadLocationException e) { - rc.failCount++; - getLog().warn(e); - } - } - - /** - * Format individual file. - * - * @param file - * the file - * @param rc - * the rc - * @param hashCache - * the hash cache - * @param basedirPath - * the basedir path - * @param dryRun - * the dry run - * - * @throws IOException - * Signals that an I/O exception has occurred. - * @throws BadLocationException - * the bad location exception - * @throws MojoFailureException - * the mojo failure exception - * @throws MojoExecutionException - * the mojo execution exception - */ - protected void doFormatFile(File file, ResultCollector rc, Properties hashCache, String basedirPath, boolean dryRun) - throws IOException, BadLocationException, MojoFailureException, MojoExecutionException { - Log log = getLog(); - log.debug("Processing file: " + file); - String originalCode = readFileAsString(file); - String originalHash = sha512hash(originalCode); - - String canonicalPath = file.getCanonicalPath(); - String path = canonicalPath.substring(basedirPath.length()); - String cachedHash = hashCache.getProperty(path); - if (cachedHash != null && cachedHash.equals(originalHash)) { - rc.skippedCount++; - log.debug("File is already formatted."); - return; - } - - Result result = null; - String formattedCode = null; - if (file.getName().endsWith(".java") && javaFormatter.isInitialized()) { - if (skipJavaFormatting) { - getLog().info("Java formatting is skipped"); - result = Result.SKIPPED; - } else { - formattedCode = this.javaFormatter.formatFile(file, originalCode, this.lineEnding); - } - } else if (file.getName().endsWith(".js") && jsFormatter.isInitialized()) { - if (skipJsFormatting) { - getLog().debug("Javascript formatting is skipped"); - result = Result.SKIPPED; - } else { - formattedCode = this.jsFormatter.formatFile(file, originalCode, this.lineEnding); - } - } else if (file.getName().endsWith(".html") && htmlFormatter.isInitialized()) { - if (skipHtmlFormatting) { - getLog().debug("Html formatting is skipped"); - result = Result.SKIPPED; - } else { - formattedCode = this.htmlFormatter.formatFile(file, originalCode, this.lineEnding); - } - } else if (file.getName().endsWith(".xml") && xmlFormatter.isInitialized()) { - if (skipXmlFormatting) { - getLog().info("Xml formatting is skipped"); - result = Result.SKIPPED; - } else { - formattedCode = this.xmlFormatter.formatFile(file, originalCode, this.lineEnding); - } - } else if (file.getName().endsWith(".json") && jsonFormatter.isInitialized()) { - if (skipJsonFormatting) { - getLog().info("json formatting is skipped"); - result = Result.SKIPPED; - } else { - formattedCode = this.jsonFormatter.formatFile(file, originalCode, this.lineEnding); - } - } else if (file.getName().endsWith(".css") && cssFormatter.isInitialized()) { - if (skipCssFormatting) { - getLog().debug("css formatting is skipped"); - result = Result.SKIPPED; - } else { - formattedCode = this.cssFormatter.formatFile(file, originalCode, this.lineEnding); - } - } else { - log.debug("No formatter found or initialization failed for file " + file.getName()); - result = Result.SKIPPED; - } - - // If not skipped, check formatting result - if (!Result.SKIPPED.equals(result)) { - if (formattedCode == null) { - result = Result.FAIL; - } else if (originalCode.equals(formattedCode)) { - result = Result.SKIPPED; - } else { - result = Result.SUCCESS; - } - } - - // Process the result type - if (Result.SKIPPED.equals(result)) { - rc.skippedCount++; - } else if (Result.SUCCESS.equals(result)) { - rc.successCount++; - rc.diff.add(DiffUtils.diff(originalCode, formattedCode, null)); - } else if (Result.FAIL.equals(result)) { - rc.failCount++; - return; - } - - // Write the cache - String formattedHash; - if (Result.SKIPPED.equals(result)) { - formattedHash = originalHash; - } else { - formattedHash = sha512hash(Strings.nullToEmpty(formattedCode)); - } - hashCache.setProperty(path, formattedHash); - hashCacheWritten = true; - - // If we had determined to skip write, do so now after cache was written - if (Result.SKIPPED.equals(result)) { - log.debug("File is already formatted. Writing to cache only."); - return; - } - - // As a safety check, if our hash matches, skip the write of file (should never occur) - if (originalHash.equals(formattedHash)) { - rc.skippedCount++; - log.debug("Equal hash code. Not writing result to file."); - return; - } - - // Now write the file - if (!dryRun) { - writeStringToFile(formattedCode, file); - } - } - - /** - * sha512hash. - * - * @param str - * the str - * - * @return the string - */ - private String sha512hash(String str) { - return Hashing.sha512().hashBytes(str.getBytes(getEncoding())).toString(); - } - - /** - * Read the given file and return the content as a string. - * - * @param file - * the file - * - * @return the string - * - * @throws IOException - * Signals that an I/O exception has occurred. - */ - private String readFileAsString(File file) throws IOException { - StringBuilder fileData = new StringBuilder(1000); - try (BufferedReader reader = new BufferedReader(ReaderFactory.newReader(file, this.encoding))) { - char[] buf = new char[1024]; - int numRead = 0; - while ((numRead = reader.read(buf)) != -1) { - String readData = String.valueOf(buf, 0, numRead); - fileData.append(readData); - buf = new char[1024]; - } - } - return fileData.toString(); - } - - /** - * Write the given string to a file. - * - * @param str - * the str - * @param file - * the file - * - * @throws IOException - * Signals that an I/O exception has occurred. - */ - private void writeStringToFile(String str, File file) throws IOException { - if (!file.exists() && file.isDirectory()) { - return; - } - - try (BufferedWriter bw = new BufferedWriter(WriterFactory.newWriter(file, this.encoding))) { - bw.write(str); - } - } - - /** - * Create a {@link CodeFormatter} instance to be used by this mojo. - * - * @throws MojoExecutionException - * the mojo execution exception - */ - private void createCodeFormatter() throws MojoExecutionException { - // Java Setup - Map<String, String> javaFormattingOptions = getFormattingOptions(this.configFile); - if (javaFormattingOptions != null) { - this.javaFormatter.init(javaFormattingOptions, this); - } - // Javascript Setup - Map<String, String> jsFormattingOptions = getFormattingOptions(this.configJsFile); - if (jsFormattingOptions != null) { - this.jsFormatter.init(jsFormattingOptions, this); - } - // Html Setup - if (configHtmlFile != null) { - this.htmlFormatter.init(getOptionsFromPropertiesFile(this.configHtmlFile), this); - } - // Xml Setup - if (configXmlFile != null) { - Map<String, String> xmlFormattingOptions = getOptionsFromPropertiesFile(this.configXmlFile); - xmlFormattingOptions.put("lineending", this.lineEnding.getChars()); - this.xmlFormatter.init(xmlFormattingOptions, this); - } - // Json Setup - if (configJsonFile != null) { - Map<String, String> jsonFormattingOptions = getOptionsFromPropertiesFile(this.configJsonFile); - jsonFormattingOptions.put("lineending", this.lineEnding.getChars()); - this.jsonFormatter.init(jsonFormattingOptions, this); - } - // Css Setup - if (configCssFile != null) { - this.cssFormatter.init(getOptionsFromPropertiesFile(configCssFile), this); - } - // stop the process if not config files where found - if (javaFormattingOptions == null && jsFormattingOptions == null && configHtmlFile == null - && configXmlFile == null && configCssFile == null) { - throw new MojoExecutionException( - "You must provide a Java, Javascript, HTML, XML, JSON, or CSS configuration file."); - } - } - - /** - * Return the options to be passed when creating {@link CodeFormatter} instance. - * - * @return the formatting options or null if not config file found - * - * @throws MojoExecutionException - * the mojo execution exception - */ - private Map<String, String> getFormattingOptions(String newConfigFile) throws MojoExecutionException { - if (this.useEclipseDefaults) { - getLog().info("Using Ecipse Defaults"); - // Use defaults only for formatting - Map<String, String> options = new HashMap<>(); - options.put(JavaCore.COMPILER_SOURCE, this.compilerSource); - options.put(JavaCore.COMPILER_COMPLIANCE, this.compilerCompliance); - options.put(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, this.compilerTargetPlatform); - return options; - } - - return getOptionsFromConfigFile(newConfigFile); - } - - /** - * Read config file and return the config as {@link Map}. - * - * @return the options from config file - * - * @throws MojoExecutionException - * the mojo execution exception - */ - private Map<String, String> getOptionsFromConfigFile(String newConfigFile) throws MojoExecutionException { - - this.getLog().debug("Using search path at: " + this.basedir.getAbsolutePath()); - this.resourceManager.addSearchPath(FileResourceLoader.ID, this.basedir.getAbsolutePath()); - - try (InputStream configInput = this.resourceManager.getResourceAsInputStream(newConfigFile)) { - return new ConfigReader().read(configInput); - } catch (ResourceNotFoundException e) { - throw new MojoExecutionException("Cannot find config file [" + newConfigFile + "]"); - } catch (IOException e) { - throw new MojoExecutionException("Cannot read config file [" + newConfigFile + "]", e); - } catch (SAXException e) { - throw new MojoExecutionException("Cannot parse config file [" + newConfigFile + "]", e); - } catch (ConfigReadException e) { - throw new MojoExecutionException(e.getMessage(), e); - } - } - - /** - * Read properties file and return the properties as {@link Map}. - * - * @return the options from properties file or null if not properties file found - * - * @throws MojoExecutionException - * the mojo execution exception - */ - private Map<String, String> getOptionsFromPropertiesFile(String newPropertiesFile) throws MojoExecutionException { - - this.getLog().debug("Using search path at: " + this.basedir.getAbsolutePath()); - this.resourceManager.addSearchPath(FileResourceLoader.ID, this.basedir.getAbsolutePath()); - - Properties properties = new Properties(); - try { - properties.load(this.resourceManager.getResourceAsInputStream(newPropertiesFile)); - } catch (ResourceNotFoundException e) { - getLog().debug("Property file [" + newPropertiesFile + "] cannot be found", e); - return new HashMap<>(); - } catch (IOException e) { - throw new MojoExecutionException("Cannot read config file [" + newPropertiesFile + "]", e); - } - - final Map<String, String> map = new HashMap<>(); - for (final String name : properties.stringPropertyNames()) { - map.put(name, properties.getProperty(name)); - } - return map; - } - - static class ResultCollector { - - int successCount; - - int failCount; - - int skippedCount; - - int readOnlyCount; - - List<Patch<String>> diff = new ArrayList<>(); - } - - @Override - public String getCompilerSources() { - return this.compilerSource; - } - - @Override - public String getCompilerCompliance() { - return this.compilerCompliance; - } - - @Override - public String getCompilerCodegenTargetPlatform() { - return this.compilerTargetPlatform; - } - - @Override - public File getTargetDirectory() { - return this.targetDirectory; - } - - @Override - public Charset getEncoding() { - return Charset.forName(this.encoding); - } -} diff --git a/init/camel-format-plugin/src/main/java/net/revelc/code/formatter/ValidateMojo.java b/init/camel-format-plugin/src/main/java/net/revelc/code/formatter/ValidateMojo.java deleted file mode 100755 index 1a25e21..0000000 --- a/init/camel-format-plugin/src/main/java/net/revelc/code/formatter/ValidateMojo.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package net.revelc.code.formatter; - -import java.io.File; -import java.io.IOException; -import java.util.List; -import java.util.Properties; - -import com.github.difflib.patch.AbstractDelta; -import com.github.difflib.patch.Patch; -import org.apache.maven.plugin.MojoExecutionException; -import org.apache.maven.plugin.MojoFailureException; -import org.apache.maven.plugins.annotations.LifecyclePhase; -import org.apache.maven.plugins.annotations.Mojo; -import org.apache.maven.plugins.annotations.Parameter; -import org.eclipse.jface.text.BadLocationException; - -/** - * This mojo is very similar to Formatter mojo, but it is focused on CI servers. - * - * If the code ain't formatted as expected this mojo will fail the build - * - * @author marvin.froeder - */ -@Mojo(name = "validate", defaultPhase = LifecyclePhase.VALIDATE, requiresProject = true, threadSafe = true) -public class ValidateMojo extends FormatterMojo { - - @Parameter(defaultValue = "false", property = "aggregator", required = true) - private boolean aggregator; - - @Parameter(defaultValue = "${project.executionRoot}", required = true) - private boolean executionRoot; - - @Override - public void execute() throws MojoExecutionException, MojoFailureException { - if (this.aggregator && !this.executionRoot) { - return; - } - - super.execute(); - } - - @Override - protected void doFormatFile(File file, ResultCollector rc, Properties hashCache, String basedirPath, boolean dryRun) - throws IOException, MojoFailureException, BadLocationException, MojoExecutionException { - super.doFormatFile(file, rc, hashCache, basedirPath, true); - - if (rc.successCount != 0) { - final String message = String.format( - "File '%s' has not been previously formatted. Please format file and commit before running validation!%n%s", - file, diffToString(rc.diff)); - throw new MojoFailureException(message); - } - if (rc.failCount != 0) { - throw new MojoExecutionException("Error formating '" + file + "' "); - } - } - - private static String diffToString(List<Patch<String>> diff) { - final String NL = System.lineSeparator(); - StringBuilder sb = new StringBuilder(); - - for (Patch<String> patch : diff) { - for (AbstractDelta<String> delta : patch.getDeltas()) { - sb.append("Type:\t").append(delta.getType()).append(NL); - if (delta.getSource() != null) { - sb.append("Line:\t").append(delta.getSource().getPosition()).append(NL); - if (!delta.getSource().getLines().isEmpty()) { - sb.append("Source:").append(NL); - for (String line : delta.getSource().getLines()) { - sb.append(line).append(NL); - } - } - } - - if (delta.getTarget() != null && !delta.getTarget().getLines().isEmpty()) { - sb.append("Target:").append(NL); - for (String line : delta.getTarget().getLines()) { - sb.append(line).append(NL); - } - } - sb.append("===============").append(NL); - } - } - return sb.toString(); - } -} diff --git a/init/camel-format-plugin/src/main/java/net/revelc/code/formatter/java/JavaFormatter.java b/init/camel-format-plugin/src/main/java/net/revelc/code/formatter/java/JavaFormatter.java deleted file mode 100755 index 1124f38..0000000 --- a/init/camel-format-plugin/src/main/java/net/revelc/code/formatter/java/JavaFormatter.java +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package net.revelc.code.formatter.java; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import net.revelc.code.formatter.AbstractCacheableFormatter; -import net.revelc.code.formatter.ConfigurationSource; -import net.revelc.code.formatter.Formatter; -import net.revelc.code.formatter.LineEnding; -import org.eclipse.jdt.core.ToolFactory; -import org.eclipse.jdt.core.formatter.CodeFormatter; -import org.eclipse.jface.text.BadLocationException; -import org.eclipse.jface.text.Document; -import org.eclipse.jface.text.IDocument; -import org.eclipse.jface.text.IRegion; -import org.eclipse.jface.text.Region; -import org.eclipse.text.edits.TextEdit; - -public class JavaFormatter extends AbstractCacheableFormatter implements Formatter { - - private static final String EXCLUSION_PATTERN = "org.apache.camel.formatter.java.exclusion_pattern"; - - private CodeFormatter formatter; - private Pattern exclusionPattern; - - @Override - public void init(Map<String, String> options, ConfigurationSource cfg) { - super.initCfg(cfg); - - this.formatter = ToolFactory.createCodeFormatter(options, ToolFactory.M_FORMAT_EXISTING); - String ep = options.get(EXCLUSION_PATTERN); - if (ep != null) { - exclusionPattern = Pattern.compile(ep, Pattern.MULTILINE); - } - } - - @Override - public String doFormat(String code, LineEnding ending) throws IOException, BadLocationException { - TextEdit te; - try { - List<IRegion> regions = new ArrayList<>(); - int start = 0; - if (exclusionPattern != null) { - Matcher matcher = exclusionPattern.matcher(code); - while (matcher.find()) { - int s = matcher.start(); - int e = matcher.end(); - regions.add(new Region(start, s - start)); - start = e; - } - } - regions.add(new Region(start, code.length() - start)); - - te = this.formatter.format(CodeFormatter.K_COMPILATION_UNIT | CodeFormatter.F_INCLUDE_COMMENTS, code, - regions.toArray(new IRegion[0]), 0, ending.getChars()); - if (te == null) { - this.log.debug( - "Code cannot be formatted. Possible cause is unmatched source/target/compliance version."); - return null; - } - } catch (IndexOutOfBoundsException e) { - this.log.debug("Code cannot be formatted for text -->" + code + "<--", e); - return null; - } - - IDocument doc = new Document(code); - te.apply(doc); - String formattedCode = doc.get(); - - if (code.equals(formattedCode)) { - return null; - } - return formattedCode; - } - - @Override - public boolean isInitialized() { - return formatter != null; - } - -} diff --git a/init/camel-format-plugin/src/main/resources/META-INF/LICENSE.txt b/init/camel-format-plugin/src/main/resources/META-INF/LICENSE.txt deleted file mode 100644 index 6b0b127..0000000 --- a/init/camel-format-plugin/src/main/resources/META-INF/LICENSE.txt +++ /dev/null @@ -1,203 +0,0 @@ - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - diff --git a/init/camel-format-plugin/src/main/resources/META-INF/MANIFEST.MF b/init/camel-format-plugin/src/main/resources/META-INF/MANIFEST.MF deleted file mode 100644 index e69de29..0000000 diff --git a/init/camel-format-plugin/src/main/resources/META-INF/NOTICE.txt b/init/camel-format-plugin/src/main/resources/META-INF/NOTICE.txt deleted file mode 100644 index 033c9a1..0000000 --- a/init/camel-format-plugin/src/main/resources/META-INF/NOTICE.txt +++ /dev/null @@ -1,14 +0,0 @@ - ========================================================================= - == NOTICE file corresponding to the section 4 d of == - == the Apache License, Version 2.0, == - == in this case for the Apache Camel distribution. == - ========================================================================= - - This product includes software developed by - The Apache Software Foundation (http://www.apache.org/). - - This product includes software developed by - code.revelc.net (https://code.revelc.net/). - - Please read the different LICENSE files present in the licenses directory of - this distribution. diff --git a/init/pom.xml b/init/pom.xml index 50e628f..da6bdec 100644 --- a/init/pom.xml +++ b/init/pom.xml @@ -34,7 +34,6 @@ <description>Camel Init</description> <modules> - <module>camel-format-plugin</module> <module>camel-bundle-plugin</module> </modules> diff --git a/parent/pom.xml b/parent/pom.xml index e85b166..c417ad0 100644 --- a/parent/pom.xml +++ b/parent/pom.xml @@ -185,6 +185,7 @@ <flatpack-version>4.0.4</flatpack-version> <flink-version>1.12.2</flink-version> <fop-version>2.6</fop-version> + <formatter-maven-plugin-version>2.14.0</formatter-maven-plugin-version> <ftpserver-version>1.1.1</ftpserver-version> <freemarker-version>2.3.31</freemarker-version> <geronimo-annotation-1.0-spec-version>1.1.1</geronimo-annotation-1.0-spec-version> @@ -252,7 +253,7 @@ <ical4j-version>1.0.7</ical4j-version> <icu4j-version>68.2</icu4j-version> <ignite-version>2.9.1</ignite-version> - <impsort-maven-plugin-version>1.5.0</impsort-maven-plugin-version> + <impsort-maven-plugin-version>1.6.0</impsort-maven-plugin-version> <infinispan-version>12.0.1.Final</infinispan-version> <influx-java-driver-version>2.21</influx-java-driver-version> <influx-guava-version>20.0</influx-guava-version> @@ -4081,9 +4082,9 @@ </executions> </plugin> <plugin> - <groupId>org.apache.camel</groupId> - <artifactId>camel-format-plugin</artifactId> - <version>${project.version}</version> + <groupId>net.revelc.code.formatter</groupId> + <artifactId>formatter-maven-plugin</artifactId> + <version>${formatter-maven-plugin-version}</version> <configuration> <configFile>camel-eclipse-formatter-config.xml</configFile> <skip>${format.skip}</skip> @@ -4093,6 +4094,7 @@ <cachedir>${basedir}/target</cachedir> <excludes>${sourcecheckExcludes}</excludes> <lineEnding>KEEP</lineEnding> + <javaExclusionPattern>\b((from|fromF)\([^;]*\.end[^;]*?\)|rest\([^;]*?\));</javaExclusionPattern> </configuration> <dependencies> <dependency> @@ -4537,8 +4539,8 @@ <artifactId>maven-checkstyle-plugin</artifactId> </plugin> <plugin> - <groupId>org.apache.camel</groupId> - <artifactId>camel-format-plugin</artifactId> + <groupId>net.revelc.code.formatter</groupId> + <artifactId>formatter-maven-plugin</artifactId> <executions> <execution> <id>format</id> diff --git a/tests/pom.xml b/tests/pom.xml index 3b75d57..58b0293 100644 --- a/tests/pom.xml +++ b/tests/pom.xml @@ -67,8 +67,8 @@ </executions> </plugin> <plugin> - <groupId>org.apache.camel</groupId> - <artifactId>camel-format-plugin</artifactId> + <groupId>net.revelc.code.formatter</groupId> + <artifactId>formatter-maven-plugin</artifactId> </plugin> </plugins> </build> diff --git a/tooling/pom.xml b/tooling/pom.xml index e894af4..f8c8c86 100644 --- a/tooling/pom.xml +++ b/tooling/pom.xml @@ -51,8 +51,8 @@ <build> <plugins> <plugin> - <groupId>org.apache.camel</groupId> - <artifactId>camel-format-plugin</artifactId> + <groupId>net.revelc.code.formatter</groupId> + <artifactId>formatter-maven-plugin</artifactId> </plugin> </plugins> </build>
