Android kotlin fragment: how to get the activity's viewmodel - android-fragments

In a Fragment: how do you get a reference to the ViewModel of the Activity?
The Android docs say to do
private val model: MainActivityViewModel by activityViewModels()
but -- as is normal for Android docs -- it doesn't work.
Cannot inline bytecode built with JVM target 1.8 into bytecode that is being built with JVM target 1.6. Please specify proper '-jvm-target' option
Others suggest
model = ViewModelProviders.of(activity!!).get(MainActivityViewModel::class.java)
but that isn't allowed because ViewModelProviders is deprecated.
So: how do you do it?
Is it documented anywhere?

it seems like jvm version problem,try add this in your build.gradle
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = "1.8"
}

Related

Application not syncing when adding AdMob dependencies

Hello I am new to android and I am having an issue syncing my app when trying to add the dependencies for the the admob the following error appears:
'''
In project 'app' a resolved Google Play services library dependency depends on another at an exact version (e.g. "[18.0.
2]", but isn't being resolved to that version. Behavior exhibited by the library will be unknown.
Dependency failing: com.google.android.gms:play-services-measurement-api:18.0.2 -> com.google.android.gms:play-services-
measurement-sdk-api#[18.0.2], but play-services-measurement-sdk-api version was 18.0.3.
The following dependencies are project dependencies that are direct or have transitive dependencies that lead to the art
ifact with the issue.
-- Project 'app' depends onto com.google.firebase:firebase-bom#{strictly 26.8.0}
-- Project 'app' depends onto com.google.android.gms:play-services-ads-lite#{strictly 20.6.0}
-- Project 'app' depends onto com.google.android.gms:play-services-measurement-sdk-api#{strictly 18.0.3}
-- Project 'app' depends onto com.google.firebase:firebase-bom#26.8.0
-- Project 'app' depends onto com.google.android.gms:play-services-measurement-api#{strictly 18.0.2}
-- Project 'app' depends onto com.google.android.gms:play-services-ads#{strictly 20.6.0}
-- Project 'app' depends onto com.google.android.gms:play-services-ads#20.6.0
-- Project 'app' depends onto com.google.firebase:firebase-analytics#{strictly 18.0.2}
-- Project 'app' depends onto com.google.android.gms:play-services-ads-lite#20.6.0
For extended debugging info execute Gradle from the command line with ./gradlew --info :app:assembleDebug to see the dep
endency paths to the artifact. This error message came from the google-services Gradle plugin, report issues at https://
github.com/google/play-services-plugins and disable by adding "googleServices { disableVersionCheck = true }" to your bu
ild.gradle file.
'''
the following is the build.gradle file :
plugins {
id 'com.android.application'
id 'com.google.gms.google-services'
}
apply plugin: 'kotlin-android'
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 29
buildToolsVersion "30.0.2"
defaultConfig {
applicationId "rubydev.learningforkids"
minSdkVersion 21
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'com.google.android.material:material:1.2.1'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
implementation 'androidx.work:work-runtime:2.3.4'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.recyclerview:recyclerview:1.1.0'
implementation 'com.google.firebase:firebase-auth:20.0.3'
implementation 'com.google.firebase:firebase-firestore:22.1.2'
implementation 'com.google.firebase:firebase-storage:19.2.2'
implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.2.0'
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.2.0'
implementation 'androidx.navigation:navigation-fragment:2.3.3'
implementation 'androidx.navigation:navigation-ui:2.3.3'
implementation 'com.google.android.gms:play-services-ads-lite:20.6.0'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
implementation platform('com.google.firebase:firebase-bom:26.8.0')
implementation 'com.google.firebase:firebase-analytics'
implementation "androidx.core:core-ktx:1.6.0"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.google.android.material:material:1.1.0-alpha10'
implementation 'com.thebluealliance:spectrum:0.7.1'
implementation 'com.squareup.picasso:picasso:2.71828'
implementation 'com.tomer:fadingtextview:2.6'
implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.19'
implementation 'de.hdodenhof:circleimageview:3.0.0'
implementation 'com.google.android.material:material:1.3.0-alpha03'
implementation 'com.github.dhaval2404:imagepicker:2.1'
implementation 'com.github.lzyzsd:circleprogress:1.2.1'
implementation 'net.danlew:android.joda:2.10.9.1'
implementation 'io.github.pilgr:paperdb:2.7.1'
implementation 'com.google.android.gms:play-services-ads:20.6.0'
implementation 'com.google.android.ads.consent:consent-library:1.0.6'
implementation 'com.firebaseui:firebase-ui-auth:4.2.0'
}
repositories {
mavenCentral()
}

Flutter Firebase Remote Config No virtual method isDeveloperModeEnabled()Z in class .../FirebaseRemoteConfigSettings

I have recently upgraded all my firebase libraries in my Flutter project. After that I'm getting the message:
/flutter (27126): [ERROR:flutter/shell/platform/android/platform_view_android_jni_impl.cc(43)] java.lang.NoSuchMethodError: No virtual method isDeveloperModeEnabled()Z in class Lcom/google/firebase/remoteconfig/FirebaseRemoteConfigSettings; or its super classes (declaration of 'com.google.firebase.remoteconfig.FirebaseRemoteConfigSettings' appears in /data/app/package_name-1UBO7FEPHLsC2_eb7itJLA==/base.apk!classes3.dex)
After that my app crashes with the error:
[FATAL:flutter/shell/platform/android/platform_view_android_jni_impl.cc(942)] Check failed: CheckException(env).
Currently I'm using:
firebase_remote_config: ^0.4.0+2
firebase_core: 0.5.0+1
My dependencies in the android/build.gradle:
dependencies {
classpath 'com.android.tools.build:gradle:3.6.4'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.gms:google-services:4.3.4'
classpath 'io.fabric.tools:gradle:1.28.1'
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.3.0'
}
android/app/build.gradle
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
testImplementation 'junit:junit:4.13.1'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
implementation 'androidx.multidex:multidex:2.0.1'
implementation 'com.google.firebase:firebase-config:20.0.0'
implementation 'com.facebook.android:facebook-login:7.1.0'
implementation 'com.google.firebase:firebase-messaging:21.0.0'
implementation 'com.google.android.gms:play-services-basement:17.5.0'
configurations.all {
resolutionStrategy.force 'com.google.android.gms:play-services-base:17.1.0'
}
}
Finally solved ..
Okey not only changing this line
properties.put("inDebugMode", firebaseRemoteConfigInfo.getConfigSettings().isDeveloperModeEnabled());
to
properties.put("inDebugMode", false);
& changing this
FirebaseRemoteConfigSettings settings = new FirebaseRemoteConfigSettings.Builder().setDeveloperModeEnabled(debugMode).build();
firebaseRemoteConfig.setConfigSettings(settings);
to
FirebaseRemoteConfigSettings settings = new FirebaseRemoteConfigSettings.Builder().build();
firebaseRemoteConfig.setConfigSettingsAsync(settings);
You need also to change this
FirebaseRemoteConfig.getInstance().setDefaults(defaults);
to
FirebaseRemoteConfig.getInstance().setDefaultsAsync(defaults);
Still its an annoying issue and should be solved asap
It's a bug in plugin, see github issue for details:
https://github.com/FirebaseExtended/flutterfire/issues/4035
Workaround: just add
implementation platform('com.google.firebase:firebase-bom')
To your build.gradle
Remove this code in your android app's build gradle if it is set:
rootProject.ext {
set('FlutterFire', [
FirebaseSDKVersion: '26.1.1'
])
}

How to solve error: cannot find symbol import androidx.appcompat.widget.RecyclerView in Android studio

My project works well, but when I update google play services version to 15.0.0 and adding firebase to the project, I come up with the following error:
it says error: cannot find symbol import androidx.appcompat.widget.RecyclerView, i find another thread with the same question but is does not specify the situation precisely so I decided to post a new question.
here are my Gradle dependencies:
def acraVersion = '5.1.3'
def gmsVersion = '15.0.0'
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.google.code.gson:gson:2.8.2'
implementation 'com.squareup.picasso:picasso:2.71828'
implementation 'com.squareup.retrofit2:retrofit:2.3.0'
implementation 'com.squareup.okhttp3:logging-interceptor:3.8.1'
implementation 'com.squareup.retrofit2:converter-gson:2.3.0'
implementation 'org.apache.commons:commons-text:1.7'
implementation 'com.jakewharton:butterknife:10.2.1'
implementation 'com.daimajia.easing:library:2.1#aar'
implementation 'com.daimajia.androidanimations:library:2.3#aar'
implementation 'uk.co.chrisjenx:calligraphy:2.3.0'
implementation 'com.github.apl-devs:appintro:v4.2.2'
implementation 'com.rengwuxian.materialedittext:library:2.1.4'
implementation 'co.ronash.android:pushe-base:1.4.0'
implementation "com.google.android.gms:play-services-gcm:$gmsVersion"
implementation "com.google.android.gms:play-services-maps:$gmsVersion"
implementation "com.google.android.gms:play-services-places:$gmsVersion"
//implementation 'com.android.support:recyclerview-v7:28.0.0'
implementation 'com.android.support:design:28.0.0'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'com.orhanobut:hawk:2.0.1'
implementation 'com.afollestad.material-dialogs:core:0.9.6.0'
implementation 'jp.wasabeef:picasso-transformations:2.1.2'
implementation 'com.android.support:support-v4:28.0.0'
implementation 'com.intuit.sdp:sdp-android:1.0.5'
implementation 'com.intuit.ssp:ssp-android:1.0.6'
implementation 'com.mikepenz:fastadapter:3.2.4#aar'
implementation 'com.mikepenz:fastadapter-commons:3.2.4#aar'
implementation 'com.mikepenz:fastadapter-extensions-expandable:3.2.7#aar'
implementation 'cn.aigestudio.wheelpicker:WheelPicker:1.1.2'
implementation 'com.github.yalantis:ucrop:2.2.1'
implementation("com.mikepenz:materialdrawer:6.0.6#aar") {
transitive = true
}
implementation 'co.lujun:androidtagview:1.1.4'
implementation 'com.yarolegovich:discrete-scrollview:1.4.4'
implementation 'jp.wasabeef:recyclerview-animators:2.3.0'
implementation 'com.mikepenz:google-material-typeface:3.0.1.2.original#aar'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.android.support:support-vector-drawable:28.0.0'
implementation 'android.arch.navigation:navigation-fragment:1.0.0'
implementation 'android.arch.navigation:navigation-ui:1.0.0'
implementation 'android.arch.lifecycle:extensions:1.1.1'
implementation 'com.google.android.material:material:1.0.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'androidx.vectordrawable:vectordrawable:1.0.1'
implementation 'androidx.navigation:navigation-fragment:2.0.0'
implementation 'androidx.navigation:navigation-ui:2.0.0'
implementation 'androidx.lifecycle:lifecycle-extensions:2.0.0'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.0.0'
annotationProcessor 'com.jakewharton:butterknife-compiler:10.2.1'
implementation project(path: ':toasty')
implementation project(path: ':rangebar')
implementation project(path: ':smartlocation')
implementation files('libs/ImageBase64Encoder.jar')
implementation "ch.acra:acra-mail:$acraVersion"
implementation "ch.acra:acra-dialog:$acraVersion"
implementation 'de.hdodenhof:circleimageview:3.1.0'
implementation 'com.github.jrvansuita:PickImage:2.2.4'
implementation 'com.github.Cutta:TagView:1.3'
implementation 'com.github.jakebonk:ChipView:1.0.1'
implementation 'com.android.support:multidex:1.0.3'
implementation 'com.squareup.retrofit2:converter-scalars:2.8.1'
// date picker for persian date
implementation 'com.github.aliab:Persian-Date-Picker-Dialog:1.5.2'
def paging_version = "2.1.2"
implementation "androidx.paging:paging-runtime:$paging_version"
// For Kotlin use paging-runtime-ktx
// alternatively - without Android dependencies for testing
testImplementation "androidx.paging:paging-common:$paging_version"
// For Kotlin use paging-common-ktx
// optional - RxJava support
implementation "androidx.paging:paging-rxjava2:$paging_version"
// For Kotlin use paging-rxjava2-ktx
//implementation "com.google.firebase:firebase-analytics:$gmsVersion"
}
the other thread address with the same problem and answer which is not helping me is ,
Similar thread on StackOverflow
some other solutions that I've been trying:
- Invalidate Cache and Restart
- Clean Build
another project dependency is smartlocation which needs google play sevices as well, here is the gradle file for this module dependencies:
apply plugin: 'com.android.library'
android {
compileSdkVersion 27
defaultConfig {
minSdkVersion 19
targetSdkVersion 27
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.google.android.gms:play-services-location:15.0.0'
implementation 'com.android.support:support-annotations:27.1.1'
implementation 'com.android.support:appcompat-v7:27.1.1'
}
I don't see where you added dependency for 'androidx.recyclerview:recyclerview:1.1.0'. Please add "implementation 'androidx.recyclerview:recyclerview:1.1.0'" to your build.gradle file for module level.

Severely truncated attribute while compiling JavaFX Undertow Websockets project for Android with jfxmobile-plugin

I am having an issue while compiling my JavaFX project for Android.
The project includes a bunch of libraries, Undertow Websockets is among them. I downloaded all required jars to my lib directory and included them into dependencies / compile files block of build.gradle file.
I was able to solve other issues with jar-files dependencies (mostly DuplicateFileException), but one Undertow library - undertow-core-1.3.14.Final.jar gives me a little bit of a headache.
When I add it to compile file block of gradle.build file ‘gradlew android’ gives me an error message:
What went wrong: Execution failed for task ‘:createMainDexList’.
Exception in thread “main” com.android.dx.cf.iface.ParseException:
severely truncated attribute at
com.android.dx.cf.direct.StdAttributeFactory.throwSeverelyTruncated(StdAttributeFactory.java:736)
at
com.android.dx.cf.direct.StdAttributeFactory.runtimeVisibleParameterAnnotations(StdAttributeFactory.java:661)
at
com.android.dx.cf.direct.StdAttributeFactory.parse0(StdAttributeFactory.java:162)
at
com.android.dx.cf.direct.AttributeFactory.parse(AttributeFactory.java:96)
at
com.android.dx.cf.direct.AttributeListParser.parse(AttributeListParser.java:141)
at
com.android.dx.cf.direct.AttributeListParser.parseIfNecessary(AttributeListParser.java:115)
at
com.android.dx.cf.direct.AttributeListParser.getEndOffset(AttributeListParser.java:96)
at
com.android.dx.cf.direct.MemberListParser.parse(MemberListParser.java:213)
at
com.android.dx.cf.direct.MemberListParser.parseIfNecessary(MemberListParser.java:108)
at
com.android.dx.cf.direct.MethodListParser.getList(MethodListParser.java:54)
at
com.android.dx.cf.direct.DirectClassFile.parse0(DirectClassFile.java:542)
at
com.android.dx.cf.direct.DirectClassFile.parse(DirectClassFile.java:406)
at
com.android.dx.cf.direct.DirectClassFile.parseToEndIfNecessary(DirectClassFile.java:397)
at
com.android.dx.cf.direct.DirectClassFile.getAttributes(DirectClassFile.java:311)
at
com.android.multidex.MainDexListBuilder.hasRuntimeVisibleAnnotation(MainDexListBuilder.java:191)
at
com.android.multidex.MainDexListBuilder.keepAnnotated(MainDexListBuilder.java:167)
at
com.android.multidex.MainDexListBuilder.(MainDexListBuilder.java:121)
at
com.android.multidex.MainDexListBuilder.main(MainDexListBuilder.java:91)
at
com.android.multidex.ClassReferenceListBuilder.main(ClassReferenceListBuilder.java:58)
…while parsing RuntimeVisibleParameterAnnotations attribute at offset 0009c07 > …while parsing attributes[3]
…while parsing methods[1]
…while parsing io/undertow/client/http/HttpResponseParser$$generated.class
Below is my build.gradle file contents:
task wrapper(type: Wrapper) {
gradleVersion = '2.10'
}
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'org.javafxports:jfxmobile-plugin:1.0.7'
}
}
apply plugin: 'org.javafxports.jfxmobile'
apply plugin: 'java'
apply plugin: 'application'
sourceCompatibility = 1.8
targetCompatibility = 1.8
repositories {
jcenter()
}
mainClassName = 'com.simlayserstudio.SimlayserStudio'
jfxmobile {
android {
manifest = 'src/android/AndroidManifest.xml'
// compileSdkVersion = 16 // version 4.2.1
compileSdkVersion = 23 // version 6
packagingOptions {
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/INDEX.LIST'
exclude 'META-INF/services/io.undertow.attribute.ExchangeAttributeBuilder'
exclude 'META-INF/services/io.undertow.predicate.PredicateBuilder'
exclude 'META-INF/services/io.undertow.server.handlers.builder.HandlerBuilder'
//exclude 'META-INF/services/javax.annotation.processing.Processor'
}
}
ios {
infoPList = file('src/ios/Default-Info.plist')
}
}
dependencies {
compile ('commons-codec:commons-codec:1.10',
'commons-io:commons-io:2.4',
'commons-lang:commons-lang:2.6',
// 'io.undertow:undertow-servlet:1.3.14.Final' // Duplicate zip entry [allclasses.jar:javax/annotation/Generated.class
)
compile files(
'/lib/jboss-logging-3.2.1.Final.jar', //ok wtih exclude 'META-INF/INDEX.LIST'
// '/lib/undertow-core-1.3.14.Final.jar', // ERROR com.android.dx.cf.iface.ParseException: severely truncated attribute
'/lib/undertow-servlet-1.3.14.Final.jar', // ok wtih exclude ExchangeAttributeBuilder, PredicateBuilder, HandlerBuilder
'/lib/undertow-websockets-jsr-1.3.14.Final.jar', //ok with exclude 'META-INF/INDEX.LIST'
'/lib/xnio-api-3.3.4.Final.jar', //ok with exclude 'META-INF/INDEX.LIST'
'/lib/xnio-nio-3.3.4.Final.jar', //ok with exclude 'META-INF/INDEX.LIST'
'/lib/apache-commons.jar', //ok
'/lib/com.thoughtworks.xstream.jar', //ok
'/lib/javax.websocket-api-1.0.jar', //ok
'/lib/log4j-1.2.17.jar', //ok
'/lib/xmlpull-xpp3-1.1.4c.jar', //ok
)
}
Did anybody manage generating apk with Undertow Websockets, or encounter similar issues with 3-rd party libraries?
Any help would be much appreciated.
Thank you!
I've been able to reproduce the same error you've posted, just by using this dependencies and running ./gradlew android:
dependencies {
compile ('io.undertow:undertow-servlet:1.3.19.Final') {
exclude group: 'org.jboss.spec.javax.annotation'
}
compile ('io.undertow:undertow-core:1.3.19.Final') {
exclude group: 'org.jboss.spec.javax.annotation'
}
compile ('io.undertow:undertow-websockets-jsr:1.3.19.Final') {
exclude group: 'org.jboss.spec.javax.annotation'
}
}
So in order to find out about the possible issue, I've downloaded the io.undertow` sources from here, added the required dependencies (maybe I'm not using the exact versions):
dependencies {
compile 'org.jboss.logging:jboss-logging-annotations:2.0.1.Final'
compile 'org.jboss.classfilewriter:jboss-classfilewriter:1.0.4.Final'
compile 'org.eclipse.jetty.alpn:alpn-api:1.0.0'
compile 'org.jboss.xnio:xnio-nio:3.3.4.Final'
compile 'org.jboss.xnio:xnio-api:3.3.4.Final'
compile 'org.jboss.logging:jboss-logging:3.2.1.Final'
compile 'org.jboss.spec.javax.websocket:jboss-websocket-api_1.1_spec:1.1.0.Final'
compile 'org.jboss.spec.javax.servlet:jboss-servlet-api_3.1_spec:1.0.0.Final'
}
And to avoid duplicated classes from javax.annotation, I've downloaded the sources of org.jboss.spec.javax.annotation:jboss-annotations-api_1.1_spec from here, and removed these three classes: Generated.java, PostConstruct.java and PreDestroy.java.
I was able to run ./gradlew android successfully, but I haven't tested it.
In case you still have issues building it or later running it on the device, maybe you can consider other alternatives for websockets like the Tyrus project.
This is a project were we have used it successfully.

gradle: adding jar to web-inf

i have created a gradle build and added java, scala, war, jetty code and its all working fine.
apply plugin: 'java'
apply plugin: 'scala'
apply plugin: 'war'
apply plugin: 'jetty'
List compileTime = [
"javax.servlet:servlet-api:2.4#jar",
"org.scalatra:scalatra_2.8.0:2.0.0.M2#jar",
"org.mortbay.jetty:jetty:6.1.22#jar",
"com.mongodb.casbah:casbah_2.8.0:2.0.2#jar",
"org.scala-lang:scala-library:2.8.1#jar"
]
List runTime = [
"org.scalatra:scalatra_2.8.0:2.0.0.M2#jar",
"com.mongodb.casbah:casbah_2.8.0:2.0.2#jar",
"org.scala-lang:scala-library:2.8.1#jar"
]
// "org.mortbay.jetty:servlet-api:2.5-20081211#jar",
repositories {
mavenCentral()
mavenRepo urls: ["http://scala-tools.org/repo-releases","http://mirrors.ibiblio.org/pub/mirrors/maven2","http://repo1.maven.org/maven2","https://oss.sonatype.org/content/repositories/snapshots","https://oss.sonatype.org/content/repositories/releases"]
}
dependencies {
scalaTools 'org.scala-lang:scala-compiler:2.8.1'
scalaTools 'org.scala-lang:scala-library:2.8.1'
compile compileTime
runtime runTime
testCompile "junit:junit:3.8.2"
}
task myTask (type: War) {
println configurations.runtime.collect
println classpath()
}
war {
// from 'main/webapp'
webInf { from 'src/main/webapp/WEB-INF' }
// classpath classpath() /
classpath configurations.runtime
webXml = file('src/main/webapp/WEB-INF/web.xml')
}
I like to
1) Add only the necessary jars. in the war, in the above code i am getting Jetty and servlet jars in my war. !
For dependencies that should not go into the War, use the "providedCompile" or "providedRuntime" scope.
Some remarks on your build script:
You don't have to put dependencies on the "runtime" class path that are already on the "compile" class path. Gradle does this for you. Same for "providedCompile" and "providedRuntime".
Do you really have compile dependencies on servlet API and Jetty? (Could be true, just wondering.)
Your usage of "mavenRepo urls: ..." is wrong. You need to list the repos one by one. For more information, see 32.5.1 Maven repositories in the Gradle user guide.
Not sure why you use "#jar" everywhere. This effectively disables transitive dependency management. Maybe a result of 3. ?
Your "war { ... }" configuration is the default and can be omitted. See 23.6 War in the user guide.

Resources