diff --git a/core/jreleaser-model/src/main/java/org/jreleaser/model/Snap.java b/core/jreleaser-model/src/main/java/org/jreleaser/model/Snap.java index 03f291528..ffeea1da4 100644 --- a/core/jreleaser-model/src/main/java/org/jreleaser/model/Snap.java +++ b/core/jreleaser-model/src/main/java/org/jreleaser/model/Snap.java @@ -42,7 +42,9 @@ public class Snap extends AbstractRepositoryTool { private final Set localSlots = new LinkedHashSet<>(); private final List plugs = new ArrayList<>(); private final List slots = new ArrayList<>(); + private final List architectures = new ArrayList<>(); private final SnapTap snap = new SnapTap(); + private String packageName; private String base = "core20"; private String grade = "stable"; @@ -76,6 +78,7 @@ void setAll(Snap snap) { setLocalSlots(snap.localSlots); setPlugs(snap.plugs); setSlots(snap.slots); + setArchitectures(snap.architectures); setSnap(snap.snap); } @@ -211,6 +214,31 @@ public void removeSlot(Slot slot) { } } + public List getArchitectures() { + return architectures; + } + + public void setArchitectures(List architectures) { + this.architectures.clear(); + this.architectures.addAll(architectures); + } + + public void addArchitecture(List architectures) { + this.architectures.addAll(architectures); + } + + public void addArchitecture(Architecture architecture) { + if (null != architecture) { + this.architectures.add(architecture); + } + } + + public void removeArchitecture(Architecture architecture) { + if (null != architecture) { + this.architectures.remove(architecture); + } + } + public String getExportedLogin() { return exportedLogin; } @@ -251,8 +279,24 @@ protected void asMap(boolean full, Map props) { props.put("snap", snap.asMap(full)); props.put("localPlugs", localPlugs); props.put("localSlots", localSlots); - props.put("plugs", plugs); - props.put("slots", slots); + + Map> mapped = new LinkedHashMap<>(); + for (int i = 0; i < plugs.size(); i++) { + mapped.put("plug " + i, plugs.get(i).asMap(full)); + } + props.put("plugs", mapped); + + mapped = new LinkedHashMap<>(); + for (int i = 0; i < slots.size(); i++) { + mapped.put("slot " + i, slots.get(i).asMap(full)); + } + props.put("slots", mapped); + + mapped = new LinkedHashMap<>(); + for (int i = 0; i < architectures.size(); i++) { + mapped.put("architecture " + i, architectures.get(i).asMap(full)); + } + props.put("architectures", mapped); } @Override @@ -422,4 +466,77 @@ public SnapTap() { super("snap", "snap"); } } + + public static class Architecture implements Domain { + private final List buildOn = new ArrayList<>(); + private final List runOn = new ArrayList<>(); + private Boolean ignoreError; + + public List getBuildOn() { + return buildOn; + } + + public void setBuildOn(List buildOn) { + this.buildOn.clear(); + this.buildOn.addAll(buildOn); + } + + public void addBuildOn(List buildOn) { + this.buildOn.addAll(buildOn); + } + + public void addBuildOn(String str) { + if (isNotBlank(str)) { + this.buildOn.add(str.trim()); + } + } + + public List getRunOn() { + return runOn; + } + + public void setRunOn(List runOn) { + this.runOn.clear(); + this.runOn.addAll(runOn); + } + + public void addRunOn(List runOn) { + this.runOn.addAll(runOn); + } + + public void addRunOn(String str) { + if (isNotBlank(str)) { + this.runOn.add(str.trim()); + } + } + + public boolean hasBuildOn() { + return !buildOn.isEmpty(); + } + + public boolean hasRunOn() { + return !runOn.isEmpty(); + } + + public boolean isIgnoreError() { + return ignoreError != null && ignoreError; + } + + public void setIgnoreError(Boolean ignoreError) { + this.ignoreError = ignoreError; + } + + public boolean isIgnoreErrorSet() { + return ignoreError != null; + } + + @Override + public Map asMap(boolean full) { + Map map = new LinkedHashMap<>(); + map.put("buildOn", buildOn); + map.put("runOn", runOn); + map.put("ignoreError", isIgnoreError()); + return map; + } + } } diff --git a/core/jreleaser-model/src/main/java/org/jreleaser/model/validation/GitServiceValidator.java b/core/jreleaser-model/src/main/java/org/jreleaser/model/validation/GitServiceValidator.java index eb5047a92..76684ec39 100644 --- a/core/jreleaser-model/src/main/java/org/jreleaser/model/validation/GitServiceValidator.java +++ b/core/jreleaser-model/src/main/java/org/jreleaser/model/validation/GitServiceValidator.java @@ -256,7 +256,7 @@ private static void validateChangelog(JReleaserContext context, GitService servi errors.configuration(RB.$("validation_is_missing", service.getServiceName() + ".changelog.categories[" + i + "].title")); } if (category.getLabels().isEmpty()) { - errors.configuration(RB.$("validation_ares_missing", service.getServiceName() + ".changelog.categories[" + i + "].labels")); + errors.configuration(RB.$("validation_are_missing", service.getServiceName() + ".changelog.categories[" + i + "].labels")); } i++; diff --git a/core/jreleaser-model/src/main/java/org/jreleaser/model/validation/SnapValidator.java b/core/jreleaser-model/src/main/java/org/jreleaser/model/validation/SnapValidator.java index fb5a44554..78430c93d 100644 --- a/core/jreleaser-model/src/main/java/org/jreleaser/model/validation/SnapValidator.java +++ b/core/jreleaser-model/src/main/java/org/jreleaser/model/validation/SnapValidator.java @@ -128,6 +128,14 @@ public static void validateSnap(JReleaserContext context, Distribution distribut errors.configuration(RB.$("validation_tool_multiple_artifacts", "distribution." + distribution.getName() + ".snap")); tool.disable(); } + + tool.addArchitecture(parentTool.getArchitectures()); + for (int i = 0; i < tool.getArchitectures().size(); i++) { + Snap.Architecture arch = tool.getArchitectures().get(i); + if (!arch.hasBuildOn()) { + errors.configuration(RB.$("validation_snap_missing_buildon", "distribution." + distribution.getName() + ".snap.architectures", i)); + } + } } private static void mergeSnapPlugs(Snap tool, Snap common) { diff --git a/core/jreleaser-templates/src/main/resources/META-INF/jreleaser/templates/binary/snap/snap/snapcraft.yaml.tpl b/core/jreleaser-templates/src/main/resources/META-INF/jreleaser/templates/binary/snap/snap/snapcraft.yaml.tpl index 0d26dde47..1099747ef 100644 --- a/core/jreleaser-templates/src/main/resources/META-INF/jreleaser/templates/binary/snap/snap/snapcraft.yaml.tpl +++ b/core/jreleaser-templates/src/main/resources/META-INF/jreleaser/templates/binary/snap/snap/snapcraft.yaml.tpl @@ -9,6 +9,14 @@ confinement: {{snapConfinement}} base: {{snapBase}} type: app +{{#hasArchitectures}} +architectures: + {{#snapArchitectures}} + - build-on: {{buildOn}} + {{#hasRunOn}}run-on: {{runOn}}{{/hasRunOn}} + {{#ignoreError}}build-error: ignore{{/ignoreError}} + {{/snapArchitectures}} +{{/hasArchitectures}} apps: {{distributionExecutable}}: command: $SNAP/bin/{{distributionExecutable}} diff --git a/core/jreleaser-templates/src/main/resources/META-INF/jreleaser/templates/java-binary/snap/snap/snapcraft.yaml.tpl b/core/jreleaser-templates/src/main/resources/META-INF/jreleaser/templates/java-binary/snap/snap/snapcraft.yaml.tpl index 9033b65e2..9a3650644 100644 --- a/core/jreleaser-templates/src/main/resources/META-INF/jreleaser/templates/java-binary/snap/snap/snapcraft.yaml.tpl +++ b/core/jreleaser-templates/src/main/resources/META-INF/jreleaser/templates/java-binary/snap/snap/snapcraft.yaml.tpl @@ -9,6 +9,14 @@ confinement: {{snapConfinement}} base: {{snapBase}} type: app +{{#hasArchitectures}} +architectures: + {{#snapArchitectures}} + - build-on: {{buildOn}} + {{#hasRunOn}}run-on: {{runOn}}{{/hasRunOn}} + {{#ignoreError}}build-error: ignore{{/ignoreError}} + {{/snapArchitectures}} +{{/hasArchitectures}} apps: {{distributionExecutable}}: command: $SNAP/bin/{{distributionExecutable}} diff --git a/core/jreleaser-templates/src/main/resources/META-INF/jreleaser/templates/jlink/snap/snap/snapcraft.yaml.tpl b/core/jreleaser-templates/src/main/resources/META-INF/jreleaser/templates/jlink/snap/snap/snapcraft.yaml.tpl index b5b29027b..1d0a054cd 100644 --- a/core/jreleaser-templates/src/main/resources/META-INF/jreleaser/templates/jlink/snap/snap/snapcraft.yaml.tpl +++ b/core/jreleaser-templates/src/main/resources/META-INF/jreleaser/templates/jlink/snap/snap/snapcraft.yaml.tpl @@ -9,6 +9,14 @@ confinement: {{snapConfinement}} base: {{snapBase}} type: app +{{#hasArchitectures}} +architectures: + {{#snapArchitectures}} + - build-on: {{buildOn}} + {{#hasRunOn}}run-on: {{runOn}}{{/hasRunOn}} + {{#ignoreError}}build-error: ignore{{/ignoreError}} + {{/snapArchitectures}} +{{/hasArchitectures}} apps: {{distributionExecutable}}: command: $SNAP/bin/{{distributionExecutable}} diff --git a/core/jreleaser-templates/src/main/resources/META-INF/jreleaser/templates/native-image/snap/snap/snapcraft.yaml.tpl b/core/jreleaser-templates/src/main/resources/META-INF/jreleaser/templates/native-image/snap/snap/snapcraft.yaml.tpl index 0d26dde47..1099747ef 100644 --- a/core/jreleaser-templates/src/main/resources/META-INF/jreleaser/templates/native-image/snap/snap/snapcraft.yaml.tpl +++ b/core/jreleaser-templates/src/main/resources/META-INF/jreleaser/templates/native-image/snap/snap/snapcraft.yaml.tpl @@ -9,6 +9,14 @@ confinement: {{snapConfinement}} base: {{snapBase}} type: app +{{#hasArchitectures}} +architectures: + {{#snapArchitectures}} + - build-on: {{buildOn}} + {{#hasRunOn}}run-on: {{runOn}}{{/hasRunOn}} + {{#ignoreError}}build-error: ignore{{/ignoreError}} + {{/snapArchitectures}} +{{/hasArchitectures}} apps: {{distributionExecutable}}: command: $SNAP/bin/{{distributionExecutable}} diff --git a/core/jreleaser-templates/src/main/resources/META-INF/jreleaser/templates/single-jar/snap/snap/snapcraft.yaml.tpl b/core/jreleaser-templates/src/main/resources/META-INF/jreleaser/templates/single-jar/snap/snap/snapcraft.yaml.tpl index 26046dff7..12f567967 100644 --- a/core/jreleaser-templates/src/main/resources/META-INF/jreleaser/templates/single-jar/snap/snap/snapcraft.yaml.tpl +++ b/core/jreleaser-templates/src/main/resources/META-INF/jreleaser/templates/single-jar/snap/snap/snapcraft.yaml.tpl @@ -9,6 +9,14 @@ confinement: {{snapConfinement}} base: {{snapBase}} type: app +{{#hasArchitectures}} +architectures: + {{#snapArchitectures}} + - build-on: {{buildOn}} + {{#hasRunOn}}run-on: {{runOn}}{{/hasRunOn}} + {{#ignoreError}}build-error: ignore{{/ignoreError}} + {{/snapArchitectures}} +{{/hasArchitectures}} apps: {{distributionExecutable}}: command: ${JAVA_HOME}/bin/java -jar $SNAP/{{distributionArtifactFile}} diff --git a/core/jreleaser-tools/src/main/java/org/jreleaser/tools/SnapToolProcessor.java b/core/jreleaser-tools/src/main/java/org/jreleaser/tools/SnapToolProcessor.java index e3d64d475..e622ab111 100644 --- a/core/jreleaser-tools/src/main/java/org/jreleaser/tools/SnapToolProcessor.java +++ b/core/jreleaser-tools/src/main/java/org/jreleaser/tools/SnapToolProcessor.java @@ -39,9 +39,11 @@ import static org.jreleaser.util.Constants.KEY_DISTRIBUTION_PACKAGE_DIRECTORY; import static org.jreleaser.util.Constants.KEY_PROJECT_EFFECTIVE_VERSION; import static org.jreleaser.util.Constants.KEY_PROJECT_LONG_DESCRIPTION; +import static org.jreleaser.util.Constants.KEY_SNAP_ARCHITECTURES; import static org.jreleaser.util.Constants.KEY_SNAP_BASE; import static org.jreleaser.util.Constants.KEY_SNAP_CONFINEMENT; import static org.jreleaser.util.Constants.KEY_SNAP_GRADE; +import static org.jreleaser.util.Constants.KEY_SNAP_HAS_ARCHITECTURES; import static org.jreleaser.util.Constants.KEY_SNAP_HAS_LOCAL_PLUGS; import static org.jreleaser.util.Constants.KEY_SNAP_HAS_LOCAL_SLOTS; import static org.jreleaser.util.Constants.KEY_SNAP_HAS_PLUGS; @@ -130,6 +132,8 @@ protected void fillToolProperties(Map props, Distribution distri props.put(KEY_SNAP_LOCAL_PLUGS, tool.getLocalPlugs()); props.put(KEY_SNAP_HAS_LOCAL_SLOTS, !tool.getLocalSlots().isEmpty()); props.put(KEY_SNAP_LOCAL_SLOTS, tool.getLocalSlots()); + props.put(KEY_SNAP_HAS_ARCHITECTURES, !tool.getArchitectures().isEmpty()); + props.put(KEY_SNAP_ARCHITECTURES, tool.getArchitectures()); } @Override diff --git a/core/jreleaser-utils/src/main/java/org/jreleaser/util/Constants.java b/core/jreleaser-utils/src/main/java/org/jreleaser/util/Constants.java index fed38cdc5..61de74246 100644 --- a/core/jreleaser-utils/src/main/java/org/jreleaser/util/Constants.java +++ b/core/jreleaser-utils/src/main/java/org/jreleaser/util/Constants.java @@ -240,6 +240,8 @@ public interface Constants { String KEY_SNAP_LOCAL_PLUGS = "snapLocalPlugs"; String KEY_SNAP_HAS_LOCAL_SLOTS = "snapHasLocalSlots"; String KEY_SNAP_LOCAL_SLOTS = "snapLocalSlots"; + String KEY_SNAP_HAS_ARCHITECTURES = "hasArchitectures"; + String KEY_SNAP_ARCHITECTURES = "snapArchitectures"; String KEY_SNAP_REPO_URL = "snapRepoUrl"; String KEY_SNAP_REPO_CLONE_URL = "snapRepoCloneUrl"; diff --git a/core/jreleaser-utils/src/main/resources/org/jreleaser/bundle/Messages.properties b/core/jreleaser-utils/src/main/resources/org/jreleaser/bundle/Messages.properties index 396b3e0c1..efa7f7fd8 100644 --- a/core/jreleaser-utils/src/main/resources/org/jreleaser/bundle/Messages.properties +++ b/core/jreleaser-utils/src/main/resources/org/jreleaser/bundle/Messages.properties @@ -225,6 +225,7 @@ validation_must_not_be_null = {} must not be null validation_is_null = {} is null validation_is_empty = {} is empty validation_is_missing = {} is missing +validation_are_missing = {} are missing validation_directory_not_exist = {} does not exist: {} validation_is_not_a_directory = {} is not a directory: {} validation_directory_is_empty = {} is empty: {} @@ -234,6 +235,8 @@ validation_multiple_assemblers = {} has more than 1 assembler: {} validation_brew_multiple_artifact = {} has more than one {} artifact validation_brew_single_artifact = {} can only have a single matching .dmg, .pkg, or .zip artifact validation_brew_duplicate_definition = {} is defined for more than one distribution: {} +# do not translate .buildOn +validation_snap_missing_buildon = {}[{}].buildOn must define at least one entry validation_tool_multiple_artifacts = {} has more than one artifact that may be packaged validation_discussions_enabled = discussions may only be used when releasing to GitHub validation_distributions_java = {} is set to {} but neither {} nor {} have been set diff --git a/plugins/jreleaser-gradle-plugin/src/main/groovy/org/jreleaser/gradle/plugin/dsl/Snap.groovy b/plugins/jreleaser-gradle-plugin/src/main/groovy/org/jreleaser/gradle/plugin/dsl/Snap.groovy index b21dd5c9a..c9cb5ab29 100644 --- a/plugins/jreleaser-gradle-plugin/src/main/groovy/org/jreleaser/gradle/plugin/dsl/Snap.groovy +++ b/plugins/jreleaser-gradle-plugin/src/main/groovy/org/jreleaser/gradle/plugin/dsl/Snap.groovy @@ -61,8 +61,12 @@ interface Snap extends RepositoryTool { void snap(Action action) + void architecture(Action action) + void snap(@DelegatesTo(strategy = Closure.DELEGATE_FIRST, value = Tap) Closure action) + void architecture(@DelegatesTo(strategy = Closure.DELEGATE_FIRST, value = Architecture) Closure action) + @CompileStatic interface Slot { MapProperty getAttributes() @@ -84,4 +88,17 @@ interface Snap extends RepositoryTool { void addAttribute(String key, String value) } + + @CompileStatic + interface Architecture { + ListProperty getBuildOn() + + void addBuildOn(String str) + + ListProperty getRunOn() + + void addRunOn(String str) + + Property getIgnoreError() + } } \ No newline at end of file diff --git a/plugins/jreleaser-gradle-plugin/src/main/groovy/org/jreleaser/gradle/plugin/internal/dsl/SnapImpl.groovy b/plugins/jreleaser-gradle-plugin/src/main/groovy/org/jreleaser/gradle/plugin/internal/dsl/SnapImpl.groovy index 611266bc0..2bcf392a3 100644 --- a/plugins/jreleaser-gradle-plugin/src/main/groovy/org/jreleaser/gradle/plugin/internal/dsl/SnapImpl.groovy +++ b/plugins/jreleaser-gradle-plugin/src/main/groovy/org/jreleaser/gradle/plugin/internal/dsl/SnapImpl.groovy @@ -58,6 +58,8 @@ class SnapImpl extends AbstractRepositoryTool implements Snap { final NamedDomainObjectContainer plugs final NamedDomainObjectContainer slots + private final NamedDomainObjectContainer architectures + @Inject SnapImpl(ObjectFactory objects) { super(objects) @@ -89,6 +91,15 @@ class SnapImpl extends AbstractRepositoryTool implements Snap { return slot } }) + + architectures = objects.domainObjectContainer(ArchitectureImpl, new NamedDomainObjectFactory() { + @Override + ArchitectureImpl create(String name) { + ArchitectureImpl architecture = objects.newInstance(ArchitectureImpl, objects) + architecture.name = name + architecture + } + }) } @Override @@ -133,6 +144,11 @@ class SnapImpl extends AbstractRepositoryTool implements Snap { action.execute(commitAuthor) } + @Override + void architecture(Action action) { + action.execute(architectures.maybeCreate("architecture-${architectures.size()}".toString())) + } + @Override void snap(@DelegatesTo(strategy = Closure.DELEGATE_FIRST, value = Tap) Closure action) { ConfigureUtil.configure(action, snap) @@ -143,6 +159,11 @@ class SnapImpl extends AbstractRepositoryTool implements Snap { ConfigureUtil.configure(action, commitAuthor) } + @Override + void architecture(@DelegatesTo(strategy = Closure.DELEGATE_FIRST, value = Architecture) Closure action) { + ConfigureUtil.configure(action, architectures.maybeCreate("architecture-${architectures.size()}".toString())) + } + org.jreleaser.model.Snap toModel() { org.jreleaser.model.Snap tool = new org.jreleaser.model.Snap() fillToolProperties(tool) @@ -166,6 +187,9 @@ class SnapImpl extends AbstractRepositoryTool implements Snap { tool.slots.addAll(slots.collect([]) { SlotImpl slot -> slot.toModel() } as Set) + for (ArchitectureImpl architecture : architectures) { + tool.addArchitecture(architecture.toModel()) + } tool } @@ -246,4 +270,41 @@ class SnapImpl extends AbstractRepositoryTool implements Snap { plug } } + + @CompileStatic + static class ArchitectureImpl implements Architecture { + String name + final ListProperty buildOn + final ListProperty runOn + final Property ignoreError + + @Inject + ArchitectureImpl(ObjectFactory objects) { + buildOn = objects.listProperty(String).convention(Providers.notDefined()) + runOn = objects.listProperty(String).convention(Providers.notDefined()) + ignoreError = objects.property(Boolean).convention(Providers.notDefined()) + } + + @Override + void addRunOn(String str) { + if (isNotBlank(str)) { + runOn.add(str.trim()) + } + } + + @Override + void addBuildOn(String str) { + if (isNotBlank(str)) { + buildOn.add(str.trim()) + } + } + + org.jreleaser.model.Snap.Architecture toModel() { + org.jreleaser.model.Snap.Architecture architecture = new org.jreleaser.model.Snap.Architecture() + architecture.buildOn = (List) buildOn.getOrElse([]) + architecture.runOn = (List) runOn.getOrElse([]) + architecture.ignoreError = ignoreError.getOrElse(false) + architecture + } + } } diff --git a/plugins/jreleaser-maven-plugin/src/main/java/org/jreleaser/maven/plugin/Snap.java b/plugins/jreleaser-maven-plugin/src/main/java/org/jreleaser/maven/plugin/Snap.java index 37c84596e..29781fd94 100644 --- a/plugins/jreleaser-maven-plugin/src/main/java/org/jreleaser/maven/plugin/Snap.java +++ b/plugins/jreleaser-maven-plugin/src/main/java/org/jreleaser/maven/plugin/Snap.java @@ -36,6 +36,7 @@ public class Snap extends AbstractRepositoryTool { private final Set localSlots = new LinkedHashSet<>(); private final List plugs = new ArrayList<>(); private final List slots = new ArrayList<>(); + private final List architectures = new ArrayList<>(); private final Tap snap = new Tap(); private String packageName; private String base; @@ -57,6 +58,7 @@ void setAll(Snap snap) { setPlugs(plugs); setSlots(slots); setSnap(snap.snap); + setArchitectures(snap.architectures); } public String getPackageName() { @@ -100,22 +102,6 @@ public void setLocalPlugs(Set localPlugs) { this.localPlugs.addAll(localPlugs); } - public void addLocalPlugs(Set localPlugs) { - this.localPlugs.addAll(localPlugs); - } - - public void addLocalPlug(String localPlug) { - if (isNotBlank(localPlug)) { - this.localPlugs.add(localPlug.trim()); - } - } - - public void removeLocalPlug(String localPlug) { - if (isNotBlank(localPlug)) { - this.localPlugs.remove(localPlug.trim()); - } - } - public Set getLocalSlots() { return localSlots; } @@ -125,22 +111,6 @@ public void setLocalSlots(Set localSlots) { this.localSlots.addAll(localSlots); } - public void addLocalSlots(Set localSlots) { - this.localSlots.addAll(localSlots); - } - - public void addLocalSlot(String localSlot) { - if (isNotBlank(localSlot)) { - this.localSlots.add(localSlot.trim()); - } - } - - public void removeLocalSlot(String localSlot) { - if (isNotBlank(localSlot)) { - this.localSlots.remove(localSlot.trim()); - } - } - public List getPlugs() { return plugs; } @@ -150,22 +120,6 @@ public void setPlugs(List plugs) { this.plugs.addAll(plugs); } - public void addPlugs(List plugs) { - this.plugs.addAll(plugs); - } - - public void addPlug(Plug plug) { - if (null != plug) { - this.plugs.add(plug); - } - } - - public void removePlug(Plug plug) { - if (null != plug) { - this.plugs.remove(plug); - } - } - public List getSlots() { return slots; } @@ -175,20 +129,13 @@ public void setSlots(List slots) { this.slots.addAll(slots); } - public void addSlots(List slots) { - this.slots.addAll(slots); - } - - public void addSlot(Slot slot) { - if (null != slot) { - this.slots.add(slot); - } + public List getArchitectures() { + return architectures; } - public void removeSlot(Slot slot) { - if (null != slot) { - this.slots.remove(slot); - } + public void setArchitectures(List architectures) { + this.architectures.clear(); + this.architectures.addAll(architectures); } public File getExportedLogin() { @@ -257,14 +204,6 @@ public void setAttributes(Map attributes) { this.attributes.putAll(attributes); } - public void addAttributes(Map attributes) { - this.attributes.putAll(attributes); - } - - public void addAttribute(String key, String value) { - attributes.put(key, value); - } - public List getReads() { return reads; } @@ -274,22 +213,6 @@ public void setReads(List reads) { this.reads.addAll(reads); } - public void addReads(List read) { - this.reads.addAll(read); - } - - public void addRead(String read) { - if (isNotBlank(read)) { - this.reads.add(read.trim()); - } - } - - public void removeRead(String read) { - if (isNotBlank(read)) { - this.reads.remove(read.trim()); - } - } - public List getWrites() { return writes; } @@ -298,22 +221,6 @@ public void setWrites(List writes) { this.writes.clear(); this.writes.addAll(writes); } - - public void addWrites(List write) { - this.writes.addAll(write); - } - - public void addWrite(String write) { - if (isNotBlank(write)) { - this.writes.add(write.trim()); - } - } - - public void removeWrite(String write) { - if (isNotBlank(write)) { - this.writes.remove(write.trim()); - } - } } public static class Plug { @@ -336,20 +243,41 @@ public void setAttributes(Map attributes) { this.attributes.clear(); this.attributes.putAll(attributes); } + } - public void addAttributes(Map attributes) { - this.attributes.putAll(attributes); + public static class Architecture { + private final List buildOn = new ArrayList<>(); + private final List runOn = new ArrayList<>(); + private Boolean ignoreError; + + public List getBuildOn() { + return buildOn; + } + + public void setBuildOn(List buildOn) { + this.buildOn.clear(); + this.buildOn.addAll(buildOn); + } + + public List getRunOn() { + return runOn; + } + + public void setRunOn(List runOn) { + this.runOn.clear(); + this.runOn.addAll(runOn); + } + + public boolean isIgnoreError() { + return ignoreError != null && ignoreError; } - public void addAttribute(String key, String value) { - attributes.put(key, value); + public void setIgnoreError(Boolean ignoreError) { + this.ignoreError = ignoreError; } - public static Plug copyOf(Plug other) { - Plug copy = new Plug(); - copy.setName(other.getName()); - copy.setAttributes(other.getAttributes()); - return copy; + public boolean isIgnoreErrorSet() { + return ignoreError != null; } } } diff --git a/plugins/jreleaser-maven-plugin/src/main/java/org/jreleaser/maven/plugin/internal/JReleaserModelConverter.java b/plugins/jreleaser-maven-plugin/src/main/java/org/jreleaser/maven/plugin/internal/JReleaserModelConverter.java index 5545a2dbb..51af8ae52 100644 --- a/plugins/jreleaser-maven-plugin/src/main/java/org/jreleaser/maven/plugin/internal/JReleaserModelConverter.java +++ b/plugins/jreleaser-maven-plugin/src/main/java/org/jreleaser/maven/plugin/internal/JReleaserModelConverter.java @@ -1199,6 +1199,7 @@ private static org.jreleaser.model.Snap convertSnap(Snap tool) { t.setLocalSlots(tool.getLocalSlots()); t.setPlugs(convertPlugs(tool.getPlugs())); t.setSlots(convertSlots(tool.getSlots())); + t.setArchitectures(convertArchitectures(tool.getArchitectures())); t.setSnap(convertSnapTap(tool.getSnap())); t.setCommitAuthor(convertCommitAuthor(tool.getCommitAuthor())); return t; @@ -1226,20 +1227,36 @@ private static org.jreleaser.model.Snap.Plug convertArtifact(Snap.Plug plug) { } private static List convertSlots(List slots) { - List ps = new ArrayList<>(); + List ss = new ArrayList<>(); for (Snap.Slot slot : slots) { - ps.add(convertSlot(slot)); + ss.add(convertSlot(slot)); } - return ps; + return ss; } private static org.jreleaser.model.Snap.Slot convertSlot(Snap.Slot slot) { - org.jreleaser.model.Snap.Slot p = new org.jreleaser.model.Snap.Slot(); - p.setName(tr(slot.getName())); - p.setAttributes(slot.getAttributes()); - p.setReads(tr(slot.getReads())); - p.setWrites(tr(slot.getWrites())); - return p; + org.jreleaser.model.Snap.Slot s = new org.jreleaser.model.Snap.Slot(); + s.setName(tr(slot.getName())); + s.setAttributes(slot.getAttributes()); + s.setReads(tr(slot.getReads())); + s.setWrites(tr(slot.getWrites())); + return s; + } + + private static List convertArchitectures(List architectures) { + List as = new ArrayList<>(); + for (Snap.Architecture architecture : architectures) { + as.add(convertArchitecture(architecture)); + } + return as; + } + + private static org.jreleaser.model.Snap.Architecture convertArchitecture(Snap.Architecture architecture) { + org.jreleaser.model.Snap.Architecture a = new org.jreleaser.model.Snap.Architecture(); + a.setBuildOn(architecture.getBuildOn()); + a.setRunOn(architecture.getRunOn()); + if (architecture.isIgnoreErrorSet()) a.setIgnoreError(architecture.isIgnoreError()); + return a; } private static org.jreleaser.model.Spec convertSpec(Spec tool) {