Gradle DSL method not found: 'mavenCentral()' - java

pluginManagement {
repositories {
gradlePluginPortal()
mavenCentral()
mavenLocal()
maven {
url "s3://$s3_bucket"
authentication {
awsIm(AwsImAuthentication)
}
}
}
resolutionStrategy {
eachPlugin {
if (requested.id.namespace.startsWith('com.microservice')) {
useVersion "1.5.x"
}
}
}
}
Could not find method mavenCentral() for arguments [] on object of
type
org.gradle.plugin.repository.internal.DefaultPluginRepositoriesSpec.
in settings.gradle file. getting the error like above, how to fix this?

Related

No signature of method: build_8dh6mniy6si97pidyodkv8hy2.publishing() is applicable for argument types

I have a repository with the Avro schemas and I would like to publish it in the Gitlab private package. My Gradle file is below -
plugins {
id 'java'
id 'com.github.davidmc24.gradle.plugin.avro' version '1.5.0'
id 'maven-publish'
}
group = 'tech.seedz'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '11'
repositories {
mavenCentral()
}
dependencies {
implementation 'org.apache.avro:avro:1.11.1'
}
test {
useJUnitPlatform()
}
publishing {
publications {
library(MavenPublication) {
from components.java
}
}
repositories {
maven {
url "https://gitlab.com/api/v4/projects/7/packages/maven"
credentials(HttpHeaderCredentials) {
name = "Avro-Schema"
username "$mavenUser"
password "$mavenPassword"
}
authentication {
header(HttpHeaderAuthentication)
}
}
}
}
When I run the gradle publish, I get the following error,
A problem occurred evaluating root project 'los-avro-schema'.
> No signature of method: build_8dh6mniy6si97pidyodkv8hy2.publishing() is applicable for argument types: (build_8dh6mniy6si97pidyodkv8hy2$_run_closure4) values: [build_8dh6mniy6si97pidyodkv8hy2$_run_closure4#3e010b87]
What's this and how do I solve the problem?

I can't find allproject

sorry newbie here
i want use TextFieldBoxes
the installation need to find :
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
why i cant find allproject, here my build.gradle :
buildscript {
repositories {
google()
mavenCentral()
}
dependencies {
classpath "com.android.tools.build:gradle:7.0.2"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
help :D
use below code
maven { url 'https://www.jitpack.io' }

Error Prone and NullAway Illegal Access Exception

I am incorporating null away and error prone into my app and have added the following to my top-level build.gradle
buildscript {
repositories {
google()
maven { url 'https://plugins.gradle.org/m2/' }
...
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.2'
classpath "net.ltgt.gradle:gradle-errorprone-plugin:0.0.16"
}
}
subprojects {
apply from: rootProject.file("gradle/nullaway.gradle")
}
...
then in the nullaway.gradle file I have
buildscript {
repositories {
maven {
url "https://plugins.gradle.org/m2/"
}
}
}
apply plugin: 'net.ltgt.errorprone'
if (this.name == 'javalib1' || this.name == 'javalib2') {
apply plugin: 'java-library'
dependencies {
annotationProcessor deps.thirdparty.nullaway
errorprone deps.thirdparty.error_prone
}
} else {
if (this.name == 'app') {
apply plugin: 'com.android.application'
} else {
apply plugin: 'com.android.library'
}
dependencies {
annotationProcessor deps.thirdparty.nullaway
errorprone deps.thirdparty.error_prone
}
}
tasks.withType(JavaCompile) {
if (!name.toLowerCase().contains("test")) {
options.compilerArgs += [
"-Xep:NullAway:WARN",
"-XepOpt:NullAway:AnnotatedPackages=com.mypackage",
"-Xep:RestrictTo:WARN",
"-XepExcludedPaths:.*/build/generated/.*"]
}
}
With this setup whenever I try to build my app I get an exception
Caused by: java.lang.IllegalAccessError: tried to access class com.google.common.graph.BaseGraph from class com.google.common.graph.Traverser
at com.google.common.graph.Traverser.forTree(Traverser.java:134)
at dagger.internal.codegen.ValidationReport.<clinit>(ValidationReport.java:63)
at dagger.internal.codegen.InjectValidator.validateMembersInjectionType(InjectValidator.java:257)
at dagger.internal.codegen.InjectBindingRegistryImpl.tryRegisterMembersInjectedType(InjectBindingRegistryImpl.java:269)
at dagger.internal.codegen.InjectBindingRegistryImpl.tryRegisterMembersInjectedType(InjectBindingRegistryImpl.java:253)
at dagger.internal.codegen.InjectProcessingStep$1.visitVariableAsField(InjectProcessingStep.java:67)
at dagger.internal.codegen.InjectProcessingStep$1.visitVariableAsField(InjectProcessingStep.java:57)
at com.sun.tools.javac.code.Symbol$VarSymbol.accept(Symbol.java:1550)
at dagger.internal.codegen.InjectProcessingStep.process(InjectProcessingStep.java:56)
at dagger.shaded.auto.common.BasicAnnotationProcessor.process(BasicAnnotationProcessor.java:330)
at dagger.shaded.auto.common.BasicAnnotationProcessor.process(BasicAnnotationProcessor.java:181)
I check the notes and I am using dagger version 2.16 and as you can see I have the exclude for build/generated files. What am I missing?

How to extract buildscript from build.gradle

I have following buildscript section in my build.gradle:
buildscript {
ext {
nexusUrl = project.hasProperty("myNexusUrl") ? myNexusUrl : "http://10.199.0.99:8081/repository/maven-public/"
}
repositories {
maven { url nexusUrl }
}
dependencies {
classpath group: 'mygroup', name: 'MyGradleLibrary', version: '1.0.1'
}
}
How can I extract this code to external file, so that it doesn't break the build?
Create a plugin from your library and publish it to that Nexus. Then, add this lines in your settings.gradle:
pluginManagement {
repositories {
maven {
url "…"
}
gradlePluginPortal()
}
resolutionStrategy {
eachPlugin {
if (requested.id.namespace == 'mygroup.gradle-library') {
useModule('mygroup.gradle-library:1.0.1')
}
}
}
}
Here you state that you want to substitute mygroup.gradle-library plugin with mygroup.gradle-library:1.0.1 dependency.
Then just add a plugin in your build.gradle:
plugins {
id 'mygroup.gradle-library'
}
Now you have you dependency on the build classpath without buildscript block.
EDIT
In order to apply this to all your projects, put these lines in init script ~/.gradle/init.gradle ($GRADLE_USER_HOME/init.gradle):
settingsEvaluated {
pluginManagement {
repositories {
maven {
url "…"
}
gradlePluginPortal()
}
resolutionStrategy {
eachPlugin {
if (requested.id.namespace == 'mygroup.gradle-library') {
useModule('mygroup.gradle-library:1.0.1')
}
}
}
}
}
After that plugin blocks should work. However, it will work only for you but not for your teammates, unless they do the same.
If you don't like plugins you can still do "global" configuration via init scripts like demonstrated. Read more about the available APIs.

No signature of method: archives.internal.DefaultManifest.srcFile()

I am trying to setUp my first gradle project with android studio:
I am getting the following error, which does not make any sense to me since 'app/src/main/AndroidManifest.xml' is a string.
Error:(23, 0) No signature of method:
org.gradle.api.java.archives.internal.DefaultManifest.srcFile() is
applicable for argument types: (java.lang.String) values:
[app/src/main/AndroidManifest.xml]
The gradle build script looks like this:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.9.2'
classpath 'org.robolectric.gradle:gradle-android-test-plugin:0.9.4'
classpath "org.mockito:mockito-core:1.9.5"
}
}
apply plugin: 'android'
allprojects {
repositories {
mavenCentral()
}
}
sourceSets {
main {
manifest.srcFile("app/src/main/AndroidManifest.xml")
}
unitTest {
java.srcDir file('src/test/java')
resources.srcDir file('src/test/res')
}
}
configurations {
unitTestCompile.extendsFrom runtime
unitTestRuntime.extendsFrom unitTestCompile
}
dependencies {
repositories {
mavenCentral()
}
unitTestCompile files("$project.buildDir/classes/release")
unitTestCompile 'junit:junit:4.10'
unitTestCompile 'org.robolectric:robolectric:2.1.+'
unitTestCompile 'com.google.android:android:4.0.1.2'
}
task unitTest(type:Test, dependsOn: assemble) {
testClassesDir = project.sourceSets.unitTest.output.classesDir
classpath = project.sourceSets.unitTest.runtimeClasspath
}
android {
compileSdkVersion 19
buildToolsVersion "19.0.0"
}
check.dependsOn unitTest
Thanks for any help.
Torsten
The error message means that either there is no method named srcFile on sourceSets.main.manifest, or it doesn't accept a string as argument. (Often it's the former.) I think that what you are trying to configure here is android { sourceSets { ... } }, not sourceSets { ... }.

Categories