Skip to content

Commit

Permalink
[jgitflow-maven-plugin] merging 'release/1.3.0' into 'master'
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanseifert committed Apr 23, 2020
2 parents 399754a + be2b1a8 commit 7c90193
Show file tree
Hide file tree
Showing 25 changed files with 226 additions and 65 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,19 @@ npm-debug.log
.settings
.externalToolBuilders
.pmd
.eclipse-pmd
.checkstyle
.idea
.vagrant
*.iml
.DS_Store
*.retry
.rubygems
.sass-cache
.rubygems-gem-maven-plugin
*.sublime-*
*nbactions*.xml
.temp/
.vlt
.vlt-sync*
.brackets.json
12 changes: 6 additions & 6 deletions .travis.maven-settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

<repository>
<id>central</id>
<url>http://repo1.maven.org/maven2/</url>
<url>https://repo1.maven.org/maven2/</url>
<layout>default</layout>
<releases>
<enabled>true</enabled>
Expand All @@ -57,7 +57,7 @@

<repository>
<id>wcm-io-apache-intermediate-release</id>
<url>http://wcm.io/maven/repositories/apache-intermediate-release</url>
<url>https://wcm.io/maven/repositories/apache-intermediate-release</url>
<layout>default</layout>
<releases>
<enabled>true</enabled>
Expand All @@ -83,7 +83,7 @@

<repository>
<id>apache-snapshots</id>
<url>http://repository.apache.org/snapshots</url>
<url>https://repository.apache.org/snapshots</url>
<layout>default</layout>
<releases>
<enabled>false</enabled>
Expand All @@ -100,7 +100,7 @@

<pluginRepository>
<id>central</id>
<url>http://repo1.maven.org/maven2/</url>
<url>https://repo1.maven.org/maven2/</url>
<layout>default</layout>
<releases>
<enabled>true</enabled>
Expand All @@ -126,7 +126,7 @@

<pluginRepository>
<id>wcm-io-apache-intermediate-release</id>
<url>http://wcm.io/maven/repositories/apache-intermediate-release</url>
<url>https://wcm.io/maven/repositories/apache-intermediate-release</url>
<layout>default</layout>
<releases>
<enabled>true</enabled>
Expand All @@ -152,7 +152,7 @@

<pluginRepository>
<id>apache-snapshots</id>
<url>http://repository.apache.org/snapshots</url>
<url>https://repository.apache.org/snapshots</url>
<layout>default</layout>
<releases>
<enabled>false</enabled>
Expand Down
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
language: java

jdk:
- oraclejdk8
- openjdk8
- openjdk11

# Make sure travis can use container-based infrastructure
Expand Down
37 changes: 37 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
@Library('pipeline-library') pipelineLibrary
@Library('pv-pipeline-library') pvPipelineLibrary


import io.wcm.devops.jenkins.pipeline.ssh.SSHTarget

import static de.provision.devops.jenkins.pipeline.utils.ConfigConstants.*
import static io.wcm.devops.jenkins.pipeline.utils.ConfigConstants.*

// See:
// https://github.com/pro-vision/jenkins-pv-pipeline-library
// https://github.com/pro-vision/jenkins-pv-pipeline-library/blob/master/docs/config-structure.md
// Also have a look at https://github.com/wcm-io-devops/jenkins-pipeline-library for further configuration options

List triggers = defaults.getTriggers()
triggers.push(githubPush())

Map config = [
(BUILD_WRAPPER): [
(BUILD_WRAPPER_SSH_TARGETS): [new SSHTarget("ssh-wcm.io")]
],
(PROPERTIES) : [
(PROPERTIES_PIPELINE_TRIGGERS): triggers
],
(STAGE_COMPILE): [
(MAVEN): [
(MAVEN_GOALS): ["clean", "deploy", "site-deploy"],
]
],
(STAGE_FEATURE_PREPARATION): [
(STAGE_FEATURE_PREPARATION_MERGE): [
(STAGE_FEATURE_PREPARATION_MERGE_ENABLED): false
]
]
]

routeDefaultJenkinsFile(config)
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
<img src="http://wcm.io/images/favicon-16@2x.png"/> CONGA Plugin for Apache Sling
<img src="https://wcm.io/images/favicon-16@2x.png"/> CONGA Plugin for Apache Sling
======
[![Build Status](https://travis-ci.org/wcm-io-devops/conga-sling-plugin.png?branch=develop)](https://travis-ci.org/wcm-io-devops/conga-sling-plugin)
[![Code Coverage](https://codecov.io/gh/wcm-io-devops/conga-sling-plugin/branch/develop/graph/badge.svg)](https://codecov.io/gh/wcm-io-devops/conga-sling-plugin)

Documentation: http://devops.wcm.io/conga/plugins/sling/<br/>
Documentation: https://devops.wcm.io/conga/plugins/sling/<br/>
Issues: https://wcm-io.atlassian.net/projects/WDCONGA<br/>
Wiki: https://wcm-io.atlassian.net/wiki/<br/>
Continuous Integration: https://travis-ci.org/conga-sling-plugin


## Build from sources

If you want to build from sources make sure you have configured all [Maven Repositories](http://devops.wcm.io/maven.html) in your settings.xml.
If you want to build from sources make sure you have configured all [Maven Repositories](https://devops.wcm.io/maven.html) in your settings.xml.

See [Travis Maven settings.xml](https://github.com/conga-sling-plugin/blob/master/.travis.maven-settings.xml) for an example with a full configuration.

Expand Down
9 changes: 9 additions & 0 deletions changes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,15 @@
xsi:schemaLocation="http://maven.apache.org/changes/1.0.0 http://maven.apache.org/plugins/maven-changes-plugin/xsd/changes-1.0.0.xsd">
<body>

<release version="1.3.0" date="2020-04-23">
<action type="add" dev="sseifert">
Add support for [:repoinit] sections when generating OSGi configurations from Sling Provisioning files.
</action>
<action type="fix" dev="sseifert">
Provisioning file format escaping rules: Escape variable expressions ${...} in values to ensure they are passed through and not interpreted as provisioning file variables.
</action>
</release>

<release version="1.2.6" date="2019-05-08">
<action type="update" dev="sseifert">
Read Felix ConfigAdmin configuration files with latest version (1.9.14), but write it using the old file format form ConfigAdmin 1.8.4 to support AEM 6.1 and below.
Expand Down
10 changes: 5 additions & 5 deletions conga-sling-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,19 @@
#L%
-->

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>io.wcm.devops</groupId>
<artifactId>io.wcm.devops.parent_toplevel</artifactId>
<version>1.1.4</version>
<version>1.2.2</version>
<relativePath />
</parent>

<groupId>io.wcm.devops.conga.plugins</groupId>
<artifactId>io.wcm.devops.conga.plugins.sling</artifactId>
<version>1.2.6</version>
<version>1.3.0</version>
<packaging>jar</packaging>

<name>CONGA Sling Plugin</name>
Expand Down Expand Up @@ -62,14 +62,14 @@
<groupId>org.apache.felix</groupId>
<artifactId>org.apache.felix.configadmin</artifactId>
<!-- Support latest config file format for reading, stick with version 1.8.4 for writing (ConfigurationHandler class is copied to this plugin) -->
<version>1.9.14</version>
<version>1.9.16</version>
<scope>compile</scope>
</dependency>

<dependency>
<groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.provisioning.model</artifactId>
<version>1.8.4</version>
<version>1.8.6</version>
<scope>compile</scope>
</dependency>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
*/
package io.wcm.devops.conga.plugins.sling.handlebars.escaping;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

import io.wcm.devops.conga.generator.spi.handlebars.EscapingStrategyPlugin;
import io.wcm.devops.conga.generator.spi.handlebars.context.EscapingStrategyContext;
import io.wcm.devops.conga.generator.util.FileUtil;
Expand All @@ -34,6 +37,8 @@ public class ProvisioningEscapingStrategy implements EscapingStrategyPlugin {
*/
public static final String NAME = "sling-provisioning";

private static final Pattern VARIABLE_PATTERN = Pattern.compile("\\$\\{([^\\{\\}]+)\\}");

@Override
public String getName() {
return NAME;
Expand All @@ -47,8 +52,22 @@ public boolean accepts(String fileExtension, EscapingStrategyContext pluginConte

@Override
public String escape(CharSequence value, EscapingStrategyContext pluginContext) {
if (value == null) {
return null;
}

// use same escaping rules as for OSGi configurations
return value == null ? null : OsgiConfigEscapingStrategy.ESCAPE_OSGI_CONFIG.translate(value);
String escapedValue = OsgiConfigEscapingStrategy.ESCAPE_OSGI_CONFIG.translate(value);

// escape variables ${...} with \${...} - otherwise lead to "Unknown variable" error when validating sling provisioning file
StringBuffer result = new StringBuffer();
Matcher matcher = VARIABLE_PATTERN.matcher(escapedValue);
while (matcher.find()) {
matcher.appendReplacement(result, "\\\\\\$\\{" + matcher.group(1) + "\\}");
}
matcher.appendTail(result);

return result.toString();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

import org.apache.sling.provisioning.model.Model;

import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import io.wcm.devops.conga.generator.GeneratorException;
import io.wcm.devops.conga.generator.spi.PostProcessorPlugin;
import io.wcm.devops.conga.generator.spi.context.FileContext;
Expand Down Expand Up @@ -57,6 +58,7 @@ public boolean accepts(FileContext file, PostProcessorContext context) {
}

@Override
@SuppressFBWarnings("RV_RETURN_VALUE_IGNORED_BAD_PRACTICE")
public List<FileContext> apply(FileContext fileContext, PostProcessorContext context) {
File file = fileContext.getFile();
try {
Expand All @@ -80,11 +82,11 @@ public List<FileContext> apply(FileContext fileContext, PostProcessorContext con
* @param model Provisioning Model
* @param dir Target directory
* @param context Post processor context
* @throws IOException
*/
private List<FileContext> generateOsgiConfigurations(Model model, File dir, PostProcessorContext context) throws IOException {
return ProvisioningUtil.visitOsgiConfigurations(model, new ConfigConsumer<FileContext>() {
@Override
@SuppressFBWarnings("RV_RETURN_VALUE_IGNORED_BAD_PRACTICE")
public FileContext accept(String path, Dictionary<String, Object> properties) throws IOException {
context.getLogger().info(" Generate " + path);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@

import org.apache.felix.cm.file.FilePersistenceManager;

import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;

/*
* This file is COPIED from the sources of org.apache.felix.configadmin 1.8.4
* to write the configuration using the old (single line) array style, which is required to support
Expand All @@ -66,7 +68,8 @@
* </pre>
*/
//CHECKSTYLE:OFF
@SuppressWarnings({ "unchecked", "unused", "javadoc" })
@SuppressWarnings({ "unchecked", "unused", "javadoc", "PMD" })
@SuppressFBWarnings({ "PERFORMANCE", "STYLE" })
class ConfigurationHandler_ConfigAdmin184 {

protected static final String ENCODING = "UTF-8";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import org.apache.sling.provisioning.model.ModelUtility;
import org.apache.sling.provisioning.model.ModelUtility.ResolverOptions;
import org.apache.sling.provisioning.model.RunMode;
import org.apache.sling.provisioning.model.Section;
import org.apache.sling.provisioning.model.io.ModelReader;

import com.google.common.collect.ImmutableList;
Expand All @@ -60,6 +61,9 @@ public final class ProvisioningUtil {
*/
public static final String TEXT_FILE_EXTENSION = "txt";

private static final String REPOINIT_SECTION = "repoinit";
private static final String REPOINIT_PID = "org.apache.sling.jcr.repoinit.RepositoryInitializer";

private ProvisioningUtil() {
// static methods only
}
Expand Down Expand Up @@ -109,6 +113,8 @@ public static Model getModel(FileContext file) throws IOException {
public static <R> List<R> visitOsgiConfigurations(Model model, ConfigConsumer<R> consumer) throws IOException {
List<R> results = new ArrayList<>();
for (Feature feature : model.getFeatures()) {

// OSGi configurations
for (RunMode runMode : feature.getRunModes()) {
for (Configuration configuration : runMode.getConfigurations()) {
String path = getPathForConfiguration(configuration, runMode);
Expand All @@ -118,6 +124,38 @@ public static <R> List<R> visitOsgiConfigurations(Model model, ConfigConsumer<R>
}
}
}

// repoinit statements
for (Section section : feature.getAdditionalSections(REPOINIT_SECTION)) {

// repoinit script
String script = section.getContents();
if (StringUtils.isBlank(script)) {
continue;
}

// associated run modes
String runModesString = section.getAttributes().get("runModes");
RunMode runMode;
if (runModesString != null) {
runMode = new RunMode(StringUtils.split(runModesString, ","));
}
else {
runMode = new RunMode(null);
}

// prepare repoinit OSGi configuration
String pid = StringUtils.defaultString(feature.getName(), "conga")
+ (runModesString != null ? "-" + StringUtils.replace(runModesString, ",", "-") : "");
Configuration configuration = new Configuration(pid, REPOINIT_PID);
configuration.getProperties().put("scripts", new String[] { script });
String path = getPathForConfiguration(configuration, runMode);
R result = consumer.accept(path, configuration.getProperties());
if (result != null) {
results.add(result);
}
}

}
return results;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,17 @@
/**
* WARNING: Test is disabled, see {@link OsgiConfigFileHeader} javadocs.
*/
public class OsgiConfigFileHeaderTest {
class OsgiConfigFileHeaderTest {

private FileHeaderPlugin underTest;

@BeforeEach
public void setUp() {
void setUp() {
underTest = new PluginManagerImpl().get(OsgiConfigFileHeader.NAME, FileHeaderPlugin.class);
}

@Test
public void testApply() throws Exception {
void testApply() throws Exception {
File file = new File("target/generation-test/fileHeader.config");
FileUtils.write(file, "myscript", StandardCharsets.UTF_8);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,17 @@
import io.wcm.devops.conga.generator.spi.context.FileHeaderContext;
import io.wcm.devops.conga.generator.util.PluginManagerImpl;

public class ProvisioningFileHeaderTest {
class ProvisioningFileHeaderTest {

private FileHeaderPlugin underTest;

@BeforeEach
public void setUp() {
void setUp() {
underTest = new PluginManagerImpl().get(ProvisioningFileHeader.NAME, FileHeaderPlugin.class);
}

@Test
public void testApply() throws Exception {
void testApply() throws Exception {
File file = new File("target/generation-test/fileHeader.txt");
FileUtils.copyFile(new File(getClass().getResource("/validProvisioning.txt").toURI()), file);

Expand Down
Loading

0 comments on commit 7c90193

Please sign in to comment.