I am trying to use SimpleNativeHooks in my kotlin gradle project. I use the kotlin gradle dsl, but SimpleNativeHooks can not be found and downloaded. The error I get is:
:KJ:launch:test: Could not find org.repeats.simplenativehooks:simplenativehooks:0.0.1.
Required by:
project :KJ:launch
Possible solution:
- Declare repository providing the artifact, see the documentation at https://docs.gradle.org/current/userguide/declaring_repositories.html
The code I am currently using for the repo is:
dependencyResolutionManagement {
repositories{
maven {
url = java.net.URI("https://raw.github.com/repeats/SimpleNativeHooks/maven-export/")
}
}
}
But on the github README, the maven example includes a few others as well. I'm wondering if the reason I'm getting an error in my gradle build is because I haven't properly converted that maven code into gradle, maybe because I missed some of those fields (like the repo id, which I don't know how to include in gradle).
This URL is not a fair maven repository (it returns 400: Invalid request after 301: Permanent redirect), so you need to give Gradle a hint, where to look for artifacts metadata - in this case, there is pom.xml in the root :
maven {
url = uri("https://raw.github.com/repeats/SimpleNativeHooks/maven-export/")
metadataSources {
mavenPom()
}
}
Related
I am currently building an android navigation app and have run into an issue. The full error is:
Execution failed for task ':app:checkDebugAarMetadata'.
Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
Could not find com.mapbox.navigator:mapbox-navigation-native:7.0.0.
> Searched in the following locations:
>- https://dl.google.com/dl/android/maven2/com/mapbox/navigator/mapbox-navigation-native/7.0.0/mapbox-navigation-native-7.0.0.pom
> - https://jcenter.bintray.com/com/mapbox/navigator/mapbox-navigation-native/7.0.0/mapbox-navigation-native-7.0.0.pom
>- https://api.mapbox.com/downloads/v2/releases/maven/com/mapbox/navigator/mapbox-navigation-native/7.0.0/mapbox-navigation-native-7.0.0.pom
>Required by:
>project :app > com.mapbox.mapboxsdk:mapbox-android-navigation-ui:0.42.6 > com.mapbox.mapboxsdk:mapbox-android-navigation:0.42.6
Possible solution:
Declare repository providing the artifact, see the documentation at https://docs.gradle.org/current/userguide/declaring_repositories.html
I am following this tutorial: https://docs.mapbox.com/help/tutorials/android-navigation-sdk/?size=n_10_n
In my app-level build.gradle file, I added this dependency:
implementation 'com.mapbox.mapboxsdk:mapbox-android-navigation-ui:0.42.6'
And in my module-level build.gradle file, under repositories, I added this:
maven { url 'https://mapbox.bintray.com/mapbox' }
So I am really not sure why it is giving me this issue. Could anyone possibly assist?
I had the same problem and solved it by deleting all maven entries that had something to do with bitray like:
maven { url "http://dl.bintray.com/piasy/maven" }
maven { url 'https://mapbox.bintray.com/mapbox' }
the next step is to set the mapbox download url to:
'https://api.mapbox.com/downloads/v2/releases/maven'
Then i changed the username to 'mapbox' like this:
maven {
// url 'https://api.mapbox.com/downloads/v1/navigation/android/maven' // old one
url 'https://api.mapbox.com/downloads/v2/releases/maven' // new one
authentication {
basic(BasicAuthentication)
}
credentials {
username = "mapbox" // This should always be `mapbox` (not your username).
password = project.properties['MAPBOX_DOWNLOADS_TOKEN'] ?: ""
}
}
If doing this you get error 401 instead of 403 you will have to create a new, secret Mapbox Access Token with the scope DOWNLAODS:READ
I hope it is helpfull for you!
refs: https://github.com/mapbox/mapbox-navigation-android/issues/4533#issuecomment-880672321
Where exactly did you add the repository? This is supposed to be in the module level build.gradle under allprojects>repositories:
allprojects {
repositories {
google()
jcenter()
maven { url 'https://mapbox.bintray.com/mapbox' }
}
}
If you are starting your development with Mapbox, I would recommend to start with the recent version of the Navigation SDK, as the move to 1.0+ will make breaking changes to the application you are building with the tutorial.
I would recommend following this example:
https://docs.mapbox.com/android/navigation/examples/basic-nav-sdk-only/
Please be aware that the way to add the dependencies has changed with Navigation SDK 1.0+. This is documented here:
https://docs.mapbox.com/android/navigation/overview/#install-the-navigation-sdk
I have a problem to understand how to add the "used by" inside my project java with Gradle.
My question is, is possible to add the used by with Gradle inside the java project?
Is possible using the "used by" inside a for the project? (stupid question)
Information on the project
The repository of the project is loaded to sonatype.
Sorry the question very stupid, but I don't understand how to do it
I finded a solution and I will try to describe it.
Github has not supported the "Dependency graph" with gradle but supported the maven, so Github when fint the "pom.xml" inside the root directory, create the Dependency graph, so we can enable the "used by" for the project.
Now for resolve the problem I need to create the pom file with gradle, with this code
I have created the file gradle.proprieties with this proprieties
GROUP_ID = your group id
ARCTIFACT_ID = your arctifact id
VERSION = your version
I have added this task inside the build.gradle, it used the maven plugin
apply plugin: 'maven'
task createPom {
pom {
project {
groupId GROUP_ID
artifactId ARCTIFACT_ID
version VERSION
inceptionYear '2019'
licenses {
license {
name 'MIT'
url 'https://github.com/vincenzopalazzo/material-ui-swing/blob/masternow/LICENSE'
distribution 'repo'
}
}
}
}.writeTo("pom.xml")
}
For enable the "used by" inside the project I have used this guide
I need help with the following problem:
Right now, I want to use my Java Gradle Project to build this github-project:
https://github.com/PaperMC/Paper but the project but it's a maven project.
I found a plugin for adding github projects as dependencies but it fails here.
An alternative would be to use this jenkins here: https://ci.destroystokyo.com/job/Paper/
However here I'm struggling to make my gradle always use the newest build without having to reasign the chaning version numbers by hand.
Can someone help me out because I have no idea what and how to add to the build.gradle.
Thanks in advance!
Edit:
I found the Maven-Syntax for the correct pull here:
https://paper.readthedocs.io/en/paper-1.11/developers/#plugin-developers
But when I try to convert the information to Gradle I still fail when I try to leave out the version so that Gradle would fetch the latest one. Can someone provide a valid snipped for this? I have never done this before.
According to this guy, you can use a fake ivy repository.
As https://ci.destroystokyo.com/job/Paper/lastSuccessfulBuild/artifact/paperclip.jar points on the latest build, just set up your repository like this :
repositories {
ivy {
url "https://ci.destroystokyo.com/job/Paper/lastSuccessfulBuild/artifact/"
layout 'pattern' , {
ivy '[module]-ivy.xml'
artifact '[module](.[ext])'
}
}
}
And then, use the dependency (the group is not relevant here)
dependencies {
compile 'anything:paperclip'
}
It will get the right file
$ gradle build
Download https://ci.destroystokyo.com/job/Paper/lastSuccessfulBuild/artifact/paperclip.jar
...
I have gradle multi-module project configured with kotlin-script. I'd like to add publishing to maven repository and I found maven-publish plugin for it. But it seems to skip the version configured for each project:
MyProject/build.gradle.kts:
subprojects {
apply {
plugin("maven-publish")
}
configure<PublishingExtension>() {
publications {
repositories { ... }
create<MavenPublication>("myPublication") {
from(components.getByName("java"))
logger.lifecycle("test: ${project.group} ${project.name} ${project.version}")
}
}
MyProject/subproject1/build.gradle.kts:
version = "1.0.0-SNAPSHOT"
gradle publish output:
test: my.project subproject1 unspecified
artifact file does not exist: '.../MyProject/subproject1/build/libs/subproject1.jar'
File subproject1.jar doesn't exist, but subproject1-1.0.0-SNAPSHOT.jar does. How to make gradle get the correct version of module?
I found a similar problem while using the maven-publish plugin:
I was trying to set the repository URL depending on project version as described in the gradle docs here and this answer.
But I found the version always resolved to (as in the question) as the default (un-set) value: unspecified.
So I guess those documentation examples are for a project's build.gradle and not a general gradle script.
Anyway, I believe the problem is due to the timing of the execution of the blocks in the gradle script. The project.version could not be accessed where I wanted it. So I ended up passing a parameter to the gradlew command with the -Pparameter flag.
Gradle has a configuration and then an execution stage.
Refer to documentation:
https://docs.gradle.org/current/userguide/build_lifecycle.html
https://www.oreilly.com/library/view/gradle-beyond-the/9781449373801/ch03.html
and an apparently similar problem, https://discuss.gradle.org/t/maven-publication-closure-is-evaluated-too-early/19911
About your problem, it may be the same as I have described, or perhaps the reason is simpler:
Looking at the structure of your gradle file, it does not appear to match the hierarchy specified in the maven-publish documentation. In particular, repositories {} block should be at the same level as publications {}, not inside of it.
Possibly related:
Gradle maven publish plugin config has reference to dynamically created gradle task
Gradle shouldRunAfter not available for a task
I am building an application using Gradle, JDK 8, Java FX, and Test FX. I need to be on JDK 8 for our application to work on all platforms with our tech stack. My problem is that I am unable to get code coverage into our build. I found this link...
https://github.com/jacoco/jacoco/issues/74
...and using the Jacoco preview build at the top, I was able to replace my intellij JARs and successfully run my tests and get the coverage. However, I am having trouble putting this into my build.gradle. From what I can tell, I need to add a local repository in my build script...
...
apply plugin: "jacoco"
...
buildscript {
repositories {
// Local Repo
// MVN Repo(s)
}
dependencies {
// Classpaths
}
}
jacoco {
toolVersion = "0.6.4.201311160552" // I need this specific version, which isn't on a MVN repo
}
...I tried to add my local repo several ways including...
flatDir(dirs: "lib")
flatDir dirs: "${projectDir}/lib"
maven { url uri("lib") }
one or two other ways I forget
...my lib folder contains the exact contents, unchanged, from the preview build zip's lib folder in the link above. It doesn't seem like gradle is having a problem locating the local repo, but it is having trouble finding the JAR. I assume there is something wrong with the way I am naming it or the way that it is "packaged". I have tried modifying the JAR names but I keep getting the error...
What went wrong:
A problem occurred configuring root project 'myProject'.
Could not resolve all dependencies for configuration ':classpath'.
Could not find :org.jacoco.agent:.
Required by:
:myProject:unspecified
...any ideas why my JAR is not being found? Thanks!
"Answering" my own question, despite the fact that I still haven't quite figured it out. Anyways, here are two links I found that seem to solve my problem...
http://forums.gradle.org/gradle/topics/jacocotestreport_is_skipping
...following some of these instructions allow my tests to run, but I am still not able to run "gradle jacocoTestReport" without it failing.
UPDATE
OKAY! I figured it out, the link above did help me figure it out. My problem was with the asm-all JAR, since there were several, I did not know which one to use. In order to get jacoco working with Java 1.8, you do not need to specify the toolVersion property. All you need to do is add the following to your dependencies block (not the buildscript block, the code block)...
jacocoAgent files(
"$projectDir/lib/org.jacoco.agent-0.6.4.201311160552.jar")
jacocoAnt files(
"$projectDir/lib/org.jacoco.ant-0.6.4.201311160552.jar",
"$projectDir/lib/org.jacoco.core-0.6.4.201311160552.jar",
"$projectDir/lib/org.jacoco.report-0.6.4.201311160552.jar",
"$projectDir/lib/asm-all-5.0_BETA.jar")
...where the asm-all-5.0_BETA.jar is taken from the org.ow2.asm group found at...
http://mvnrepository.com/artifact/org.ow2.asm/asm-all/5.0_BETA
...hope this helps!
for reference, latest jacoco libs are changed so i'm sharing the following snippet:
dependencies{
jacocoAgent files("$rootProject.projectDir/lib/org.jacoco.agent-0.8.3.201904130250.jar")
jacocoAnt files("$rootProject.projectDir/lib/org.jacoco.ant-0.8.3.201904130250.jar",
"$rootProject.projectDir/lib/org.jacoco.core-0.8.3.201904130250.jar",
"$rootProject.projectDir/lib/org.jacoco.report-0.8.3.201904130250.jar",
"$rootProject.projectDir/lib/asm-7.0.jar",
"$rootProject.projectDir/lib/asm-tree-7.0.jar",
"$rootProject.projectDir/lib/asm-commons-7.0.jar"
)
}