Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create release version 1.15 #34

Merged
merged 22 commits into from
Nov 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
cd648d5
Feature/#15 reserved words break functionality (#20)
joostoudeman Oct 11, 2021
38b7b04
mark mojos threadsafe (#22)
joostoudeman Oct 11, 2021
6c8c63c
update dependencies and major fixes (#21)
joostoudeman Nov 8, 2021
a113e6f
feature/log-target-support (#24)
Joostvzanden Jan 22, 2023
0309784
update dependencies (#25)
joostoudeman Jan 22, 2023
a3a7e8d
slf4j-log4j12 has been renamed/relocated to slf4j-reload4
mxdrenthe Jan 25, 2023
fbf1ef6
Upgrade Groovy to version 4
mxdrenthe Jan 25, 2023
8e8e284
Merge pull request #30 from openweb-nl/feature/groovy-upgrade-version-4
mxdrenthe Jan 26, 2023
f3cebed
Merge pull request #28 from openweb-nl/feature/#26-slf4j-relocated
mxdrenthe Jan 26, 2023
2ad3016
Add github pipeline to project
mxdrenthe Jan 26, 2023
5a1b7fe
Removal of plexus plugin
mxdrenthe Jan 25, 2023
0b4179e
Adding pom file adjustments
mxdrenthe Jan 25, 2023
939047e
Add space between parameters
mxdrenthe Jan 26, 2023
9b08823
Change version of dependency graph
mxdrenthe Jan 26, 2023
96bdfda
Not working action removed
mxdrenthe Jan 26, 2023
605be86
Try multi module version
mxdrenthe Jan 26, 2023
cf164fc
Add provided scope to maven-plugin-api dependency
mxdrenthe Jan 26, 2023
cf3b5b4
Merge pull request #31 from openweb-nl/feature/add-github-actions
mxdrenthe Jan 26, 2023
7d1ecca
Merge pull request #32 from openweb-nl/feature/maven-warning-during-b…
mxdrenthe Jan 26, 2023
22b186f
Merge pull request #29 from openweb-nl/feature/remove-plexus-plugin
mxdrenthe Jan 26, 2023
0faeded
Merge branch 'develop' into release/1.15
mxdrenthe Nov 27, 2023
eee1e06
Merge pull request #33 from openweb-nl/release/1.15
mxdrenthe Nov 27, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-maven

# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.

name: Java CI with Maven

on:
push:
branches: [ "develop" ]
pull_request:
branches: [ "develop" ]

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'temurin'
cache: maven
- name: Build with Maven
run: mvn -B verify --file pom.xml

# Optional: Uploads the full dependency graph to GitHub to improve the quality of Dependabot alerts this repository can receive
- name: Maven Dependency Tree Dependency Submission
uses: advanced-security/maven-dependency-submission-action@multi-module
21 changes: 5 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Project for Hippo Updaters Maven Plugin
This project is designed for Hippo developers to have an easy way to create updaters in groovy, without being bothered with the bootstrap xml.
This project is designed for Hippo developers to have an easy way to create updaters in groovy, without being bothered with the repository data yaml.

For use the updaters are located in their own submodule. Nicely separated from other bootstrap.
They are groovy scripts, so the editor can easily provide autocomplete and stuff, configured by Annotations.
Expand Down Expand Up @@ -34,7 +34,6 @@ To add mixin(s) (since 1.14):
```
## Use of the maven plugin
In the build section of the (new) module containing the groovy updater scripts, define the execution of the plugin
*For Hippo 12 use the *'generate-yaml'* goal.*
```xml
<plugin>
<groupId>nl.openweb.hippo.updater</groupId>
Expand All @@ -45,7 +44,7 @@ In the build section of the (new) module containing the groovy updater scripts,
<id>default-resources</id>
<phase>compile</phase>
<goals>
<goal>generate-xml</goal>
<goal>generate-yaml</goal>
</goals>
</execution>
</executions>
Expand All @@ -59,12 +58,9 @@ In the build section of the (new) module containing the groovy updater scripts,
* **targetDir**
* where to generate the bootstrap
```(default: ${project.build.outputDirectory})```
* **defaultContentRoot** (since 1.12)
* **defaultContentRoot**
* default contentroot value _(registry/queue)_
```(default: queue)```
* **initializeNamePrefix**
* prefix in the ecm-extension.xml nodenames
```(default:hippo-updater-) ```
* **yamlContentPath** (since 1.13)
* relative path for the yaml queue bootstrap files
```(default: hcm-content/configuration/update)```
Expand All @@ -73,7 +69,7 @@ In the build section of the (new) module containing the groovy updater scripts,
```(default: hcm-config/configuration/update)```


When using a separate module in Hippo 12, don't forget to place an hcm-module.yaml in the project.
When using a separate module, don't forget to place an hcm-module.yaml in the project.
```yaml
group:
name: hippoproject
Expand Down Expand Up @@ -131,15 +127,8 @@ set the system property `groovy.sync.watchedModules` in the cargo container.
</configuration>
</plugin>
```
### Log4j
### Log4j2
Add an info logging level for nl.openweb.hippo.groovy to your development log4j configuration
```xml
<logger name="nl.openweb.hippo.groovy" additivity="false">
<level value="info"/>
<appender-ref ref="messages"/>
</logger>
```
**Log4j2:**
```xml
<Logger name="nl.openweb.hippo.groovy" additivity="false" level="info">
<AppenderRef ref="messages"/>
Expand Down
2 changes: 1 addition & 1 deletion annotations/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,4 @@
<scope>test</scope>
</dependency>
</dependencies>
</project>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import java.lang.annotation.Target;

/**
* Bootstrap annotation to define properties in the hippoecm-extension.xml
* Bootstrap annotation to define where to bootstrap the script
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
Expand All @@ -32,7 +32,7 @@ enum ContentRoot {
QUEUE("queue"),
REGISTRY("registry");

private String value;
private final String value;

ContentRoot(String value) {
this.value = value;
Expand All @@ -46,9 +46,16 @@ public String toString() {

ContentRoot contentroot() default ContentRoot.DEFAULT;

double sequence() default 99999.0d;

/**
* reload the script
* applies if contentroot is queue, and a version is defined.
* @return
*/
boolean reload() default false;

/**
* if the reload is set to true, the version will be used for bootstrapping
* @return
*/
String version() default "";
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,22 @@
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
public @interface Updater {
enum LogTarget {
DEFAULT(""),
LOG_FILES("LOG FILES"),
REPOSITORY("REPOSITORY");

private final String value;

LogTarget(String value) {
this.value = value;
}

@Override
public String toString() {
return value;
}
}
String name();

String description() default "";
Expand All @@ -44,4 +60,6 @@
long throttle() default 1000L;

String mixin() default "";

LogTarget logTarget() default LogTarget.DEFAULT;
}
12 changes: 2 additions & 10 deletions bootstrapgenerator/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,6 @@
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
</dependency>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-utils</artifactId>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
Expand All @@ -45,7 +41,7 @@
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<groupId>org.apache.groovy</groupId>
<artifactId>groovy</artifactId>
</dependency>

Expand All @@ -69,10 +65,6 @@
<artifactId>jcr</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-runtime</artifactId>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
Expand Down Expand Up @@ -101,4 +93,4 @@
</plugin>
</plugins>
</build>
</project>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,21 @@
import nl.openweb.hippo.groovy.annotations.Bootstrap;
import nl.openweb.hippo.groovy.annotations.Exclude;
import nl.openweb.hippo.groovy.annotations.Updater;

import static nl.openweb.hippo.groovy.model.Constants.Files.GROOVY_EXTENSION;

public abstract class Generator {
protected static final String NEWLINE = "\n";
private static final List<Class<?>> ANNOTATED_CLASSES = Arrays.asList(Exclude.class, Bootstrap.class, Updater.class, Bootstrap.ContentRoot.class);
private static final String HIPPO_CONFIGURATION_UPDATE_PATH_PREFIX = "/hippo:configuration/hippo:update/hippo:";
private static final String REGEX_WHITESPACE = "\\s*";
private static final String REGEX_ANNOTATIONS_SNIPPET = "(?:[\\w\\W]+[\\n|;]" + REGEX_WHITESPACE + "import [\\w.]+[;|\\n]+)?(?=[\\w\\W]*@[\\w.]*Updater)([\\w\\W]*)(?=(?:public )?class \\w+ extends [\\w\\W]+" + REGEX_WHITESPACE + "\\{)";
private static final String REGEX_ATTR_NAME = "([A-Za-z]\\w*)";
private static final String REGEX_ATTR_VALUE_SINGLEQUOTE = "('.*?(?<!\\\\)('))";
private static final String REGEX_ATTR_VALUE_QUOTE = "(\".*?(?<!\\\\)(\"))";
private static final String REGEX_ATTR_VALUE_TRIPQUOTE = "('''([\\s\\S]*)''')";
private static final String REGEX_ATTR_VALUE_SIMPLE = "true|false|([^,^\\)]+)";
private static final String REGEX_COMMA = "\\s*,*\\s*";
private static final String REGEX_COMMA = REGEX_WHITESPACE + ",*" + REGEX_WHITESPACE;
private static final String REGEX_ATTR_VALUE = "("
+ REGEX_ATTR_VALUE_SINGLEQUOTE
+ "|"
Expand All @@ -57,32 +59,54 @@ public abstract class Generator {
+ REGEX_ATTR_VALUE_SIMPLE
+ ")?";
private static final String REGEX_ATTRIBUTES = REGEX_WHITESPACE + REGEX_ATTR_NAME + REGEX_WHITESPACE + "=" + REGEX_WHITESPACE + REGEX_ATTR_VALUE + REGEX_COMMA;
private static final String ANNOTATION_PAYLOAD = REGEX_WHITESPACE + "(\\((" + REGEX_ATTRIBUTES + ")*\\))?";
private static final String ANNOTATION_PAYLOAD = "(?:" + REGEX_WHITESPACE + "\\((" + REGEX_ATTRIBUTES + ")*\\))?";

protected static Bootstrap.ContentRoot defaultContentRoot = Bootstrap.ContentRoot.QUEUE;

protected Generator() {
}

public static List<String> getAnnotations(final String script){
//Strip comments
String codeBlock = script.replaceAll("\\s/\\*[\\w\\W]*\\*/", StringUtils.EMPTY);
if(codeBlock.startsWith("/*")) {
codeBlock = StringUtils.substringAfter(codeBlock, "*/");
}
codeBlock = codeBlock.replaceAll("\\n//.*", StringUtils.EMPTY);
final Matcher matcher = Pattern.compile(REGEX_ANNOTATIONS_SNIPPET).matcher(codeBlock);
final List<String> annotationStrings = new ArrayList<>();
if(matcher.find()) {
final String snippet = matcher.group(1);
for (final Class<?> annotationClass : getAnnotationClasses()) {
final String annotation = getAnnotation(snippet, annotationClass);
if (StringUtils.isNotBlank(annotation)) {
annotationStrings.add(annotation);
}
}
}
return annotationStrings;
}

public static String stripAnnotations(final String script) {
return stripAnnotations(script, false);
}

public static String stripAnnotations(final String script, final boolean keepSpaces) {
String result = script;
for (String annotation : getAnnotations(script)) {
result = result.replace("\n" + annotation, StringUtils.EMPTY);
result = result.replace(annotation, StringUtils.EMPTY);
}
for (final Class<?> aClass : getAnnotationClasses()) {
if (result.contains(aClass.getPackage().getName()) &&
result.contains(aClass.getSimpleName())) {
result = stripAnnotation(result, aClass.getSimpleName());
result = stripAnnotation(result, aClass.getCanonicalName());
result = result.replaceAll("import\\s*" + aClass.getCanonicalName() + "\\s*[;]?\n", "");
}
result = result.replaceAll("import" + REGEX_WHITESPACE + aClass.getCanonicalName() + REGEX_WHITESPACE + "[;]?\n", StringUtils.EMPTY);
}
if (keepSpaces) {
int scriptClassStartLine = getClassStartLineNr(script);
int strippedClassStartLine = getClassStartLineNr(result);
String addition = StringUtils.repeat(NEWLINE, scriptClassStartLine - strippedClassStartLine);
result = result.replaceFirst("\nclass ", addition + "\nclass ");
} else {
result = result.replaceAll("(\n){3,}", "\n\n");
}
return result;
}
Expand All @@ -99,13 +123,6 @@ private static int getClassStartLineNr(final String script) {
return lineNr;
}

private static String stripAnnotation(final String script, final String className) {
final String regex = getAnnotationRegex(className);
String s = script.replaceAll(regex, StringUtils.EMPTY);
s = s.replaceAll("(\n){3,}", "\n\n");
return s;
}

public static String getAnnotation(final String script, final String className) {
final String regex = getAnnotationRegex(className);
Matcher matcher = Pattern.compile(regex).matcher(script);
Expand All @@ -117,7 +134,7 @@ private static String getAnnotationRegex(final String className) {
return annotationName + ANNOTATION_PAYLOAD;
}

public static String getAnnotation(final String script, final Class clazz) {
public static String getAnnotation(final String script, final Class<?> clazz) {
String simple = getAnnotation(script, clazz.getSimpleName());

return StringUtils.isNotBlank(simple) ?
Expand All @@ -141,7 +158,7 @@ public static List<File> getGroovyFiles(final File dir) {
final List<File> allFiles = new ArrayList<>();
if (groovyFiles != null) {
allFiles.addAll(Arrays.asList(groovyFiles));
Collections.sort(allFiles, Comparator.comparing(File::getName));
allFiles.sort(Comparator.comparing(File::getName));
}
if (directories != null) {
Arrays.stream(directories)
Expand Down

This file was deleted.

Loading
Loading