Skip to content

HBASE-27802 Manage static javascript resources programatically #6864

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

Merged
merged 6 commits into from
May 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions hbase-rest/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@
<skipAssembly>true</skipAssembly>
</configuration>
</plugin>
<!-- Copy the static web resources (JS, CSS, images, etc.) from hbase-server sources -->
<!-- Copy the static web resources (JS, CSS, images, etc.) from hbase-server -->
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<executions>
Expand All @@ -295,7 +295,7 @@
<overwrite>true</overwrite>
<resources>
<resource>
<directory>../hbase-server/src/main/resources/hbase-webapps/static</directory>
<directory>../hbase-server/target/hbase-webapps/static</directory>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know that this is how you found it, but does it make better sense to include an explicit dependency on the new webjars jar from hbase-rest? I doubt that we can remove the dependency on hbase-server, but it would be one fewer thing and make the dependency tree more obvious.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Many thanks, I completely agree your point that here and now we will have and implicit dependency from hbase-rest to hbase-server which is not obvious from first look. Also agree that this is not the best and would be better to have an explicit dependency.

The problem is that if we directly add the webjars to the dependencies section of the hbase-rest pom.xml, then those webjars will be included (packaged) into the hbase-rest jar which - as far as I understand - we want to avoid.

Maybe we could duplicate the maven-dependency-plugin (and then the copy steps) usage also to hbase-rest but then this would introduce a lot of XML duplication.

Other solution could be to extract the downloading and extraction of the webjars to a separate sub-project and then hase-server, hbase-rest and hbase-thrift could depend on it.

But I'm not a Maven expert by an means so if you have any better ideas please feel free to propose them. :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Created a new Jira to improve this: https://issues.apache.org/jira/browse/HBASE-29355

</resource>
</resources>
</configuration>
Expand Down
104 changes: 104 additions & 0 deletions hbase-server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -752,7 +752,9 @@
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>${maven.dependency.version}</version>
<executions>
<execution>
<id>create-mrapp-generated-classpath</id>
Expand All @@ -768,6 +770,108 @@
<outputFile>${project.build.directory}/test-classes/mrapp-generated-classpath</outputFile>
</configuration>
</execution>
<execution>
<id>unpack-ui-resources-js</id>
<goals>
<goal>unpack</goal>
</goals>
<phase>process-resources</phase>
<configuration>
<artifactItems>
<artifactItem>
<groupId>org.webjars</groupId>
<artifactId>bootstrap</artifactId>
<version>${bootstrap.version}</version>
<type>jar</type>
<overWrite>true</overWrite>
<includes>**/js/bootstrap.min.js</includes>
<fileMappers>
<fileMapper implementation="org.codehaus.plexus.components.io.filemappers.FlattenFileMapper"/>
</fileMappers>
</artifactItem>
<artifactItem>
<groupId>org.webjars</groupId>
<artifactId>jquery</artifactId>
<version>${jquery.version}</version>
<type>jar</type>
<overWrite>true</overWrite>
<includes>**/jquery.min.js</includes>
<fileMappers>
<fileMapper implementation="org.codehaus.plexus.components.io.filemappers.FlattenFileMapper"/>
</fileMappers>
</artifactItem>
<artifactItem>
<groupId>org.webjars</groupId>
<artifactId>tablesorter</artifactId>
<version>${tablesorter.version}</version>
<type>jar</type>
<overWrite>true</overWrite>
<includes>**/jquery.tablesorter.min.js,
**/parsers/parser-date-iso8601.min.js</includes>
<fileMappers>
<fileMapper implementation="org.codehaus.plexus.components.io.filemappers.FlattenFileMapper"/>
</fileMappers>
</artifactItem>
<artifactItem>
<groupId>org.webjars</groupId>
<artifactId>vega</artifactId>
<version>${vega.version}</version>
<type>jar</type>
<overWrite>true</overWrite>
<includes>**/vega.min.js</includes>
<fileMappers>
<fileMapper implementation="org.codehaus.plexus.components.io.filemappers.FlattenFileMapper"/>
</fileMappers>
</artifactItem>
<artifactItem>
<groupId>org.webjars</groupId>
<artifactId>vega-embed</artifactId>
<version>${vega-embed.version}</version>
<type>jar</type>
<overWrite>true</overWrite>
<includes>**/vega-embed.min.js</includes>
<fileMappers>
<fileMapper implementation="org.codehaus.plexus.components.io.filemappers.FlattenFileMapper"/>
</fileMappers>
</artifactItem>
<artifactItem>
<groupId>org.webjars</groupId>
<artifactId>vega-lite</artifactId>
<version>${vega-lite.version}</version>
<type>jar</type>
<overWrite>true</overWrite>
<includes>**/vega-lite.min.js</includes>
<fileMappers>
<fileMapper implementation="org.codehaus.plexus.components.io.filemappers.FlattenFileMapper"/>
</fileMappers>
</artifactItem>
</artifactItems>
<outputDirectory>${project.build.directory}/hbase-webapps/static/js</outputDirectory>
</configuration>
</execution>
<execution>
<id>unpack-ui-resources-css</id>
<goals>
<goal>unpack</goal>
</goals>
<phase>process-resources</phase>
<configuration>
<artifactItems>
<artifactItem>
<groupId>org.webjars</groupId>
<artifactId>bootstrap</artifactId>
<version>${bootstrap.version}</version>
<type>jar</type>
<overWrite>true</overWrite>
<includes>**/css/bootstrap.min.css</includes>
<fileMappers>
<fileMapper implementation="org.codehaus.plexus.components.io.filemappers.FlattenFileMapper"/>
</fileMappers>
</artifactItem>
</artifactItems>
<outputDirectory>${project.build.directory}/hbase-webapps/static/css</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ See the License for the specific language governing permissions and
limitations under the License.
</%doc>

<script type="text/javascript" src="/static/js/vega@5.32.0.min.js"></script>
<script type="text/javascript" src="/static/js/vega-lite@5.23.0.min.js"></script>
<script type="text/javascript" src="/static/js/vega-embed@6.29.0.min.js"></script>
<script type="text/javascript" src="/static/js/vega.min.js"></script>
<script type="text/javascript" src="/static/js/vega-lite.min.js"></script>
<script type="text/javascript" src="/static/js/vega-embed.min.js"></script>

<div id="vis" style="width:80%;"></div>
<script type="text/javascript">
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

4 changes: 2 additions & 2 deletions hbase-thrift/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@
<skipAssembly>true</skipAssembly>
</configuration>
</plugin>
<!-- Copy the static web resources (JS, CSS, images, etc.) from hbase-server sources -->
<!-- Copy the static web resources (JS, CSS, images, etc.) from hbase-server -->
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<executions>
Expand All @@ -205,7 +205,7 @@
<overwrite>true</overwrite>
<resources>
<resource>
<directory>../hbase-server/src/main/resources/hbase-webapps/static</directory>
<directory>../hbase-server/target/hbase-webapps/static</directory>
</resource>
</resources>
</configuration>
Expand Down
14 changes: 11 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -914,6 +914,7 @@
<maven.eclipse.version>2.10</maven.eclipse.version>
<maven.gpg.version>3.0.1</maven.gpg.version>
<maven.javadoc.version>3.4.0</maven.javadoc.version>
<maven.dependency.version>3.8.1</maven.dependency.version>
<maven.warbucks.version>1.1.0</maven.warbucks.version>
<maven.project.info.report.version>3.1.2</maven.project.info.report.version>
<maven-owasp-plugin.version>12.1.0</maven-owasp-plugin.version>
Expand Down Expand Up @@ -1040,6 +1041,13 @@
<apacheds.version>2.0.0.AM26</apacheds.version>
<ldap-api.version>2.0.0</ldap-api.version>
<webjars-dir>${project.build.directory}/META-INF/resources/webjars</webjars-dir>
<!-- Web UI dependencies -->
<bootstrap.version>5.3.3</bootstrap.version>
<jquery.version>3.7.1</jquery.version>
<tablesorter.version>2.32.0</tablesorter.version>
<vega.version>5.32.0</vega.version>
<vega-embed.version>6.29.0</vega-embed.version>
<vega-lite.version>5.23.0</vega-lite.version>
</properties>
<!-- Sorted by groups of dependencies then groupId and artifactId -->
<dependencyManagement>
Expand Down Expand Up @@ -2756,7 +2764,7 @@
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>unpack</id>
<id>unpack-website-resources</id>
<goals>
<goal>unpack</goal>
</goals>
Expand Down Expand Up @@ -2975,9 +2983,9 @@
<artifactId>maven-antrun-plugin</artifactId>
<version>${maven.antrun.version}</version>
<inherited>false</inherited>
<!-- Rename the book.pdf generated by asciidoctor -->
<executions>
<execution>
<!-- Rename the book.pdf generated by asciidoctor -->
<id>rename-pdf</id>
<goals>
<goal>run</goal>
Expand All @@ -2989,8 +2997,8 @@
</target>
</configuration>
</execution>
<!-- Copy static CSS and JS files for the website. -->
<execution>
<!-- Copy static CSS and JS files for the website. -->
<id>copy-css-js-to-site</id>
<goals>
<goal>run</goal>
Expand Down