Skip to content

Commit d426fc7

Browse files
authored
XCOMMONS-3349: Make it easier to create webjar modules using node (#4206)
1 parent eba94d0 commit d426fc7

File tree

139 files changed

+66
-206
lines changed

Some content is hidden

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

139 files changed

+66
-206
lines changed

pom.xml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -123,10 +123,6 @@
123123
<oracle.groupId>com.oracle.database.jdbc</oracle.groupId>
124124
<oracle.artifactId>ojdbc11</oracle.artifactId>
125125
<oracle.version>21.17.0.0</oracle.version>
126-
127-
<!-- Versions of Node related tools -->
128-
<node.version>v22.16.0</node.version>
129-
<npm.version>11.4.1</npm.version>
130126
</properties>
131127
<scm>
132128
<tag>HEAD</tag>
@@ -1199,6 +1195,11 @@
11991195
<artifactId>xwiki-commons-tool-webjar-handlers</artifactId>
12001196
<version>${commons.version}</version>
12011197
</extension>
1198+
<extension>
1199+
<groupId>org.xwiki.commons</groupId>
1200+
<artifactId>xwiki-commons-tool-webjar-node-handlers</artifactId>
1201+
<version>${commons.version}</version>
1202+
</extension>
12021203
<!-- Needed to add support for the "xar" packaging -->
12031204
<extension>
12041205
<groupId>org.xwiki.commons</groupId>
@@ -1701,7 +1702,7 @@
17011702
<!-- Forbid JAR extensions to have XAR runtime dependencies -->
17021703
<bannedDependencyType>
17031704
<dependencyType>xar</dependencyType>
1704-
<projectPackaging>jar|webjar</projectPackaging>
1705+
<projectPackaging>jar|webjar|webjar-node</projectPackaging>
17051706
<!-- Integration test modules are never going to be installed as extension, and they need to depend
17061707
on XAR modules -->
17071708
<projectArtifactId>^((?!-test-docker|.*-test-tests).)*$</projectArtifactId>

xwiki-platform-core/xwiki-platform-extension/xwiki-platform-extension-distribution/src/main/java/org/xwiki/extension/distribution/internal/job/step/AbstractExtensionDistributionStep.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ protected void install(ExtensionId extensionId, String namespace, boolean jarOnR
8080
ScriptExtensionRewriter rewriter = new ScriptExtensionRewriter();
8181
rewriter.installExtensionTypeOnRootNamespace("jar");
8282
rewriter.installExtensionTypeOnRootNamespace("webjar");
83+
rewriter.installExtensionTypeOnRootNamespace("webjar-node");
8384
installRequest.setRewriter(rewriter);
8485
}
8586

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
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+
package org.xwiki.extension.jar.internal.validator;
21+
22+
import javax.inject.Named;
23+
import javax.inject.Singleton;
24+
25+
import org.xwiki.component.annotation.Component;
26+
import org.xwiki.extension.internal.validator.AbstractExtensionValidator;
27+
import org.xwiki.extension.jar.internal.handler.JarExtensionHandler;
28+
import org.xwiki.security.authorization.Right;
29+
30+
/**
31+
* Check rights for webjar extensions.
32+
*
33+
* @version $Id$
34+
* @since 17.5.0RC1
35+
*/
36+
@Component
37+
@Named(JarExtensionHandler.WEBJAR_NODE)
38+
@Singleton
39+
public class WebjarNodeExtensionValidator extends AbstractExtensionValidator
40+
{
41+
42+
/**
43+
* Default constructor.
44+
*/
45+
public WebjarNodeExtensionValidator()
46+
{
47+
this.entityRight = Right.ADMIN;
48+
}
49+
}
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
org.xwiki.extension.jar.internal.validator.JarExtensionValidator
22
org.xwiki.extension.jar.internal.validator.WebjarExtensionValidator
3+
org.xwiki.extension.jar.internal.validator.WebjarNodeExtensionValidator

xwiki-platform-core/xwiki-platform-livedata/xwiki-platform-livedata-webjar/pom.xml

Lines changed: 4 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
<artifactId>xwiki-platform-livedata</artifactId>
2828
<version>17.5.0-SNAPSHOT</version>
2929
</parent>
30-
<packaging>webjar</packaging>
30+
<packaging>webjar-node</packaging>
3131
<artifactId>xwiki-platform-livedata-webjar</artifactId>
3232
<name>XWiki Platform - Live Data - WebJar</name>
3333
<properties>
@@ -84,43 +84,19 @@
8484
<artifactId>maven-resources-plugin</artifactId>
8585
<executions>
8686
<execution>
87-
<!-- We keep the Vue files and the build configuration files in separate folders in the source tree but
88-
we need them in the same folder when building the Vue components. -->
89-
<id>copy-vue-resources</id>
87+
<!-- Copy the remaining less file. Can be removed once XWIKI-23080 is done. -->
88+
<id>copy-less-resources</id>
9089
<phase>validate</phase>
9190
<goals>
9291
<goal>copy-resources</goal>
9392
</goals>
94-
<configuration>
95-
<outputDirectory>${project.build.directory}/vue</outputDirectory>
96-
<resources>
97-
<resource>
98-
<directory>src/main/vue</directory>
99-
<excludes>
100-
<exclude>dist</exclude>
101-
<exclude>node_modules</exclude>
102-
</excludes>
103-
</resource>
104-
</resources>
105-
</configuration>
106-
</execution>
107-
<execution>
108-
<!-- Copy the generated Vue components to the WebJar folder. -->
109-
<id>copy-vue-components</id>
110-
<phase>process-resources</phase>
111-
<goals>
112-
<goal>copy-resources</goal>
113-
</goals>
11493
<configuration>
11594
<outputDirectory>
11695
${project.build.outputDirectory}/META-INF/resources/webjars/${project.artifactId}/${project.version}
11796
</outputDirectory>
11897
<resources>
11998
<resource>
120-
<directory>${project.build.directory}/vue/dist</directory>
121-
</resource>
122-
<resource>
123-
<directory>${project.build.directory}/vue/src/</directory>
99+
<directory>${project.build.directory}/node-src/src/</directory>
124100
<includes>
125101
<include>variables.less</include>
126102
</includes>
@@ -130,74 +106,6 @@
130106
</execution>
131107
</executions>
132108
</plugin>
133-
<!-- Skip jsHint because we use ESLint through the frontend-maven-plugin -->
134-
<plugin>
135-
<groupId>org.xwiki.contrib</groupId>
136-
<artifactId>jshint-maven-plugin</artifactId>
137-
<executions>
138-
<execution>
139-
<id>default-lint</id>
140-
<phase>none</phase>
141-
</execution>
142-
</executions>
143-
</plugin>
144-
<plugin>
145-
<groupId>com.github.eirslett</groupId>
146-
<artifactId>frontend-maven-plugin</artifactId>
147-
<executions>
148-
<execution>
149-
<id>install-node-and-npm</id>
150-
<goals>
151-
<goal>install-node-and-npm</goal>
152-
</goals>
153-
<configuration>
154-
<nodeVersion>${node.version}</nodeVersion>
155-
<npmVersion>${npm.version}</npmVersion>
156-
</configuration>
157-
</execution>
158-
<execution>
159-
<id>npm-install</id>
160-
<goals>
161-
<goal>npm</goal>
162-
</goals>
163-
<configuration>
164-
<arguments>ci</arguments>
165-
</configuration>
166-
</execution>
167-
<execution>
168-
<id>npm-run-lint</id>
169-
<goals>
170-
<goal>npm</goal>
171-
</goals>
172-
<configuration>
173-
<arguments>run lint</arguments>
174-
</configuration>
175-
<phase>test</phase>
176-
</execution>
177-
<execution>
178-
<id>npm-run-test</id>
179-
<goals>
180-
<goal>npm</goal>
181-
</goals>
182-
<configuration>
183-
<arguments>run test:unit</arguments>
184-
</configuration>
185-
<phase>test</phase>
186-
</execution>
187-
<execution>
188-
<id>npm-run-build</id>
189-
<goals>
190-
<goal>npm</goal>
191-
</goals>
192-
<configuration>
193-
<arguments>run build</arguments>
194-
</configuration>
195-
</execution>
196-
</executions>
197-
<configuration>
198-
<workingDirectory>${project.build.directory}/vue</workingDirectory>
199-
</configuration>
200-
</plugin>
201109
</plugins>
202110
</build>
203111
</project>

xwiki-platform-core/xwiki-platform-notifications/xwiki-platform-notifications-webjar/pom.xml

Lines changed: 1 addition & 103 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
<artifactId>xwiki-platform-notifications</artifactId>
2828
<version>17.5.0-SNAPSHOT</version>
2929
</parent>
30-
<packaging>webjar</packaging>
30+
<packaging>webjar-node</packaging>
3131
<artifactId>xwiki-platform-notifications-webjar</artifactId>
3232
<name>XWiki Platform - Notifications - WebJar</name>
3333
<properties>
@@ -61,106 +61,4 @@
6161
<scope>runtime</scope>
6262
</dependency>
6363
</dependencies>
64-
<build>
65-
<plugins>
66-
<plugin>
67-
<artifactId>maven-resources-plugin</artifactId>
68-
<executions>
69-
<execution>
70-
<id>copy-vue-resources</id>
71-
<phase>validate</phase>
72-
<goals>
73-
<goal>copy-resources</goal>
74-
</goals>
75-
<configuration>
76-
<outputDirectory>${project.build.directory}/vue</outputDirectory>
77-
<resources>
78-
<resource>
79-
<directory>src/main/vue</directory>
80-
<excludes>
81-
<exclude>dist</exclude>
82-
<exclude>node_modules</exclude>
83-
</excludes>
84-
</resource>
85-
</resources>
86-
</configuration>
87-
</execution>
88-
<execution>
89-
<!-- Copy the generated Vue components to the WebJar folder. -->
90-
<id>copy-vue-components</id>
91-
<phase>process-resources</phase>
92-
<goals>
93-
<goal>copy-resources</goal>
94-
</goals>
95-
<configuration>
96-
<outputDirectory>${project.build.outputDirectory}/META-INF/resources/webjars/${project.artifactId}/${project.version}</outputDirectory>
97-
<resources>
98-
<resource>
99-
<directory>${project.build.directory}/vue/dist</directory>
100-
</resource>
101-
</resources>
102-
</configuration>
103-
</execution>
104-
</executions>
105-
</plugin>
106-
<!-- Skip jsHint because we use ESLint through the frontend-maven-plugin -->
107-
<plugin>
108-
<groupId>org.xwiki.contrib</groupId>
109-
<artifactId>jshint-maven-plugin</artifactId>
110-
<executions>
111-
<execution>
112-
<id>default-lint</id>
113-
<phase>none</phase>
114-
</execution>
115-
</executions>
116-
</plugin>
117-
<plugin>
118-
<groupId>com.github.eirslett</groupId>
119-
<artifactId>frontend-maven-plugin</artifactId>
120-
<executions>
121-
<execution>
122-
<id>install-node-and-npm</id>
123-
<goals>
124-
<goal>install-node-and-npm</goal>
125-
</goals>
126-
<configuration>
127-
<nodeVersion>${node.version}</nodeVersion>
128-
<npmVersion>${npm.version}</npmVersion>
129-
</configuration>
130-
</execution>
131-
<execution>
132-
<id>npm-install</id>
133-
<goals>
134-
<goal>npm</goal>
135-
</goals>
136-
<configuration>
137-
<arguments>ci</arguments>
138-
</configuration>
139-
</execution>
140-
<execution>
141-
<id>npm-run-build</id>
142-
<goals>
143-
<goal>npm</goal>
144-
</goals>
145-
<configuration>
146-
<arguments>run build</arguments>
147-
</configuration>
148-
</execution>
149-
<execution>
150-
<id>npm-run-lint</id>
151-
<goals>
152-
<goal>npm</goal>
153-
</goals>
154-
<configuration>
155-
<arguments>run lint</arguments>
156-
</configuration>
157-
<phase>test</phase>
158-
</execution>
159-
</executions>
160-
<configuration>
161-
<workingDirectory>${project.build.directory}/vue</workingDirectory>
162-
</configuration>
163-
</plugin>
164-
</plugins>
165-
</build>
16664
</project>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"dev": "vite",
88
"build": "run-p type-check \"build-only {@}\" --",
99
"preview": "vite preview",
10-
"test:unit": "vitest --run",
10+
"test:unit": "vitest --run --passWithNoTests",
1111
"build-only": "vite build",
1212
"type-check": "vue-tsc --build",
1313
"lint": "eslint . --fix",

xwiki-platform-core/xwiki-platform-web/xwiki-platform-web-templates/src/main/resources/templates/extension.vm

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1213,6 +1213,7 @@ $namespace##
12131213
#if ($extensionConfig.installJAROnRoot)
12141214
#set ($discard = $installPlanRequest.rewriter.installExtensionTypeOnRootNamespace('jar'))
12151215
#set ($discard = $installPlanRequest.rewriter.installExtensionTypeOnRootNamespace('webjar'))
1216+
#set ($discard = $installPlanRequest.rewriter.installExtensionTypeOnRootNamespace('webjar-node'))
12161217
#end
12171218
#set ($discard = $extensionManager.createInstallPlan($installPlanRequest))
12181219
#handleExtensionJobStartFailure('extensions.install.error.prepareFailure')

xwiki-platform-tools/xwiki-platform-tool-packager-plugin/src/main/java/com/xpn/xwiki/tool/backup/DataMojo.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ public void executeInternal() throws MojoExecutionException
6767
ScriptExtensionRewriter rewriter = new ScriptExtensionRewriter();
6868
rewriter.installExtensionTypeOnRootNamespace("jar");
6969
rewriter.installExtensionTypeOnRootNamespace("webjar");
70+
rewriter.installExtensionTypeOnRootNamespace("webjar-node");
7071
installRequest.setRewriter(rewriter);
7172

7273
// Use superadmin as pages author

xwiki-platform-tools/xwiki-platform-tool-packager-plugin/src/main/java/org/xwiki/tool/packager/internal/MavenBuildJarExtensionHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
* @version $Id$
3636
* @since 9.5RC1
3737
*/
38-
@Component(hints = { "jar", "webjar" })
38+
@Component(hints = { "jar", "webjar", "webjar-node" })
3939
@Singleton
4040
public class MavenBuildJarExtensionHandler extends AbstractExtensionHandler
4141
{

0 commit comments

Comments
 (0)