Skip to content

Commit 1af27f4

Browse files
authored
Merge branch 'xwiki:master' into XWIKI-19383
2 parents b7580ae + 91030e5 commit 1af27f4

File tree

126 files changed

+1905
-327
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

126 files changed

+1905
-327
lines changed

.github/pull_request_template.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Jira URL
2+
3+
<!-- Add the link to the corresponding JIRA issue referenced in a commit message. Unless this is a [Misc] commit,
4+
see https://dev.xwiki.org/xwiki/bin/view/Community/DevelopmentPractices#HRule:Don27tcreateunnecessaryissues
5+
-->
6+
7+
# Changes
8+
9+
## Description
10+
11+
<!-- Describe the main changes brought in this PR. -->
12+
13+
*
14+
15+
## Clarifications
16+
17+
<!-- Provide extra hints to make it easier to understand the PR. Those could be:
18+
* Explanation of choices made in this PR
19+
* Anchor towards extra resources needed to understand the context of this PR (e.g., a forum proposal).
20+
* Links to other issues this issue depends on
21+
-->
22+
23+
*
24+
25+
# Screenshots & Video
26+
27+
<!-- If this PR introduces any UI change, it's recommended to highlight it with before/after screenshots
28+
or even a screen recording for complex interactions.
29+
-->
30+
31+
# Executed Tests
32+
33+
<!-- Especially important for regression fixes.
34+
Indicate how changes were tested (e.g., what maven commands were run to validate them).
35+
-->
36+
37+
# Expected merging strategy
38+
39+
* Prefers squash: Yes <!-- No — Explain why. -->
40+
* Backport on branches:
41+
*

.github/renovate.json5

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*
2+
* See the NOTICE file distributed with this work for additional
3+
* information regarding copyright ownership.
4+
*
5+
* This is free software; you can redistribute it and/or modify it
6+
* under the terms of the GNU Lesser General Public License as
7+
* published by the Free Software Foundation; either version 2.1 of
8+
* the License, or (at your option) any later version.
9+
*
10+
* This software is distributed in the hope that it will be useful,
11+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13+
* Lesser General Public License for more details.
14+
*
15+
* You should have received a copy of the GNU Lesser General Public
16+
* License along with this software; if not, write to the Free
17+
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18+
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
19+
*/
20+
{
21+
// We want all suggestions right away
22+
"prHourlyLimit" : 0,
23+
"prConcurrentLimit" : 0,
24+
25+
// Create different pull request for each major upgrade
26+
"separateMajorMinor": true,
27+
"separateMultipleMajor": true,
28+
29+
// There is no point trying to find update for commons and rendering dependencies
30+
"packageRules": [
31+
{
32+
"matchPackagePrefixes": ["org.xwiki.commons:", "org.xwiki.rendering:"],
33+
"enabled": false
34+
}
35+
]
36+
}

.mvn/gradle-enterprise.xml renamed to .mvn/develocity.xml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@
2020
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
2121
-->
2222

23-
<gradleEnterprise
24-
xmlns="https://www.gradle.com/gradle-enterprise-maven" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
25-
xsi:schemaLocation="https://www.gradle.com/gradle-enterprise-maven https://www.gradle.com/schema/gradle-enterprise-maven.xsd">
23+
<develocity
24+
xmlns="https://www.gradle.com/develocity-maven" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
25+
xsi:schemaLocation="https://www.gradle.com/develocity-maven https://www.gradle.com/schema/develocity-maven.xsd">
2626
<server>
2727
<url>https://ge.xwiki.org</url>
2828
</server>
@@ -31,11 +31,11 @@
3131
<!-- Always publish build scans on CI but on demand for devs so that we don't get false positives on ge.xwiki.org
3232
due to local changes from users and so that it doesn't pollute the ge.xwiki.org data.
3333
To force publishing a build scan: -Dscan -->
34-
<publish>#{env['CI'] == null ? 'ON_DEMAND' : 'ALWAYS'}</publish>
34+
<publish><![CDATA[env['CI'] == null ? 'ON_DEMAND' : 'ALWAYS']]</publish>
3535
<captureGoalInputFiles>true</captureGoalInputFiles>
3636
<!-- Use background scans only locally to avoid potential issues on CI (the ephemeral docker agent could terminate
3737
as soon as the build is finished and thus the upload may be terminated before it completes) -->
38-
<backgroundBuildScanUpload>#{env['CI'] == null}</backgroundBuildScanUpload>
38+
<backgroundBuildScanUpload><![CDATA[env['CI'] == null]]</backgroundBuildScanUpload>
3939
</buildScan>
4040
<buildCache>
4141
<!-- Notes:
@@ -44,15 +44,15 @@
4444
more to save the goal outputs since they're not going to be re-used.
4545
-->
4646
<local>
47-
<enabled>#{env['CI'] == null}</enabled>
47+
<enabled><![CDATA[env['CI'] == null]]</enabled>
4848
</local>
4949
<remote>
5050
<!-- Notes:
5151
* To disable the remote build cache on the command line, pass: -Dgradle.cache.remote.enabled=false
5252
-->
5353
<enabled>true</enabled>
5454
<!-- Only CI jobs are allowed to store build outputs in the remote cache -->
55-
<storeEnabled>#{env['CI'] != null}</storeEnabled>
55+
<storeEnabled><![CDATA[isTrue(env['CI']) and isTrue(env['GRADLE_ENTERPRISE_ACCESS_KEY'])]]</storeEnabled>
5656
<server>
5757
<!-- Note: Remote cache authentication is handled in the Maven settings.xml file. The id below is the one
5858
found in settings.xml -->
@@ -63,4 +63,4 @@
6363
</server>
6464
</remote>
6565
</buildCache>
66-
</gradleEnterprise>
66+
</develocity>

.mvn/extensions.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@
2323
<extensions>
2424
<extension>
2525
<groupId>com.gradle</groupId>
26-
<artifactId>gradle-enterprise-maven-extension</artifactId>
27-
<version>1.18.1</version>
26+
<artifactId>develocity-maven-extension</artifactId>
27+
<version>1.21</version>
2828
</extension>
2929
<extension>
3030
<groupId>com.gradle</groupId>
3131
<artifactId>common-custom-user-data-maven-extension</artifactId>
32-
<version>1.12.2</version>
32+
<version>1.13</version>
3333
</extension>
3434
</extensions>

Jenkinsfile

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,7 @@ stage ('Rendering Builds') {
5353
node {
5454
// Run the quality checks.
5555
// Sonar notes:
56-
// - we need sonar:sonar to perform the analysis
57-
// - we need sonar = true to push the analysis to Sonarcloud
56+
// - we need sonar:sonar to perform the analysis and push the results to Sonarcloud
5857
// - we need jacoco:report to execute jacoco and compute test coverage
5958
// - we need -Pcoverage and -Dxwiki.jacoco.itDestFile to tell Jacoco to compute a single global Jacoco
6059
// coverage for the full reactor (so that the coverage percentage computed takes into account module tests
@@ -63,8 +62,7 @@ stage ('Rendering Builds') {
6362
name: 'Quality',
6463
goals: 'clean install jacoco:report sonar:sonar',
6564
profiles: 'repository-snapshots,quality,legacy,coverage',
66-
properties: '-Dxwiki.jacoco.itDestFile=`pwd`/target/jacoco-it.exec',
67-
sonar: true
65+
properties: '-Dxwiki.jacoco.itDestFile=`pwd`/target/jacoco-it.exec'
6866
)
6967
}
7068
},

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Read our [Release Notes](http://www.xwiki.org/xwiki/bin/view/ReleaseNotes/).
1919
* [Continuous Integration](http://ci.xwiki.org/) setup launches a build for each commit
2020
* [Issue Tracker](http://jira.xwiki.org/browse/XRENDERING) if you want to report an issue
2121
* [Development Flow](http://dev.xwiki.org/xwiki/bin/view/Community/DevelopmentPractices#HGeneralDevelopmentFlow) to see the full list of tools we use to build XWiki
22-
* [![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)
22+
* [![Revved up by Develocity](https://img.shields.io/badge/Revved%20up%20by-Develocity-06A0CE?logo=Gradle&labelColor=02303A)](https://ge.xwiki.org/scans)
2323

2424
## Community
2525
We're always looking for contributors!

pom.xml

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,15 @@
2323
<parent>
2424
<groupId>org.xwiki.commons</groupId>
2525
<artifactId>xwiki-commons-pom</artifactId>
26-
<version>15.7-SNAPSHOT</version>
26+
<version>16.3.0-SNAPSHOT</version>
2727
<!-- Note: Do not modify the <relativePath> tag here as this can cause issues. See the pom.xml for xwiki-platform
2828
for more details. By using an empty value we force Maven to resolve the parent from the Maven repositories,
2929
see http://maven.apache.org/ref/3.2.3/maven-model/maven.html#class_parent -->
3030
<relativePath/>
3131
</parent>
3232
<groupId>org.xwiki.rendering</groupId>
3333
<artifactId>xwiki-rendering</artifactId>
34-
<version>15.7-SNAPSHOT</version>
34+
<version>16.3.0-SNAPSHOT</version>
3535
<name>XWiki Rendering - Parent POM</name>
3636
<packaging>pom</packaging>
3737
<description>XWiki Rendering - Parent POM</description>
@@ -275,7 +275,6 @@
275275
</differences>
276276
</revapi.differences>
277277
-->
278-
279278

280279
</analysisConfiguration>
281280
</configuration>
@@ -288,8 +287,6 @@
288287
<id>standalone</id>
289288
<activation>
290289
<property>
291-
<!-- This property is automatically defined by the Maven release plugin when executing
292-
a release. Thus this profile will be automatically enabled when releasing -->
293290
<name>performRelease</name>
294291
<value>true</value>
295292
</property>
@@ -321,8 +318,8 @@
321318
<pluginRepositories>
322319
<pluginRepository>
323320
<id>xwiki-snapshots</id>
324-
<name>XWiki Nexus Plugin Snapshot Repository Proxy</name>
325-
<url>https://nexus.xwiki.org/nexus/content/groups/public-snapshots</url>
321+
<name>XWiki Nexus Plugin Snapshot Repository</name>
322+
<url>https://nexus-snapshots.xwiki.org/repository/snapshots</url>
326323
<releases>
327324
<enabled>false</enabled>
328325
</releases>
@@ -345,8 +342,8 @@
345342
<repositories>
346343
<repository>
347344
<id>xwiki-snapshots</id>
348-
<name>XWiki Nexus Snapshot Repository Proxy</name>
349-
<url>https://nexus.xwiki.org/nexus/content/groups/public-snapshots</url>
345+
<name>XWiki Nexus Snapshot Repository</name>
346+
<url>https://nexus-snapshots.xwiki.org/repository/snapshots</url>
350347
<releases>
351348
<enabled>false</enabled>
352349
</releases>

xwiki-rendering-api/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,14 @@
2525
<parent>
2626
<groupId>org.xwiki.rendering</groupId>
2727
<artifactId>xwiki-rendering</artifactId>
28-
<version>15.7-SNAPSHOT</version>
28+
<version>16.3.0-SNAPSHOT</version>
2929
</parent>
3030
<artifactId>xwiki-rendering-api</artifactId>
3131
<name>XWiki Rendering - Api</name>
3232
<packaging>jar</packaging>
3333
<description>XWiki Rendering - Api</description>
3434
<properties>
35-
<xwiki.jacoco.instructionRatio>0.63</xwiki.jacoco.instructionRatio>
35+
<xwiki.jacoco.instructionRatio>0.62</xwiki.jacoco.instructionRatio>
3636
<!-- Skipping revapi since xwiki-rendering-legacy-api wraps this module and runs checks on it -->
3737
<xwiki.revapi.skip>true</xwiki.revapi.skip>
3838
</properties>

xwiki-rendering-api/src/main/java/org/xwiki/rendering/block/AbstractBlock.java

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,20 @@
2525
import java.util.LinkedHashMap;
2626
import java.util.List;
2727
import java.util.Map;
28+
import java.util.Optional;
29+
import java.util.function.Function;
2830

31+
import org.apache.commons.lang3.ObjectUtils;
2932
import org.apache.commons.lang3.builder.EqualsBuilder;
3033
import org.apache.commons.lang3.builder.HashCodeBuilder;
3134
import org.xwiki.rendering.block.match.BlockMatcher;
3235
import org.xwiki.rendering.block.match.BlockNavigator;
3336
import org.xwiki.rendering.block.match.CounterBlockMatcher;
37+
import org.xwiki.rendering.block.match.FunctionBlockMatcher;
38+
import org.xwiki.rendering.block.match.MetadataBlockMatcher;
3439
import org.xwiki.rendering.listener.Listener;
40+
import org.xwiki.rendering.listener.MetaData;
41+
import org.xwiki.rendering.syntax.Syntax;
3542

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

57+
/**
58+
* Store attributes, see {@link #getAttribute(String)} for more explanations what attributes are.
59+
*/
60+
private Map<String, Object> attributes;
61+
5062
/**
5163
* The Blocks this Block contains.
5264
*/
@@ -399,6 +411,40 @@ public void setParameters(Map<String, String> parameters)
399411
}
400412
}
401413

414+
@Override
415+
public Map<String, Object> getAttributes()
416+
{
417+
return this.attributes == null ? Collections.emptyMap()
418+
: Collections.unmodifiableMap(this.attributes);
419+
}
420+
421+
@Override
422+
public Object getAttribute(String name)
423+
{
424+
return this.attributes == null ? null : this.attributes.get(name);
425+
}
426+
427+
@Override
428+
public void setAttribute(String name, Object value)
429+
{
430+
if (this.attributes == null) {
431+
this.attributes = new LinkedHashMap<>(1);
432+
}
433+
434+
this.attributes.put(name, value);
435+
}
436+
437+
@Override
438+
public void setAttributes(Map<String, Object> attributes)
439+
{
440+
if (this.attributes == null) {
441+
this.attributes = new LinkedHashMap<>(attributes);
442+
} else {
443+
this.attributes.clear();
444+
this.attributes.putAll(attributes);
445+
}
446+
}
447+
402448
@Override
403449
public void setParent(Block parentBlock)
404450
{
@@ -467,6 +513,7 @@ public boolean equals(Object obj)
467513

468514
builder.append(getChildren(), ((Block) obj).getChildren());
469515
builder.append(getParameters(), ((Block) obj).getParameters());
516+
builder.append(getAttributes(), ((Block) obj).getAttributes());
470517

471518
return builder.isEquals();
472519
}
@@ -481,6 +528,7 @@ public int hashCode()
481528

482529
builder.append(this.childrenBlocks);
483530
builder.append(this.parameters);
531+
builder.append(this.attributes);
484532

485533
return builder.toHashCode();
486534
}
@@ -511,6 +559,9 @@ public Block clone(BlockFilter blockFilter)
511559
((AbstractBlock) block).parameters = new LinkedHashMap<>(this.parameters);
512560
}
513561

562+
// Clone attribute values if possible as documented in getAttribute().
563+
this.getAttributes().forEach((key, value) -> block.setAttribute(key, ObjectUtils.cloneIfPossible(value)));
564+
514565
if (this.childrenBlocks != null) {
515566
((AbstractBlock) block).childrenBlocks = new ArrayList<>(this.childrenBlocks.size());
516567
for (Block childBlock : this.childrenBlocks) {
@@ -584,4 +635,26 @@ public <T extends Block> T getFirstBlock(BlockMatcher matcher, Axes axes)
584635

585636
return navigator.getFirstBlock(this, axes);
586637
}
638+
639+
@Override
640+
public Optional<Syntax> getSyntaxMetadata()
641+
{
642+
MetaDataBlock metaDataBlock = getFirstBlock(MetadataBlockMatcher.SYNTAX, Axes.ANCESTOR_OR_SELF);
643+
644+
if (metaDataBlock != null) {
645+
return Optional.ofNullable((Syntax) metaDataBlock.getMetaData().getMetaData(MetaData.SYNTAX));
646+
}
647+
648+
return Optional.empty();
649+
}
650+
651+
@Override
652+
public <T> Optional<T> get(Function<Block, Optional<T>> searcher, Axes axes)
653+
{
654+
FunctionBlockMatcher<T> matcher = new FunctionBlockMatcher<>(searcher);
655+
656+
getFirstBlock(matcher, Axes.ANCESTOR_OR_SELF);
657+
658+
return matcher.getValue();
659+
}
587660
}

0 commit comments

Comments
 (0)