Skip to content

Commit da6c145

Browse files
committed
Upgrade to XP8 #378
1 parent 30a5896 commit da6c145

File tree

12 files changed

+80
-45
lines changed

12 files changed

+80
-45
lines changed

build.gradle

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,31 +2,29 @@ plugins {
22
id 'java'
33
id 'jacoco'
44
id 'maven-publish'
5-
id 'com.enonic.defaults' version '2.1.6'
6-
id 'com.enonic.xp.base' version '3.6.2'
7-
id 'com.github.node-gradle.node' version '7.1.0'
5+
alias( libs.plugins.enonic.defaults )
6+
alias( libs.plugins.enonic.xp.base )
7+
alias( libs.plugins.node.gradle )
88
}
99

1010
java {
11-
sourceCompatibility = JavaVersion.VERSION_11
12-
targetCompatibility = sourceCompatibility
11+
toolchain {
12+
languageVersion = JavaLanguageVersion.of(21)
13+
}
1314
}
1415

15-
1616
dependencies {
17-
// compileOnly: This is used for dependencies that are only needed during
18-
// compilation. The library itself is not included in the final application
19-
// build.
2017
compileOnly "com.enonic.xp:core-api:${xpVersion}"
2118
compileOnly "com.enonic.xp:portal-api:${xpVersion}"
2219
compileOnly "com.enonic.xp:script-api:${xpVersion}"
2320
compileOnly "com.enonic.xp:admin-api:${xpVersion}"
2421

25-
implementation 'com.enonic.lib:lib-router:3.2.0'
22+
implementation libs.lib.router
2623

27-
testImplementation 'org.mockito:mockito-core:5.18.0'
28-
testImplementation 'org.mockito:mockito-junit-jupiter:5.18.0'
29-
testImplementation 'org.junit.jupiter:junit-jupiter:5.11.4'
24+
testImplementation platform( libs.mockito.core )
25+
testImplementation libs.junit.jupiter
26+
testImplementation libs.mockito.jupiter
27+
testRuntimeOnly libs.junit.launcher
3028
testImplementation "com.enonic.xp:testing:${xpVersion}"
3129
testImplementation "com.enonic.xp:admin-api:${xpVersion}"
3230
}
@@ -38,6 +36,7 @@ processResources {
3836
}
3937

4038
repositories {
39+
mavenLocal()
4140
mavenCentral()
4241
xp.enonicRepo('dev')
4342
}
@@ -49,8 +48,6 @@ jacocoTestReport {
4948
}
5049
}
5150

52-
check.dependsOn jacocoTestReport
53-
5451
test {
5552
useJUnitPlatform()
5653
}
@@ -67,7 +64,7 @@ node {
6764
version = '20.14.0'
6865
}
6966

70-
tasks.withType(Copy) {
67+
tasks.withType( Copy ).configureEach {
7168
includeEmptyDirs = false
7269
}
7370

@@ -87,8 +84,6 @@ tasks.register('npmBuild', NpmTask) {
8784
inputs.dir 'src/main/resources'
8885
outputs.dir 'build/resources/main'
8986
}
90-
jar.dependsOn npmBuild
91-
compileTestJava.dependsOn npmBuild
9287

9388
tasks.register('npmCheck', NpmTask) {
9489
dependsOn npmInstall
@@ -101,8 +96,6 @@ tasks.register('npmCheck', NpmTask) {
10196
]
10297
}
10398

104-
check.dependsOn npmCheck
105-
10699
tasks.register('npmTest', NpmTask) {
107100
args = [
108101
'run',
@@ -115,7 +108,6 @@ tasks.register('npmTest', NpmTask) {
115108
inputs.dir 'src/bun'
116109
outputs.dir 'coverage'
117110
}
118-
test.dependsOn npmTest
119111

120112
tasks.register('publishToNpm', NpmTask ) {
121113
onlyIf { !version.endsWith( '-SNAPSHOT' ) }
@@ -124,4 +116,8 @@ tasks.register('publishToNpm', NpmTask ) {
124116
workingDir = file('build/types')
125117
}
126118

119+
jar.dependsOn npmBuild
120+
compileTestJava.dependsOn npmBuild
121+
test.dependsOn npmTest
122+
check.dependsOn npmCheck, jacocoTestReport
127123
publish.dependsOn publishToNpm

gradle.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
group = com.enonic.lib
22
projectName = lib-asset
3-
xpVersion = 7.14.0
4-
version = 1.0.4-SNAPSHOT
3+
xpVersion = 8.0.0-SNAPSHOT
4+
version = 2.0.0-SNAPSHOT

gradle/libs.versions.toml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
[versions]
2+
3+
junit = "6.0.0"
4+
mockito = "5.20.0"
5+
enonicDefaults = "2.1.6"
6+
enonicXpGradle = "3.6.2"
7+
nodeGradle = "7.1.0"
8+
9+
[libraries]
10+
11+
junit-jupiter = { module = "org.junit.jupiter:junit-jupiter", version.ref = "junit" }
12+
junit-launcher = { module = "org.junit.platform:junit-platform-launcher" }
13+
mockito-core = { module = "org.mockito:mockito-bom", version.ref = "mockito" }
14+
mockito-jupiter = { module = "org.mockito:mockito-junit-jupiter", version.ref = "mockito" }
15+
16+
lib-router = { module = "com.enonic.lib:lib-router", version = "4.0.0-SNAPSHOT" }
17+
18+
[plugins]
19+
enonic-defaults = { id = "com.enonic.defaults", version.ref = "enonicDefaults" }
20+
enonic-xp-base = { id = "com.enonic.xp.base", version.ref = "enonicXpGradle" }
21+
node-gradle = { id = "com.github.node-gradle.node", version.ref = "nodeGradle" }

gradle/wrapper/gradle-wrapper.jar

130 Bytes
Binary file not shown.

gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.1-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.1-bin.zip
44
networkTimeout=10000
55
validateDistributionUrl=true
66
zipStoreBase=GRADLE_USER_HOME

gradlew

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
# See the License for the specific language governing permissions and
1616
# limitations under the License.
1717
#
18+
# SPDX-License-Identifier: Apache-2.0
19+
#
1820

1921
##############################################################################
2022
#
@@ -55,7 +57,7 @@
5557
# Darwin, MinGW, and NonStop.
5658
#
5759
# (3) This script is generated from the Groovy template
58-
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
60+
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
5961
# within the Gradle project.
6062
#
6163
# You can find Gradle at https://github.com/gradle/gradle/.
@@ -84,7 +86,8 @@ done
8486
# shellcheck disable=SC2034
8587
APP_BASE_NAME=${0##*/}
8688
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
87-
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
89+
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s
90+
' "$PWD" ) || exit
8891

8992
# Use the maximum available, or set MAX_FD != -1 to use that value.
9093
MAX_FD=maximum

gradlew.bat

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
@rem See the License for the specific language governing permissions and
1414
@rem limitations under the License.
1515
@rem
16+
@rem SPDX-License-Identifier: Apache-2.0
17+
@rem
1618

1719
@if "%DEBUG%"=="" @echo off
1820
@rem ##########################################################################

src/main/java/com/enonic/lib/asset/RequestVerifierHandler.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import com.enonic.xp.script.bean.BeanContext;
1616
import com.enonic.xp.script.bean.ScriptBean;
1717
import com.enonic.xp.site.Site;
18+
import com.enonic.xp.site.SiteConfigsDataSerializer;
1819
import com.enonic.xp.web.WebException;
1920

2021
public class RequestVerifierHandler
@@ -90,7 +91,8 @@ private boolean verifyRequestMountedOnSites( final ApplicationKey applicationKey
9091

9192
final Site site = contentResolverResult.getNearestSite();
9293

93-
final boolean isAppInstalledOnSite = site != null && site.getSiteConfigs().get( applicationKey ) != null;
94+
final boolean isAppInstalledOnSite = site != null &&
95+
SiteConfigsDataSerializer.fromData( site.getData().getRoot() ).get( applicationKey ) != null;
9496

9597
if ( !isAppInstalledOnSite )
9698
{

src/main/resources/services/asset/asset.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@ router.get('{path:.*}', (request: Request): Response => {
1010
});
1111

1212
export const all = (request: Request): Response => {
13-
return router.dispatch(request) as Response;
13+
return router.dispatch(request);
1414
}

src/test/java/com/enonic/lib/asset/AssetUrlBuilderTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,10 @@ void testCreateAssetUrlAdminSiteOnProject()
5353
portalRequest.setBranch( Branch.from( "branch" ) );
5454
portalRequest.setBaseUri( "/admin/site/preview" );
5555
portalRequest.setRawPath( "/admin/site/preview/project/branch/" );
56+
portalRequest.setContentPath( ContentPath.ROOT );
5657

5758
runFunction( "lib/assetUrl-test.js", "createAssetUrlAdminSiteOnProject" );
5859

59-
verify( contentService, times( 1 ) ).findNearestSiteByPath( any( ContentPath.class ) );
6060
verify( portalUrlService, times( 1 ) ).generateUrl( any( GenerateUrlParams.class ) );
6161
}
6262

@@ -71,6 +71,7 @@ void testCreateAssetUrlOnSite()
7171
portalRequest.setBranch( Branch.from( "branch" ) );
7272
portalRequest.setBaseUri( "/site" );
7373
portalRequest.setRawPath( "/site/project/branch/mysite" );
74+
portalRequest.setContentPath( ContentPath.from( "/mysite" ) );
7475

7576
runFunction( "lib/assetUrl-test.js", "createAssetUrlOnSite" );
7677

0 commit comments

Comments
 (0)