Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -284,9 +284,7 @@ private Collection<Artifact> getAllNonTestScopedDependencies() throws MojoExecut
private Collection<Artifact> getAllDependencies() throws MojoExecutionException {
List<Artifact> artifacts = new ArrayList<>();

for (Iterator<?> dependencies = project.getDependencies().iterator(); dependencies.hasNext();) {
Dependency dependency = (Dependency) dependencies.next();

for (Dependency dependency : project.getDependencies()) {
String groupId = dependency.getGroupId();
String artifactId = dependency.getArtifactId();

Expand Down Expand Up @@ -407,10 +405,7 @@ private List<ConfigurerOption> processClass(String fqn) throws ClassNotFoundExce

private boolean filterSetter(Method setter) {
// special for some
if ("setBindingMode".equals(setter.getName())) {
// we only want the string setter
return setter.getParameterTypes()[0] == String.class;
} else if ("setHostNameResolver".equals(setter.getName())) {
if ("setBindingMode".equals(setter.getName()) || "setHostNameResolver".equals(setter.getName())) {
// we only want the string setter
return setter.getParameterTypes()[0] == String.class;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
import org.sonatype.plexus.build.incremental.BuildContext;

public abstract class AbstractGenerateMojo extends AbstractMojo {
private static final String INCREMENTAL_DATA = "";

@Parameter(property = "project", required = true, readonly = true)
protected MavenProject project;
Expand All @@ -63,7 +64,7 @@ public void execute() throws MojoExecutionException, MojoFailureException {
writeIncrementalInfo(project);
}
} catch (Exception e) {
throw new MojoFailureException("Error generating data " + e.toString(), e);
throw new MojoFailureException("Error generating data " + e, e);
}
}

Expand Down Expand Up @@ -103,10 +104,9 @@ protected void invoke(Class<? extends AbstractMojo> mojoClass, Map<String, Objec
private void writeIncrementalInfo(MavenProject project) throws MojoExecutionException {
try {
Path cacheData = getIncrementalDataPath(project);
String curdata = getIncrementalData();
Files.createDirectories(cacheData.getParent());
try (Writer w = Files.newBufferedWriter(cacheData)) {
w.append(curdata);
w.append(INCREMENTAL_DATA);
}
} catch (IOException e) {
throw new MojoExecutionException("Error checking manifest uptodate status", e);
Expand All @@ -116,14 +116,8 @@ private void writeIncrementalInfo(MavenProject project) throws MojoExecutionExce
private boolean isUpToDate(MavenProject project) throws MojoExecutionException {
try {
Path cacheData = getIncrementalDataPath(project);
String prvdata;
if (Files.isRegularFile(cacheData)) {
prvdata = new String(Files.readAllBytes(cacheData), StandardCharsets.UTF_8);
} else {
prvdata = null;
}
String curdata = getIncrementalData();
if (curdata.equals(prvdata)) {
final String prvdata = getPreviousRunData(cacheData);
if (INCREMENTAL_DATA.equals(prvdata)) {
long lastmod = Files.getLastModifiedTime(cacheData).toMillis();
Set<String> stale = Stream.concat(Stream.concat(
project.getCompileSourceRoots().stream().map(File::new),
Expand Down Expand Up @@ -155,6 +149,14 @@ private boolean isUpToDate(MavenProject project) throws MojoExecutionException {
return false;
}

private String getPreviousRunData(Path cacheData) throws IOException {
if (Files.isRegularFile(cacheData)) {
return new String(Files.readAllBytes(cacheData), StandardCharsets.UTF_8);
} else {
return null;
}
}

private String getIncrementalData() {
return "";
}
Expand Down Expand Up @@ -183,7 +185,7 @@ private Stream<String> newer(long lastmod, File file) {
try (ZipFile zf = new ZipFile(file)) {
return zf.stream().filter(ze -> !ze.isDirectory())
.filter(ze -> ze.getLastModifiedTime().toMillis() > lastmod)
.map(ze -> file.toString() + "!" + ze.getName()).collect(Collectors.toList()).stream();
.map(ze -> file + "!" + ze.getName()).collect(Collectors.toList()).stream();
} catch (IOException e) {
throw new IOException("Error reading zip file: " + file, e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ public static boolean haveResourcesChanged(Log log, MavenProject project, BuildC
}

protected static <T> Supplier<T> cache(Supplier<T> supplier) {
return new Supplier<T>() {
return new Supplier<>() {
T value;

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@

import javax.annotation.Generated;

import org.apache.camel.maven.packaging.dsl.DslHelper;
import org.apache.camel.tooling.model.BaseModel;
import org.apache.camel.tooling.model.ComponentModel;
import org.apache.camel.tooling.model.ComponentModel.EndpointOptionModel;
Expand Down Expand Up @@ -845,7 +846,7 @@ private boolean synchronizeEndpointBuildersStaticClass(List<Method> methods) thr
javaClass.addAnnotation(Generated.class).setStringValue("value", EndpointDslMojo.class.getName());

// sort methods
Collections.sort(methods, (m1, m2) -> m1.getName().compareToIgnoreCase(m2.getName()));
methods.sort((m1, m2) -> m1.getName().compareToIgnoreCase(m2.getName()));
// create method
for (Method method : methods) {
javaClass.addMethod(method);
Expand Down Expand Up @@ -919,19 +920,7 @@ private static String camelCaseLower(String s) {
}
if (s != null) {
s = s.substring(0, 1).toLowerCase() + s.substring(1);
switch (s) {
case "class":
s = "clas";
break;
case "package":
s = "packag";
break;
case "rest":
s = "restEndpoint";
break;
default:
break;
}
s = DslHelper.sanitizeText(s);
}
return s;
}
Expand Down Expand Up @@ -963,7 +952,7 @@ private String getMainDescription(ComponentModel model) {
if (option.isDeprecated()) {
descSb.append(" <strong>deprecated</strong>");
}
descSb.append("\n" + option.getDescription());
descSb.append("\n").append(option.getDescription());
if (option.getDefaultValue() != null) {
descSb.append("\nDefault value: ").append(option.getDefaultValue());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ private void executeUriEndpoint() {
}
}
// make sure we sort the classes in case one inherit from the other
classes.sort((c1, c2) -> compareClasses(c1, c2));
classes.sort(this::compareClasses);

Map<Class, ComponentModel> models = new HashMap<>();
for (Class<?> classElement : classes) {
Expand Down Expand Up @@ -295,9 +295,8 @@ protected ComponentModel writeJSonSchemeAndPropertyConfigurer(

private String getExcludedEnd(Metadata classElement) {
String excludedEndpointProperties = "";
Metadata endpointMetadata = classElement;
if (endpointMetadata != null) {
excludedEndpointProperties = endpointMetadata.excludeProperties();
if (classElement != null) {
excludedEndpointProperties = classElement.excludeProperties();
}
return excludedEndpointProperties;
}
Expand Down Expand Up @@ -339,7 +338,7 @@ private String loadResource(String fileName) {
}
data = PackageHelper.loadText(is);
} catch (Exception e) {
throw new RuntimeException("Error while loading " + fileName + ": " + e.toString(), e);
throw new RuntimeException("Error while loading " + fileName + ": " + e, e);
}
resources.put(fileName, data);
return data;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public static String generateEndpointUriFactory(String pn, String cn, String psn
w.append("\n");
w.append(" @Override\n");
w.append(" public boolean isLenientProperties() {\n");
w.append(" return " + model.isLenientProperties() + ";\n");
w.append(" return ").append(model.isLenientProperties()).append(";\n");
w.append(" }\n");
w.append("}\n");
w.append("\n");
Expand Down Expand Up @@ -213,7 +213,7 @@ private static String alternativeSchemes(ComponentModel model) {
for (String alt : alts) {
sj.add("\"" + alt + "\"");
}
sb.append(sj.toString());
sb.append(sj);
sb.append("}");
}
if (sb.length() == 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,8 @@ public static String escape(final String raw) {
}

final String escapedCurlyBrackets = CURLY_BRACKET_ESCAPE.matcher(raw).replaceAll("\\\\$1\\}");
final String escapedUrls = URL_ESCAPE.matcher(escapedCurlyBrackets).replaceAll("\\\\$1");

return escapedUrls;
return URL_ESCAPE.matcher(escapedCurlyBrackets).replaceAll("\\\\$1");
}

public static String componentName(String scheme) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,10 @@
package org.apache.camel.maven.packaging;

import java.io.File;
import java.io.FileFilter;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

import org.apache.camel.tooling.util.PackageHelper;
Expand Down Expand Up @@ -91,12 +89,8 @@ public static void generateArchetypeCatalog(Log log, MavenProject project, Maven
log.info("Scanning for Camel Maven Archetypes from directory: " + archetypes);

// find all archetypes which are in the parent dir of the build dir
File[] dirs = archetypes.listFiles(new FileFilter() {
@Override
public boolean accept(File pathname) {
return pathname.getName().startsWith("camel-archetype") && pathname.isDirectory();
}
});
File[] dirs
= archetypes.listFiles(pathname -> pathname.getName().startsWith("camel-archetype") && pathname.isDirectory());

List<ArchetypeModel> models = new ArrayList<>();

Expand Down Expand Up @@ -154,7 +148,7 @@ public boolean accept(File pathname) {
}

// sort the models by artifact id so its generated in same order
Collections.sort(models, (o1, o2) -> o1.getArtifactId().compareToIgnoreCase(o2.getArtifactId()));
models.sort((o1, o2) -> o1.getArtifactId().compareToIgnoreCase(o2.getArtifactId()));

log.info("Found " + models.size() + " archetypes");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
Expand Down Expand Up @@ -222,8 +221,9 @@ public int prepareDataFormat() throws MojoExecutionException {
.collect(Collectors.toSet());
List<DataFormatOptionModel> options = parseConfigurationSource(project, javaType);
options.removeIf(o -> !names.contains(o.getName()));
names.removeAll(options.stream().map(DataFormatOptionModel::getName).collect(Collectors.toList()));
names.removeAll(Arrays.asList("id"));
options.stream().map(DataFormatOptionModel::getName).collect(Collectors.toList())
.forEach(names::remove);
names.removeAll(List.of("id"));
if (!names.isEmpty()) {
log.warn("Unmapped options: " + String.join(",", names));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@ protected void updatePomAndCommonBin(File allComponentsPom, String groupId, Stri
StringBuilder sb = new StringBuilder();
for (String aid : artifactIds) {
sb.append(" <dependency>\n");
sb.append(" <groupId>" + groupId + "</groupId>\n");
sb.append(" <artifactId>" + aid + "</artifactId>\n");
sb.append(" <groupId>").append(groupId).append("</groupId>\n");
sb.append(" <artifactId>").append(aid).append("</artifactId>\n");
sb.append(" <version>${project.version}</version>\n");
sb.append(" </dependency>\n");
}
Expand All @@ -130,7 +130,7 @@ protected void updatePomAndCommonBin(File allComponentsPom, String groupId, Stri
// update common-bin.xml
sb = new StringBuilder();
for (String aid : artifactIds) {
sb.append(" <include>" + groupId + ":" + aid + "</include>\n");
sb.append(" <include>").append(groupId).append(":").append(aid).append("</include>\n");
}
changed = sb.toString();
updated = updateXmlFile(commonBinXml, token, changed, " ");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ public class PrepareCatalogMojo extends AbstractMojo {

private Collection<Path> allJsonFiles;
private Collection<Path> allPropertiesFiles;
private Map<Path, BaseModel<?>> allModels = new HashMap<>();
private final Map<Path, BaseModel<?>> allModels = new HashMap<>();

private static String asComponentName(Path file) {
String name = file.getFileName().toString();
Expand Down Expand Up @@ -825,10 +825,9 @@ private void printMissingDocumentsReport(Set<String> docs, Set<String> component
missing.clear();

for (String other : others) {
String name = other;

if (!docs.contains(name)) {
missing.add(name);
if (!docs.contains(other)) {
missing.add(other);
}
}
if (!missing.isEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,7 @@ private String templateExamples(List<ExampleModel> models, long deprecated) thro
Map<String, Object> map = new HashMap<>();
map.put("examples", models);
map.put("numberOfDeprecated", deprecated);
String out = (String) TemplateRuntime.eval(template, map, Collections.singletonMap("util", MvelHelper.INSTANCE));
return out;
return (String) TemplateRuntime.eval(template, map, Collections.singletonMap("util", MvelHelper.INSTANCE));
} catch (Exception e) {
throw new MojoExecutionException("Error processing mvel template. Reason: " + e, e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ protected void updateParentPom(String groupId, File dir, String token) throws Mo
StringBuilder sb = new StringBuilder();
for (String aid : artifactIds) {
sb.append(" <dependency>\n");
sb.append(" <groupId>" + groupId + "</groupId>\n");
sb.append(" <artifactId>" + aid + "</artifactId>\n");
sb.append(" <groupId>").append(groupId).append("</groupId>\n");
sb.append(" <artifactId>").append(aid).append("</artifactId>\n");
sb.append(" <version>${project.version}</version>\n");
sb.append(" </dependency>\n");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -403,9 +403,9 @@ private static String createGetOrCreateConfiguration(
String line1 = String.format(" private %s %s(%s target) {\n", configurationClass, methodName, targetClass);
String line2 = String.format(" if (target.%s() == null) {\n", getter);
String line3 = String.format(" target.%s(new %s());\n", setter, configurationClass);
String line4 = String.format(" }\n");
String line4 = " }\n";
String line5 = String.format(" return target.%s();\n", getter);
String line6 = String.format(" }\n");
String line6 = " }\n";

sb.append(line1).append(line2).append(line3).append(line4).append(line5).append(line6);
return sb.toString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ private boolean processAttribute(

// we want to skip inheritErrorHandler which is only applicable for
// the load-balancer
boolean loadBalancer = "LoadBalanceDefinition".equals(originalClassType.getSimpleName().toString());
boolean loadBalancer = "LoadBalanceDefinition".equals(originalClassType.getSimpleName());
if (!loadBalancer && "inheritErrorHandler".equals(name)) {
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -757,8 +757,7 @@ private static String loadEipJson(File file) {
}

private ComponentModel generateComponentModel(String json) {
ComponentModel component = JsonMapper.generateComponentModel(json);
return component;
return JsonMapper.generateComponentModel(json);
}

private OtherModel generateOtherModel(String json) {
Expand All @@ -767,8 +766,7 @@ private OtherModel generateOtherModel(String json) {
}

private DataFormatModel generateDataFormatModel(String json) {
DataFormatModel model = JsonMapper.generateDataFormatModel(json);
return model;
return JsonMapper.generateDataFormatModel(json);
}

private AnnotationModel generateAnnotationModel(Class<?> annotation) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public List<String> checkXRef(Path path) throws IOException {
Map<String, String> attributes = (Map) ((Map) site.get("asciidoc")).get("attributes");
if (attributes != null) {
attributes = attributes.entrySet().stream()
.collect(Collectors.toMap(e -> "{" + e.getKey() + "}", e -> e.getValue()));
.collect(Collectors.toMap(e -> "{" + e.getKey() + "}", Map.Entry::getValue));
}
Map<String, List<Path>> componentPaths = new HashMap<>();
Map<String, List<String>> componentNavs = new HashMap<>();
Expand Down Expand Up @@ -116,7 +116,7 @@ public List<String> checkXRef(Path path) throws IOException {
.filter(Files::isRegularFile)
.forEach(page -> {
Path rel = pagesDir.relativize(page);
pages.put(component + ":" + m + ":" + rel.toString(), page);
pages.put(component + ":" + m + ":" + rel, page);
});
});
}
Expand Down
Loading