Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanseifert committed Nov 20, 2023
2 parents b1acb2c + 7b264d6 commit 73633ab
Show file tree
Hide file tree
Showing 18 changed files with 290 additions and 167 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/maven-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
java: [11, 17]
java: [11, 17, 21]
os: [ubuntu-latest]
distribution: [temurin]
include:
Expand All @@ -39,6 +39,6 @@ jobs:
java-version: ${{ matrix.java }}
maven-executable: ./mvnw
sonar-run-on-os: ubuntu-latest
sonar-run-on-java-version: 11
sonar-run-on-java-version: 17
sonar-token: ${{ secrets.SONAR_TOKEN }}
github-token: ${{ secrets.GITHUB_TOKEN }}
4 changes: 3 additions & 1 deletion .github/workflows/maven-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

name: Deploy

concurrency: ${{ github.workflow }}

on:
push:
branches:
Expand All @@ -15,7 +17,7 @@ jobs:

steps:
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Configure GIT
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release-from-tag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
permissions:
contents: write
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: ncipollo/release-action@v1
with:
body: 'Changes: https://devops.wcm.io/conga/plugins/sling/changes-report.html'
Expand Down
Binary file modified .mvn/wrapper/maven-wrapper.jar
Binary file not shown.
8 changes: 4 additions & 4 deletions .mvn/wrapper/maven-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
# to you 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.
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.4/apache-maven-3.8.4-bin.zip
wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.4/apache-maven-3.9.4-bin.zip
wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar
6 changes: 6 additions & 0 deletions changes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@
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.4" date="2023-11-20">
<action type="fix" dev="sseifert" issue="5">
Generate run modes for configurations in order as expected by AEM Analyser Plugin.
</action>
</release>

<release version="1.3.2" date="2023-03-27">
<action type="update" dev="sseifert">
Switch to Java 11 as minimum version.
Expand Down
6 changes: 3 additions & 3 deletions conga-sling-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.sling.parent</artifactId>
<version>1.3.2</version>
<version>1.3.4</version>
<relativePath>../parent/pom.xml</relativePath>
</parent>

<groupId>io.wcm.devops.conga.plugins</groupId>
<artifactId>io.wcm.devops.conga.plugins.sling</artifactId>
<version>1.3.2</version>
<version>1.3.4</version>
<packaging>jar</packaging>

<name>CONGA Sling Plugin</name>
Expand Down Expand Up @@ -60,7 +60,7 @@
<dependency>
<groupId>io.wcm.devops.conga</groupId>
<artifactId>io.wcm.devops.conga.generator</artifactId>
<version>1.15.0</version>
<version>1.16.2</version>
<scope>compile</scope>
</dependency>

Expand Down
4 changes: 2 additions & 2 deletions conga-sling-plugin/src/it/example/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<parent>
<groupId>io.wcm.maven</groupId>
<artifactId>io.wcm.maven.global-parent</artifactId>
<version>44</version>
<version>54</version>
<relativePath/>
</parent>

Expand All @@ -45,7 +45,7 @@
<plugin>
<groupId>io.wcm.devops.conga</groupId>
<artifactId>conga-maven-plugin</artifactId>
<version>1.15.0</version>
<version>1.16.2</version>
<extensions>true</extensions>
<dependencies>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,24 +118,24 @@ class ConfigurationHandler_ConfigAdmin184 {
type2Code = new HashMap();

// simple (exclusive String whose type code is not written)
type2Code.put(Integer.class, new Integer(TOKEN_SIMPLE_INTEGER));
type2Code.put(Long.class, new Integer(TOKEN_SIMPLE_LONG));
type2Code.put(Float.class, new Integer(TOKEN_SIMPLE_FLOAT));
type2Code.put(Double.class, new Integer(TOKEN_SIMPLE_DOUBLE));
type2Code.put(Byte.class, new Integer(TOKEN_SIMPLE_BYTE));
type2Code.put(Short.class, new Integer(TOKEN_SIMPLE_SHORT));
type2Code.put(Character.class, new Integer(TOKEN_SIMPLE_CHARACTER));
type2Code.put(Boolean.class, new Integer(TOKEN_SIMPLE_BOOLEAN));
type2Code.put(Integer.class, Integer.valueOf(TOKEN_SIMPLE_INTEGER));
type2Code.put(Long.class, Integer.valueOf(TOKEN_SIMPLE_LONG));
type2Code.put(Float.class, Integer.valueOf(TOKEN_SIMPLE_FLOAT));
type2Code.put(Double.class, Integer.valueOf(TOKEN_SIMPLE_DOUBLE));
type2Code.put(Byte.class, Integer.valueOf(TOKEN_SIMPLE_BYTE));
type2Code.put(Short.class, Integer.valueOf(TOKEN_SIMPLE_SHORT));
type2Code.put(Character.class, Integer.valueOf(TOKEN_SIMPLE_CHARACTER));
type2Code.put(Boolean.class, Integer.valueOf(TOKEN_SIMPLE_BOOLEAN));

// primitives
type2Code.put(Integer.TYPE, new Integer(TOKEN_PRIMITIVE_INT));
type2Code.put(Long.TYPE, new Integer(TOKEN_PRIMITIVE_LONG));
type2Code.put(Float.TYPE, new Integer(TOKEN_PRIMITIVE_FLOAT));
type2Code.put(Double.TYPE, new Integer(TOKEN_PRIMITIVE_DOUBLE));
type2Code.put(Byte.TYPE, new Integer(TOKEN_PRIMITIVE_BYTE));
type2Code.put(Short.TYPE, new Integer(TOKEN_PRIMITIVE_SHORT));
type2Code.put(Character.TYPE, new Integer(TOKEN_PRIMITIVE_CHAR));
type2Code.put(Boolean.TYPE, new Integer(TOKEN_PRIMITIVE_BOOLEAN));
type2Code.put(Integer.TYPE, Integer.valueOf(TOKEN_PRIMITIVE_INT));
type2Code.put(Long.TYPE, Integer.valueOf(TOKEN_PRIMITIVE_LONG));
type2Code.put(Float.TYPE, Integer.valueOf(TOKEN_PRIMITIVE_FLOAT));
type2Code.put(Double.TYPE, Integer.valueOf(TOKEN_PRIMITIVE_DOUBLE));
type2Code.put(Byte.TYPE, Integer.valueOf(TOKEN_PRIMITIVE_BYTE));
type2Code.put(Short.TYPE, Integer.valueOf(TOKEN_PRIMITIVE_SHORT));
type2Code.put(Character.TYPE, Integer.valueOf(TOKEN_PRIMITIVE_CHAR));
type2Code.put(Boolean.TYPE, Integer.valueOf(TOKEN_PRIMITIVE_BOOLEAN));

// reverse map to map type codes to classes, string class mapping
// to be added manually, as the string type code is not written and
Expand All @@ -145,7 +145,7 @@ class ConfigurationHandler_ConfigAdmin184 {
Map.Entry entry = (Map.Entry)ti.next();
code2Type.put(entry.getValue(), entry.getKey());
}
code2Type.put(new Integer(TOKEN_SIMPLE_STRING), String.class);
code2Type.put(Integer.valueOf(TOKEN_SIMPLE_STRING), String.class);

NAME_CHARS = new BitSet();
for (int i = '0'; i <= '9'; i++) {
Expand Down Expand Up @@ -301,7 +301,7 @@ private Object readValue(PushbackReader pr) throws IOException {

// read value kind code if type code is not a value kinde code
int code;
if (code2Type.containsKey(new Integer(type))) {
if (code2Type.containsKey(Integer.valueOf(type))) {
code = read(pr);
}
else {
Expand Down Expand Up @@ -346,7 +346,7 @@ private Object readArray(int typeCode, PushbackReader pr) throws IOException {
}

if (c == TOKEN_ARR_CLOS) {
Class type = (Class)code2Type.get(new Integer(typeCode));
Class type = (Class)code2Type.get(Integer.valueOf(typeCode));
Object array = Array.newInstance(type, list.size());
for (int i = 0; i < list.size(); i++) {
Array.set(array, i, list.get(i));
Expand Down Expand Up @@ -414,12 +414,12 @@ private Object readSimple(int code, PushbackReader pr) throws IOException {
case TOKEN_SIMPLE_FLOAT:
case TOKEN_PRIMITIVE_FLOAT:
int fBits = Integer.parseInt(readQuoted(pr));
return new Float(Float.intBitsToFloat(fBits));
return Float.valueOf(Float.intBitsToFloat(fBits));

case TOKEN_SIMPLE_DOUBLE:
case TOKEN_PRIMITIVE_DOUBLE:
long dBits = Long.parseLong(readQuoted(pr));
return new Double(Double.longBitsToDouble(dBits));
return Double.valueOf(Double.longBitsToDouble(dBits));

case TOKEN_SIMPLE_BYTE:
case TOKEN_PRIMITIVE_BYTE:
Expand All @@ -433,7 +433,7 @@ private Object readSimple(int code, PushbackReader pr) throws IOException {
case TOKEN_PRIMITIVE_CHAR:
String cString = readQuoted(pr);
if (cString != null && cString.length() > 0) {
return new Character(cString.charAt(0));
return Character.valueOf(cString.charAt(0));
}
return null;

Expand Down Expand Up @@ -668,11 +668,11 @@ private static void writeType(Writer out, Class valueType) throws IOException {
private static void writeSimple(Writer out, Object value) throws IOException {
if (value instanceof Double) {
double dVal = ((Double)value).doubleValue();
value = new Long(Double.doubleToRawLongBits(dVal));
value = Long.valueOf(Double.doubleToRawLongBits(dVal));
}
else if (value instanceof Float) {
float fVal = ((Float)value).floatValue();
value = new Integer(Float.floatToRawIntBits(fVal));
value = Integer.valueOf(Float.floatToRawIntBits(fVal));
}

out.write(TOKEN_VAL_OPEN);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@
import java.io.InputStreamReader;
import java.io.Reader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import java.util.SortedSet;
import java.util.TreeSet;

Expand All @@ -41,8 +43,6 @@
import org.apache.sling.provisioning.model.Section;
import org.apache.sling.provisioning.model.io.ModelReader;

import com.google.common.collect.ImmutableList;

import io.wcm.devops.conga.generator.spi.context.FileContext;
import io.wcm.devops.conga.generator.util.FileUtil;

Expand Down Expand Up @@ -145,7 +145,7 @@ public static <R> List<R> visitOsgiConfigurations(Model model, ConfigConsumer<R>
}

// prepare repoinit OSGi configuration
String pid = StringUtils.defaultString(feature.getName(), "conga")
String pid = Objects.toString(feature.getName(), "conga")
+ (runModesString != null ? "-" + StringUtils.replace(runModesString, ",", "-") : "");
Configuration configuration = new Configuration(pid, REPOINIT_PID);
configuration.getProperties().put("scripts", new String[] { script });
Expand All @@ -164,9 +164,9 @@ public static <R> List<R> visitOsgiConfigurations(Model model, ConfigConsumer<R>
* Get the relative path for a configuration
*/
private static String getPathForConfiguration(Configuration configuration, RunMode runMode) {
SortedSet<String> runModesList = new TreeSet<>();
SortedSet<String> runModesList = new TreeSet<>(new RunModeComparator());
if (runMode.getNames() != null) {
runModesList.addAll(ImmutableList.copyOf(runMode.getNames()));
runModesList.addAll(Arrays.asList(runMode.getNames()));
}

// run modes directory
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*
* #%L
* wcm.io
* %%
* Copyright (C) 2023 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.sling.util;

import java.io.Serializable;
import java.util.Comparator;
import java.util.Set;

import org.apache.commons.lang3.StringUtils;
import org.jetbrains.annotations.Nullable;

/**
* Comparator sorts run modes alphabetically.
* However, service run modes (author, publish) are always put at the first position.
*/
public class RunModeComparator implements Comparator<String>, Serializable {
private static final long serialVersionUID = 1L;

private static final Set<String> SERVICE_RUNMODES = Set.of("author", "publish");

@Override
public int compare(String runmode1, String runmode2) {
if (isServiceRunmode(runmode1) && !isServiceRunmode(runmode2)) {
return -1;
}
if (!isServiceRunmode(runmode1) && isServiceRunmode(runmode2)) {
return 1;
}
return StringUtils.compare(runmode1, runmode2);
}

private static boolean isServiceRunmode(@Nullable String runmode) {
return runmode != null && SERVICE_RUNMODES.contains(runmode);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ void testProvisioningExample() throws Exception {
assertExists("my.factory-my.pid.config");
assertExists("mode1/my.factory-my.pid2.config");
assertExists("mode2/my.pid2.config");
assertExists("publish.prod/my.pid2.config");

// validate repoinit statements
config = readConfig("org.apache.sling.jcr.repoinit.RepositoryInitializer-test.config");
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* #%L
* wcm.io
* %%
* Copyright (C) 2023 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.sling.util;

import static org.junit.jupiter.api.Assertions.assertEquals;

import java.util.Arrays;
import java.util.List;
import java.util.SortedSet;
import java.util.TreeSet;
import java.util.stream.Collectors;

import org.junit.jupiter.api.Test;

class RunModeComparatorTest {

@Test
void testCompare() {
assertEquals(List.of("mode1", "mode2"), comparedList("mode2", "mode1"));
assertEquals(List.of("publish", "mode1", "mode2", "prod"), comparedList("mode2", "mode1", "publish", "prod"));
assertEquals(List.of("author", "publish", "mode1", "mode2", "prod"), comparedList("mode2", "mode1", "publish", "prod", "author"));
}

private static List<String> comparedList(String... runmodes) {
SortedSet<String> set = new TreeSet<>(new RunModeComparator());
set.addAll(Arrays.asList(runmodes));
return set.stream().collect(Collectors.toList());
}

}
5 changes: 5 additions & 0 deletions conga-sling-plugin/src/test/resources/validProvisioning.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@
my.pid2
stringProperty="value4"

[configurations runModes=publish,prod]

my.pid2
stringProperty="value5"


[:repoinit]
create path /repoinit/test1
Expand Down
Loading

0 comments on commit 73633ab

Please sign in to comment.