jiazhai closed pull request #3221: Make pulsar compile on windows
URL: https://github.com/apache/pulsar/pull/3221
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git a/managed-ledger-shaded/pom.xml b/managed-ledger-shaded/pom.xml
index 1535528755..405d4b366c 100644
--- a/managed-ledger-shaded/pom.xml
+++ b/managed-ledger-shaded/pom.xml
@@ -282,7 +282,7 @@
<goal>exec</goal>
</goals>
<configuration>
-
<executable>${project.parent.basedir}/src/rename-netty-native-libs.sh</executable>
+
<executable>${project.parent.basedir}/src/${rename.netty.native.libs}</executable>
<arguments>
<argument>${project.artifactId}</argument>
</arguments>
diff --git a/pom.xml b/pom.xml
index 93da47bd8d..2aaca3ad35 100644
--- a/pom.xml
+++ b/pom.xml
@@ -196,6 +196,9 @@ flexible messaging model and an intuitive client
API.</description>
<protobuf-maven-plugin.version>0.6.1</protobuf-maven-plugin.version>
<exec-maven-plugin.version>1.6.0</exec-maven-plugin.version>
<aspectj-maven-plugin.version>1.11.1</aspectj-maven-plugin.version>
+
+ <!-- Used to configure rename.netty.native. Libs -->
+
<rename.netty.native.libs>rename-netty-native-libs.sh</rename.netty.native.libs>
</properties>
<dependencyManagement>
@@ -667,7 +670,7 @@ flexible messaging model and an intuitive client
API.</description>
<dependency>
<groupId>com.github.ben-manes.caffeine</groupId>
<artifactId>caffeine</artifactId>
- <version>2.3.3</version>
+ <version>2.6.2</version>
</dependency>
<dependency>
@@ -1460,6 +1463,18 @@ flexible messaging model and an intuitive client
API.</description>
</plugins>
</build>
</profile>
+
+ <profile>
+ <id>windows</id>
+ <activation>
+ <os>
+ <family>Windows</family>
+ </os>
+ </activation>
+ <properties>
+
<rename.netty.native.libs>rename-netty-native-libs.cmd</rename.netty.native.libs>
+ </properties>
+ </profile>
</profiles>
<repositories>
diff --git a/pulsar-broker-shaded/pom.xml b/pulsar-broker-shaded/pom.xml
index 31aab59e8c..ad08135198 100644
--- a/pulsar-broker-shaded/pom.xml
+++ b/pulsar-broker-shaded/pom.xml
@@ -344,7 +344,7 @@
<goal>exec</goal>
</goals>
<configuration>
-
<executable>${project.parent.basedir}/src/rename-netty-native-libs.sh</executable>
+
<executable>${project.parent.basedir}/src/${rename.netty.native.libs}</executable>
<arguments>
<argument>${project.artifactId}</argument>
</arguments>
diff --git a/pulsar-client-kafka-compat/pulsar-client-kafka-shaded/pom.xml
b/pulsar-client-kafka-compat/pulsar-client-kafka-shaded/pom.xml
index b171c652ea..c480b7533f 100644
--- a/pulsar-client-kafka-compat/pulsar-client-kafka-shaded/pom.xml
+++ b/pulsar-client-kafka-compat/pulsar-client-kafka-shaded/pom.xml
@@ -257,7 +257,7 @@
<goal>exec</goal>
</goals>
<configuration>
-
<executable>${project.parent.basedir}/../src/rename-netty-native-libs.sh</executable>
+
<executable>${project.parent.basedir}/../src/${rename.netty.native.libs}</executable>
<arguments>
<argument>${project.artifactId}</argument>
</arguments>
diff --git a/pulsar-client-shaded/pom.xml b/pulsar-client-shaded/pom.xml
index c461849a61..fbbe7cfc5a 100644
--- a/pulsar-client-shaded/pom.xml
+++ b/pulsar-client-shaded/pom.xml
@@ -275,7 +275,7 @@
<goal>exec</goal>
</goals>
<configuration>
-
<executable>${project.parent.basedir}/src/rename-netty-native-libs.sh</executable>
+
<executable>${project.parent.basedir}/src/${rename.netty.native.libs}</executable>
<arguments>
<argument>${project.artifactId}</argument>
</arguments>
diff --git a/site/docs/latest/getting-started/docker.md
b/site/docs/latest/getting-started/docker.md
index 6e1220f70c..6913a06418 100644
--- a/site/docs/latest/getting-started/docker.md
+++ b/site/docs/latest/getting-started/docker.md
@@ -46,7 +46,19 @@ $ docker run -it \
bin/pulsar standalone
```
+Under Windows, you should use something like the following docker command:
+
+```shell
+$ docker run -it \
+ -p 6650:6650 \
+ -p 8080:8080 \
+ -v "$PWD/data:/pulsar/data".ToLower() \
+ apachepulsar/pulsar:{{site.current_version}} \
+ bin/pulsar standalone
+```
+
A few things to note about this command:
+ * `$PWD/data` : The docker host directory under the Windows operating system
must be lowercase.`$PWD/data` can provide you with the specified directory, for
example: `E:/data`.
* `-v $PWD/data:/pulsar/data`: This will make the process inside the
container to store the
data and metadata in the filesystem outside the container, in order to not
start "fresh" every
time the container is restarted.
diff --git a/site2/docs/getting-started-docker.md
b/site2/docs/getting-started-docker.md
index a045df1e57..f343dd9683 100644
--- a/site2/docs/getting-started-docker.md
+++ b/site2/docs/getting-started-docker.md
@@ -17,11 +17,23 @@ $ docker run -it \
-p 6650:6650 \
-p 8080:8080 \
-v $PWD/data:/pulsar/data \
- apachepulsar/pulsar:{{pulsar:version}} \
+ apachepulsar/pulsar:{{site.current_version}} \
+ bin/pulsar standalone
+```
+
+Under Windows, you should use something like the following docker command:
+
+```shell
+$ docker run -it \
+ -p 6650:6650 \
+ -p 8080:8080 \
+ -v "$PWD/data:/pulsar/data".ToLower() \
+ apachepulsar/pulsar:{{site.current_version}} \
bin/pulsar standalone
```
A few things to note about this command:
+ * `$PWD/data` : The docker host directory under the Windows operating system
must be lowercase.`$PWD/data` can provide you with the specified directory, for
example: `E:/data`.
* `-v $PWD/data:/pulsar/data`: This will make the process inside the
container to store the
data and metadata in the filesystem outside the container, in order to not
start "fresh" every
time the container is restarted.
diff --git
a/site2/website/versioned_docs/version-2.1.0-incubating/getting-started-docker.md
b/site2/website/versioned_docs/version-2.1.0-incubating/getting-started-docker.md
index 56ecd51bd4..1401df30a3 100644
---
a/site2/website/versioned_docs/version-2.1.0-incubating/getting-started-docker.md
+++
b/site2/website/versioned_docs/version-2.1.0-incubating/getting-started-docker.md
@@ -18,11 +18,23 @@ $ docker run -it \
-p 6650:6650 \
-p 8080:8080 \
-v $PWD/data:/pulsar/data \
- apachepulsar/pulsar:{{pulsar:version}} \
+ apachepulsar/pulsar:{{site.current_version}} \
+ bin/pulsar standalone
+```
+
+Under Windows, you should use something like the following docker command:
+
+```shell
+$ docker run -it \
+ -p 6650:6650 \
+ -p 8080:8080 \
+ -v "$PWD/data:/pulsar/data".ToLower() \
+ apachepulsar/pulsar:{{site.current_version}} \
bin/pulsar standalone
```
A few things to note about this command:
+ * `$PWD/data` : The docker host directory under the Windows operating system
must be lowercase.`$PWD/data` can provide you with the specified directory, for
example: `E:/data`.
* `-v $PWD/data:/pulsar/data`: This will make the process inside the
container to store the
data and metadata in the filesystem outside the container, in order to not
start "fresh" every
time the container is restarted.
diff --git a/src/rename-netty-native-libs.cmd b/src/rename-netty-native-libs.cmd
new file mode 100644
index 0000000000..9003f6d0ef
--- /dev/null
+++ b/src/rename-netty-native-libs.cmd
@@ -0,0 +1,82 @@
+@REM
+@REM Licensed to the Apache Software Foundation (ASF) under one
+@REM or more contributor license agreements. See the NOTICE file
+@REM distributed with this work for additional information
+@REM regarding copyright ownership. The ASF licenses this file
+@REM to you under the Apache License, Version 2.0 (the
+@REM "License"); you may not use this file except in compliance
+@REM with the License. You may obtain a copy of the License at
+@REM
+@REM http://www.apache.org/licenses/LICENSE-2.0
+@REM
+@REM Unless required by applicable law or agreed to in writing,
+@REM software distributed under the License is distributed on an
+@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+@REM KIND, either express or implied. See the License for the
+@REM specific language governing permissions and limitations
+@REM under the License.
+@REM
+
+@echo off
+
+set ARTIFACT_ID=%1
+set JAR_PATH=%cd%/target/%ARTIFACT_ID%.jar
+set FILE_PREFIX=META-INF/native
+
+:: echo %JAR_PATH%
+:: echo %FILE_PREFIX%
+
+ECHO.
+echo ----- Renaming epoll lib in %JAR_PATH% ------
+set TMP_DIR=%temp%\tmp_pulsar
+
+rd %TMP_DIR% /s /q
+mkdir %TMP_DIR%
+
+set UNZIP_CMD=unzip -q %JAR_PATH% -d %TMP_DIR%
+call %UNZIP_CMD%
+
+:: echo %UNZIP_CMD%
+:: echo %TMP_DIR%
+
+cd /d %TMP_DIR%/%FILE_PREFIX%
+
+:: Loop through the number of groups
+SET Obj_Length=2
+SET Obj[0].FROM=libnetty_transport_native_epoll_x86_64.so
+SET Obj[0].TO=liborg_apache_pulsar_shade_netty_transport_native_epoll_x86_64.so
+SET Obj[1].FROM=libnetty_tcnative_linux_x86_64.so
+SET Obj[1].TO=liborg_apache_pulsar_shade_netty_tcnative_linux_x86_64.so
+SET Obj_Index=0
+
+:LoopStart
+IF %Obj_Index% EQU %Obj_Length% GOTO END
+
+SET Obj_Current.FROM=0
+SET Obj_Current.TO=0
+
+FOR /F "usebackq delims==. tokens=1-3" %%I IN (`SET Obj[%Obj_Index%]`) DO (
+ SET Obj_Current.%%J=%%K.so
+)
+
+echo "Renaming %Obj_Current.FROM% -> %Obj_Current.TO%"
+call ren %Obj_Current.FROM% %Obj_Current.TO%
+
+SET /A Obj_Index=%Obj_Index% + 1
+
+GOTO LoopStart
+:: Loop end
+
+:END
+cd /d %TMP_DIR%
+
+:: Overwrite the original ZIP archive
+rd %JAR_PATH% /s /q
+set ZIP_CMD=zip -q -r %JAR_PATH% .
+:: echo %ZIP_CMD%
+call %ZIP_CMD%
+:: echo %TMP_DIR%
+rd %TMP_DIR% /s /q
+
+exit /b 0
+:: echo.&pause&goto:eof
\ No newline at end of file
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services