I have project which using Gradle to publish our SNAPSHOT artifact's to remote Maven Repository.
When I publish to Maven, time stamp and build number is getting appended to Jar name. And I am trying to download the latest version ie myjar-1.6.0-20170926.190543-10.jar from one of other project. I am not able to download until unless, I remove it from my .gradle or restart my work space.
myjar-1.6.0-20170926.162756-7.jar
myjar-1.6.0-20170926.162756-7.jar.md5
myjar-1.6.0-20170926.162756-7.jar.sha1
myjar-1.6.0-20170926.162756-7.pom
myjar-1.6.0-20170926.162756-7.pom.md5
myjar-1.6.0-20170926.162756-7.pom.sha1
myjar-1.6.0-20170926.182639-8.jar
myjar-1.6.0-20170926.182639-8.jar.md5
myjar-1.6.0-20170926.182639-8.jar.sha1
myjar-1.6.0-20170926.182639-8.pom
myjar-1.6.0-20170926.182639-8.pom.md5
myjar-1.6.0-20170926.182639-8.pom.sha1
myjar-1.6.0-20170926.182748-9.jar
myjar-1.6.0-20170926.182748-9.jar.md5
myjar-1.6.0-20170926.182748-9.jar.sha1
myjar-1.6.0-20170926.182748-9.pom
myjar-1.6.0-20170926.182748-9.pom.md5
myjar-1.6.0-20170926.182748-9.pom.sha1
myjar-1.6.0-20170926.190543-10.jar
myjar-1.6.0-20170926.190543-10.jar.md5
myjar-1.6.0-20170926.190543-10.jar.sha1
myjar-1.6.0-20170926.190543-10.pom
myjar-1.6.0-20170926.190543-10.pom.md5
myjar-1.6.0-20170926.190543-10.pom.sha1
The dependency project has below
configurations.all {
resolutionStrategy.cacheDynamicVersionsFor 0, 'seconds'
resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
}
compile ( group: "com.test", name:"myjar", version: "1.6.0-SNAPSHOT", changing: true );
Also tried with
compile ( "com.test:myjar:latest.integration);
But nothing working out. Let me know how to fix this?
You can run the local build with --refresh-dependencies. See the answers to this question How can I force gradle to redownload dependencies? for more information.
I encounter the same situation as you.
Develop environment: Android Studio 4.0
Building tools: gradle 3.6
Computer: Mac
I'm at app end, while I am using a jar from server end, the jar is included by adding maven repo and adding project dependency in build.gradle, like this:
buildscript {
repositories {
mavenLocal()
maven { url 'http://maven.xxx.com/xxx/xxx/‘ }
}}
dependencies {
...
implementation ‘project_group_id:artifact_id:latest.integration’
}
Instead of using ./gradlew build --refresh-dependencies to clear cache, I directly went to the cache folder /Users/your_user_name/.gradle/caches/modules-2/files-2.1 and delete the local jar in order to download updated one.
But still failed...
Finally we found the cause is weird:
we included several maven repo, one repo has the same project as the one we need, but it has only one version for each version code.It is in front of the maven repo from which we can download newest jar, therefore it blocked the update of the newest version.
We exchange the sequence of these two repo, and the problem disappear.
In my case, it's nothing to do with the maven config or the cache, it is due to repo included in gradle. Further reason still need to dig.
Hope can help the ones who meet the same problem.
Related
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 a custom library uploaded to bintray maven with version 1.0.0
To download it for any project i have used the following code
repositories {
maven {
url "http://dl.bintray.com/<org or user name>/<repo-name>"
}
}
And inside my app level build.gradle i have added the dependency
dependencies {
.....
compile 'my-group-id:artifactId:versionId'
.....
}
Recently i upgraded the versionId to 1.0.2 and it doesn't compile. For version 1.0.0 it compiles fine.
Heres the error i get
Error: Could not find sdk.jar (com.appunfold:sdk:1.0.2).
Searched in the following locations:
http://dl.bintray.com/appunfold/android/com/appunfold/sdk/1.0.2/sdk-1.0.2.jar
I checked the files inside 1.0.2. It contains sdk-1.0.2.aar (not sdk-1.0.2.jar)and compared it with the files inside 1.0.0. It contains the same with the version 1.0.0 i,e sdk-1.0.0.aar.
I couldn't find the reason why it is not able to download for a different version. Anybody faced the same issue?
Found the solution after a deep few hours of research.
I think Android Studio by default searches for jar files. But since in my case only aar files are available i had to specify one more parameter (#aar) while compiling the dependency.
It looks like this
dependencies {
.....
compile 'my-group-id:artifactId:versionId:#aar'
.....
}
I'm working on an OSGi bundle using bndtools in Eclipse. I just added a new bundle (apache commons logging) to the cnf/localrepo repository, and our CI server is now failing the build:
[Gradle] - Launching build.
[workspace] $ gradle build
:mybundle : Cannot find /error/com.springsource.org.apache.commons.logging;version=0 Not found in [bnd-cache, Release, Local, Bndtools Hub, /var/lib/jenkins/jobs/myapp/workspace/cnf/nonosgi-repo r/w=true]
Error : com.springsource.org.apache.commons.logging;version=0 Not found in [bnd-cache, Release, Local, Bndtools Hub, /var/lib/jenkins/jobs/myapp/workspace/cnf/nonosgi-repo r/w=true]
Project names lightly obfuscated just for simplicity.
It appears to me that the gradle plugin doesn't refresh the repository index - if one of my teammates updates from our vcs without refreshing in Eclipse, then they get the same error.
I know bndtools has the org.osgi.impl.bundle.repoindex.cli plugin, but I don't know enough about bndtools or gradle to apply it to my project. I also feel as though either (a) the gradle plugin should refresh the repositories on its own or (b) I'm using the repositories incorrectly.
Is it possible to add a task to our build.gradle that refreshes the indexes before a build?
Should we instead move all our dependencies to an online repository so bnd doesn't need to manage the indexes?
What kind of repo is cnf/localrepo? If it is a FileRepo, then you don't need an index. You just put the bundles in a folder/filename format for the bundle's bsn/version. If is is an indexed repo, then you must maintain the index and commit it with the new bundles added to the repo. This is we manage the bundle-hub repo. Whenever a new bundle is added, we update the index.
As for the gradle plugin, you can write a task to reindex you repo each build. See https://groups.google.com/forum/#!searchin/bndtools-users/index$20gradle/bndtools-users/OQ0Ns5v0ELo/JOB803lBBwAJ for a discussion about how to do this.
Should we instead move all our dependencies to an online repository so bnd doesn't need to manage the indexes?
Probably, but for various reasons it's easier in the short-term to continue to use our LocalIndexedRepository.
Is it possible to add a task to our build.gradle that refreshes the indexes before a build?
bndtools' Bundle-Hub repository uses the org.osgi.impl.bundle.repoindex.cli plugin to reindex the repository in its build.gradle. Since I'm not fluent in groovy or gradle, I simply copied its code into cnf/localrepo/build.gradle:
repositories {
mavenCentral()
}
configurations {
repoindex
}
dependencies {
repoindex group: 'biz.aQute.bnd', name: 'org.osgi.impl.bundle.repoindex.cli', version: '3.0.0'
}
defaultTasks = [':index']
task('index') {
/* Bundles to index. */
def bundles = fileTree(projectDir) {
include '**/*.jar'
exclude '**/*-latest.jar'
exclude '.*/'
}
doLast {
javaexec {
main = '-jar' // first arg must be the jar
args configurations.repoindex.singleFile
args '-n', 'Local' // REPO NAME HERE
args bundles*.absolutePath
}.assertNormalExitValue()
}
}
Thanks to BJ Hargrave for pointing me in the direction of Bundle-Hub's scripts.
I have an archetype that we use to create new projects. At the point of project creation (i.e. when someone executes mvn archetype:generate) I want to pin some of the dependencies to RELEASE version available at that time (I strongly oppose putting <version>RELEASE</version> in POM file).
Is there a way I can make archetype to resolve RELEASE version and pin that for some of the libraries.
Only way I solve this problem right now is by releasing new version of archetype every time some of the core libraries are released and then hard coding versions of those in the archetype-resources/pom.xml
I did see couple of similar questions but none of the solutions for those work for me.
As I already mentioned, that I want to pin the latest release version available at the time of creating project from archetype. Using `RELEASE means that I can not recreate binaries from same source code as I will end up fetching a different version of dependency.
Let me explain with concrete example.
I have an archetype with maven co-ordinate com.my-company:my-awesome-framework:1.0.
I have a library with maven co-ordinates com.my-company:core-lib:1.0.
Developer-1 runs command mvn archeype:generate my-awesome-framework. He fills in required details and creates project called service-foo. service -foo has dependency core-lib and since.
We add more features to core-lib and release version 2.0
Developer-1 build service-foo it still builds with core-lib version 1.0. (since he hasn't changed the version the project's POM file. Had I used <version>RELEASE<version> for 'core-lib, this timeservice-foowould have built with version2.0of thecore-lib`)
Devloper-2 runs mvn archetype:generate my-awesome-framework. He fills out required fields and creates a service called service-bar. Now this time since core-lib version 2.0. Note that I did not modify my-awesome-archetype to update version for core-lib inside archetype-resources\pom.xml
I hope this clarifies my use case
I solved this using archetype-post-generate.groovy, script. Maven archetype plugin executes that (if available) after the project has been created. There one can use Maven versions plugin to update to the latest releases.
Here is an example how you can update both versions in properties and in parent project (in Spring Boot in this case):
dir = new File(new File(request.outputDirectory), request.artifactId)
def run(String cmd) {
def process = cmd.execute(null, dir)
process.waitForProcessOutput((Appendable)System.out, System.err)
if (process.exitValue() != 0) {
throw new Exception("Command '$cmd' exited with code: ${process.exitValue()}")
}
}
run("echo 'Updating to latest Vaadin version...'")
run("mvn versions:update-properties")
run("echo 'Updating to latest Spring Boot version...'")
run("mvn versions:update-parent")
The downside is that Eclipse don't seem to execute that script, but in other major IDEs and command line this work just fine.
The groovy script form my Vaadin + Spring Boot archetype in GitHub.
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"
)
}