I try to set up the Mapbox vision sample app (https://github.com/mapbox/mapbox-vision-android), but not able to test the Mapbox Vision SDK sample app.
Dependency files are not downloading due to the Forbidden error.
Error :
Could not GET 'https://mapbox.bintray.com/mapbox/com/mapbox/navigator/mapbox-navigation-native/7.0.0/mapbox-navigation-native-7.0.0.pom'. Received status code 403 from server: Forbidden
Disable Gradle 'offline mode' and sync project.
Could you please share the details for how to fix this issue?
Followed the instructions mentioned on https://docs.mapbox.com/android/vision/guides/install/ page and used new tokens but the same issue still exists.
Gradle file:
allprojects {
repositories {
google()
jcenter()
maven { url "https://mapbox.bintray.com/mapbox" }
maven {
url 'https://api.mapbox.com/downloads/v1/vision/android/maven'
authentication {
basic(BasicAuthentication)
}
credentials {
username "mapbox"
password 'MAP_BOX_KEY'
}
}
maven { url 'http://raw.github.com/saki4510t/libcommon/master/repository/' }
}
}
Gradle dependency :
implementation "com.mapbox.mapboxsdk:mapbox-android-sdk:$mapbox_sdk"
implementation "com.mapbox.mapboxsdk:mapbox-android-navigation:$mapbox_navigation"
implementation "com.mapbox.mapboxsdk:mapbox-android-navigation-ui:$mapbox_navigation"
implementation "com.mapbox.mapboxsdk:mapbox-android-core:$mapbox_core"
implementation "com.mapbox.vision:mapbox-android-vision:0.13.0"
implementation "com.mapbox.vision:mapbox-android-vision-ar:0.13.0"
implementation "com.mapbox.vision:mapbox-android-vision-safety:0.13.0"
implementation 'com.mapbox.mapboxsdk:mapbox-sdk-turf:5.8.0'
implementation 'com.mapbox.mapboxsdk:mapbox-sdk-geojson:5.8.0'
implementation 'com.mapbox.mapboxsdk:mapbox-sdk-core:5.8.0'
implementation 'com.mapbox.mapboxsdk:mapbox-sdk-services:5.8.0'
Related
I have a Gradle 7.2 custom plugin that is working properly. I want to configure it to use the new Gradle Version Catalog for dependency information. I know how to configure and use the version catalog, and have generated a shared jar for our shared dependencies. It is being read by a few other builds without any issues.
However, I cannot seem to find the correct incantation to consume the version catalog jar by the plugin when it is setting dependencies. I keep getting "Extension of type 'VersionCatalogsExtension' does not exist".
Here are two snippets showing what I have done to access the version catalog in the apply method:
override fun apply(project: Project) {
val libs = project
.extensions
.getByType(VersionCatalogsExtension::class.java)
.named("libs")
addBuildDependencies(libs)
.
.
.
private fun Project.addBuildDependencies(libs: VersionCatalog) {
dependencies.apply {
// BOMs
add(JavaPlugin.IMPLEMENTATION_CONFIGURATION_NAME, platform(libs.findDependency("arrow.bom").get()))
add(JavaPlugin.IMPLEMENTATION_CONFIGURATION_NAME, platform(libs.findDependency("detekt.bom").get()))
I'd appreciate any snippets or redirects.
Thanks,
Mike
How are you applying the plugin?
I noticed that if you're trying to do it from an allProjects or subprojects block it doesn't work, it fails with this error:
Extension of type 'VersionCatalogsExtension' does not exist. Currently registered extension types: ...
I assume this the same reason why we can't use libs directly inside those blocks, see this comment for more details.
A solution is to reference the custom plugin directly in the projects that will use it and avoid cross-configuration.
Please make sure you add this block of code in your settings.gradle.kts file
enableFeaturePreview("VERSION_CATALOGS")
// == Define locations for components ==
dependencyResolutionManagement {
repositories {
google()
mavenCentral()
gradlePluginPortal()
}
versionCatalogs {
create("libs") {
from(files("PATH/libs.versions.toml"))
}
}
}
I am new to Gradle, but need to build an opensource project that uses it, from my machine on the corporate network. The project has recently moved to Kotlin DSL, so some plugins are required.
I need to use our corporate Nexus server to fetch the plugin dependencies, and I would like to set this globally, because I don't want to have to modify the settings.gradle.kts in all the projects (I've tried this and it works)
If I want to do this globally, I understand from https://docs.gradle.org/current/userguide/plugins.html#sec:plugin_management that I need to have an init.gradle.kts file in my USER_HOME/.gradle directory. That's what I did, here's the content of the file :
settingsEvaluated { settings ->
settings.pluginManagement {
repositories {
mavenLocal()
maven("https://my_corporate_nexus/")
}
}
}
But when I then trigger my build, here's what I get :
* What went wrong:
Script compilation errors:
Line 1: settingsEvaluated { settings ->
^ None of the following functions can be called with the arguments supplied:
public open fun settingsEvaluated(p0: Closure<(raw) Any!>): Unit defined in Init_gradle
public open fun settingsEvaluated(p0: Action<in Settings!>): Unit defined in Init_gradle
public final fun settingsEvaluated(p0: Settings!.() -> Unit): Unit defined in Init_gradle
Below are my version details, as provided by gradle -v :
Gradle 4.9
Kotlin DSL: 0.18.4
Kotlin: 1.2.41
Groovy: 2.4.12
So it looks likes there's something obvious I am missing.
Any idea what it could be ?
it seems to work with :
settingsEvaluated {
settings.pluginManagement {
repositories {
mavenLocal()
maven("https://my_corporate_nexus/")
}
}
}
no settings -> .
I am not sure whether documentation is wrong or if my setup is specific though...
While trying to upgrade some of our scripts to Gradle 4.0.1 on of the plugins we are using is failing and I thought of fixing that plugin first. The plugin is a third party open source project.
So I have cloned the project and tried to compile it. However it fails with following message:
c:\source\gradle-xld-plugin>gradlew build
FAILURE: Build failed with an exception.
* Where:
Build file 'C:\source\gradle-xld-plugin\build.gradle' line: 2
* What went wrong:
Plugin [id: 'com.gradle.plugin-publish', version: '0.9.7'] was not found in
any of the following sources:
- Gradle Core Plugins (plugin is not in 'org.gradle' namespace)
- maven(https://artifactory/java-v) (Could not resolve plugin artifact 'com.gradle.plugin-publish:com.gradle.plugin-publish.gradle.plugin:0.9.7')
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --
debug option to get more log output.
BUILD FAILED in 0s
The build.gradle script for the plugin starts like this:
plugins {
id "com.gradle.plugin-publish" version "0.9.7"
id "com.github.hierynomus.license" version "0.11.0"
id 'nebula.nebula-release' version '4.0.1'
id "com.jfrog.bintray" version "1.7.3"
}
In addition to this the company policy dictates we have to go through an internal artifactory server, so following has been added to the settings.gradle file:
pluginManagement {
repositories {
maven {
url "https://artifactory/java-v"
}
}
}
The jar file exists at following location: https://artifactory/java-v/com/gradle/publish/plugin-publish-plugin/0.9.7/plugin-publish-plugin-0.9.7.jar
but when I look at the error message I am a little puzzled that it says that it cannot find com.gradle.plugin-publish:com.gradle.plugin-publish.gradle.plugin:0.9.7.
It seems to have suffixed the id with .gradle.plugin.
Does anyone know whether I am looking at the wrong location or how come it is suffixing the id with .gradle.plugin. And shouldn't it look at a location that has the GAV like this: com.gradle.plugin-publish:com.gradle.plugin-publish:0.9.7?
And does anyone know about how the resolution mechanism for the new plugin mechanism in Gradle works.
Thanks in advance
Edit
Thanks to Mateusz Chrzaszcz I was able to progress.
The only caveat I have with the solution is that it seems like a workaround rather than a solution. But it works!
In addition to his solution you had to resolve the plugins. I was able to hack my way to actually resolve the appropriate names.
In order to do so one has to do as follows:
In a webbrowser go for the plugin: id "com.github.hierynomus.license" version "0.11.0" go to following URL: https://plugins.gradle.org/api/gradle/4.0.1/plugin/use/com.github.hierynomus.license/0.11.0
The json returned contains the GAV needed in the useModule call. Use that
The following serves as an example:
resolutionStrategy {
eachPlugin {
if (requested.id.namespace == 'com.gradle' && requested.id.name == 'plugin-publish') {
useModule('com.gradle.publish:plugin-publish-plugin:0.9.7')
} else if(requested.id.namespace == 'com.github.hierynomus' && requested.id.name == 'license') {
useModule('nl.javadude.gradle.plugins:license-gradle-plugin:0.11.0')
}
}
}
Try to implement Plugin Resolution Rules.
According to gradle documentation:
Plugin resolution rules allow you to modify plugin requests made in plugins {} blocks, e.g. changing the requested version or explicitly specifying the implementation artifact coordinates.
To add resolution rules, use the resolutionStrategy {} inside the pluginManagement {} block
like that:
pluginManagement {
resolutionStrategy {
eachPlugin {
if (requested.id.namespace == 'com.gradle.plugin-publish') {
useModule('com.gradle.plugin-publish:0.9.7') //try a few combinations
}
}
}
repositories {
maven {
url 'https://artifactory/java-v'
}
}
}
Keep in mind this is incubating feature though.
I have several Grails 3 projects. Most are plugins and one is the main app that depends on the plugins.
Can someone who has successfully published a Grails 3 project to an Artifactory repo tell me how you did it? What gradle plugin do you use and what do you need to add to your build.gradle to make it work?
Regards,
Rob
I blogged the answer:
http://rvanderwerf.blogspot.com/2015/07/how-to-publish-grails-3-plugin.html
Basically you need to strip out anything in the POM with no version on it as Grails/Boot managed those deps.
I just started working with grails 3, specifically version 3.2.8.
I found that placing the following entry at the end of build.gradle works where artifactory_user, artifactory_password, artifactory_snapshotUrl, and artifactory_releaseUrl are defined in gradle.properties.
publishing {
repositories {
maven {
credentials {
username artifactory_user
password artifactory_password
}
if (version.endsWith('SNAPSHOT')) {
url artifactory_snapshotUrl
} else {
url artifactory_releaseUrl
}
}
}
}
File gradle.properties reads:
grailsVersion=3.2.8
grailsWrapperVersion=1.0.0
gormVersion=6.0.9.RELEASE
gradleWrapperVersion=3.4.1
app_version=0.0.1-SNAPSHOT
artifactory_user=admin
artifactory_password=password
artifactory_contextUrl=http://myserver.myorg.org:8081/artifactory
artifactory_snapshotUrl=http://myserver.myorg.org:8081/artifactory/libs-snapshot-local
artifactory_releaseUrl=http://myserver.myorg.org:8081/artifactory/libs-release-local
I have project wide settings in a plugin, called parent, that attempts to apply the maven-publish plugin and then programmatically configure the publishing extension. This seems to work but when I apply this plugin in a build.gradle script I can not configure publishing extension to set the project specific publications.
I receive the error:
Cannot configure the 'publishing' extension after it has been accessed.
My intent was to set up the publishing repository in the parent plugin and then let each build.gradle script add the appropriate publications.
Is there a way to do this?
Currently ParentPlugin.groovy looks like:
def void apply(Project project) {
project.getProject().apply plugin: 'maven-publish'
def publishingExtension = project.extensions.findByName('publishing')
publishingExtension.with {
repositories {
maven {
mavenLocal()
credentials {
username getPropertyWithDefault(project.getProject(), 'publishUserName', 'dummy')
password getPropertyWithDefault(project.getProject(), 'publishPassword', 'dummy')
}
}
}
}
}
My client build.gradle fails when it tries to configure the publishing extension.
apply plugin: 'parent'
publishing {
publications {
mavenJava(MavenPublication) {
groupId 'agroup'
artifactId 'anartifactid'
version '1.0.0-SNAPSHOT'
from components.java
}
}
}
Is this possible? Is there another way I should be approaching this?
NOTE regarding repositories{} and publications{} for plugin maven-publish:
Topic: How to workaround this perplexing gradle fatal error message:
Cannot configure the 'publishing' extension after it has been accessed
First thing to try (deep magic):
(note "project." prefix is optional)
-- Configure publications and repositories not like this:
project.publishing {publications {...}}
project.publishing {repositories {...}}
but instead like this recommended style:
project.publishing.publications {...}
project.publishing.repositories {...}
It would be instructive for a gradle guru to explain why this trick works.
Another known workaround is to make sure that each apply of plugin
maven-publish is in the same project code block as
project.publishing.repositories and project.publishing.publications.
But that is more complex and harder to do than the first thing to try,
since by default the CBF applies maven-publish and a second apply of it
may itself cause the same error.
maven-publish is normally applied in pub/scripts/publish-maven.gradle,
unless PUB_PUBLISH_MAVEN is set to override that file location,
in which case the caller should apply plugin maven-publish.
See https://orareview.us.oracle.com/29516818 for how this not-preferred
workaround can be done (for project emcapms) while still using the CBF.
P.S. Someday I'll write this up with minimal code examples. But I'm putting this hard-won knowedge out there now to save other folks from wasting days on this common maven-publish issue.
To deal with this, I wrote another plugin, which can delay modifications to the publication while also avoid a "reading" of the extension, which would put it in the "configured" state. The plugin is called nebula-publishing-plugin, the code for the "lazy" block can be found in the github repo. It looks like this:
/**
* All Maven Publications
*/
def withMavenPublication(Closure withPubClosure) {
// New publish plugin way to specify artifacts in resulting publication
def addArtifactClosure = {
// Wait for our plugin to be applied.
project.plugins.withType(PublishingPlugin) { PublishingPlugin publishingPlugin ->
DefaultPublishingExtension publishingExtension = project.getExtensions().getByType(DefaultPublishingExtension)
publishingExtension.publications.withType(MavenPublication, withPubClosure)
}
}
// It's possible that we're running in someone else's afterEvaluate, which means we need to run this immediately
if (project.getState().executed) {
addArtifactClosure.call()
} else {
project.afterEvaluate addArtifactClosure
}
}
You would then call it like this:
withMavenPublication { MavenPublication t ->
def webComponent = project.components.getByName('web')
// TODO Include deps somehow
t.from(webComponent)
}
The plugin is available in jcenter() as 'com.netflix.nebula:nebula-publishing-plugin:1.9.1'.
A little bit late, but I found a solution that does not require an additional plugin:
(This has been taken from one of my internal plugins, that can work with old and new publishing, thus the ...withType... stuff.
instead of:
project.plugins.withType(MavenPublishPlugin) {
project.publishsing {
publications {
myPub(MavenPublication) {
artifact myJar
}
}
}
}
do this:
project.plugins.withType(MavenPublishPlugin) {
project.extensions.configure PublishingExtension, new ClosureBackedAction( {
publications {
myPub(MavenPublication) {
artifact myJar
}
}
})
}
This will not resolve the Extension immediately, but will apply the configuration at the time when it gets first resolved by someone.
Of course it would perfectly make sense to use this style of configuration in your project-wide plugin to configure the repositories and use the publication extension in the build scripts as usual. This would avoid confusion for buildscript authors.