-
-
Save wborn/0e3cd275be724e827ef88bb04b7eb12a to your computer and use it in GitHub Desktop.
#!/bin/bash | |
# Make sure to update the WORKSPACE dir in this script! | |
# The script will clean and reset the WORKSPACE so it's best to use a separate dir for this. | |
# Afterwards make sure you build with Maven and skip checks and tests with: | |
# mvn clean install -DskipChecks=true -Dmaven.test.skip=true -Dspotless.check.skip=true | |
WORKSPACE="$HOME/git/openhab/openhab-addons-port" | |
cd "$WORKSPACE" | |
git clean -dfx | |
git reset --hard | |
git pull | |
removed_modules=() | |
# remove Eclipse IoT Marketplace client | |
# all marketplace extensions are incompatible with OH3 and the marketplace itself will also be replaced | |
removed_modules+=("org.openhab.extensionservice.marketplace") | |
removed_modules+=("org.openhab.extensionservice.marketplace.automation") | |
# remove audio sinks as they are now part of core | |
removed_modules+=("org.openhab.io.javasound") | |
removed_modules+=("org.openhab.io.webaudio") | |
# remove rotalra1x binding | |
# the rotel binding should be used instead, see https://github.com/openhab/openhab-addons/issues/7577 | |
removed_modules+=("org.openhab.binding.rotelra1x") | |
# remove netatmo binding | |
# the netatmo binding has a dependency to older swagger libs for code generation, this needs to be adapted for 3.x, see https://github.com/openhab/openhab-addons/issues/8274 | |
removed_modules+=("org.openhab.binding.netatmo") | |
# remove velux binding | |
# the velux binding uses deprecated Thing API methods, this needs to be adapted for 3.x, see https://github.com/openhab/openhab-addons/issues/7402 | |
removed_modules+=("org.openhab.binding.velux") | |
# remove modules that fail to compile due to the Whiteboard migration | |
# these modules have a dependency on Jersey which cannot be easily removed on the 2.5.x branch | |
removed_modules+=("org.openhab.io.hueemulation") | |
# remove imperihome-io add-on | |
# this bundle makes use of the persistence API which had breaking changes between 2.5 and 3.0, see https://github.com/openhab/openhab-addons/issues/8290 | |
removed_modules+=("org.openhab.io.imperihome") | |
# remove modules for add-ons that already exist on main branch | |
for module in $(curl -s https://raw.githubusercontent.com/openhab/openhab-addons/main/bundles/pom.xml | grep '<module>' | sed -E 's|\s+<module>(.+)</module>|\1|') | |
do | |
removed_modules+=($module) | |
done | |
# remove module code, itest and update POMs | |
for module in ${removed_modules[@]} | |
do | |
if [ -d "${WORKSPACE}/bundles/$module" ]; then | |
echo "removing bundle $module" | |
rm -rf "${WORKSPACE}/bundles/$module" | |
sed -i "/<module>$module<\\/module>/d" "${WORKSPACE}/bundles/pom.xml" | |
if [ -d "${WORKSPACE}/itests/$module.tests" ]; then | |
echo "removing itest $module.tests" | |
rm -rf "${WORKSPACE}/itests/$module.tests" | |
sed -i "/<module>$module.tests<\\/module>/d" "${WORKSPACE}/itests/pom.xml" | |
fi | |
cat "${WORKSPACE}/bom/openhab-addons/pom.xml" | | |
tr '\n' '\f' | | |
sed -e "s| <dependency>\f <groupId>org.openhab.addons.bundles</groupId>\f <artifactId>$module</artifactId>\f <version>\${project.version}</version>\f </dependency>\f||" | | |
tr '\f' '\n' > "${WORKSPACE}/bom/openhab-addons/pom.xml.new" | |
mv "${WORKSPACE}/bom/openhab-addons/pom.xml.new" "${WORKSPACE}/bom/openhab-addons/pom.xml" | |
fi | |
done | |
mvn versions:set -DgenerateBackupPoms=false -DnewVersion=3.1.0-SNAPSHOT | |
# change ESH-INF to OH-INF | |
echo "renaming ESH-INF to OH-INF in bundles" | |
find ${WORKSPACE}/bundles -name "ESH-INF" -type d | grep -v "\.git" | grep -v "/target/" | while read f | |
do | |
newfile="${f/ESH-INF/OH-INF}" | |
mv $f $newfile | |
done | |
find ${WORKSPACE}/bundles -type f | grep -v "\.git" | grep -v "/target/" | while read f | |
do | |
sed -i "s|ESH-INF|OH-INF|g" "$f" | |
done | |
echo "renaming ESH-INF to OH-INF in itests" | |
find ${WORKSPACE}/itests -name "ESH-INF" -type d | grep -v "\.git" | grep -v "/target/" | while read f | |
do | |
newfile="${f/ESH-INF/OH-INF}" | |
mv $f $newfile | |
done | |
find ${WORKSPACE}/itests -type f | grep -v "\.git" | grep -v "/target/" | while read f | |
do | |
sed -i "s|ESH-INF|OH-INF|g" "$f" | |
done | |
# fix main pom.xml | |
sed -i "s|<ohc.version>2.5.0|<ohc.version>3.1.0-SNAPSHOT|g" "${WORKSPACE}/pom.xml" | |
sed -i "s|<oh.java.version>1.8|<oh.java.version>11|g" "${WORKSPACE}/pom.xml" | |
sed -i "s|<version>\[1.8.0\-40,1.9),\[9.0,12.0)|<version>\[11.0,12.0)|g" "${WORKSPACE}/pom.xml" | |
sed -i "s|<javase>1.8|<javase>11|g" "${WORKSPACE}/bundles/pom.xml" | |
sed -i "s|<javase>1.8|<javase>11|g" "${WORKSPACE}/features/pom.xml" | |
# exclude itests until updated to JUnit 5 Jupiter API | |
sed -i "s|<module>itests</module>|<!-- <module>itests</module> -->|g" "${WORKSPACE}/pom.xml" | |
# update Java version in .classpath and .bndrun files | |
find ${WORKSPACE} -name '.classpath' -o -name '*.bndrun' -type f | grep -v "\.git" | grep -v "/target/" | while read f | |
do | |
sed -i "s|JavaSE-1.8|JavaSE-11|g" "$f" | |
done | |
# change file content | |
find ${WORKSPACE}/bundles -type f | grep -v "\.git" | grep -v "/target/" | while read f | |
do | |
echo replace in file $f | |
sed -i "s|org\(.\)eclipse.smarthome|org\1openhab\1core|g" "$f" | |
sed -i "s|http://www.eclipse.org/smarthome|https://openhab.org|g" "$f" | |
sed -i "s|https://www.eclipse.org/smarthome|https://openhab.org|g" "$f" | |
sed -i "s|//eclipse.org/smarthome|//openhab.org|g" "$f" | |
# bruteforce strip double core names | |
sed -i "s|core\(.\)core|core|g" "$f" | |
done | |
find ${WORKSPACE}/itests -type f | grep -v "\.git" | grep -v "/target/" | while read f | |
do | |
echo replace in file $f | |
sed -i "s|org\(.\)eclipse.smarthome|org\1openhab\1core|g" "$f" | |
sed -i "s|http://www.eclipse.org/smarthome|https://openhab.org|g" "$f" | |
sed -i "s|https://www.eclipse.org/smarthome|https://openhab.org|g" "$f" | |
sed -i "s|//eclipse.org/smarthome|//openhab.org|g" "$f" | |
# bruteforce strip double core names | |
sed -i "s|core\(.\)core|core|g" "$f" | |
done | |
# update mqtt binding for https://github.com/openhab/openhab-core/pull/1291 | |
find ${WORKSPACE}/bundles/org.openhab.binding.mqtt/src/test -type f | grep -v "\.git" | grep -v "/target/" | while read f | |
do | |
sed -i "s|TopicSubscribers|Subscription|g" "$f" | |
done | |
# this test fails to compile, see https://github.com/openhab/openhab-addons/issues/7590 | |
mv "${WORKSPACE}/bundles/org.openhab.binding.mqtt/src/test/java/org/openhab/binding/mqtt/internal/MQTTTopicDiscoveryServiceTest.java" "${WORKSPACE}/bundles/org.openhab.binding.mqtt/src/test/java/org/openhab/binding/mqtt/internal/MQTTTopicDiscoveryServiceTest.java.tobefixed" |
The script is almost the same as what Jenkins is using and I never got time to look into why the tests failed and are also skipped by Jenkins.
But it would be better if we have the option to enable them again! I always forget to add the option for skipping the tests. ;-)
I had some time to look into those build issues @cweitkamp.
Some of the grep -v ".git"
commands weren't properly escaped so they would match all files if there was "git" in the workspace dir:
Which there was for me when using:
WORKSPACE="$HOME/git/openhab/openhab-addons-port"
So now it properly replaces all occurrences which fixes #1 and #3.
#2 seems to be caused by openhab/openhab-core#1291 where TopicSubscribers
was replaced with a Subscription
class. So it now replaces those imports. Though the constructor argument can no longer be used so MQTTTopicDiscoveryServiceTest
fails to compile, so for now I've renamed it so it isn't run.
I've also added renaming of JavaSE-1.8 to JavaSE-11 in .classpath and .bndrun files.
After resolving the itest runbundles most itests work, except for the feed and ntp itests.
👍
I cannot wait to test it. Maybe I will find some time this evening or tomorrow.
I filed an issue for the MQTT TopicSubscribers
issue and added it to OH3 project so we do not forget it.
Thanks for the script. I'm testing it right away.
Will add some comments of you don't mind. Build failed on some tests: 1 and 3 could be fixed easily - wondering why your script did not replace "ESH" by "OH" in those files.
https://github.com/openhab/openhab-addons/blob/b19b0b204aa2ae2ba11348589d717af5ca4b9382/bundles/org.openhab.binding.dwdunwetter/src/test/java/org/openhab/binding/dwdunwetter/DwdUnwetterHandlerTest.java#L106-L107
https://github.com/openhab/openhab-addons/blob/b19b0b204aa2ae2ba11348589d717af5ca4b9382/bundles/org.openhab.binding.networkupstools/src/test/java/org/openhab/binding/networkupstools/internal/NutNameChannelsTest.java#L134-L135