From 89be4fba22193aa0fa173c97b25a39cb93ddf3b1 Mon Sep 17 00:00:00 2001 From: Valentin Petrovych Date: Thu, 25 Nov 2021 15:24:32 +0200 Subject: [PATCH] feat(scripts): check scripts, correct examples in PrebidKotlinDemo #293 --- .../prebidkotlindemo/ads/inapp/InAppBanner.kt | 2 +- .../ads/inapp/InAppVideoBanner.kt | 2 +- .../ads/inappgam/InAppGamBanner.kt | 6 +- .../ads/inappgam/InAppGamInterstitial.kt | 6 +- .../inappgam/InAppGamRewardedInterstitial.kt | 6 +- .../ads/inappgam/InAppGamVideoBanner.kt | 10 +- .../ads/inappgam/InAppGamVideoInterstitial.kt | 6 +- .../ads/inappmopub/InAppMoPubBanner.kt | 2 +- PrebidMobile/omsdk-android/build.gradle | 1 + scripts/buildPrebidMobileRendering.sh | 101 ------------------ scripts/full_clean.sh | 0 scripts/testPrebidMobile.sh | 4 +- 12 files changed, 14 insertions(+), 132 deletions(-) delete mode 100755 scripts/buildPrebidMobileRendering.sh create mode 100644 scripts/full_clean.sh diff --git a/Example/PrebidDemoKotlin/src/main/java/org/prebid/mobile/prebidkotlindemo/ads/inapp/InAppBanner.kt b/Example/PrebidDemoKotlin/src/main/java/org/prebid/mobile/prebidkotlindemo/ads/inapp/InAppBanner.kt index 93da5d729..eadbf6798 100644 --- a/Example/PrebidDemoKotlin/src/main/java/org/prebid/mobile/prebidkotlindemo/ads/inapp/InAppBanner.kt +++ b/Example/PrebidDemoKotlin/src/main/java/org/prebid/mobile/prebidkotlindemo/ads/inapp/InAppBanner.kt @@ -21,7 +21,7 @@ object InAppBanner { } fun destroy() { - adView?.stopRefresh() + adView?.destroy() adView = null } diff --git a/Example/PrebidDemoKotlin/src/main/java/org/prebid/mobile/prebidkotlindemo/ads/inapp/InAppVideoBanner.kt b/Example/PrebidDemoKotlin/src/main/java/org/prebid/mobile/prebidkotlindemo/ads/inapp/InAppVideoBanner.kt index 28f5d6a30..aba161006 100644 --- a/Example/PrebidDemoKotlin/src/main/java/org/prebid/mobile/prebidkotlindemo/ads/inapp/InAppVideoBanner.kt +++ b/Example/PrebidDemoKotlin/src/main/java/org/prebid/mobile/prebidkotlindemo/ads/inapp/InAppVideoBanner.kt @@ -19,7 +19,7 @@ object InAppVideoBanner { } fun destroy() { - bannerView?.stopRefresh() + bannerView?.destroy() bannerView = null } diff --git a/Example/PrebidDemoKotlin/src/main/java/org/prebid/mobile/prebidkotlindemo/ads/inappgam/InAppGamBanner.kt b/Example/PrebidDemoKotlin/src/main/java/org/prebid/mobile/prebidkotlindemo/ads/inappgam/InAppGamBanner.kt index 4626768af..f3114514f 100644 --- a/Example/PrebidDemoKotlin/src/main/java/org/prebid/mobile/prebidkotlindemo/ads/inappgam/InAppGamBanner.kt +++ b/Example/PrebidDemoKotlin/src/main/java/org/prebid/mobile/prebidkotlindemo/ads/inappgam/InAppGamBanner.kt @@ -8,7 +8,6 @@ import org.prebid.mobile.rendering.bidding.parallel.BannerView object InAppGamBanner { private var adView: BannerView? = null - private var eventHandler: GamBannerEventHandler? = null fun create(wrapper: ViewGroup, autoRefreshTime: Int, width: Int, height: Int, adUnitId: String, configId: String) { val eventHandler = GamBannerEventHandler(wrapper.context, adUnitId, AdSize(width, height)) @@ -20,11 +19,8 @@ object InAppGamBanner { } fun destroy() { - adView?.stopRefresh() + adView?.destroy() adView = null - - eventHandler?.destroy() - eventHandler = null } } \ No newline at end of file diff --git a/Example/PrebidDemoKotlin/src/main/java/org/prebid/mobile/prebidkotlindemo/ads/inappgam/InAppGamInterstitial.kt b/Example/PrebidDemoKotlin/src/main/java/org/prebid/mobile/prebidkotlindemo/ads/inappgam/InAppGamInterstitial.kt index f81d94f38..5b733ef8e 100644 --- a/Example/PrebidDemoKotlin/src/main/java/org/prebid/mobile/prebidkotlindemo/ads/inappgam/InAppGamInterstitial.kt +++ b/Example/PrebidDemoKotlin/src/main/java/org/prebid/mobile/prebidkotlindemo/ads/inappgam/InAppGamInterstitial.kt @@ -10,7 +10,6 @@ import org.prebid.mobile.rendering.errors.AdException object InAppGamInterstitial { private var adUnit: InterstitialAdUnit? = null - private var eventHandler: GamInterstitialEventHandler? = null fun create( activity: Activity, @@ -19,7 +18,7 @@ object InAppGamInterstitial { adUnitId: String, configId: String ) { - eventHandler = GamInterstitialEventHandler(activity, adUnitId) + val eventHandler = GamInterstitialEventHandler(activity, adUnitId) adUnit = InterstitialAdUnit(activity, configId, AdSize(minPercentageWidth, minPercentageHeight), eventHandler) adUnit?.setInterstitialAdUnitListener(object : InterstitialAdUnitListener { override fun onAdLoaded(interstitialAdUnit: InterstitialAdUnit?) { @@ -37,9 +36,6 @@ object InAppGamInterstitial { fun destroy() { adUnit?.destroy() adUnit = null - - eventHandler?.destroy() - eventHandler = null } } \ No newline at end of file diff --git a/Example/PrebidDemoKotlin/src/main/java/org/prebid/mobile/prebidkotlindemo/ads/inappgam/InAppGamRewardedInterstitial.kt b/Example/PrebidDemoKotlin/src/main/java/org/prebid/mobile/prebidkotlindemo/ads/inappgam/InAppGamRewardedInterstitial.kt index 12ac19cdb..5605a622e 100644 --- a/Example/PrebidDemoKotlin/src/main/java/org/prebid/mobile/prebidkotlindemo/ads/inappgam/InAppGamRewardedInterstitial.kt +++ b/Example/PrebidDemoKotlin/src/main/java/org/prebid/mobile/prebidkotlindemo/ads/inappgam/InAppGamRewardedInterstitial.kt @@ -8,11 +8,10 @@ import org.prebid.mobile.rendering.errors.AdException object InAppGamRewardedInterstitial { - private var eventHandler: GamRewardedEventHandler? = null private var adUnit: RewardedAdUnit? = null fun create(activity: Activity, adUnitId: String, configId: String) { - eventHandler = GamRewardedEventHandler(activity, adUnitId) + val eventHandler = GamRewardedEventHandler(activity, adUnitId) adUnit = RewardedAdUnit(activity, configId, eventHandler) adUnit?.setRewardedAdUnitListener(object : RewardedAdUnitListener { override fun onAdLoaded(rewardedAdUnit: RewardedAdUnit?) { @@ -29,9 +28,6 @@ object InAppGamRewardedInterstitial { } fun destroy() { - eventHandler?.destroy() - eventHandler = null - adUnit?.destroy() adUnit = null } diff --git a/Example/PrebidDemoKotlin/src/main/java/org/prebid/mobile/prebidkotlindemo/ads/inappgam/InAppGamVideoBanner.kt b/Example/PrebidDemoKotlin/src/main/java/org/prebid/mobile/prebidkotlindemo/ads/inappgam/InAppGamVideoBanner.kt index 1c46a3208..b245face3 100644 --- a/Example/PrebidDemoKotlin/src/main/java/org/prebid/mobile/prebidkotlindemo/ads/inappgam/InAppGamVideoBanner.kt +++ b/Example/PrebidDemoKotlin/src/main/java/org/prebid/mobile/prebidkotlindemo/ads/inappgam/InAppGamVideoBanner.kt @@ -8,7 +8,6 @@ import org.prebid.mobile.rendering.bidding.parallel.BannerView object InAppGamVideoBanner { - private var eventHandler: GamBannerEventHandler? = null private var bannerView: BannerView? = null fun create( @@ -19,9 +18,9 @@ object InAppGamVideoBanner { adUnitId: String, configId: String ) { - eventHandler = GamBannerEventHandler(wrapper.context, adUnitId, AdSize(width, height)) + val eventHandler = GamBannerEventHandler(wrapper.context, adUnitId, AdSize(width, height)) - bannerView = BannerView(wrapper.context, configId, eventHandler!!) + bannerView = BannerView(wrapper.context, configId, eventHandler) bannerView?.videoPlacementType = VideoPlacementType.IN_BANNER bannerView?.setAutoRefreshDelay(autoRefreshTime) wrapper.addView(bannerView) @@ -30,10 +29,7 @@ object InAppGamVideoBanner { } fun destroy() { - eventHandler?.destroy() - eventHandler = null - - bannerView?.stopRefresh() + bannerView?.destroy() bannerView = null } diff --git a/Example/PrebidDemoKotlin/src/main/java/org/prebid/mobile/prebidkotlindemo/ads/inappgam/InAppGamVideoInterstitial.kt b/Example/PrebidDemoKotlin/src/main/java/org/prebid/mobile/prebidkotlindemo/ads/inappgam/InAppGamVideoInterstitial.kt index 5c4661c6e..484a2b936 100644 --- a/Example/PrebidDemoKotlin/src/main/java/org/prebid/mobile/prebidkotlindemo/ads/inappgam/InAppGamVideoInterstitial.kt +++ b/Example/PrebidDemoKotlin/src/main/java/org/prebid/mobile/prebidkotlindemo/ads/inappgam/InAppGamVideoInterstitial.kt @@ -9,11 +9,10 @@ import org.prebid.mobile.rendering.errors.AdException object InAppGamVideoInterstitial { - private var eventHandler: GamInterstitialEventHandler? = null private var adUnit: InterstitialAdUnit? = null fun create(activity: Activity, adUnitId: String, configId: String) { - eventHandler = GamInterstitialEventHandler(activity, adUnitId) + val eventHandler = GamInterstitialEventHandler(activity, adUnitId) adUnit = InterstitialAdUnit(activity, configId, AdUnitFormat.VIDEO, eventHandler) adUnit?.setInterstitialAdUnitListener(object : InterstitialAdUnitListener { override fun onAdLoaded(interstitialAdUnit: InterstitialAdUnit?) { @@ -29,9 +28,6 @@ object InAppGamVideoInterstitial { } fun destroy() { - eventHandler?.destroy() - eventHandler = null - adUnit?.destroy() adUnit = null } diff --git a/Example/PrebidDemoKotlin/src/main/java/org/prebid/mobile/prebidkotlindemo/ads/inappmopub/InAppMoPubBanner.kt b/Example/PrebidDemoKotlin/src/main/java/org/prebid/mobile/prebidkotlindemo/ads/inappmopub/InAppMoPubBanner.kt index f00e94b36..8a5609a91 100644 --- a/Example/PrebidDemoKotlin/src/main/java/org/prebid/mobile/prebidkotlindemo/ads/inappmopub/InAppMoPubBanner.kt +++ b/Example/PrebidDemoKotlin/src/main/java/org/prebid/mobile/prebidkotlindemo/ads/inappmopub/InAppMoPubBanner.kt @@ -46,7 +46,7 @@ object InAppMoPubBanner { bannerView?.destroy() bannerView = null - adUnit?.stopRefresh() + adUnit?.destroy() adUnit = null } diff --git a/PrebidMobile/omsdk-android/build.gradle b/PrebidMobile/omsdk-android/build.gradle index c072e73f3..b92fe6a26 100644 --- a/PrebidMobile/omsdk-android/build.gradle +++ b/PrebidMobile/omsdk-android/build.gradle @@ -1,3 +1,4 @@ +// In case of updating version don't forget to update buildPrebidMobile.sh script configurations.maybeCreate("default") artifacts.add("default", file("${omSdkModuleName}-${omSdkVersion}.aar")) diff --git a/scripts/buildPrebidMobileRendering.sh b/scripts/buildPrebidMobileRendering.sh deleted file mode 100755 index 7c563cb62..000000000 --- a/scripts/buildPrebidMobileRendering.sh +++ /dev/null @@ -1,101 +0,0 @@ -#!/usr/bin/env bash - -if [ -d "scripts" ]; then - cd scripts/ || true -fi - -set -e - -cd .. - -# $1 - module name -function generateArtifacts() { - echo "Generating artifacts and javadoc for module: ${1}" - - ./gradlew :"${1}":assemble - ./gradlew :"${1}":javadocJar - ./gradlew :"${1}":sourcesJar -} - -# $1 - regex, $2 - file to search, $3 createDir -function findVariableWithRegex() { - local foundMatch="" - - while read -r line; do - if [[ $line =~ ${1} ]]; then - foundMatch=${BASH_REMATCH[1]} - fi - done <"${2}" - - echo "$foundMatch" -} - -MODULE_NAME_RENDERING_SDK="PrebidMobile-rendering" -MODULE_NAME_MOPUB="PrebidMobile-mopubAdapters" -MODULE_NAME_EVENT_HANDLERS="PrebidMobile-gamEventHandlers" -MODULE_NAME_OM_SDK="omsdk-android" - -ARTIFACT_ID_RENDERING_SDK="prebid-mobile-sdk-rendering" -ARTIFACT_ID_MOPUB_ADAPTERS="prebid-mobile-sdk-mopubAdapters" -ARTIFACT_ID_GAM_EVENT_HANDLERS="prebid-mobile-sdk-gamEventHandlers" - -PATH_BASE="$PWD" -PATH_BASE_SDK_MODULE="${PATH_BASE}/PrebidMobile" -PATH_BASE_ARTIFACT="${PATH_BASE}/build/generated-artifacts/org/prebid" -PATH_OUTPUT="${PATH_BASE}/generated/rendering" -PATH_LIBS="build/libs" - -# set the default release version to what's in the project's build.gradle file -prebidVersionRegex="prebidVersionName.*=.*\"(.*)\"" -omSdkVersionRegex="omSdkVersion.*=.*\"(.*)\"" -VERSION_RELEASE="$(findVariableWithRegex "${prebidVersionRegex}" "${PATH_BASE}"/build.gradle)" -VERSION_OM_SDK="$(findVariableWithRegex "${omSdkVersionRegex}" "${PATH_BASE}"/build.gradle)" - -echo "Building artifacts for version: [${VERSION_RELEASE}], OM SDK version: [${VERSION_OM_SDK}]" - -generateArtifacts ${MODULE_NAME_RENDERING_SDK} -generateArtifacts ${MODULE_NAME_EVENT_HANDLERS} -generateArtifacts ${MODULE_NAME_MOPUB} - -# Generate and publish .pom (includes previously generated .aar). This step will include OM SDK artifacts local deploy. -./gradlew publishAllPublicationsToLocalArtifactsRepository - -mkdir -p "${PATH_OUTPUT}" -echo "Moving artifacts to $PATH_OUTPUT" - -# Pay attention that for cycle depends on order and element count in moduleArray and artifactIdArray. -# Modify with caution. -moduleArray=("${MODULE_NAME_RENDERING_SDK}" "${MODULE_NAME_MOPUB}" "${MODULE_NAME_EVENT_HANDLERS}") -artifactIdArray=("${ARTIFACT_ID_RENDERING_SDK}" "${ARTIFACT_ID_MOPUB_ADAPTERS}" "${ARTIFACT_ID_GAM_EVENT_HANDLERS}") - -for i in "${!moduleArray[@]}"; do - moduleName="${moduleArray[i]}" - artifactId="${artifactIdArray[i]}" - - echo "Extracting module: [${moduleName}], artifactId: [${artifactId}] for moving .aar, .pom, javadoc and sources into appropriate output folder." - - outputArtifactPath="${PATH_OUTPUT}/${artifactId}" - mkdir -p "${outputArtifactPath}" - - # Moves and renames aar and pom files per module to output folder (with artifact id as destinationPath). - # Renaming is performed to remove version from pom and aar file names. Example resulting path: %project%/generated/rendering/%artifactId%/%artifactId%.pom - mv $"${PATH_BASE_ARTIFACT}/${artifactId}/${VERSION_RELEASE}/${artifactId}-${VERSION_RELEASE}.aar" "${outputArtifactPath}/${artifactId}.aar" - mv $"${PATH_BASE_ARTIFACT}/${artifactId}/${VERSION_RELEASE}/${artifactId}-${VERSION_RELEASE}.pom" "${outputArtifactPath}/${artifactId}.pom" - - # Moves and renames generated javadoc per module. - mv $"${PATH_BASE_SDK_MODULE}/${moduleName}/${PATH_LIBS}/${moduleName}-javadoc.jar" "${outputArtifactPath}/${artifactId}-javadoc.jar" - mv $"${PATH_BASE_SDK_MODULE}/${moduleName}/${PATH_LIBS}/${moduleName}-sources.jar" "${outputArtifactPath}/${artifactId}-sources.jar" -done - -outputArtifactPath="${PATH_OUTPUT}/${MODULE_NAME_OM_SDK}" -mkdir -p "${outputArtifactPath}" - -# Moves OM SDK pom and aar to output folder. -echo "Extracting module: [OM SDK] for moving .aar and .pom into appropriate output folder." - -PATH_OM_SDK_ARTIFACT="${PATH_BASE_ARTIFACT}/${MODULE_NAME_OM_SDK}/${VERSION_OM_SDK}/${MODULE_NAME_OM_SDK}-${VERSION_OM_SDK}" -mv $"${PATH_OM_SDK_ARTIFACT}.aar" "${outputArtifactPath}/${MODULE_NAME_OM_SDK}.aar" -mv $"${PATH_OM_SDK_ARTIFACT}.pom" "${outputArtifactPath}/${MODULE_NAME_OM_SDK}.pom" - -echo "Done!" -echo "Files can be found in $PATH_OUTPUT" \ No newline at end of file diff --git a/scripts/full_clean.sh b/scripts/full_clean.sh new file mode 100644 index 000000000..e69de29bb diff --git a/scripts/testPrebidMobile.sh b/scripts/testPrebidMobile.sh index f26eb06d2..8aaecfd04 100755 --- a/scripts/testPrebidMobile.sh +++ b/scripts/testPrebidMobile.sh @@ -19,4 +19,6 @@ echoX "clean previous build" echoX "start unit tests" ./gradlew PrebidMobile:testDebugUnitTest -./gradlew PrebidMobile-rendering:testDebugUnitTest \ No newline at end of file +./gradlew PrebidMobile-rendering:testDebugUnitTest +./gradlew PrebidMobile-gamEventHandlers:testDebugUnitTest +./gradlew PrebidMobile-mopubAdapters:testDebugUnitTest \ No newline at end of file