How to solve this error?
Error:(24, 1) A problem occurred evaluating root project 'myproject10'.
Failed to apply plugin [id 'org.gradle.checkstyle']
Could not create service of type CachingFileHasher using TaskExecutionServices.createFileSnapshotter().
subprojects {
def projectName = it.name
if (projectName != "graphql-java-support") {
apply from: "../gradle/dependencies.gradle"
}
buildscript {
System.properties['com.android.build.gradle.overrideVersionCheck'] = 'true'
repositories {
jcenter()
maven { url "https://jitpack.io" }
maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
}
}
repositories {
jcenter()
maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
maven { url 'https://maven.google.com' }
}
if (projectName != "graphql-java-support") {
apply plugin: 'checkstyle'
checkstyle {
toolVersion = "5.9"
configFile rootProject.file('checkstyle.xml')
configProperties = ['checkstyle.cache.file': rootProject.file('build/checkstyle.cache')]
ignoreFailures false
showViolations true
}
task checkstyle(type: Checkstyle) {
source 'src/main/java'
include '**/*.java'
classpath = files()
}
afterEvaluate {
if (project.tasks.findByName('check')) {
check.dependsOn('checkstyle')
}
}
}
}
project.ext.preDexLibs = !project.hasProperty('disablePreDex')
subprojects {
project.plugins.whenPluginAdded { plugin ->
if ("com.android.build.gradle.AppPlugin".equals(plugin.class.name)) {
project.android.dexOptions.preDexLibraries = rootProject.ext.preDexLibs
} else if ("com.android.build.gradle.LibraryPlugin".equals(plugin.class.name)) {
project.android.dexOptions.preDexLibraries = rootProject.ext.preDexLibs
}
}
}
Related
my project has two different build.gradle files written with groovy Syntax.
I´d like to change this groovy written gradle file into a gradle file written with Kotlin Syntax (build.gradle.kts).
I´ll show you the root project build.gradle file.
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
//ext.kotlin_version = '1.2-M2'
ext.kotlin_version = '1.1.51'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.0-alpha01'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
allprojects {
repositories {
google()
jcenter()
mavenCentral()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
I tried several "ways" i found in the internet, but nothing worked. Renaming the file, which is obviously not the Solution, didn´t help. I´ve created a new build.gradle.kts file in my root project but the file isn´t shown in my project.
Also gradle didn´t recognize the new file.
So my question is: How can i transform my groovy build.gradle file into a kotlin build.gradle.kts and add this new file into my existing project?
Thanks for your help.
Of course renaming won't help. You'll need to re-write it using Kotlin DSL. It is similar to Groovy, but with some differences. Read their docs, look at the examples.
In your case, the issues are:
ext.kotlin_version is not valid Kotlin syntax, use square brackets
All Kotlin strings use double quotes
Braces are required around parameters for most function calls (there are exceptions, like infix functions)
Slighlty different task management API. There are different styles available. You can declare all the tasks in tasks block as strings, or use a single typed function, as in the example below.
Take a look at the converted top-level build.gradle.kts:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext["kotlin_version"] = "1.1.51"
repositories {
google()
jcenter()
}
dependencies {
classpath ("com.android.tools.build:gradle:3.1.0-alpha01")
classpath ("org.jetbrains.kotlin:kotlin-gradle-plugin:${ext["kotlin_version"]}")
}
}
allprojects {
repositories {
google()
jcenter()
mavenCentral()
}
}
task<Delete>("clean") {
delete(rootProject.buildDir)
}
buildscript {
extra.apply {
var kotlin_version = "1.7.10"
var navigationVersion = "2.5.0"
var hilt_version = "2.42"
}
// .kotlin_version("1.7.10")
// ext.navigationVersion("2.5.0")
// ext.hilt_version("2.42")
repositories {
gradlePluginPortal()
google()
mavenCentral()
jcenter()
}
dependencies {
classpath("com.android.tools.build:gradle:7.2.1")
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.10")
classpath("androidx.navigation:navigation-safe-args-gradle-plugin:2.5.0")
classpath("com.google.firebase:firebase-crashlytics-gradle:2.9.1")
classpath("com.google.gms:google-services:4.3.13")
classpath("com.google.firebase:perf-plugin:1.4.1")
classpath("com.google.dagger:hilt-android-gradle-plugin:2.42")
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
// classpath("com.google.dagger:hilt-android-gradle-plugin:$extra.hilt_version")
}
}
allprojects {
repositories {
gradlePluginPortal()
mavenCentral()
google()
jcenter()
maven { url = uri("https://jitpack.io") }
maven { url = uri("https://cdn.veriff.me/android/") }
flatDir {
dirs("libs")
}
}
}
tasks.register("clean"){
delete(setOf(rootProject.buildDir))
}
import extensions.*
import java.time.LocalDate
import java.time.format.DateTimeFormatter.*
plugins {
id(Plugins.ANDROID_APPLICATION)
id(Plugins.ANDROID)
id(Plugins.PARCELIZE)
id(Plugins.KAPT)
id(Plugins.NAVIGATION_SAFE_ARGS)
id(Plugins.GOOGLE_SERVICES)
id(Plugins.CRASH_ANALYTICS)
id(Plugins.PERFORMANCE_ANALYTICS)
id(Plugins.DAGGER_HILT)
}
var applicationName = "abc`enter code here`"
android {
compileSdk = AndroidConfig.COMPILE_SDK
bundle {
language {
enableSplit = false
}
}
defaultConfig {
configurations.all {
resolutionStrategy { force(AndroidConfig.FORCE_STRATEGY) }
}
applicationId = AndroidConfig.APPLICATION_ID
minSdkVersion(AndroidConfig.MIN_SDK)
targetSdkVersion(AndroidConfig.TARGET_SDK)
versionCode = AndroidConfig.VERSION_CODE
versionName = AndroidConfig.VERSION_NAME
testInstrumentationRunner = AndroidConfig.TEST_INSTRUMENTATION_RUNNER
//javaCompileOptions.annotationProcessorOptions.arguments['dagger.hilt.disableModulesHaveInstallInCheck'] = 'true'
}
applicationVariants.all {
outputs.all {
var formattedDate = LocalDate.now()//LocalDate.now().format(ofPattern("yyyy-MM-dd"))
var outputFileName =
"${applicationName}_${buildType.name}_${formattedDate}_v${defaultConfig.versionName}.apk"
}
}
buildTypes {
getByName("debug") {
// minifyEnabled = "false"
isMinifyEnabled = false
isTestCoverageEnabled = true
isShrinkResources = false
isDebuggable = true
proguardFiles(getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro")
testProguardFiles(getDefaultProguardFile("proguard-android.txt"),
"proguardTest-rules.pro")
// FirebasePerformance {
// // Set this flag to 'false' to disable #AddTrace annotation processing and
// // automatic HTTP/S network request monitoring
// // for a specific build variant at compile time.
// isInstrumentationEnabled = true
// }
}
getByName("release") {
isMinifyEnabled = false
isShrinkResources = false
proguardFiles(getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro")
testProguardFiles(getDefaultProguardFile("proguard-android.txt"),
"proguardTest-rules.pro")
}
}
buildFeatures {
viewBinding = true
dataBinding = true
}
// compileOptions {
// sourceCompatibility = JavaVersion.VERSION_11
// targetCompatibility = JavaVersion.VERSION_11
// }
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = JavaVersion.VERSION_11.toString()
//freeCompilerArgs= ["-Xjvm-default=compatibility"]
freeCompilerArgs = listOf("-Xjvm-default=compatibility")
// freecompilerargs = List( -Xjvm-default=compatibility)
}
flavorDimensions("mode")
productFlavors {
maybeCreate("Staging")
maybeCreate("PreProduction")
maybeCreate("Production")
getByName("Staging") {
applicationIdSuffix = ".staging"
//versionNameSuffix = ".staging"
}
getByName("Production") {
dimension = "mode"
resValue("string", "app_name", "abc")
}
}
packagingOptions {
resources.excludes += "META-INF/DEPENDENCIES"
resources.excludes += "META-INF/NOTICE"
resources.excludes += "META-INF/LICENSE"
resources.excludes += "META-INF/LICENSE.txt"
resources.excludes += "META-INF/NOTICE.txt"
// excludes += ['META-INF/DEPENDENCIES', 'META-INF/NOTICE', 'META-INF/LICENSE', 'META-INF/LICENSE.txt', 'META-INF/NOTICE.txt']
}
dynamicFeatures += setOf(":BuyCryptoModule",":"points")
}
dependencies {
//includeing file libs
val daggerVersion = "2.42"
implementation(fileTree(mapOf("dir" to "libs", "include" to listOf("*.jar"))))
implementation(files("geetest_captcha_android_v1.7.1.1_20220308"))
appModuleDeps()
kaptAndroidTest("com.google.dagger:hilt-compiler:2.42")
// For local unit tests
testImplementation("com.google.dagger:hilt-android-testing:2.42")
kaptTest("com.google.dagger:hilt-compiler:2.42")
implementation(files("libs/opencsv-5.2.jar"))
kaptAndroidTest("com.google.dagger:dagger-compiler:$daggerVersion")
kaptTest("com.google.dagger:dagger-compiler:$daggerVersion")
releaseImplementation("com.github.ChuckerTeam.Chucker:library-no-op:3.5.2")
}
kapt {
correctErrorTypes = true
arguments {
// Make Hilt share the same definition of Components in tests instead of
// creating a new set of Components per test class.
arg("dagger.hilt.shareTestComponents", "true")
}
}
I try to build java library using android studio and want to host at my local artifactory.
I face this problem at noon. Try different code, but no improvements.
buildscript {
repositories {
jcenter()
}
repositories {
maven {
url 'http://localhost:8081/artifactory/libs-release-local'
credentials {
username = "${artifactory_user}"
password = "${artifactory_password}"
}
name = "maven-main-cache"
}
}
dependencies {
classpath "org.jfrog.buildinfo:build-info-extractor-gradle:3.0.1"
}
}
project.getExtensions().getByName("ext")
apply plugin: 'scala'
apply plugin: 'maven-publish'
apply plugin: "com.jfrog.artifactory"
version = '1.0.0-SNAPSHOT'
group = 'com.buransky'
repositories {
add buildscript.repositories.getByName("maven-main-cache")
}
dependencies {
compile 'org.scala-lang:scala-library:2.11.2'
}
tasks.withType(ScalaCompile) {
scalaCompileOptions.useAnt = false
}
artifactory {
contextUrl = "${artifactory_contextUrl}"
publish {
repository {
repoKey = 'libs-snapshot-local'
username = "${artifactory_user}"
password = "${artifactory_password}"
maven = true
}
defaults {
publications ('mavenJava')
}
}
}
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
}
}
}
Above my build.gradle code block.
Please help. I didn't found any solutions in google
Looking here it looks like it's
artifactory {
publish {
repository {
ivy {
mavenCompatible = true
}
}
}
}
Instead of
artifactory {
publish {
repository {
maven = true
}
}
}
I have a multiproject build where I need to publish some dependencies to a custom local Maven repository on disk and then add this folder to a distribution zip.
I define publishing tasks for each subproject using the maven-publish plugin.
subprojects {
apply plugin: 'maven-publish'
configurations {
offlineDependencies
}
publishing {
publications {
configurations.each { config ->
if (config.name == "offlineDependencies") {
def files = config.files
config.dependencies.each { dep ->
files.each { file ->
if (file.name == "${dep.name}-${dep.version}.jar") {
"${dep.name}"(MavenPublication) {
artifact (file) {
groupId = "${dep.group}"
artifactId = "${dep.name}"
version = "${dep.version}"
}
}
}
}
}
}
}
}
repositories {
maven {
name 'dependencies'
url '../build/repository'
}
}
}
}
Using the distribution plugin I create a zip file
distributions {
release {
baseName 'release'
contents {
from('src/main/resources/')
into("repository"){
from("$buildDir/repository")
}
}
}
}
How can I make sure that all the dynamically created publish tasks are run before creating the zip file?
I tried making a new task for all subprojects that depends on the dynamically created tasks, but it seems they're not created yet at that time.
subprojects {
task offlineDep << {
println 'Creating offline dependencies'
}
offlineDep.dependsOn {
tasks.findAll { task -> task.name.endsWith('PublicationToDependenciesRepository') }
}
}
I found a solution to this problem. By collecting the names of the artifacts and generating the tasknames I know will be created later and adding them as dependencies.
subprojects {
apply plugin: 'maven-publish'
def offlineDependencyNames = []
publishing {
publications {
configurations.each { config ->
if (config.name == "offlineDependencies") {
def files = config.files
config.dependencies.each { dep ->
files.each { file ->
if (file.name == "${dep.name}-${dep.version}.jar") {
offlineDependencyNames << dep.name
"${dep.name}"(MavenPublication) {
artifact (file) {
groupId = "${dep.group}"
artifactId = "${dep.name}"
version = "${dep.version}"
}
}
}
}
}
}
}
}
repositories {
maven {
name 'dependencies'
url "${rootProject.buildDir}/repository"
}
}
}
task publishOfflineDependencies
publishOfflineDependencies.dependsOn {
offlineDependencyNames.collect { name ->
"publish${name[0].toUpperCase()}${name.substring(1)}PublicationToDependenciesRepository"
}
}
}
releaseDistZip.dependsOn {
subprojects.collect {
p -> p.path + ':publishOfflineDependencies'
}
}
To integrate Cucumber with Serenity, I have created below Gardle file. Serenity is working fine, however I am not able to use it with Cucumber. When I use #RunWith(CucumberWithSerenity.class) in runner class, it gives me unresolved type error.
build.gradle:
apply plugin: "java"
apply plugin: "maven"
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'net.serenity-bdd.aggregator'
apply plugin: 'com.jfrog.bintray'
group = "myorg"
version = 1.0
repositories {
maven {
url "http://nexus2.sdmc.ao-srv.com/content/groups/inhouse_dit/"
}
}
buildscript {
repositories {
maven {
url "http://nexus2.sdmc.ao-srv.com/content/groups/inhouse_dit/"
}
}
dependencies {
classpath("net.serenity-bdd:serenity-gradle-plugin:1.0.47")
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:0.6'
}
}
ext {
bintrayBaseUrl = 'https://api.bintray.com/maven'
bintrayRepository = 'maven'
bintrayPackage = 'serenity-cucumber'
projectDescription = 'Serenity Cucumber integration'
if (!project.hasProperty("bintrayUsername")) {
bintrayUsername = 'wakaleo'
}
if (!project.hasProperty("bintrayApiKey")) {
bintrayApiKey = ''
}
serenityCoreVersion = '1.0.49'
cucumberJVMVersion = '1.2.2'
//versionCounter = new ProjectVersionCounter(isRelease: project.hasProperty("releaseBuild"))
}
sourceSets.all { set ->
def jarTask = task("${set.name}Jar", type: Jar) {
baseName = baseName + "-$set.name"
from set.output
}
artifacts {
archives jarTask
}
}
sourceSets {
api
impl
}
dependencies {
apiCompile 'commons-codec:commons-codec:1.5'
implCompile sourceSets.api.output
implCompile 'commons-lang:commons-lang:2.6'
compile "info.cukes:cucumber-java:${cucumberJVMVersion}"
compile "info.cukes:cucumber-junit:${cucumberJVMVersion}"
testCompile 'net.serenity-bdd:core:1.0.47'
testCompile 'net.serenity-bdd:serenity-junit:1.0.47'
testCompile('junit:junit:4.11')
testCompile('org.assertj:assertj-core:1.7.0')
testCompile('org.slf4j:slf4j-simple:1.7.7')
testCompile sourceSets.api.output
testCompile sourceSets.impl.output
testCompile 'org.codehaus.groovy:groovy-all:2.3.6'
testCompile("org.spockframework:spock-core:0.7-groovy-2.0") {
exclude group: "junit"
exclude module: "groovy-all"
}
testCompile("com.github.goldin:spock-extensions:0.1.4") {
exclude module: "spock-core"
exclude module: "slf4j-api"
}
runtime configurations.apiRuntime
runtime configurations.implRuntime
}
gradle.startParameter.continueOnFailure = true
jar {
from sourceSets.api.output
from sourceSets.impl.output
manifest {
attributes("Implementation-Title": "Serenity Cucumber Plugin",
"Implementation-Version": project.version.toString())
}
}
task sourcesJar(type: Jar, dependsOn: classes) {
classifier = 'sources'
from sourceSets.main.allSource
}
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
}
artifacts {
archives sourcesJar, javadocJar
}
bintray {
user = bintrayUsername //this usually comes form gradle.properties file in ~/.gradle
key = bintrayApiKey //this usually comes form gradle.properties file in ~/.gradle
publications = ['mavenJava'] // see publications closure
pkg {
repo = 'maven'
userOrg = 'serenity'
name = 'serenity-cucumber'
desc = 'Serenity Cucumber integration'
licenses = ['Apache-2.0']
labels = ['serenity','bdd','cucumber']
}
}
uploadArchives {
repositories {
mavenDeployer {
repository(url: uri("${buildDir}/repo"))
addFilter("main") { artifact, file -> artifact.name == project.name }
["api", "impl"].each { type ->
addFilter(type) { artifact, file -> artifact.name.endsWith("-$type") }
// We now have to map our configurations to the correct maven scope for each pom
["compile", "runtime"].each { scope ->
configuration = configurations[type + scope.capitalize()]
["main", type].each { pomName ->
pom(pomName).scopeMappings.addMapping 1, configuration, scope
}
}
}
}
}
}
task wrapper (type: Wrapper) {
gradleVersion = '2.3'
distributionUrl = 'http://nexus2.sdmc.ao-srv.com/content/repositories/inhouse_dit_thirdparty/org/gradle/gradle-bin/2.3/gradle-2.3-bin.zip'
}
Please suggest what I need to change to run serenity with Cucumber. Thanks in advance.
You need to add serenity-cucumber to your dependencies:
testCompile 'net.serenity-bdd:serenity-cucumber:1.0.17'
Following line fixed the issue for me (gradle 4.10):
testCompile group: 'net.serenity-bdd', name: 'serenity-cucumber', version: '1.9.40'
Have an err with compiling gradle idea
error see on screen
http://upwap.ru/1884422
apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'code-quality'
apply plugin: 'groovy'
apply plugin: 'eclipse'
apply plugin: 'project-reports'
sourceCompatibility = 1.6 archivesBaseName = 'opas-client'
ideaModule { downloadJavadoc = true }
buildscript {
repositories {
mavenRepo urls: "f:/dev/lib/"
}
}
version = '0.1'
gradle.taskGraph.whenReady {taskGraph ->
if (taskGraph.hasTask(':release')) {
version = '0.1.2' // } else { // version = '1.0.624'
}
}
repositories {
mavenRepo urls: "f:/dev/lib/"
}
dependencies {
groovy group: 'org.codehaus.groovy', name: 'groovy-all', version: '1.7.5'
compile 'log4j:log4j:1.2.14',
'com.caucho:hessian:4.0.7',
'com.toedter:jcalendar:1.3.2',
'org.springframework:spring-context-support:3.0.5.RELEASE',
'org.springframework:spring-web:3.0.5.RELEASE',
'com.jgoodies:looks:2.2.2',
'com.jgoodies:animation:1.2.0',
'com.jgoodies:binding:2.0.6',
'com.jgoodies:forms:1.2.1',
'com.jgoodies:validation:2.0.1'
testCompile 'junit:junit:4.7',
'org.unitils:unitils-spring:3.1',
'org.unitils:unitils-easymock:3.1',
'org.unitils:unitils-inject:3.1',
'org.springframework:spring-test:3.0.5.RELEASE'
}
manifest.mainAttributes(
'Implementation-Title': 'victoria',
'Implementation-Version': version,
'Main-Class': 'com.sirius.opas.client.Client',
'Class-Path':manifestClasspath() )
task release(dependsOn: 'jar') << {
ant.delete(dir:releaseDir, quiet:"true" )
ant.mkdir(dir:releaseDir)
copy {
from configurations.compile
into "${releaseDir}/${releaseLibDir}"
}
copy {
from "$libsDir/${archivesBaseName}-${version}.jar"
from "dist/start.sh"
from "dist/start.cmd"
into "${releaseDir}"
}
}
String manifestClasspath() {
String classes = ""
configurations.compile.files.each { file ->
classes += " ${releaseLibDir}/${file.name}"
}
return classes
}
I think you are simply missing a dependency that provides BeanDefinition class. Try adding 'org.springframework:spring-beans:3.0.5.RELEASE' to your compile dependencies list.