Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanseifert committed Oct 17, 2022
2 parents 81d14a9 + 6f97745 commit e895a4e
Show file tree
Hide file tree
Showing 11 changed files with 211 additions and 32 deletions.
12 changes: 12 additions & 0 deletions changes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,18 @@
xsi:schemaLocation="http://maven.apache.org/changes/1.0.0 https://maven.apache.org/plugins/maven-changes-plugin/xsd/changes-1.0.0.xsd">
<body>

<release version="2.18.6" date="2022-10-17">
<action type="update" dev="sseifert">
conga-aem-maven-plugin: Make use of ${project.build.outputTimestamp} for reproducible builds for dispatcher configuration and processed packages in "all" package.
</action>
<action type="fix" dev="sseifert">
conga-aem-maven-plugin: Use Commons Compress to produce "all" package to avoid platform-dependencies in last modified dates.
</action>
<action type="fix" dev="sseifert">
conga-aem-maven-plugin: Ensure consistent line ending for properties.xml in "all" package to avoid platform-dependencies.
</action>
</release>

<release version="2.18.4" date="2022-08-15">
<action type="update" dev="sseifert">
conga-aem-maven-plugin: Check bundle status before package manager install status as the latter may report errors if certain bundles are restarted.
Expand Down
4 changes: 2 additions & 2 deletions conga-aem-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@
<parent>
<groupId>io.wcm.devops.conga.plugins</groupId>
<artifactId>io.wcm.devops.conga.plugins.aem.parent</artifactId>
<version>2.18.4</version>
<version>2.18.6</version>
<relativePath>../parent/pom.xml</relativePath>
</parent>

<groupId>io.wcm.devops.conga.plugins</groupId>
<artifactId>io.wcm.devops.conga.plugins.aem</artifactId>
<version>2.18.4</version>
<version>2.18.6</version>
<packaging>jar</packaging>

<name>CONGA AEM Plugin</name>
Expand Down
4 changes: 2 additions & 2 deletions parent/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

<groupId>io.wcm.devops.conga.plugins</groupId>
<artifactId>io.wcm.devops.conga.plugins.aem.parent</artifactId>
<version>2.18.4</version>
<version>2.18.6</version>
<packaging>pom</packaging>

<name>CONGA AEM Plugin</name>
Expand Down Expand Up @@ -75,7 +75,7 @@
<dependency>
<groupId>io.wcm.tooling.commons</groupId>
<artifactId>io.wcm.tooling.commons.crx-packmgr-helper</artifactId>
<version>2.1.4</version>
<version>2.1.6</version>
</dependency>

<dependency>
Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@
<parent>
<groupId>io.wcm.devops.conga.plugins</groupId>
<artifactId>io.wcm.devops.conga.plugins.aem.parent</artifactId>
<version>2.18.4</version>
<version>2.18.6</version>
<relativePath>parent/pom.xml</relativePath>
</parent>

<groupId>io.wcm.devops.conga.plugins</groupId>
<artifactId>io.wcm.devops.conga.plugins.aem.root</artifactId>
<version>2.18.4</version>
<version>2.18.6</version>
<packaging>pom</packaging>

<name>CONGA AEM Plugin</name>
Expand Down
6 changes: 3 additions & 3 deletions tooling/conga-aem-crypto-cli/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@
<parent>
<groupId>io.wcm.devops.conga.plugins</groupId>
<artifactId>io.wcm.devops.conga.plugins.aem.parent</artifactId>
<version>2.18.4</version>
<version>2.18.6</version>
<relativePath>../../parent/pom.xml</relativePath>
</parent>

<groupId>io.wcm.devops.conga.plugins</groupId>
<artifactId>conga-aem-crypto-cli</artifactId>
<packaging>jar</packaging>
<version>2.18.4</version>
<version>2.18.6</version>

<name>CONGA AEM Crypto Command Line Interface</name>
<description>Command line tool to generate Crypto keys for AEM.</description>
Expand All @@ -42,7 +42,7 @@
<dependency>
<groupId>io.wcm.devops.conga.plugins</groupId>
<artifactId>io.wcm.devops.conga.plugins.aem</artifactId>
<version>2.18.4</version>
<version>2.18.6</version>
<scope>compile</scope>
<exclusions>
<!-- Exclude all deps - only crypto util classes are used -->
Expand Down
6 changes: 3 additions & 3 deletions tooling/conga-aem-maven-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@
<parent>
<groupId>io.wcm.devops.conga.plugins</groupId>
<artifactId>io.wcm.devops.conga.plugins.aem.parent</artifactId>
<version>2.18.4</version>
<version>2.18.6</version>
<relativePath>../../parent/pom.xml</relativePath>
</parent>

<groupId>io.wcm.devops.conga.plugins</groupId>
<artifactId>conga-aem-maven-plugin</artifactId>
<packaging>maven-plugin</packaging>
<version>2.18.4</version>
<version>2.18.6</version>

<name>CONGA AEM Maven Plugin</name>
<description>wcm.io DevOps CONGA - CONfiguration GenerAtor Maven Plugin for AEM</description>
Expand Down Expand Up @@ -63,7 +63,7 @@
<dependency>
<groupId>io.wcm.devops.conga.plugins</groupId>
<artifactId>io.wcm.devops.conga.plugins.aem</artifactId>
<version>2.18.4</version>
<version>2.18.6</version>
<scope>compile</scope>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/*
* #%L
* wcm.io
* %%
* Copyright (C) 2022 wcm.io
* %%
* 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
*
* http://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.
* #L%
*/
package io.wcm.devops.conga.plugins.aem.maven;

import java.nio.file.attribute.FileTime;
import java.util.Date;

import org.apache.maven.archiver.MavenArchiver;
import org.jetbrains.annotations.Nullable;

/**
* Parse/convert ${project.build.outputTimestamp}.
*/
public class BuildOutputTimestamp {

private final Date date;

/**
* @param outputTimestamp Configured output timestamp
*/
public BuildOutputTimestamp(@Nullable String outputTimestamp) {
MavenArchiver mavenArchiver = new MavenArchiver();
this.date = mavenArchiver.parseOutputTimestamp(outputTimestamp);
}

/**
* @return true if a valid timestamp is configured
*/
public boolean isValid() {
return date != null;
}

/**
* @return Date or null if not a valid date
*/
@Nullable
public Date toDate() {
return date;
}

/**
* @return FileTime or null if not a valid date
*/
@Nullable
public FileTime toFileTime() {
if (date != null) {
return FileTime.fromMillis(date.toInstant().getEpochSecond());
}
return null;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,9 @@ public final class CloudManagerAllPackageMojo extends AbstractCloudManagerMojo {
@Parameter(property = "conga.cloudManager.allPackage.skip", defaultValue = "false")
private boolean skip;

@Parameter(defaultValue = "${project.build.outputTimestamp}")
private String outputTimestamp;

@Parameter(readonly = true, defaultValue = "${project}")
private MavenProject project;
@Component
Expand Down Expand Up @@ -264,7 +267,8 @@ private AllPackageBuilder createBuilder(String packageName) {
.autoDependenciesMode(this.autoDependenciesMode)
.runModeOptimization(this.runModeOptimization)
.packageTypeValidation(this.packageTypeValidation)
.logger(getLog());
.logger(getLog())
.buildOutputTimestamp(new BuildOutputTimestamp(outputTimestamp));
}

private void buildAllPackage(AllPackageBuilder builder) throws MojoExecutionException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ public final class CloudManagerDispatcherConfigMojo extends AbstractCloudManager
@Component(role = Archiver.class, hint = "zip")
private ZipArchiver zipArchiver;

@Parameter(defaultValue = "${project.build.outputTimestamp}")
private String outputTimestamp;

@Override
public void execute() throws MojoExecutionException, MojoFailureException {
if (skip) {
Expand Down Expand Up @@ -92,6 +95,11 @@ private void buildDispatcherConfig(File environmentDir, File nodeDir) throws Moj
addZipDirectory(basePath, nodeDir, Collections.singleton(ModelParser.MODEL_FILE));
zipArchiver.setDestFile(targetFile);

BuildOutputTimestamp buildOutputTimestamp = new BuildOutputTimestamp(outputTimestamp);
if (buildOutputTimestamp.isValid()) {
zipArchiver.configureReproducible(buildOutputTimestamp.toDate());
}

zipArchiver.createArchive();
}
catch (ArchiverException | IOException ex) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@
import java.util.Properties;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
import java.util.zip.ZipOutputStream;

import org.apache.commons.compress.archivers.zip.ZipArchiveEntry;
import org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream;
import org.apache.commons.compress.archivers.zip.ZipFile;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.io.IOUtils;
Expand All @@ -65,6 +65,7 @@
import com.google.common.collect.ImmutableSet;

import io.wcm.devops.conga.plugins.aem.maven.AutoDependenciesMode;
import io.wcm.devops.conga.plugins.aem.maven.BuildOutputTimestamp;
import io.wcm.devops.conga.plugins.aem.maven.PackageTypeValidation;
import io.wcm.devops.conga.plugins.aem.maven.RunModeOptimization;
import io.wcm.devops.conga.plugins.aem.maven.model.BundleFile;
Expand Down Expand Up @@ -105,6 +106,7 @@ public final class AllPackageBuilder {
private RunModeOptimization runModeOptimization = RunModeOptimization.OFF;
private PackageTypeValidation packageTypeValidation = PackageTypeValidation.STRICT;
private Log log;
private BuildOutputTimestamp buildOutputTimestamp;

private static final String RUNMODE_DEFAULT = "$default$";
private static final Set<String> ALLOWED_PACKAGE_TYPES = ImmutableSet.of(
Expand Down Expand Up @@ -172,6 +174,15 @@ public AllPackageBuilder version(String value) {
return this;
}

/**
* @param value Build output timestamp
* @return this
*/
public AllPackageBuilder buildOutputTimestamp(BuildOutputTimestamp value) {
this.buildOutputTimestamp = value;
return this;
}

private Log getLog() {
if (this.log == null) {
this.log = new SystemStreamLog();
Expand Down Expand Up @@ -530,18 +541,18 @@ private List<TemporaryContentPackageFile> processContentPackage(ContentPackageFi

// iterate through entries and write them to the temp. zip file
try (FileOutputStream fos = new FileOutputStream(tempFile);
ZipOutputStream zipOut = new ZipOutputStream(fos)) {
Enumeration<? extends ZipEntry> zipInEntries = zipFileIn.entries();
ZipArchiveOutputStream zipOut = new ZipArchiveOutputStream(fos)) {
Enumeration<? extends ZipArchiveEntry> zipInEntries = zipFileIn.getEntries();
while (zipInEntries.hasMoreElements()) {
ZipEntry zipInEntry = zipInEntries.nextElement();
ZipArchiveEntry zipInEntry = zipInEntries.nextElement();
if (!zipInEntry.isDirectory()) {
try (InputStream is = zipFileIn.getInputStream(zipInEntry)) {
boolean processedEntry = false;

// if entry is properties.xml, update dependency information
if (StringUtils.equals(zipInEntry.getName(), "META-INF/vault/properties.xml")) {
Properties props = new Properties();
props.loadFromXML(is);
FileVaultProperties fileVaultProps = new FileVaultProperties(is);
Properties props = fileVaultProps.getProperties();
addSuffixToPackageName(props, pkg, environmentRunMode);

// update package dependencies
Expand All @@ -557,9 +568,10 @@ private List<TemporaryContentPackageFile> processContentPackage(ContentPackageFi
props.put(NAME_PACKAGE_TYPE, packageType);
}

ZipEntry zipOutEntry = newZipEntry(zipInEntry);
zipOut.putNextEntry(zipOutEntry);
props.storeToXML(zipOut, null);
ZipArchiveEntry zipOutEntry = newZipEntry(zipInEntry);
zipOut.putArchiveEntry(zipOutEntry);
fileVaultProps.storeToXml(zipOut);
zipOut.closeArchiveEntry();
processedEntry = true;
}

Expand Down Expand Up @@ -589,13 +601,13 @@ else if (StringUtils.equals(FilenameUtils.getExtension(zipInEntry.getName()), "z

// otherwise transfer the binary data 1:1
if (!processedEntry) {
ZipEntry zipOutEntry = newZipEntry(zipInEntry);
zipOut.putNextEntry(zipOutEntry);
ZipArchiveEntry zipOutEntry = newZipEntry(zipInEntry);
zipOut.putArchiveEntry(zipOutEntry);
IOUtils.copy(is, zipOut);
zipOut.closeArchiveEntry();
}
}

zipOut.closeEntry();
}
}
}
Expand All @@ -615,12 +627,12 @@ else if (StringUtils.equals(FilenameUtils.getExtension(zipInEntry.getName()), "z
return result;
}

private static ZipEntry newZipEntry(ZipEntry in) {
ZipEntry out = new ZipEntry(in.getName());
if (in.getCreationTime() != null) {
out.setCreationTime(in.getCreationTime());
private ZipArchiveEntry newZipEntry(ZipArchiveEntry in) {
ZipArchiveEntry out = new ZipArchiveEntry(in.getName());
if (buildOutputTimestamp != null && buildOutputTimestamp.isValid()) {
out.setLastModifiedTime(buildOutputTimestamp.toFileTime());
}
if (in.getLastModifiedTime() != null) {
else if (in.getLastModifiedTime() != null) {
out.setLastModifiedTime(in.getLastModifiedTime());
}
return out;
Expand Down
Loading

0 comments on commit e895a4e

Please sign in to comment.