Skip to content

Commit

Permalink
Support for empty build items
Browse files Browse the repository at this point in the history
  • Loading branch information
dmlloyd committed Aug 27, 2019
1 parent 4703d0e commit 3d94af6
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import org.wildfly.common.Assert;

import io.quarkus.builder.item.BuildItem;
import io.quarkus.builder.item.EmptyBuildItem;
import io.quarkus.builder.item.NamedBuildItem;
import io.quarkus.builder.item.SymbolicBuildItem;

Expand Down Expand Up @@ -147,6 +148,9 @@ public BuildStepBuilder produces(Class<? extends BuildItem> type) {
if (NamedBuildItem.class.isAssignableFrom(type)) {
throw new IllegalArgumentException("Cannot produce a named build item without a name");
}
if (EmptyBuildItem.class.isAssignableFrom(type)) {
throw new IllegalArgumentException("Cannot produce an empty build item");
}
addProduces(new ItemId(type, null), Constraint.REAL, ProduceFlags.NONE);
return this;
}
Expand All @@ -166,6 +170,9 @@ public BuildStepBuilder produces(Class<? extends BuildItem> type, ProduceFlag fl
if (NamedBuildItem.class.isAssignableFrom(type)) {
throw new IllegalArgumentException("Cannot produce a named build item without a name");
}
if (EmptyBuildItem.class.isAssignableFrom(type)) {
throw new IllegalArgumentException("Cannot produce an empty build item");
}
addProduces(new ItemId(type, null), Constraint.REAL, ProduceFlags.of(flag));
return this;
}
Expand All @@ -185,6 +192,9 @@ public BuildStepBuilder produces(Class<? extends BuildItem> type, ProduceFlags f
if (NamedBuildItem.class.isAssignableFrom(type)) {
throw new IllegalArgumentException("Cannot produce a named build item without a name");
}
if (EmptyBuildItem.class.isAssignableFrom(type)) {
throw new IllegalArgumentException("Cannot produce an empty build item");
}
addProduces(new ItemId(type, null), Constraint.REAL, flags);
return this;
}
Expand Down Expand Up @@ -224,7 +234,7 @@ public <N> BuildStepBuilder produces(Class<? extends NamedBuildItem<N>> type, N
}

/**
* Declare that the build step "produces" a virtual item with the given identifier.
* Declare that the build step "produces" an empty item with the given identifier.
*
* @param symbolic the item identifier (must not be {@code null})
* @return this builder
Expand Down Expand Up @@ -261,6 +271,9 @@ public BuildStepBuilder consumes(Class<? extends BuildItem> type) {
if (NamedBuildItem.class.isAssignableFrom(type)) {
throw new IllegalArgumentException("Cannot consume a named build item without a name");
}
if (EmptyBuildItem.class.isAssignableFrom(type)) {
throw new IllegalArgumentException("Cannot consume an empty build item");
}
addConsumes(new ItemId(type, null), Constraint.REAL, ConsumeFlags.NONE);
return this;
}
Expand Down Expand Up @@ -293,6 +306,9 @@ public BuildStepBuilder consumes(Class<? extends BuildItem> type, ConsumeFlags f
if (NamedBuildItem.class.isAssignableFrom(type)) {
throw new IllegalArgumentException("Cannot consume a named build item without a name");
}
if (EmptyBuildItem.class.isAssignableFrom(type)) {
throw new IllegalArgumentException("Cannot consume an empty build item");
}
addConsumes(new ItemId(type, null), Constraint.REAL, flags);
return this;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package io.quarkus.builder.item;

/**
* An empty build item. Empty build items carry no data and may be used, for example, for ordering and for
* running steps which don't otherwise produce anything.
*/
public abstract class EmptyBuildItem extends BuildItem {
protected EmptyBuildItem() {
throw new UnsupportedOperationException("Cannot construct empty build items");
}
}

This file was deleted.

This file was deleted.

0 comments on commit 3d94af6

Please sign in to comment.