React Native Map Box Execution Failed transform classes with Dex / JarMerging - mapbox

I've just started using MapBox in react-native but I appear to be getting the following error
* What went wrong:
Execution failed for task ':app:transformClassesWithDexForDebug'.
> com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.dex.DexIndexOverflowException: method ID not in [0, 0xffff]: 65536
Enabling multidex with
multiDexEnabled true
I then get the following
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
> com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: okhttp3/internal/ws/RealWebSocket$1.class
Here's the config
build.gradle .../android
allprojects {
repositories {
mavenLocal()
jcenter()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$rootDir/../node_modules/react-native/android"
}
// Add jitpack repository (added by tipsi-stripe)
maven { url "https://jitpack.io" }
maven { url "https://maven.google.com" }
}
}
build.gradle ../app
dependencies {
compile project(':mapbox-react-native-mapbox-gl')
compile project(':react-native-branch')
compile project(':react-native-camera')
compile project(':tipsi-stripe')
compile project(':react-native-device-info')
compile project(':react-native-vector-icons')
compile project(':react-native-i18n')
compile project(':react-native-geocoder')
compile project(':react-native-fbsdk')
compile(project(':react-native-maps')) {
exclude group: 'com.google.android.gms', module: 'play-services-base'
exclude group: 'com.google.android.gms', module: 'play-services-maps'
}
compile fileTree(dir: "libs", include: ["*.jar"])
compile "com.android.support:appcompat-v7:25.0.0"
compile "com.facebook.react:react-native:+" // From node_modules
compile 'com.google.android.gms:play-services-base:11.+'
compile 'com.google.android.gms:play-services-maps:11.+'
}
settings.gradle
include ':mapbox-react-native-mapbox-gl'
project(':mapbox-react-native-mapbox-gl').projectDir = new File(rootProject.projectDir, '../node_modules/#mapbox/react-native-mapbox-gl/android/rctmgl')
include ':react-native-branch'
project(':react-native-branch').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-branch/android')
include ':react-native-camera'
project(':react-native-camera').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-camera/android')
include ':tipsi-stripe'
project(':tipsi-stripe').projectDir = new File(rootProject.projectDir, '../node_modules/tipsi-stripe/android')
include ':react-native-device-info'
project(':react-native-device-info').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-device-info/android')
include ':react-native-vector-icons'
project(':react-native-vector-icons').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-vector-icons/android')
include ':react-native-i18n'
project(':react-native-i18n').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-i18n/android')
include ':react-native-geocoder'
project(':react-native-geocoder').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-geocoder/android')
include ':react-native-fbsdk'
project(':react-native-fbsdk').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-fbsdk/android')
include ':react-native-maps'
project(':react-native-maps').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-maps/lib/android')
include ':app'
MainApplication.java
import android.app.Application;
import android.content.Intent;
import com.facebook.CallbackManager;
import com.facebook.FacebookSdk;
import com.facebook.react.ReactApplication;
import com.mapbox.rctmgl.RCTMGLPackage;
import io.branch.rnbranch.RNBranchPackage;
import io.branch.referral.Branch;
import com.lwansbrough.RCTCamera.RCTCameraPackage;
import com.gettipsi.stripe.StripeReactPackage;
import com.learnium.RNDeviceInfo.RNDeviceInfo;
import com.oblador.vectoricons.VectorIconsPackage;
import com.i18n.reactnativei18n.ReactNativeI18n;
import com.devfd.RNGeocoder.RNGeocoderPackage;
import com.facebook.reactnative.androidsdk.FBSDKPackage;
import com.facebook.react.ReactNativeHost;
import com.facebook.react.ReactPackage;
import com.facebook.react.shell.MainReactPackage;
import com.facebook.soloader.SoLoader;
import com.airbnb.android.react.maps.MapsPackage;
import java.util.Arrays;
import java.util.List;
public class MainApplication extends Application implements ReactApplication {
private static CallbackManager mCallbackManager = CallbackManager.Factory.create();
protected static CallbackManager getCallbackManager() {
return mCallbackManager;
}
private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
#Override
public boolean getUseDeveloperSupport() {
return BuildConfig.DEBUG;
}
#Override
protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
new MainReactPackage(),
new RCTMGLPackage(),
new RNBranchPackage(),
new RCTCameraPackage(),
new StripeReactPackage(),
new RNDeviceInfo(),
new MapsPackage(),
new VectorIconsPackage(),
new ReactNativeI18n(),
new RNGeocoderPackage(),
new FBSDKPackage(mCallbackManager)
);
}
};
#Override
public ReactNativeHost getReactNativeHost() {
return mReactNativeHost;
}
#Override
public void onCreate() {
super.onCreate();
FacebookSdk.sdkInitialize(getApplicationContext());
SoLoader.init(this, /* native exopackage */ false);
// initialize the Branch object
Branch.setPlayStoreReferrerCheckTimeout(0);
Branch.getAutoInstance(this);
}
}
Stacktrace
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:transformDexArchiveWithDexMergerForDebug'.
> com.android.build.api.transform.TransformException: com.android.dex.DexException: Multiple dex files define Lokhttp3/internal/ws/WebSocketReader;
* Try:
Run with --info or --debug option to get more log output.
* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:transformDexArchiveWithDexMergerForDebug'.
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:100)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:70)
at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:63)
at org.gradle.api.internal.tasks.execution.ResolveTaskOutputCachingStateExecuter.execute(ResolveTaskOutputCachingStateExecuter.java:54)
at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58)
at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:88)
at org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStateTaskExecuter.execute(ResolveTaskArtifactStateTaskExecuter.java:52)
at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52)
at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:54)
at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:34)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker$1.run(DefaultTaskGraphExecuter.java:248)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:197)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:107)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:241)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:230)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.processTask(DefaultTaskPlanExecutor.java:124)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.access$200(DefaultTaskPlanExecutor.java:80)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:105)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:99)
at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.execute(DefaultTaskExecutionPlan.java:625)
at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.executeWithTask(DefaultTaskExecutionPlan.java:580)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.run(DefaultTaskPlanExecutor.java:99)
at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46)
at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
Caused by: java.lang.RuntimeException: com.android.build.api.transform.TransformException: com.android.dex.DexException: Multiple dex files define Lokhttp3/internal/ws/WebSocketReader;
at com.android.builder.profile.Recorder$Block.handleException(Recorder.java:55)
at com.android.builder.profile.ThreadRecorder.record(ThreadRecorder.java:104)
at com.android.build.gradle.internal.pipeline.TransformTask.transform(TransformTask.java:213)
at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:73)
at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$IncrementalTaskAction.doExecute(DefaultTaskClassInfoStore.java:173)
at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$StandardTaskAction.execute(DefaultTaskClassInfoStore.java:134)
at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$StandardTaskAction.execute(DefaultTaskClassInfoStore.java:121)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$1.run(ExecuteActionsTaskExecuter.java:122)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:197)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:107)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:111)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:92)
... 27 more
Caused by: com.android.build.api.transform.TransformException: com.android.dex.DexException: Multiple dex files define Lokhttp3/internal/ws/WebSocketReader;
at com.android.build.gradle.internal.transforms.DexMergerTransform.transform(DexMergerTransform.java:230)
at com.android.build.gradle.internal.pipeline.TransformTask$2.call(TransformTask.java:222)
at com.android.build.gradle.internal.pipeline.TransformTask$2.call(TransformTask.java:218)
at com.android.builder.profile.ThreadRecorder.record(ThreadRecorder.java:102)
... 39 more
Caused by: com.android.dex.DexException: Multiple dex files define Lokhttp3/internal/ws/WebSocketReader;
at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:661)
at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:616)
at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:598)
at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:171)
at com.android.dx.merge.DexMerger.merge(DexMerger.java:198)
at com.android.builder.dexing.DexArchiveMergerCallable.call(DexArchiveMergerCallable.java:61)
at com.android.builder.dexing.DexArchiveMergerCallable.call(DexArchiveMergerCallable.java:36)
* Get more help at https://help.gradle.org
BUILD FAILED in 8s
148 actionable tasks: 4 executed, 144 up-to-date
I'm not sure if this is a matter of my current project config or what not, but i've not seen reports of this so far.
Update with adding in workaround enables app to launch but then another issue arises: NoClassDefFoundError: com.google.android.gms.wallet.MaskedWalletRequest
I've now added in configurations.all { resolutionStrategy.force 'com.squareup.okhttp3:okhttp:3.4.1' } as suggested by https://github.com/facebook/react-native/issues/12646 which enables the app to build succesfully but then there is an issue of NoClassDefFoundError: com.google.android.gms.wallet.MaskedWalletRequest
Just to clarify moving over to mapbox, I'll no longer need react-native-maps, and the reason for the move over is the greater level of detail i.e. in the buildings.
Thanks, appreciate you're help

Looks like a similar issue was raised against the repo and can probably be resolved if you...
exclude android.arch.core module from the mapbox project

compile 'com.google.android.gms:play-services-base:11.+'
compile 'com.google.android.gms:play-services-maps:11.+`
Version for com.google.android.gms:play-services should be same in build.gradle for app. and and in build.gradle of your packages installed.
-Here 11.+ version refers to any version greater then 11 which currently
available.i would suggest to make this version static and copy that version in build.gradle of your package in node-modules which gives error.
it is necessary to have same com.google.android.gms:play-services version throughout the app

Thankfully I was finally able to get mapbox in on my android version in react-native after resolving issues that popped up along the way: First of all my first attempt was on an older version of react-native 0.44.0, I later upgraded to the latest version of react native
"react-native": "^0.50.3",
and using react
"react": "^16.1.1",
Error
* What went wrong:
Execution failed for task ':app:transformClassesWithDexForDebug'.
> com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.dex.DexIndexOverflowException: method ID not in [0, 0xffff]: 65536
This was the first, the app exceeds the maximum number of methods so we go ahead and enable multiDex in app/gradle
android {
compileSdkVersion 25
defaultConfig {
...
multiDexEnabled true
The next issue was
* What went wrong:
Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
> com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: okhttp3/internal/ws/RealWebSocket$1.class
One approach to resolving this was found to use on the older version of react-native but this was not required it seems on the most recent version following the upgrade with react-native-git-upgrade
configurations.all { resolutionStrategy.force 'com.squareup.okhttp3:okhttp:3.4.1' }
Another issue that popped up was
Failed to resolve: android.arch.lifecycle:extension:1.0.0-alpha3
which was resolved by adding maven { url 'https://maven.google.com' } to
allprojects {
repositories {
jcenter()
mavenCentral()
maven { url 'https://maven.google.com' }
}
}
Then there was an Aapt exception error which was resolved by adding to gradle.properties
android.enableAapt2=false
The app would now build succesfully but on starting irrespective of whether upraded to the latest version or not would show the error
C++ Exception in 'NativeModules': java.lang.NoClassDefFoundError: com.google.android.gms.wallet.MaskedWalletRequest
which was resolved by adding
implementation 'com.google.android.gms:play-services-wallet:11.+'
to our gradle dependencies.
And then the app built and started succesfully with no errors.
I think upgrading to the latest version of react-native, react, helped a great deal with compatability, speed, and performance, as well as by using the latest version of gradle and for example when doing so
configurations.all { resolutionStrategy.force 'com.squareup.okhttp3:okhttp:3.4.1' }
was needed to be added assuming that conflict must have been resolved in a later version.
Anyway, hope this helps someone, and pleased to say I've finally got mapbox in the app.
Thanks to #nitaliano for helping out over at https://github.com/mapbox/react-native-mapbox-gl/issues/785, and providing guidance, a long with the references and help found on https://github.com/tipsi/tipsi-stripe/issues/18 https://github.com/facebook/react-native/issues/12646 https://github.com/mapbox/react-native-mapbox-gl/issues/767 and also the help from Chris Geirman and Rajat Gupta here.
The following references were also helpful
https://facebook.github.io/react-native/docs/upgrading.html
https://reactjs.org/blog/2017/04/07/react-v15.5.0.html
https://reactjs.org/blog/2017/09/26/react-v16.0.html
https://github.com/mlaursen/react-md/issues/325
https://www.npmjs.com/package/prop-types
https://github.com/mapbox/react-native-mapbox-gl/blob/master/example/src/App.js
https://github.com/mapbox/react-native-mapbox-gl/blob/master/example/src/components/ShowMap.js
Mapbox: Cant add LocationLayer plugin in gradle
https://github.com/tipsi/tipsi-stripe/issues/18
https://developer.android.com/studio/build/gradle-plugin-3-0-0-migration.html
Thanks again 👍

Related

How to Integrate Gatling with existing Spring-Boot + Gradle application

I am trying to integrate Gatling to perform automation load testing. but I am getting different errors. I need some help on this topic.
I am using JDK-11 version
My Controller class as follows
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
#RestController
#RequestMapping("/health")
public class HealthController {
private static final Logger LOGGER = LoggerFactory.getLogger(HealthController.class);
#Autowired
OptionRepository repository;
#GetMapping("/{id}/options")
public List<Health> findAllOptions(#PathVariable("id") Long id) {
return (List<Health>) repository.findAll(id);
}
#GetMapping("/{id}/valid/dates")
public List<Health> findByDates(#PathVariable("id") Long id) {
return repository.findDates(id);
}
}
#Data
class Health{
List<String> options;
List<String> dates;
}
My build.gradle as follows
/* ========================
* Build
* ========================
*/
buildscript {
ext {
springBootVersion = '2.4.4.RELEASE'
}
repositories {
mavenCentral()
maven {
url "https://plugins.gradle.org/m2/"
}
maven { url 'https://repo.spring.io/snapshot' }
jcenter()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:2.4.4")
classpath "io.spring.gradle:dependency-management-plugin:0.6.1.RELEASE"
}
}
/* ========================
* Plugins
* ========================
*/
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
apply plugin: 'jacoco'
apply plugin: 'scala'
apply plugin: 'java-library'
/* ========================
* Project Info
* ========================
*/
version = '1.0.0'
sourceCompatibility = 11
targetCompatibility = 11
defaultTasks 'bootRun'
tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
}
/* ========================
* Dependencies
* =========================
*/
repositories {
mavenCentral()
maven { url 'https://repo.spring.io/snapshot' }
}
configurations {
providedRuntime
}
dependencies {
compileOnly 'org.projectlombok:lombok:1.18.16'
annotationProcessor 'org.projectlombok:lombok:1.18.16'
testCompileOnly 'org.projectlombok:lombok:1.18.16'
testAnnotationProcessor 'org.projectlombok:lombok:1.18.16'
compile('org.springframework.boot:spring-boot-starter-actuator')
compile('org.springframework.boot:spring-boot-starter-web')
compile('org.springframework.boot:spring-boot-starter-security')
compile 'org.springframework.boot:spring-boot-starter-thymeleaf'
compile ('org.springframework.security.oauth.boot:spring-security-oauth2-autoconfigure:2.4.4')
compile('io.jsonwebtoken:jjwt:0.9.0')
compile ('org.apache.commons:commons-csv:1.8')
compile("org.mybatis.spring.boot:mybatis-spring-boot-starter:2.1.3")
compile 'org.apache.commons:commons-lang3:3.6'
compile 'org.apache.commons:commons-collections4:4.0'
runtime('org.springframework.boot:spring-boot-devtools')
providedRuntime('org.springframework.boot:spring-boot-starter-tomcat')
runtimeOnly('org.postgresql:postgresql:42.2.19')
testCompile('org.springframework.boot:spring-boot-starter-test')
testCompile('com.github.javafaker:javafaker:0.15')
implementation ('org.mybatis.spring.boot:mybatis-spring-boot-test-autoconfigure:1.2.2')
implementation ('org.liquibase:liquibase-core:4.3.2')
implementation ('org.springdoc:springdoc-openapi-maven-plugin:1.2')
implementation ('org.springdoc:springdoc-openapi-ui:1.5.5')
implementation ('com.microsoft.sqlserver:mssql-jdbc:9.2.1.jre8')
//Tried with this libraries
//compile 'org.scala-lang:scala-library:2.10.1'
//implementation ('net.alchim31.maven:scala-maven-plugin:4.5.1')
//implementation ('io.gatling:gatling-maven-plugin:3.1.2')
testCompile('io.gatling.highcharts:gatling-charts-highcharts:2.3.0')
}
/* ========================
* Task Configuration
* ========================
*/
test {
finalizedBy jacocoTestReport // report is always generated after tests run
filter {
excludeTestsMatching "com.dev.*"
}
}
test.onlyIf { project.hasProperty('executeTests') }
jacoco {
toolVersion = "0.8.6"
}
jacocoTestReport {
reports {
xml.enabled false
csv.enabled false
html.destination file("${buildDir}/reports/jacoco")
}
afterEvaluate {
classDirectories.setFrom(files(classDirectories.files.collect {
fileTree(dir: it,
exclude: ['**/domain/**'
]
)
}))
}
}
apply plugin: 'jacoco'
jacocoTestCoverageVerification {
violationRules {
rule {
limit {
minimum = 0.9
}
}
rule {
enabled = false
element = 'CLASS'
includes = ['org.gradle.*']
limit {
counter = 'LINE'
value = 'TOTALCOUNT'
maximum = 0.3
}
}
}
}
/**
* Gatling load tests
*/
task loadTest(type: JavaExec) {
dependsOn testClasses
description = "Load Test With Gatling"
group = "Load Test"
classpath = sourceSets.test.runtimeClasspath
jvmArgs = [
"-Dgatling.core.directory.binaries=${sourceSets.test.output.classesDirs.toString()}"
]
main = "io.gatling.app.Gatling"
args = [
"--simulation", "com.dev.ApiGatlingSimulationTest",
"--results-folder", "${buildDir}/gatling-results",
//"--binaries-folder", sourceSets.test.output.classesDirs.toString(),
"--bodies-folder", sourceSets.test.resources.srcDirs.toList().first().toString() + "/gatling/bodies",
]
}
def logbackGatlingConfig() {
return sourceSets.test.resources.find { it.name == 'logback-gatling.xml' }
}
bootJar { baseName = 'migroes-services' }
My scala test suit as follows
package com.dev
import io.gatling.core.scenario.Simulation
import io.gatling.core.Predef._
import io.gatling.http.Predef._
import java.util.Date
import scala.concurrent.duration.FiniteDuration
import scala.concurrent.duration.Duration
import java.util.concurrent.TimeUnit
class ApiGatlingSimulationTest extends Simulation {
val scn = scenario("Dev Status").repeat(1000, "n") {
exec(
http("Get All Options")
.get("http://localhost:8080/health/dev-001/options")
.check(status.is(200))
).pause(Duration.apply(5, TimeUnit.MILLISECONDS))
}.repeat(1000, "n") {
exec(
http("Valid Dates")
.get("http://localhost:8090/health/dev-002/valid/dates")
.check(status.is(200))
)
}
setUp(scn.inject(atOnceUsers(30))).maxDuration(FiniteDuration.apply(10, "minutes"))
}
Currently I am getting below error from Command line.
I am first running the application via STS & then trying to fire gradle loadTest command.
D:\dev-repo\migroes-services>gradle clean build
> Task :compileJava
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
> Task :compileTestJava
Note: D:\dev-repo\migroes-services\src\test\java\com\dev\services\TestUtils.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.8.3/userguide/command_line_interface.html#sec:command_line_warnings
BUILD SUCCESSFUL in 1m 3s
8 actionable tasks: 8 executed
D:\dev-repo\migroes-services>gradle loadTest
> Task :loadTest
21:02:53.898 [GatlingSystem-akka.actor.default-dispatcher-2] INFO akka.event.slf4j.Slf4jLogger - Slf4jLogger started
Exception in thread "main" io.gatling.core.session.el.ElParserException: Failed to parse VIN with error 'class [B cannot be cast to class [C ([B and [C are in module java.base of loader 'bootstrap')'
at io.gatling.core.session.el.ElCompiler.parseEl(ElCompiler.scala:249)
at io.gatling.core.session.el.ElCompiler$.parse(ElCompiler.scala:171)
at io.gatling.core.session.el.ElCompiler$.compile(ElCompiler.scala:174)
at io.gatling.core.session.el.package$El$.el$extension(package.scala:26)
at io.gatling.core.ValidationImplicits.stringToExpression(ValidationImplicits.scala:48)
at io.gatling.core.ValidationImplicits.stringToExpression$(ValidationImplicits.scala:48)
at io.gatling.core.Predef$.stringToExpression(Predef.scala:22)
at com.dev.ApiGatlingSimulationTest.<init>(ApiGatlingSimulationTest.scala:15)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)
at java.base/java.lang.Class.newInstance(Class.java:584)
at io.gatling.app.Runner.run0(Runner.scala:79)
at io.gatling.app.Runner.run(Runner.scala:64)
at io.gatling.app.Gatling$.start(Gatling.scala:59)
at io.gatling.app.Gatling$.fromArgs(Gatling.scala:43)
at io.gatling.app.Gatling$.main(Gatling.scala:35)
at io.gatling.app.Gatling.main(Gatling.scala)
> Task :loadTest FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':loadTest'.
> Process 'command 'C:\Program Files\Java\jdk-11.0.8\bin\java.exe'' finished with non-zero exit value 1
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.8.3/userguide/command_line_interface.html#sec:command_line_warnings
BUILD FAILED in 15s
6 actionable tasks: 1 executed, 5 up-to-date
I am getting most of time below error.
Exception in thread "main" io.gatling.core.session.el.ElParserException: Failed to parse VIN with error 'class [B cannot be cast to class [C ([B and [C are in module java.base of loader 'bootstrap')'
I tried to reach out several different blogs and similar situations on different platform. till now no luck !!
testCompile('io.gatling.highcharts:gatling-charts-highcharts:2.3.0')
You're trying to use Gatling 2 that has been dead for years.
Please upgrade. Latest version is 3.5.1 as of now.

Spring Rest Doc (Gradle) Snippets disappear upon build

Recently switch to Gradle from Maven.
Following this tutorial for continuous REST Doc build with Gradle. https://www.youtube.com/watch?v=k5ncCJBarRI&t=1490s
Snippets are generating just fine when running test. Its when I am trying to generate asciidoc where it seems like the /build directory gets recreated without the snippets. So my generated html always shows
Unresolved directive in index.adoc - include::{snippets}/home-json/curl-request.adoc[]
I am generating the asciidoc by the following command in the terminal
gradle asciidoctor -t
// Continuous build command
// Mentioned around #1:07:40 mark
// https://www.youtube.com/watch?v=k5ncCJBarRI&t=1490s
build.gradle
plugins {
id 'org.springframework.boot' version '2.4.2'
id 'io.spring.dependency-management' version '1.0.11.RELEASE'
id 'org.asciidoctor.convert' version '1.5.8'
id 'java'
}
group = 'lab.restdocs'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '14'
repositories {
mavenCentral()
}
ext {
set('snippetsDir', file("build/generated-snippets"))
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'junit:junit:4.12'
testImplementation 'org.springframework.restdocs:spring-restdocs-mockmvc'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
developmentOnly 'org.springframework.boot:spring-boot-devtools'
}
test {
outputs.dir snippetsDir
useJUnitPlatform()
}
asciidoctor {
inputs.dir snippetsDir
dependsOn test
}
bootJar {
dependsOn asciidoctor
from ("${asciidoctor.outputDir}/html5") {
into 'static/docs'
}
}
MyTest
#RunWith(SpringRunner.class)
#SpringBootTest
#AutoConfigureMockMvc
public class HelloControllerTest {
#Autowired
private MockMvc mockMvc;
#Rule
public final JUnitRestDocumentation restDocumentation = new JUnitRestDocumentation();
#InjectMocks
private HelloController helloController;
#Mock
private HelloService helloService;
#Before
public void setUp() throws Exception {
// create a mock environment of helloController
mockMvc = MockMvcBuilders.standaloneSetup(helloController)
.apply(documentationConfiguration(this.restDocumentation))
.build();
}
#Test
public void shouldReturnDefaultMessage() throws Exception {
this.mockMvc.perform(get("/hello/string"))
.andDo(print())
.andExpect(status().isOk())
.andExpect(content().string(containsString("hello there"))
)
.andDo(document("home-string"));
}
I also checked my build.gradle against https://spring.io/guides/gs/testing-restdocs/ and https://docs.spring.io/spring-restdocs/docs/2.0.5.RELEASE/reference/html5/#configuration-uris. I don't know what I am missing...
Thanks in advance.
Edited
Ran command gradle asciidoctor --console=plain
If it makes it easier I greated a Git repo
https://github.com/erich5168/edu.rest-doc
erichuang$ gradle asciidoctor --console=plain
> Task :compileJava
> Task :processResources
> Task :classes
> Task :compileTestJava
> Task :processTestResources NO-SOURCE
> Task :testClasses
> Task :test
> Task :asciidoctor
asciidoctor: WARNING: api.adoc: line 3: include file not found: /Users/erichuang/Desktop/JE/00-Development/dev/lab/lab-rest-docs/lab.restdocs-gradlebuild/build/generated-snippets/home/curl-request.adoc
asciidoctor: WARNING: api.adoc: line 5: include file not found: /Users/erichuang/Desktop/JE/00-Development/dev/lab/lab-rest-docs/lab.restdocs-gradlebuild/build/generated-snippets/home/http-request.adoc
asciidoctor: WARNING: api.adoc: line 7: include file not found: /Users/erichuang/Desktop/JE/00-Development/dev/lab/lab-rest-docs/lab.restdocs-gradlebuild/build/generated-snippets/home/http-response.adoc
asciidoctor: WARNING: api.adoc: line 20: include file not found: /Users/erichuang/Desktop/JE/00-Development/dev/lab/lab-rest-docs/lab.restdocs-gradlebuild/build/generated-snippets/home-json/http-response.adoc
Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.5/userguide/command_line_interface.html#sec:command_line_warnings
BUILD SUCCESSFUL in 2s
5 actionable tasks: 5 executed
Apples-MBP:lab.restdocs-gradlebuild erichuang$
When run from the command line, you build isn't running any tests. The tests aren't being run as your tests are using JUnit 4 while the test task has been configured to use the JUnit Platform (JUnit 5):
test {
outputs.dir snippetsDir
useJUnitPlatform()
}
You can fix the problem either by updating your tests to use JUnit 5 or by removing useJUnitPlatform() from the test task's configuration so that it uses JUnit 4. The latter is the smaller change and leaves the test task looking like this:
test {
outputs.dir snippetsDir
}

Gradle issues with android support compilation in Unity export

I have a multidex issue while compiling my project in Unity so I exported the project and imported it to gradle. I've fixed most dependencies but I cannot get rid of the following problem:
FAILURE: Build failed with an exception.
12:05:17.012 [ERROR] [org.gradle.BuildExceptionReporter]
12:05:17.012 [ERROR] [org.gradle.BuildExceptionReporter] * What went wrong:
12:05:17.012 [ERROR] [org.gradle.BuildExceptionReporter] Execution failed for task ':mainProj:transformClassesWithJarMergingForRelease'.
12:05:17.012 [ERROR] [org.gradle.BuildExceptionReporter] > com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: android/support/compat/BuildConfig.class
12:05:17.012 [ERROR] [org.gradle.BuildExceptionReporter]
and that goes to all support* projects. I had similar issues with other sdks but I fixed them by deleting the BuildConfig.class from their classes.jar files. For some reason, when I delete this class for the supportcompat2500 project (in this specific example) it keeps coming back - and I don't know where from.
my settings.gradle is:
include ':amazonAppStore'
include ':appLovin'
include ':chartboost'
include ':googleAIDL'
include ':googlePlay'
include ':heyzap'
include ':oneSignalConfig'
include ':samsungApps'
include ':shortcutBadger115'
include ':unityAds'
include ':vungle'
include ':animatedvectordrawable2500'
include ':cardviewv72340'
include ':common'
include ':customtabs2340'
include ':facebookandroidsdk4170'
include ':facebookandroidwrapper790'
include ':onesignalunity'
include ':playservicesads980'
include ':playservicesadslite980'
include ':playservicesbase980'
include ':playservicesclearcut980'
include ':playservicesgass980'
include ':playservicesgcm980'
include ':playservicesiid980'
include ':playserviceslocation980'
include ':playservicestasks980'
include ':supportcompat2500'
include ':supportcoreui2500'
include ':supportcoreutils2500'
include ':supportfragment2500'
include ':supportmediacompat2500'
include ':supportv42500'
include ':supportvectordrawable2500'
include ':mainProj'
mainProj.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion "24.0.3"
defaultConfig {
applicationId "com.mainProj.mainProj"
minSdkVersion 15
targetSdkVersion 24
// Enabling multidex support.
multiDexEnabled true
}
lintOptions {
quiet true
abortOnError false
ignoreWarnings true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
sourceSets {
main {
manifest.srcFile 'src/main/AndroidManifest.xml'
java.srcDirs = ['src/main/java.com.mainProj.mainProj']
resources.srcDirs = ['src/main/res']
renderscript.srcDirs = ['src']
res.srcDirs = ['src/main/res']
assets.srcDirs = ['src/main/assets.bin.Data']
jniLibs.srcDirs = ['src/main/jniLibs']
}
debug.setRoot('build-types/debug')
release.setRoot('build-types/release')
}
}
dependencies {
compile 'com.android.support:multidex:1+'
compile fileTree(dir: 'libs', include: '*.jar')
compile project(':amazonAppStore')
compile project(':appLovin')
compile project(':chartboost')
compile project(':googleAIDL')
compile project(':googlePlay')
compile project(':cardviewv72340')
compile project(':customtabs2340')
compile project(':heyzap')
compile project(':oneSignalConfig')
compile project(':samsungApps')
compile project(':shortcutBadger115')
compile project(':unityAds')
compile project(':vungle')
compile project(':common')
compile project(':facebookandroidsdk4170')
compile project(':facebookandroidwrapper790')
compile project(':onesignalunity')
compile project(':playservicesads980')
compile project(':playservicesadslite980')
compile project(':playservicesbase980')
compile project(':playservicesclearcut980')
compile project(':playservicesgass980')
compile project(':playservicesgcm980')
compile project(':playservicesiid980')
compile project(':playserviceslocation980')
compile project(':playservicestasks980')
compile project(':supportcompat2500')
compile project(':supportcoreui2500')
compile project(':supportcoreutils2500')
compile project(':supportfragment2500')
compile project(':supportmediacompat2500')
compile project(':supportv42500')
compile project(':supportvectordrawable2500')
}
Project gradle:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.3'
}
}
allprojects {
repositories {
jcenter()
}
}
Would appreciate any advice/referenece. Thanks.
The problem was that
facebookandroidwrapper790
already include com.android.support and all of its sub-projects.
I've removed all
compile project(':support*')

Gradle execute Groovy script in GroovyShell with Eclipse Luna

I am getting a ClassNotFoundException: org.apache.ivy.core.report.ResolveReport when executing a gradle task, which uses Grapes to resolve dependencies.
I am using Eclipse Luna 4.4.0 with a Gradle/Groovy Project having this build.gradle:
apply plugin: 'groovy'
apply plugin:'application'
mainClassName = "de.my.app.package.Main"
version = 0.5
repositories { mavenCentral() }
dependencies {
compile 'org.codehaus.groovy:groovy-all:2.4.3'
compile group: 'org.apache.ivy', name:'ivy', version:'2.2.0'
compile 'commons-io:commons-io:2.4'
compile 'commons-codec:commons-codec:1.2'
}
task myTask << {
def groovyShell = new GroovyShell()
groovyShell.run(file('/src/scripts/groovy/de/my/app/package/scripts/SomeScript.groovy'))
}
classes.finalizedBy(myTask)
My Java Build Path inside Project->Properties looks like this:
This is SomeScript.groovy inside the Folder /src/scripts/groovy/de/my/app/package/scripts:
package de.my.app.package.scripts
#Grapes(
#Grab(group='org.eclipse.birt.runtime.3_7_1', module='org.apache.commons.codec', version='1.3.0')
)
#Grapes(
#Grab(group='commons-io', module='commons-io', version='2.4')
)
import org.apache.commons.codec.binary.Hex
println Hex.toString()
Weird thing is that executing SomeScript.groovy from cmd with groovy SomeScript.groovy does not give the error. So i am guessing it is some Eclipse config I have missed.
How can SomeScript.groovy be executed by the Gradle run from the build.gradle without causing a ClassNotFoundException: org.apache.ivy.core.report.ResolveReport?
I have found a solution for my problem. I needed this build.gradle file:
apply plugin: 'groovy'
apply plugin:'application'
mainClassName = "de.my.app.package.Main"
version = 0.5
repositories { mavenCentral() }
dependencies {
compile 'org.codehaus.groovy:groovy-all:2.4.3'
compile group: 'org.apache.ivy', name:'ivy', version:'2.2.0'
compile 'commons-io:commons-io:2.4'
compile 'commons-codec:commons-codec:1.2'
}
task myTask (type: Exec) {
def groovyHome = System.getenv("GROOVY_HOME")
def someScriptPath= new String(project.projectDir.toString()).toString() + "\\src\\scripts\\groovy\\de\\my\\app\\package\\main\\SomeScript.groovy"
commandLine "${groovyHome}\\bin\\groovy.bat", someScriptPath
}
classes.finalizedBy(myTask)
So I abandoned the approach of using the class GroovyShell, because I could not configure the classPath for it correctly.
My Script executes now before every run. Problem is solved.

Can't run Scalatest with Gradle

task scalaTest(dependsOn: testClasses) << {
description = 'Runs Scalatest suite'
ant.taskdef(name: 'scalatest',
classname: 'org.scalatest.tools.ScalaTestAntTask',
classpath: sourceSets.test.runtimeClasspath.asPath
)
ant.scalatest(runpath: sourceSets.test.output.classesDir,
haltonfailure: 'true', fork: 'false') {
reporter(type: 'stdout')
}
}
I run gradle scalaTest and I get:
* What went wrong:
Execution failed for task ':scalaTest'.
> java.lang.NoClassDefFoundError: scala/reflect/ClassManifest$
I am using Scala 2.10.2 and Gradle 1.7
dependencies {
compile 'org.scala-lang:scala-library:2.10.2'
testCompile 'org.scalatest:scalatest:1.3'
testCompile 'org.scalamock:scalamock_2.10:3.0.1'
}
What's wrong??
I do not know how to solve this one, but I can offer you a workaround. Annotate your test classes with #RunWith(classOf[JUnitRunner]), like this:
import org.scalatest.junit.JUnitRunner
import org.junit.runner.RunWith
#RunWith(classOf[JUnitRunner])
class MyTest extends FunSpec{
}
and then, gradle test should work.
Edit:
My dependencies:
compile "org.scala-lang:scala-library:2.10.1"
testCompile "org.scalatest:scalatest_2.10:1.9.1"
You can put the following in your build.gradle:
task spec(dependsOn: ['testClasses'], type: JavaExec) {
main = 'org.scalatest.tools.Runner'
args = ['-R', 'build/classes/scala/test', '-o']
classpath = sourceSets.test.runtimeClasspath
}
Note: The path my be different depending on the gradle version as pointed out in the comments by #MikeRylander. Before gradle 4 it used to be 'build/classes/test'.
Then just run gradle spec to execute your tests.
I named the task spec because there already is a test task. I don't know if you can override the default test task.
You can look up the available options here.
This response may be a bit late. But for one using scala with gradle (5.x), the following works.
Add the following plugin to gradle.
plugins {
id "com.github.maiflai.scalatest" version "0.25"
}
To run the code
> gradle test
As a bonus the test results from the above plugin would also be reported better than the default report.
rarry is correct. And even better, you can annotate a base test class with #RunWith(classOf[JUnitRunner]) once to cause all of your ScalaTest tests to run with the JUnit runner (assuming they extend the base class), e.g.:
import org.junit.runner.RunWith
import org.scalatest._
import org.scalatest.junit.JUnitRunner
#RunWith(classOf[JUnitRunner])
abstract class UnitSpec extends FlatSpec with Matchers
As of Gradle 3.2.1, following root build.gradle runs both JUnit and ScalaTest code. This code is for multi-project build, enabled via settings.gradle, that's why subprojects used.
Plus, it's on purpose uses explicit Gradle API, to minimize Gradle DSL magic.
description = 'root project'
def enableScalaTest(Project project) {
Task scalaTest = project.task(
[
'dependsOn': 'testClasses',
'description': 'Runs ScalaTest tests in the project'
],
'scalaTest',
{
ext.inputDir = project.tasks.getByName('compileTestScala').destinationDir
inputs.dir(ext.inputDir)
}
)
scalaTest.doLast({
ant.taskdef(name: 'scalatest',
classname: 'org.scalatest.tools.ScalaTestAntTask',
classpath: project.sourceSets.test.runtimeClasspath.asPath)
ant.scalatest(runpath: ext.inputDir,
fork: 'false',
haltonfailure: 'true')
{ reporter(type: 'stdout') }
})
project.getTasks().getByName('build').dependsOn(scalaTest)
}
subprojects {
apply plugin: 'scala'
repositories {
mavenCentral()
}
dependencies {
compile 'org.scala-lang:scala-library:2.12.1'
testCompile 'junit:junit:4.12'
testCompile 'org.scalatest:scalatest_2.12:3.0.1'
}
enableScalaTest(delegate)
}