Skip to content

Commit

Permalink
Merge branch 'xwiki:master' into XWIKI-19383
Browse files Browse the repository at this point in the history
  • Loading branch information
Sereza7 authored Apr 5, 2024
2 parents b7580ae + 91030e5 commit 1af27f4
Show file tree
Hide file tree
Showing 126 changed files with 1,905 additions and 327 deletions.
41 changes: 41 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Jira URL

<!-- Add the link to the corresponding JIRA issue referenced in a commit message. Unless this is a [Misc] commit,
see https://dev.xwiki.org/xwiki/bin/view/Community/DevelopmentPractices#HRule:Don27tcreateunnecessaryissues
-->

# Changes

## Description

<!-- Describe the main changes brought in this PR. -->

*

## Clarifications

<!-- Provide extra hints to make it easier to understand the PR. Those could be:
* Explanation of choices made in this PR
* Anchor towards extra resources needed to understand the context of this PR (e.g., a forum proposal).
* Links to other issues this issue depends on
-->

*

# Screenshots & Video

<!-- If this PR introduces any UI change, it's recommended to highlight it with before/after screenshots
or even a screen recording for complex interactions.
-->

# Executed Tests

<!-- Especially important for regression fixes.
Indicate how changes were tested (e.g., what maven commands were run to validate them).
-->

# Expected merging strategy

* Prefers squash: Yes <!-- No — Explain why. -->
* Backport on branches:
*
36 changes: 36 additions & 0 deletions .github/renovate.json5
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* See the NOTICE file distributed with this work for additional
* information regarding copyright ownership.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
{
// We want all suggestions right away
"prHourlyLimit" : 0,
"prConcurrentLimit" : 0,

// Create different pull request for each major upgrade
"separateMajorMinor": true,
"separateMultipleMajor": true,

// There is no point trying to find update for commons and rendering dependencies
"packageRules": [
{
"matchPackagePrefixes": ["org.xwiki.commons:", "org.xwiki.rendering:"],
"enabled": false
}
]
}
16 changes: 8 additions & 8 deletions .mvn/gradle-enterprise.xml → .mvn/develocity.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-->

<gradleEnterprise
xmlns="https://www.gradle.com/gradle-enterprise-maven" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://www.gradle.com/gradle-enterprise-maven https://www.gradle.com/schema/gradle-enterprise-maven.xsd">
<develocity
xmlns="https://www.gradle.com/develocity-maven" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://www.gradle.com/develocity-maven https://www.gradle.com/schema/develocity-maven.xsd">
<server>
<url>https://ge.xwiki.org</url>
</server>
Expand All @@ -31,11 +31,11 @@
<!-- Always publish build scans on CI but on demand for devs so that we don't get false positives on ge.xwiki.org
due to local changes from users and so that it doesn't pollute the ge.xwiki.org data.
To force publishing a build scan: -Dscan -->
<publish>#{env['CI'] == null ? 'ON_DEMAND' : 'ALWAYS'}</publish>
<publish><![CDATA[env['CI'] == null ? 'ON_DEMAND' : 'ALWAYS']]</publish>
<captureGoalInputFiles>true</captureGoalInputFiles>
<!-- Use background scans only locally to avoid potential issues on CI (the ephemeral docker agent could terminate
as soon as the build is finished and thus the upload may be terminated before it completes) -->
<backgroundBuildScanUpload>#{env['CI'] == null}</backgroundBuildScanUpload>
<backgroundBuildScanUpload><![CDATA[env['CI'] == null]]</backgroundBuildScanUpload>
</buildScan>
<buildCache>
<!-- Notes:
Expand All @@ -44,15 +44,15 @@
more to save the goal outputs since they're not going to be re-used.
-->
<local>
<enabled>#{env['CI'] == null}</enabled>
<enabled><![CDATA[env['CI'] == null]]</enabled>
</local>
<remote>
<!-- Notes:
* To disable the remote build cache on the command line, pass: -Dgradle.cache.remote.enabled=false
-->
<enabled>true</enabled>
<!-- Only CI jobs are allowed to store build outputs in the remote cache -->
<storeEnabled>#{env['CI'] != null}</storeEnabled>
<storeEnabled><![CDATA[isTrue(env['CI']) and isTrue(env['GRADLE_ENTERPRISE_ACCESS_KEY'])]]</storeEnabled>
<server>
<!-- Note: Remote cache authentication is handled in the Maven settings.xml file. The id below is the one
found in settings.xml -->
Expand All @@ -63,4 +63,4 @@
</server>
</remote>
</buildCache>
</gradleEnterprise>
</develocity>
6 changes: 3 additions & 3 deletions .mvn/extensions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@
<extensions>
<extension>
<groupId>com.gradle</groupId>
<artifactId>gradle-enterprise-maven-extension</artifactId>
<version>1.18.1</version>
<artifactId>develocity-maven-extension</artifactId>
<version>1.21</version>
</extension>
<extension>
<groupId>com.gradle</groupId>
<artifactId>common-custom-user-data-maven-extension</artifactId>
<version>1.12.2</version>
<version>1.13</version>
</extension>
</extensions>
6 changes: 2 additions & 4 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,7 @@ stage ('Rendering Builds') {
node {
// Run the quality checks.
// Sonar notes:
// - we need sonar:sonar to perform the analysis
// - we need sonar = true to push the analysis to Sonarcloud
// - we need sonar:sonar to perform the analysis and push the results to Sonarcloud
// - we need jacoco:report to execute jacoco and compute test coverage
// - we need -Pcoverage and -Dxwiki.jacoco.itDestFile to tell Jacoco to compute a single global Jacoco
// coverage for the full reactor (so that the coverage percentage computed takes into account module tests
Expand All @@ -63,8 +62,7 @@ stage ('Rendering Builds') {
name: 'Quality',
goals: 'clean install jacoco:report sonar:sonar',
profiles: 'repository-snapshots,quality,legacy,coverage',
properties: '-Dxwiki.jacoco.itDestFile=`pwd`/target/jacoco-it.exec',
sonar: true
properties: '-Dxwiki.jacoco.itDestFile=`pwd`/target/jacoco-it.exec'
)
}
},
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Read our [Release Notes](http://www.xwiki.org/xwiki/bin/view/ReleaseNotes/).
* [Continuous Integration](http://ci.xwiki.org/) setup launches a build for each commit
* [Issue Tracker](http://jira.xwiki.org/browse/XRENDERING) if you want to report an issue
* [Development Flow](http://dev.xwiki.org/xwiki/bin/view/Community/DevelopmentPractices#HGeneralDevelopmentFlow) to see the full list of tools we use to build XWiki
* [![Revved up by Gradle Enterprise](https://img.shields.io/badge/Revved%20up%20by-Gradle%20Enterprise-06A0CE?logo=Gradle&labelColor=02303A)](https://ge.xwiki.org/scans)
* [![Revved up by Develocity](https://img.shields.io/badge/Revved%20up%20by-Develocity-06A0CE?logo=Gradle&labelColor=02303A)](https://ge.xwiki.org/scans)

## Community
We're always looking for contributors!
Expand Down
15 changes: 6 additions & 9 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@
<parent>
<groupId>org.xwiki.commons</groupId>
<artifactId>xwiki-commons-pom</artifactId>
<version>15.7-SNAPSHOT</version>
<version>16.3.0-SNAPSHOT</version>
<!-- Note: Do not modify the <relativePath> tag here as this can cause issues. See the pom.xml for xwiki-platform
for more details. By using an empty value we force Maven to resolve the parent from the Maven repositories,
see http://maven.apache.org/ref/3.2.3/maven-model/maven.html#class_parent -->
<relativePath/>
</parent>
<groupId>org.xwiki.rendering</groupId>
<artifactId>xwiki-rendering</artifactId>
<version>15.7-SNAPSHOT</version>
<version>16.3.0-SNAPSHOT</version>
<name>XWiki Rendering - Parent POM</name>
<packaging>pom</packaging>
<description>XWiki Rendering - Parent POM</description>
Expand Down Expand Up @@ -275,7 +275,6 @@
</differences>
</revapi.differences>
-->


</analysisConfiguration>
</configuration>
Expand All @@ -288,8 +287,6 @@
<id>standalone</id>
<activation>
<property>
<!-- This property is automatically defined by the Maven release plugin when executing
a release. Thus this profile will be automatically enabled when releasing -->
<name>performRelease</name>
<value>true</value>
</property>
Expand Down Expand Up @@ -321,8 +318,8 @@
<pluginRepositories>
<pluginRepository>
<id>xwiki-snapshots</id>
<name>XWiki Nexus Plugin Snapshot Repository Proxy</name>
<url>https://nexus.xwiki.org/nexus/content/groups/public-snapshots</url>
<name>XWiki Nexus Plugin Snapshot Repository</name>
<url>https://nexus-snapshots.xwiki.org/repository/snapshots</url>
<releases>
<enabled>false</enabled>
</releases>
Expand All @@ -345,8 +342,8 @@
<repositories>
<repository>
<id>xwiki-snapshots</id>
<name>XWiki Nexus Snapshot Repository Proxy</name>
<url>https://nexus.xwiki.org/nexus/content/groups/public-snapshots</url>
<name>XWiki Nexus Snapshot Repository</name>
<url>https://nexus-snapshots.xwiki.org/repository/snapshots</url>
<releases>
<enabled>false</enabled>
</releases>
Expand Down
4 changes: 2 additions & 2 deletions xwiki-rendering-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@
<parent>
<groupId>org.xwiki.rendering</groupId>
<artifactId>xwiki-rendering</artifactId>
<version>15.7-SNAPSHOT</version>
<version>16.3.0-SNAPSHOT</version>
</parent>
<artifactId>xwiki-rendering-api</artifactId>
<name>XWiki Rendering - Api</name>
<packaging>jar</packaging>
<description>XWiki Rendering - Api</description>
<properties>
<xwiki.jacoco.instructionRatio>0.63</xwiki.jacoco.instructionRatio>
<xwiki.jacoco.instructionRatio>0.62</xwiki.jacoco.instructionRatio>
<!-- Skipping revapi since xwiki-rendering-legacy-api wraps this module and runs checks on it -->
<xwiki.revapi.skip>true</xwiki.revapi.skip>
</properties>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,20 @@
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.function.Function;

import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.xwiki.rendering.block.match.BlockMatcher;
import org.xwiki.rendering.block.match.BlockNavigator;
import org.xwiki.rendering.block.match.CounterBlockMatcher;
import org.xwiki.rendering.block.match.FunctionBlockMatcher;
import org.xwiki.rendering.block.match.MetadataBlockMatcher;
import org.xwiki.rendering.listener.Listener;
import org.xwiki.rendering.listener.MetaData;
import org.xwiki.rendering.syntax.Syntax;

/**
* Implementation for Block operations. All blocks should extend this class. Supports the notion of generic parameters
Expand All @@ -47,6 +54,11 @@ public abstract class AbstractBlock implements Block
*/
private Map<String, String> parameters;

/**
* Store attributes, see {@link #getAttribute(String)} for more explanations what attributes are.
*/
private Map<String, Object> attributes;

/**
* The Blocks this Block contains.
*/
Expand Down Expand Up @@ -399,6 +411,40 @@ public void setParameters(Map<String, String> parameters)
}
}

@Override
public Map<String, Object> getAttributes()
{
return this.attributes == null ? Collections.emptyMap()
: Collections.unmodifiableMap(this.attributes);
}

@Override
public Object getAttribute(String name)
{
return this.attributes == null ? null : this.attributes.get(name);
}

@Override
public void setAttribute(String name, Object value)
{
if (this.attributes == null) {
this.attributes = new LinkedHashMap<>(1);
}

this.attributes.put(name, value);
}

@Override
public void setAttributes(Map<String, Object> attributes)
{
if (this.attributes == null) {
this.attributes = new LinkedHashMap<>(attributes);
} else {
this.attributes.clear();
this.attributes.putAll(attributes);
}
}

@Override
public void setParent(Block parentBlock)
{
Expand Down Expand Up @@ -467,6 +513,7 @@ public boolean equals(Object obj)

builder.append(getChildren(), ((Block) obj).getChildren());
builder.append(getParameters(), ((Block) obj).getParameters());
builder.append(getAttributes(), ((Block) obj).getAttributes());

return builder.isEquals();
}
Expand All @@ -481,6 +528,7 @@ public int hashCode()

builder.append(this.childrenBlocks);
builder.append(this.parameters);
builder.append(this.attributes);

return builder.toHashCode();
}
Expand Down Expand Up @@ -511,6 +559,9 @@ public Block clone(BlockFilter blockFilter)
((AbstractBlock) block).parameters = new LinkedHashMap<>(this.parameters);
}

// Clone attribute values if possible as documented in getAttribute().
this.getAttributes().forEach((key, value) -> block.setAttribute(key, ObjectUtils.cloneIfPossible(value)));

if (this.childrenBlocks != null) {
((AbstractBlock) block).childrenBlocks = new ArrayList<>(this.childrenBlocks.size());
for (Block childBlock : this.childrenBlocks) {
Expand Down Expand Up @@ -584,4 +635,26 @@ public <T extends Block> T getFirstBlock(BlockMatcher matcher, Axes axes)

return navigator.getFirstBlock(this, axes);
}

@Override
public Optional<Syntax> getSyntaxMetadata()
{
MetaDataBlock metaDataBlock = getFirstBlock(MetadataBlockMatcher.SYNTAX, Axes.ANCESTOR_OR_SELF);

if (metaDataBlock != null) {
return Optional.ofNullable((Syntax) metaDataBlock.getMetaData().getMetaData(MetaData.SYNTAX));
}

return Optional.empty();
}

@Override
public <T> Optional<T> get(Function<Block, Optional<T>> searcher, Axes axes)
{
FunctionBlockMatcher<T> matcher = new FunctionBlockMatcher<>(searcher);

getFirstBlock(matcher, Axes.ANCESTOR_OR_SELF);

return matcher.getValue();
}
}
Loading

0 comments on commit 1af27f4

Please sign in to comment.