Search in sources :

Example 1 with KEY_SPEC_DIRECTORIES

use of org.jreleaser.util.Constants.KEY_SPEC_DIRECTORIES in project jreleaser by jreleaser.

the class SpecPackagerProcessor method setupJavaBinary.

private void setupJavaBinary(Distribution distribution, Map<String, Object> props) throws PackagerProcessingException {
    Artifact artifact = (Artifact) props.get(KEY_DISTRIBUTION_ARTIFACT);
    Path artifactPath = artifact.getResolvedPath(context, distribution);
    String artifactFileName = getFilename(artifactPath.getFileName().toString(), packager.getSupportedExtensions(distribution));
    try {
        List<String> entries = FileUtils.inspectArchive(artifactPath);
        Set<String> directories = new LinkedHashSet<>();
        List<String> binaries = new ArrayList<>();
        List<String> files = new ArrayList<>();
        entries.stream().filter(e -> !e.endsWith(distribution.getExecutable().resolveWindowsExtension())).filter(e -> !e.endsWith("/")).map(e -> e.substring(artifactFileName.length() + 1)).filter(e -> e.startsWith("bin/")).sorted().forEach(entry -> {
            String[] parts = entry.split("/");
            binaries.add(parts[1]);
        });
        entries.stream().filter(e -> !e.endsWith(distribution.getExecutable().resolveWindowsExtension())).filter(e -> !e.endsWith("/")).map(e -> e.substring(artifactFileName.length() + 1)).filter(e -> !e.startsWith("bin/")).sorted().forEach(entry -> {
            String[] parts = entry.split("/");
            if (parts.length > 1)
                directories.add(parts[0]);
            files.add(entry);
        });
        props.put(KEY_PROJECT_VERSION, context.getModel().getProject().version().toRpmVersion());
        props.put(KEY_SPEC_DIRECTORIES, directories);
        props.put(KEY_SPEC_BINARIES, binaries);
        props.put(KEY_SPEC_FILES, files);
    } catch (IOException e) {
        throw new PackagerProcessingException("ERROR", e);
    }
}
Also used : Path(java.nio.file.Path) LinkedHashSet(java.util.LinkedHashSet) KEY_PROJECT_VERSION(org.jreleaser.util.Constants.KEY_PROJECT_VERSION) TemplateUtils.trimTplExtension(org.jreleaser.templates.TemplateUtils.trimTplExtension) FileUtils(org.jreleaser.util.FileUtils) Artifact(org.jreleaser.model.Artifact) KEY_SPEC_DIRECTORIES(org.jreleaser.util.Constants.KEY_SPEC_DIRECTORIES) PackagerProcessingException(org.jreleaser.model.packager.spi.PackagerProcessingException) KEY_SPEC_FILES(org.jreleaser.util.Constants.KEY_SPEC_FILES) Set(java.util.Set) KEY_DISTRIBUTION_ARTIFACT(org.jreleaser.util.Constants.KEY_DISTRIBUTION_ARTIFACT) IOException(java.io.IOException) KEY_SPEC_BINARIES(org.jreleaser.util.Constants.KEY_SPEC_BINARIES) ArrayList(java.util.ArrayList) Project(org.jreleaser.model.Project) List(java.util.List) KEY_SPEC_REQUIRES(org.jreleaser.util.Constants.KEY_SPEC_REQUIRES) StringUtils.getFilename(org.jreleaser.util.StringUtils.getFilename) Spec(org.jreleaser.model.Spec) Map(java.util.Map) JReleaserContext(org.jreleaser.model.JReleaserContext) KEY_SPEC_RELEASE(org.jreleaser.util.Constants.KEY_SPEC_RELEASE) Distribution(org.jreleaser.model.Distribution) Path(java.nio.file.Path) LinkedHashSet(java.util.LinkedHashSet) KEY_SPEC_PACKAGE_NAME(org.jreleaser.util.Constants.KEY_SPEC_PACKAGE_NAME) ArrayList(java.util.ArrayList) PackagerProcessingException(org.jreleaser.model.packager.spi.PackagerProcessingException) IOException(java.io.IOException) Artifact(org.jreleaser.model.Artifact)

Aggregations

IOException (java.io.IOException)1 Path (java.nio.file.Path)1 ArrayList (java.util.ArrayList)1 LinkedHashSet (java.util.LinkedHashSet)1 List (java.util.List)1 Map (java.util.Map)1 Set (java.util.Set)1 Artifact (org.jreleaser.model.Artifact)1 Distribution (org.jreleaser.model.Distribution)1 JReleaserContext (org.jreleaser.model.JReleaserContext)1 Project (org.jreleaser.model.Project)1 Spec (org.jreleaser.model.Spec)1 PackagerProcessingException (org.jreleaser.model.packager.spi.PackagerProcessingException)1 TemplateUtils.trimTplExtension (org.jreleaser.templates.TemplateUtils.trimTplExtension)1 KEY_DISTRIBUTION_ARTIFACT (org.jreleaser.util.Constants.KEY_DISTRIBUTION_ARTIFACT)1 KEY_PROJECT_VERSION (org.jreleaser.util.Constants.KEY_PROJECT_VERSION)1 KEY_SPEC_BINARIES (org.jreleaser.util.Constants.KEY_SPEC_BINARIES)1 KEY_SPEC_DIRECTORIES (org.jreleaser.util.Constants.KEY_SPEC_DIRECTORIES)1 KEY_SPEC_FILES (org.jreleaser.util.Constants.KEY_SPEC_FILES)1 KEY_SPEC_PACKAGE_NAME (org.jreleaser.util.Constants.KEY_SPEC_PACKAGE_NAME)1