Skip to content

Commit

Permalink
[packagers] support Fedora COPR via spec. Resolves #438
Browse files Browse the repository at this point in the history
[gradle] add missing macports accessors. Fixes #562
  • Loading branch information
aalmiray committed Dec 1, 2021
1 parent d05add2 commit 98e6505
Show file tree
Hide file tree
Showing 34 changed files with 887 additions and 81 deletions.
19 changes: 18 additions & 1 deletion README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ Requires Java 8
sdk install jreleaser
----

*Jbang*
*JBang*

Requires Java 8
[source]
Expand All @@ -71,6 +71,23 @@ jbang jreleaser@jreleaser <command> [<args>]
jbang jreleaser-snapshot@jreleaser <command> [<args>]
----

*Fedora COPR*

[source]
----
$ dnf install dnf-plugins-core
$ dnf copr enable aalmiray/jreleaser
$ dnf install jreleaser
----

*Macports*

Requires Java 8
[source]
----
port install jreleaser
----

*Curl*

Requires Java 11
Expand Down
2 changes: 2 additions & 0 deletions apps/jreleaser-tool-provider/jreleaser-tool-provider.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ java {
}

task versionFile {
inputs.property('version', project.version)
outputs.file(project.layout.buildDirectory.file('VERSION'))
doLast {
project.layout.buildDirectory.file('VERSION').get().asFile.text = project.version
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,4 +231,5 @@ jreleaser.template.TEXT_success = Template gerado em {}
###############################################################################
# header
jreleaser.upload.usage.headerHeading =
jreleaser.upload.usage.header = Realiza envio de todos artefatos.
jreleaser.upload.usage.header = Realiza envio de todos artefatos.

Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@
import java.util.Arrays;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;

import static org.jreleaser.util.MustacheUtils.applyTemplate;
import static org.jreleaser.util.StringUtils.capitalize;
import static org.jreleaser.util.StringUtils.getClassNameForLowerCaseHyphenSeparatedName;
import static org.jreleaser.util.StringUtils.getFilename;
Expand Down Expand Up @@ -254,7 +255,22 @@ public Map<String, Object> artifactProps(JReleaserContext context, Artifact arti
String artifactFileName = artifact.getEffectivePath(context).getFileName().toString();
props.put(Constants.KEY_ARTIFACT_PLATFORM, platform);
props.put(Constants.KEY_ARTIFACT_FILE_NAME, artifactFileName);
props.put(Constants.KEY_ARTIFACT_NAME, getFilename(artifactFileName));
props.put(Constants.KEY_ARTIFACT_NAME, getFilename(artifactFileName, getSupportedExtensions()));
return props;
}

private Set<String> getSupportedExtensions() {
Set<String> set = new LinkedHashSet<>();
set.add(".tar.gz");
set.add(".tgz");
set.add(".tar");
set.add(".zip");
set.add(".rpm");
set.add(".dep");
set.add(".pkg");
set.add(".dmg");
set.add(".exe");
set.add(".msi");
return set;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,8 @@ private <T extends Tool> T resolveTool(String name) {
return (T) getSdkman();
case Snap.NAME:
return (T) getSnap();
case Spec.NAME:
return (T) getSpec();
default:
throw new JReleaserException(RB.$("ERROR_unsupported_packager", name));
}
Expand Down Expand Up @@ -338,6 +340,7 @@ public static Set<String> supportedPackagers() {
set.add(Scoop.NAME);
set.add(Sdkman.NAME);
set.add(Snap.NAME);
set.add(Spec.NAME);
return Collections.unmodifiableSet(set);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public class Packagers implements Domain {
private final Scoop scoop = new Scoop();
private final Sdkman sdkman = new Sdkman();
private final Snap snap = new Snap();
private final Spec spec = new Spec();

public boolean hasEnabledPackagers() {
return brew.isEnabled() ||
Expand All @@ -42,7 +43,8 @@ public boolean hasEnabledPackagers() {
macports.isEnabled() ||
scoop.isEnabled() ||
sdkman.isEnabled() ||
snap.isEnabled();
snap.isEnabled()||
spec.isEnabled();
}

void setAll(Packagers packagers) {
Expand All @@ -54,6 +56,7 @@ void setAll(Packagers packagers) {
setScoop(packagers.scoop);
setSdkman(packagers.sdkman);
setSnap(packagers.snap);
setSpec(packagers.spec);
}

public Brew getBrew() {
Expand Down Expand Up @@ -120,6 +123,14 @@ public void setSnap(Snap snap) {
this.snap.setAll(snap);
}

public Spec getSpec() {
return spec;
}

public void setSpec(Spec spec) {
this.spec.setAll(spec);
}

@Override
public Map<String, Object> asMap(boolean full) {
Map<String, Object> map = new LinkedHashMap<>();
Expand All @@ -131,6 +142,7 @@ public Map<String, Object> asMap(boolean full) {
map.putAll(scoop.asMap(full));
map.putAll(sdkman.asMap(full));
map.putAll(snap.asMap(full));
map.putAll(spec.asMap(full));
return map;
}
}
106 changes: 106 additions & 0 deletions core/jreleaser-model/src/main/java/org/jreleaser/model/Spec.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
/*
* SPDX-License-Identifier: Apache-2.0
*
* Copyright 2020-2021 The JReleaser authors.
*
* 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
*
* https://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 org.jreleaser.model;

import java.util.ArrayList;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;

import static org.jreleaser.util.StringUtils.isBlank;

/**
* @author Andres Almiray
* @since 0.9.1
*/
public class Spec extends AbstractRepositoryTool {
public static final String NAME = "spec";
private final List<String> requires = new ArrayList<>();
private final SpecRepository repository = new SpecRepository();

private String release;

public Spec() {
super(NAME);
}

void setAll(Spec spec) {
super.setAll(spec);
this.release = spec.release;
setRepository(spec.repository);
setRequires(spec.requires);
}

public String getRelease() {
return release;
}

public void setRelease(String release) {
this.release = release;
}

public SpecRepository getRepository() {
return repository;
}

public void setRepository(SpecRepository repository) {
this.repository.setAll(repository);
}

public List<String> getRequires() {
return requires;
}

public void setRequires(List<String> requires) {
this.requires.clear();
this.requires.addAll(requires);
}

@Override
protected void asMap(boolean full, Map<String, Object> props) {
super.asMap(full, props);
props.put("release", release);
props.put("requires", requires);
props.put("repository", repository.asMap(full));
}

@Override
public RepositoryTap getRepositoryTap() {
return repository;
}

@Override
public boolean supportsPlatform(String platform) {
return isBlank(platform);
}

@Override
public boolean supportsDistribution(Distribution distribution) {
return distribution.getType() == Distribution.DistributionType.JAVA_BINARY;
}

@Override
public Set<String> getSupportedExtensions() {
Set<String> set = new LinkedHashSet<>();
set.add(".tar.gz");
set.add(".tgz");
set.add(".tar");
return set;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* SPDX-License-Identifier: Apache-2.0
*
* Copyright 2020-2021 The JReleaser authors.
*
* 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
*
* https://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 org.jreleaser.model;

/**
* @author Andres Almiray
* @since 0.9.1
*/
public class SpecRepository extends AbstractRepositoryTap {
public SpecRepository() {
super("spec", "spec");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
import static org.jreleaser.model.validation.SdkmanValidator.postValidateSdkman;
import static org.jreleaser.model.validation.SdkmanValidator.validateSdkman;
import static org.jreleaser.model.validation.SnapValidator.validateSnap;
import static org.jreleaser.model.validation.SpecValidator.validateSpec;
import static org.jreleaser.util.StringUtils.getFilenameExtension;
import static org.jreleaser.util.StringUtils.isBlank;
import static org.jreleaser.util.StringUtils.isNotBlank;
Expand Down Expand Up @@ -171,6 +172,7 @@ private static void validateDistribution(JReleaserContext context, Distribution
validateScoop(context, distribution, distribution.getScoop(), errors);
validateSdkman(context, distribution, distribution.getSdkman(), errors);
validateSnap(context, distribution, distribution.getSnap(), errors);
validateSpec(context, distribution, distribution.getSpec(), errors);
}

private static boolean selectArtifactsByPlatform(JReleaserContext context, Distribution distribution) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,18 @@ public static void validatePackagers(JReleaserContext context, JReleaserContext.
packagers.getSnap().getSnap(),
errors);

packagers.getSpec().resolveEnabled(project);
packagers.getSpec().getRepository().resolveEnabled(project);
validatePackager(context,
packagers.getSpec(),
packagers.getSpec().getRepository(),
errors);

if (isBlank(packagers.getSpec().getRepository().getName())) {
packagers.getSpec().getRepository().setName(model.getRelease().getGitService().getOwner() + "-spec");
}
packagers.getSpec().getRepository().setTapName(model.getRelease().getGitService().getOwner() + "-spec");

validateSdkman(context, packagers.getSdkman(), errors);
}

Expand Down

0 comments on commit 98e6505

Please sign in to comment.