Skip to content
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

HBASE-15666 shaded dependencies for hbase-testing-util #360

Merged
merged 6 commits into from
Jul 23, 2019
Merged
Show file tree
Hide file tree
Changes from 3 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
3 changes: 3 additions & 0 deletions NOTICE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,6 @@ This product includes portions of the Guava project v14 and v21, specifically
Copyright (C) 2007 The Guava Authors

Licensed under the Apache License, Version 2.0
--
This product includes portions of Jetty project, specially
'hbase-shaded-hbase-shaded-testing-util/src/main/resources/org/apache/hadoop/hbase/shaded/org/mortbay/jetty/webapp/webdefault.xml'
13 changes: 13 additions & 0 deletions hbase-resource-bundle/src/main/resources/supplemental-models.xml
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,19 @@ under the License.
</licenses>
</project>
</supplement>
<supplement>
<project>
<groupId>javax.servlet.jsp</groupId>
<artifactId>jsp-api</artifactId>
meszibalu marked this conversation as resolved.
Show resolved Hide resolved
<licenses>
<license>
<name>CDDL 1.1</name>
<url>https://glassfish.java.net/public/CDDL+GPL_1_1.html</url>
<distribution>repo</distribution>
</license>
</licenses>
</project>
</supplement>
<supplement>
<project>
<groupId>javax.servlet.jsp</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ allowed_expr+="|^org/apache/hbase/"
allowed_expr+="|^META-INF/"
# * the folding tables from jcodings
allowed_expr+="|^tables/"
# * contents of hbase-webapps
allowed_expr+="|^hbase-webapps/"
# * HBase's default configuration files, which have the form
# "_module_-default.xml"
allowed_expr+="|^hbase-default.xml$"
Expand Down
62 changes: 62 additions & 0 deletions hbase-shaded/hbase-shaded-testing-util-tester/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<!--
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-->
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>org.apache.hbase</groupId>
<artifactId>hbase-build-configuration</artifactId>
<version>3.0.0-SNAPSHOT</version>
<relativePath>../../hbase-build-configuration</relativePath>
</parent>

<artifactId>hbase-shaded-testing-util-tester</artifactId>
<name>Apache HBase - Shaded - Testing Util Tester</name>
<description>Ensures that hbase-shaded-testing-util works with hbase-shaded-client.</description>

<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
meszibalu marked this conversation as resolved.
Show resolved Hide resolved
</dependency>

<!-- adding shaded-client as the first item on the classpath -->
<dependency>
<groupId>org.apache.hbase</groupId>
<artifactId>hbase-shaded-client</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.hbase</groupId>
<artifactId>hbase-shaded-testing-util</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
</dependencies>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/**
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.hbase.shaded;

import static org.junit.Assert.assertEquals;

import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.client.Put;
import org.apache.hadoop.hbase.client.Table;
import org.apache.hadoop.hbase.testclassification.ClientTests;
import org.apache.hadoop.hbase.testclassification.MediumTests;
import org.apache.hadoop.hbase.util.Bytes;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.ClassRule;
import org.junit.Test;
import org.junit.experimental.categories.Category;

@Category({ ClientTests.class, MediumTests.class })
public class TestShadedHBaseTestingUtility {
private static final HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility();

@ClassRule
public static final HBaseClassTestRule CLASS_RULE =
HBaseClassTestRule.forClass(TestShadedHBaseTestingUtility.class);

@BeforeClass
public static void setUp() throws Exception {
TEST_UTIL.startMiniCluster();
}

@AfterClass
public static void tearDown() throws Exception {
TEST_UTIL.shutdownMiniCluster();
}

@Test
public void testCreateTable() throws Exception {
TableName tableName = TableName.valueOf("test");

Table table = TEST_UTIL.createTable(tableName, "cf");

Put put1 = new Put(Bytes.toBytes("r1"));
put1.addColumn(Bytes.toBytes("cf"), Bytes.toBytes("c"), Bytes.toBytes(1));
table.put(put1);

Put put2 = new Put(Bytes.toBytes("r2"));
put2.addColumn(Bytes.toBytes("cf"), Bytes.toBytes("c"), Bytes.toBytes(2));
table.put(put2);

int rows = TEST_UTIL.countRows(tableName);
busbey marked this conversation as resolved.
Show resolved Hide resolved
assertEquals(2, rows);
}
}
140 changes: 140 additions & 0 deletions hbase-shaded/hbase-shaded-testing-util/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<!--
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-->
<modelVersion>4.0.0</modelVersion>

<parent>
<artifactId>hbase-shaded</artifactId>
<groupId>org.apache.hbase</groupId>
<version>3.0.0-SNAPSHOT</version>
<relativePath>..</relativePath>
</parent>

<artifactId>hbase-shaded-testing-util</artifactId>
<name>Apache HBase - Shaded - Testing Util</name>

<dependencies>
<!-- test-jar dependencies -->
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-common</artifactId>
<type>test-jar</type>
<scope>compile</scope>
Copy link
Member

Choose a reason for hiding this comment

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

compile is the default scope, so couldn't you drop it for all of the dependencies here?

Copy link
Member

Choose a reason for hiding this comment

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

PS: OK if you just want to drop these on commit. Don't need to see a new version to just omit the defaults.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Some of these dependencies are also on the classpath through transitive dependencies with test scope. That's the reason why I added them explicitly with compile scope.

Copy link
Member

@joshelser joshelser Jul 23, 2019

Choose a reason for hiding this comment

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

Does that matter? I am 99% sure that test-scoped dependencies are not transitively included (thus, the reason for making an hbase-shaded-testing-util module in the first place).

</dependency>
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-hdfs</artifactId>
<type>test-jar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.hbase</groupId>
<artifactId>hbase-common</artifactId>
<type>test-jar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.hbase</groupId>
<artifactId>hbase-server</artifactId>
<type>test-jar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.hbase</groupId>
<artifactId>hbase-zookeeper</artifactId>
<type>test-jar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.hbase</groupId>
<artifactId>hbase-hadoop-compat</artifactId>
<type>test-jar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.hbase</groupId>
<artifactId>hbase-hadoop2-compat</artifactId>
<type>test-jar</type>
<scope>compile</scope>
</dependency>

<dependency>
<groupId>org.apache.hbase</groupId>
<artifactId>hbase-testing-util</artifactId>
<version>${project.version}</version>
<scope>compile</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
<plugin>
<!--Make it so assembly:single does nothing in here-->
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<skipAssembly>true</skipAssembly>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<executions>
<execution>
<id>aggregate-into-a-jar-with-relocated-third-parties</id>
<configuration>
<artifactSet>
<excludes>
<!-- exclude J2EE modules that come in for JDK11+ (since
hadoop-3.2.0) or modules that come in for JDK8+ but
need not be included -->
<exclude>javax.annotation:javax.annotation-api</exclude>
<exclude>javax.activation:javax.activation-api</exclude>
<!--
Tell the shade plugin that in this case we want to include hadoop
by leaving out the exclude.
-->
<!-- The rest of these should be kept in sync with the parent pom -->
<exclude>org.apache.hbase:hbase-resource-bundle</exclude>
<exclude>org.slf4j:*</exclude>
<exclude>com.google.code.findbugs:*</exclude>
<exclude>com.github.stephenc.findbugs:*</exclude>
<exclude>org.apache.htrace:*</exclude>
<exclude>org.apache.yetus:*</exclude>
<exclude>log4j:*</exclude>
<exclude>commons-logging:*</exclude>
</excludes>
</artifactSet>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>

</project>
Loading