Skip to content

apply consolidation spotless-maven-plugin, formatter-maven-plugin, and impsort-maven-plugin #48397

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
90 changes: 0 additions & 90 deletions build-parent/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -673,11 +673,6 @@
<artifactId>smallrye-certificate-generator-maven-plugin</artifactId>
<version>${smallrye-certificate-generator.version}</version>
</plugin>
<plugin>
<groupId>com.diffplug.spotless</groupId>
<artifactId>spotless-maven-plugin</artifactId>
<version>2.44.4</version>
</plugin>
</plugins>
</pluginManagement>
</build>
Expand Down Expand Up @@ -723,92 +718,7 @@
</plugins>
</build>
</profile>
<profile>
<id>validate</id>
<activation>
<activeByDefault>true</activeByDefault>
<property>
<name>no-format</name>
</property>
</activation>
<build>
<plugins>
<plugin>
<groupId>net.revelc.code.formatter</groupId>
<artifactId>formatter-maven-plugin</artifactId>
<executions>
<execution>
<phase>process-sources</phase>
<goals>
<goal>validate</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>net.revelc.code</groupId>
<artifactId>impsort-maven-plugin</artifactId>
<configuration>
<removeUnused>true</removeUnused>
</configuration>
<executions>
<execution>
<id>check-imports</id>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>

<profile>
<id>format-kotlin</id>
<activation>
<activeByDefault>true</activeByDefault>
<property>
<name>!no-format</name>
</property>
<file>
<exists>src/main/kotlin</exists>
</file>
</activation>
<build>
<plugins>
<plugin>
<groupId>com.diffplug.spotless</groupId>
<artifactId>spotless-maven-plugin</artifactId>
<executions>
<execution>
<id>format-kotlin</id>
<phase>process-sources</phase>
<goals>
<goal>apply</goal>
</goals>
</execution>
</executions>

<configuration>
<kotlin>
<ktfmt>
<style>KOTLINLANG</style>
<!-- optional, other options are DEFAULT, DROPBOX, GOOGLE and KOTLINLANG -->
</ktfmt>

<!--
<ktfmt>
<style>DEFAULT</style> &lt;!&ndash; optional, other options are DEFAULT, DROPBOX, GOOGLE and KOTLINLANG &ndash;&gt;
</ktfmt>
-->

</kotlin>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>dokka</id>
<activation>
Expand Down
20 changes: 15 additions & 5 deletions core/builder/src/main/java/io/quarkus/builder/BuildChain.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ public final class BuildChain {
/**
* Create a new execution builder for this build chain.
*
* @param name the name of the build target for diagnostic purposes (must not be {@code null})
* @param name
* the name of the build target for diagnostic purposes (must not be {@code null})
*
* @return the new build execution builder (not {@code null})
*/
public BuildExecutionBuilder createExecutionBuilder(String name) {
Expand All @@ -56,9 +58,13 @@ public static BuildChainBuilder builder() {
/**
* Construct a build chain with the given name from providers found in the given class loader.
*
* @param classLoader the class loader to use
* @param classLoader
* the class loader to use
*
* @return the build chain (not {@code null})
* @throws ChainBuildException if building the chain failed
*
* @throws ChainBuildException
* if building the chain failed
*/
static BuildChain fromProviders(ClassLoader classLoader) throws ChainBuildException {
final ArrayList<BuildProvider> list = new ArrayList<>();
Expand All @@ -72,9 +78,13 @@ static BuildChain fromProviders(ClassLoader classLoader) throws ChainBuildExcept
/**
* Construct a deployment chain with the given name from the given providers.
*
* @param providers the providers to use (must not be {@code null})
* @param providers
* the providers to use (must not be {@code null})
*
* @return the deployment chain (not {@code null})
* @throws ChainBuildException if building the chain failed
*
* @throws ChainBuildException
* if building the chain failed
*/
static BuildChain fromProviders(Collection<BuildProvider> providers) throws ChainBuildException {
Assert.checkNotNullParam("providers", providers);
Expand Down
117 changes: 63 additions & 54 deletions core/builder/src/main/java/io/quarkus/builder/BuildChainBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,19 +49,21 @@ public final class BuildChainBuilder {
* <p>
* A given build step is included in the chain when one or more of the following criteria are met:
* <ul>
* <li>It includes a pre-produce step for a item which is produced by one or more build steps that is included in the
* chain</li>
* <li>It includes a produce step for a item which is consumed by a build step that is included in the chain or is a final
* item</li>
* <li>It includes a consume step for a item which is produced by a build step that is included in the chain or is an
* initial item</li>
* <li>It includes a destroy step for a item which is produced by a build step that is included in the chain or is an
* initial item</li>
* <li>It includes a pre-produce step for a item which is produced by one or more build steps that is included in
* the chain</li>
* <li>It includes a produce step for a item which is consumed by a build step that is included in the chain or is a
* final item</li>
* <li>It includes a consume step for a item which is produced by a build step that is included in the chain or is
* an initial item</li>
* <li>It includes a destroy step for a item which is produced by a build step that is included in the chain or is
* an initial item</li>
* </ul>
* In addition, the declaration of producers and consumers can cause corresponding consumers and producers to be
* included if they exist.
*
* @param buildStep the build step instance
* @param buildStep
* the build step instance
*
* @return the builder for the build step
*/
public BuildStepBuilder addBuildStep(BuildStep buildStep) {
Expand All @@ -76,14 +78,14 @@ public BuildStepBuilder addBuildStep(BuildStep buildStep) {
* <p>
* A given build step is included in the chain when one or more of the following criteria are met:
* <ul>
* <li>It includes a pre-produce step for a item which is produced by one or more build steps that is included in the
* chain</li>
* <li>It includes a produce step for a item which is consumed by a build step that is included in the chain or is a final
* item</li>
* <li>It includes a consume step for a item which is produced by a build step that is included in the chain or is an
* initial item</li>
* <li>It includes a destroy step for a item which is produced by a build step that is included in the chain or is an
* initial item</li>
* <li>It includes a pre-produce step for a item which is produced by one or more build steps that is included in
* the chain</li>
* <li>It includes a produce step for a item which is consumed by a build step that is included in the chain or is a
* final item</li>
* <li>It includes a consume step for a item which is produced by a build step that is included in the chain or is
* an initial item</li>
* <li>It includes a destroy step for a item which is produced by a build step that is included in the chain or is
* an initial item</li>
* </ul>
* In addition, the declaration of producers and consumers can cause corresponding consumers and producers to be
* included if they exist.
Expand All @@ -95,12 +97,16 @@ public BuildStepBuilder addBuildStep() {
}

/**
* Declare an initial item that will be provided to build steps in the chain. Note that if this method is called
* for a simple item, no build steps will be allowed to produce that item.
* Declare an initial item that will be provided to build steps in the chain. Note that if this method is called for
* a simple item, no build steps will be allowed to produce that item.
*
* @param type
* the item type (must not be {@code null})
*
* @param type the item type (must not be {@code null})
* @return this builder
* @throws IllegalArgumentException if the item type is {@code null}
*
* @throws IllegalArgumentException
* if the item type is {@code null}
*/
public BuildChainBuilder addInitial(Class<? extends BuildItem> type) {
Assert.checkNotNullParam("type", type);
Expand All @@ -117,12 +123,16 @@ public BuildChainBuilder loadProviders(ClassLoader classLoader) throws ChainBuil
}

/**
* Declare a final item that will be consumable after the build step chain completes. This may be any item
* that is produced in the chain.
* Declare a final item that will be consumable after the build step chain completes. This may be any item that is
* produced in the chain.
*
* @param type
* the item type (must not be {@code null})
*
* @param type the item type (must not be {@code null})
* @return this builder
* @throws IllegalArgumentException if the item type is {@code null}
*
* @throws IllegalArgumentException
* if the item type is {@code null}
*/
public BuildChainBuilder addFinal(Class<? extends BuildItem> type) {
Assert.checkNotNullParam("type", type);
Expand All @@ -137,7 +147,8 @@ ClassLoader getClassLoader() {
/**
* Sets the ClassLoader for the build. Every build step will be run with this as the TCCL.
*
* @param classLoader The ClassLoader
* @param classLoader
* The ClassLoader
*/
public void setClassLoader(ClassLoader classLoader) {
this.classLoader = classLoader;
Expand All @@ -147,7 +158,9 @@ public void setClassLoader(ClassLoader classLoader) {
* Build the build step chain from the current builder configuration.
*
* @return the constructed build chain
* @throws ChainBuildException if the chain could not be built
*
* @throws ChainBuildException
* if the chain could not be built
*/
public BuildChain build() throws ChainBuildException {
final Set<BuildStepBuilder> included = new HashSet<>(); // the set of steps already included to avoid duplicates
Expand Down Expand Up @@ -185,7 +198,8 @@ private Map<BuildStepBuilder, Set<Produce>> wireDependencies(Set<BuildStepBuilde
}
}
// add every producer
addItem(allProduces, included, toAdd, id, dependencies.computeIfAbsent(stepBuilder, x -> new HashSet<>()));
addItem(allProduces, included, toAdd, id,
dependencies.computeIfAbsent(stepBuilder, x -> new HashSet<>()));
}
}
return dependencies;
Expand All @@ -204,8 +218,7 @@ private Map<ItemId, List<Produce>> extractProducers() throws ChainBuildException
// ensure only one producer
if (initialIds.contains(id)) {
String message = "Item " + id + " cannot be produced here (it is an initial resource) ("
+ toBeAdded.getStepBuilder().getBuildStep()
+ ").";
+ toBeAdded.getStepBuilder().getBuildStep() + ").";
if (!LOG_CONFLICT_CAUSING) {
message += " Use -Dquarkus.builder.log-conflict-cause=true to see the full stacktrace.";
}
Expand All @@ -216,22 +229,18 @@ private Map<ItemId, List<Produce>> extractProducers() throws ChainBuildException
}
final boolean overridable = toBeAdded.isOverridable();
for (Produce produce : list) {
if (produce.getConstraint() == Constraint.REAL
&& produce.isOverridable() == overridable) {
if (produce.getConstraint() == Constraint.REAL && produce.isOverridable() == overridable) {
String message = "This is the location of the conflicting producer ("
+ toBeAdded.getStepBuilder().getBuildStep()
+ ").";
+ toBeAdded.getStepBuilder().getBuildStep() + ").";
if (!LOG_CONFLICT_CAUSING) {
message += " Use -Dquarkus.builder.log-conflict-cause=true to see the full stacktrace.";
}

final Throwable cause = new Throwable(message);
cause.setStackTrace(steps.get(toBeAdded.getStepBuilder()));
final ChainBuildException cbe = new ChainBuildException(
String.format("Multiple %s"
+ "producers of item %s (%s)",
overridable ? "overridable " : "", id, produce.getStepBuilder().getBuildStep()),
cause);
final ChainBuildException cbe = new ChainBuildException(String.format(
"Multiple %s" + "producers of item %s (%s)", overridable ? "overridable " : "", id,
produce.getStepBuilder().getBuildStep()), cause);
cbe.setStackTrace(steps.get(produce.getStepBuilder()));
throw cbe;
}
Expand Down Expand Up @@ -284,17 +293,17 @@ private void detectCycles(Set<BuildStepBuilder> builders, final Map<BuildStepBui
detectCycles(builders, new HashSet<>(), new HashSet<>(), dependencies, new ArrayDeque<>());
}

private void detectCycles(Set<BuildStepBuilder> builders, Set<BuildStepBuilder> visited, Set<BuildStepBuilder> checked,
final Map<BuildStepBuilder, Set<Produce>> dependencies, final Deque<Produce> producedPath)
throws ChainBuildException {
private void detectCycles(Set<BuildStepBuilder> builders, Set<BuildStepBuilder> visited,
Set<BuildStepBuilder> checked, final Map<BuildStepBuilder, Set<Produce>> dependencies,
final Deque<Produce> producedPath) throws ChainBuildException {
for (BuildStepBuilder builder : builders) {
detectCycles(builder, visited, checked, dependencies, producedPath);
}
}

private void cycleCheckProduce(Set<Produce> produceSet, Set<BuildStepBuilder> visited, Set<BuildStepBuilder> checked,
final Map<BuildStepBuilder, Set<Produce>> dependencies, final Deque<Produce> producedPath)
throws ChainBuildException {
private void cycleCheckProduce(Set<Produce> produceSet, Set<BuildStepBuilder> visited,
Set<BuildStepBuilder> checked, final Map<BuildStepBuilder, Set<Produce>> dependencies,
final Deque<Produce> producedPath) throws ChainBuildException {
for (Produce produce : produceSet) {
producedPath.add(produce);
detectCycles(produce.getStepBuilder(), visited, checked, dependencies, producedPath);
Expand Down Expand Up @@ -351,8 +360,7 @@ private void addItem(final Map<ItemId, List<Produce>> allProduces, final Set<Bui
}

private static boolean produceItem(Map<ItemId, List<Produce>> allProduces, Set<BuildStepBuilder> included,
ArrayDeque<BuildStepBuilder> toAdd, ItemId idToAdd,
Set<Produce> dependencies, boolean overrideable) {
ArrayDeque<BuildStepBuilder> toAdd, ItemId idToAdd, Set<Produce> dependencies, boolean overrideable) {
boolean modified = false;
for (Produce produce : allProduces.getOrDefault(idToAdd, Collections.emptyList())) {
final BuildStepBuilder stepBuilder = produce.getStepBuilder();
Expand All @@ -373,8 +381,8 @@ private static boolean produceItem(Map<ItemId, List<Produce>> allProduces, Set<B
return modified;
}

private Set<StepInfo> buildAllSteps(Set<BuildStepBuilder> included, Map<BuildStepBuilder, Set<Produce>> dependencies,
Set<StepInfo> startSteps) {
private Set<StepInfo> buildAllSteps(Set<BuildStepBuilder> included,
Map<BuildStepBuilder, Set<Produce>> dependencies, Set<StepInfo> startSteps) {
Map<BuildStepBuilder, Set<BuildStepBuilder>> dependents = calculateDependents(dependencies);
final Set<StepInfo> endSteps = new HashSet<>();
final Map<BuildStepBuilder, StepInfo> mappedSteps = new HashMap<>();
Expand All @@ -396,18 +404,19 @@ private static Map<BuildStepBuilder, Set<BuildStepBuilder>> calculateDependents(
return dependents;
}

private StepInfo buildOne(BuildStepBuilder toBuild, Set<BuildStepBuilder> included, Map<BuildStepBuilder, StepInfo> mapped,
Map<BuildStepBuilder, Set<BuildStepBuilder>> dependents, Map<BuildStepBuilder, Set<Produce>> dependencies,
final Set<StepInfo> startSteps, final Set<StepInfo> endSteps) {
private StepInfo buildOne(BuildStepBuilder toBuild, Set<BuildStepBuilder> included,
Map<BuildStepBuilder, StepInfo> mapped, Map<BuildStepBuilder, Set<BuildStepBuilder>> dependents,
Map<BuildStepBuilder, Set<Produce>> dependencies, final Set<StepInfo> startSteps,
final Set<StepInfo> endSteps) {
if (mapped.containsKey(toBuild)) {
return mapped.get(toBuild);
}
Set<StepInfo> dependentStepInfos = new HashSet<>();
final Set<BuildStepBuilder> dependentsOfThis = dependents.getOrDefault(toBuild, Collections.emptySet());
for (BuildStepBuilder dependentBuilder : dependentsOfThis) {
if (included.contains(dependentBuilder)) {
dependentStepInfos
.add(buildOne(dependentBuilder, included, mapped, dependents, dependencies, startSteps, endSteps));
dependentStepInfos.add(
buildOne(dependentBuilder, included, mapped, dependents, dependencies, startSteps, endSteps));
}
}
final Set<Produce> dependenciesOfThis = dependencies.getOrDefault(toBuild, Collections.emptySet());
Expand Down
Loading