I am migrating Maven project to Gradle. I needed manage dependencies so tryed resolutionStrategy like so:
def dependencyVersions = [
'org.slf4j:slf4j-api' : '1.7.2',
'javax.inject:javax.inject' : '1',
'com.google.code.findbugs:annotations' : '2.0.1',
'com.typesafe:config' : '1.0.0',
'ch.qos.logback:logback-classic' : '1.0.9',
'com.google.guava:guava' : '14.0',
'com.google.inject:guice' : '3.0',
'com.google.inject.extensions:guice-multibindings' : '3.0',
'com.google.code.gson:gson' : '2.2.2',
'joda-time:joda-time' : '2.1',
'com.thoughtworks.paranamer:paranamer' : '2.5.2',
'org.codehaus.groovy:groovy-all' : '2.0.6',
'commons-validator:commons-validator': '1.4.0',
'org.apache.shiro:shiro-core' : '1.2.1',
'junit:junit-dep' : '4.10',
'org.mockito:mockito-core' : '1.9.5',
'org.hamcrest:hamcrest-core': '1.3',
'org.hamcrest:hamcrest-library': '1.3',
'org.unitils:unitils-core': '3.3'
]
configurations.all {
resolutionStrategy {
eachDependency { DependencyResolveDetails details ->
def version = dependencyVersions["$details.requested.group:$details.requested.name"]
if (version != null)
details.useVersion version
}
}
}
but now when I try to Gradle install (into local Maven repository) I am getting this error:
Execution failed for task ':counter-module:install'.
Could not publish configuration 'archives'
Unable to initialize POM pom-default.xml: Failed to validate POM for project lt.counter at /home/workspace/counter/counter-module/build/poms/pom-default.xml
I still may be missing an aspect of your problem, but I just noticed something in the docs.
// force certain versions of dependencies (including transitive)
// *append new forced modules:
force 'asm:asm-all:3.3.1', 'commons-io:commons-io:1.4'
// *replace existing forced modules with new ones:
forcedModules = ['asm:asm-all:3.3.1']
It seems like you could do the following:
def dependencyVersions = [
'org.slf4j:slf4j-api' : '1.7.2',
'javax.inject:javax.inject' : '1',
'com.google.code.findbugs:annotations' : '2.0.1',
'com.typesafe:config' : '1.0.0',
'ch.qos.logback:logback-classic' : '1.0.9',
'com.google.guava:guava' : '14.0',
'com.google.inject:guice' : '3.0',
'com.google.inject.extensions:guice-multibindings' : '3.0',
'com.google.code.gson:gson' : '2.2.2',
'joda-time:joda-time' : '2.1',
'com.thoughtworks.paranamer:paranamer' : '2.5.2',
'org.codehaus.groovy:groovy-all' : '2.0.6',
'commons-validator:commons-validator': '1.4.0',
'org.apache.shiro:shiro-core' : '1.2.1',
'junit:junit-dep' : '4.10',
'org.mockito:mockito-core' : '1.9.5',
'org.hamcrest:hamcrest-core': '1.3',
'org.hamcrest:hamcrest-library': '1.3',
'org.unitils:unitils-core': '3.3'
]
force dependencyVersion.collect {k, v -> "$k:$v"}
To my eyes, it looks like this would accomplish two principles.
Give users a nice map notation to use when they want to play nice and add a dep with your predetermined version.
Force them to use the predetermined version any time they try to get tricky.
The default resolution strategy for Gradle is to use the newest version, so version N will be used; version N-1 will not.
You do not tell us which version of Gradle you are using and the full structure of your project(s). Are you doing a multi-project build?
Also I don't understand your custom resolution strategy - why would the version ever be null?
-- edit --
The newest version is the default resolution strategy, so the highest version encountered will be used.
Maybe have a look at Gradle's examples on custom resolution strategies, such as forcing a particular version.
Related
I have upgraded Ext Direct from 1.3.2 to 1.8.0 and Spring Framework from 4.2.6.RELEASE to 5.1.7.RELEASE
After that actions in REMOTING_API becomes empty
Ext.app.REMOTING_API = {
"url" : "/ui/.../services/router",
"namespace" : "Ext....",
"type" : "remoting",
"actions" : { }
};
I'm stuck on this, any help will be appreciated.
Could some wise guru give me a hand to get the Cache Plugin to work? I have been given this project that uses:
Grails 3.3.0
gradle 3.0
GORM 6.1.6.Release
Cache Plugin 4.0.0
I'm following https://grails-plugins.github.io/grails-cache/snapshot/guide/index.html#usage to enable Caching though the app can be started without error, the method that is annotated by #Cacheable doesn't seem to be caching. This is what my myWebApp**build.gradle** looks like:
:
compile group: 'org.grails.plugins', name: 'cache', version: '4.0.0'
compile group: 'org.grails.plugins', name: 'async'
:
This is my grails-app/conf/application.yml:
---
grails:
cache:
caches:
name: 'mycache'
---
This is how I enable cache in grails-app/conf/application.groovy:
:
grails.cache.enabled = true
grails.cache.clearAtStartup = true
:
This is my myWebApp/Application.groovy:
package myWebApp
:
class Application extends GrailsAutoConfiguration {
static void main(String[] args) {
GrailsApp.run(Application, args)
}
}
This is the method in a controller with #Cachable (grails-app/controllers/data/mycontroller.groovy):
package data
:
import org.springframework.cache.annotation.Cacheable
:
#Transactinal
class MyController {
:
#Cacheable(value='mycache')
def getSomeId() {
return anId
}
:
}
In the same controller, I am calling this method for quick test:
:
def index() {
def id = getSomeId()
:
}
:
The problem is getSomeId() didn't seem to be cached. Everytime getSomeId() was called, the body was executed in full length (I set a break point to verify). I just want to use a quick and simple cache mechanism for simple things like this.
What did I do wrong?
Thanks for all you folks, the cache finally works in my project. HOWEVER, the import for annotation must come from the plugin: grails.plugin.cache.Cacheable works, but org.springframework.annotation.Cacheable doesn't.
If I deploy an artifact to a Maven repository with version number 1.0.0-SNAPSHOT, it will get an internal version number of the form 1.0.0-21321323-2 (timestamp and number). How can I find out this version number?
When deploying an artifact to Artifactory you get a JSON response which includes the URI of the deployed artifact. You can use that to get the timestamp version. For example:
{
"repo" : "libs-snapshot-local",
"path" : "/org/jfrog/buildinfo/build-info-extractor-maven3/2.5.4-SNAPSHOT/build-info-extractor-maven3-2.5.4-20160205.203000-1.jar",
"created" : "2016-02-05T22:30:00.624+02:00",
"createdBy" : "admin",
"downloadUri" : "http://localhost:8081/artifactory/libs-snapshot-local/org/jfrog/buildinfo/build-info-extractor-maven3/2.5.4-SNAPSHOT/build-info-extractor-maven3-2.5.4-20160205.203000-1.jar",
"mimeType" : "application/java-archive",
"size" : "67966",
"checksums" : {
"sha1" : "f608440d5aadc64a5ef50320a385aeae49abd58a",
"md5" : "a844a8ab8226ff25854127480f3cfeac"
},
"originalChecksums" : {
},
"uri" : "http://localhost:8081/artifactory/libs-snapshot-local/org/jfrog/buildinfo/build-info-extractor-maven3/2.5.4-SNAPSHOT/build-info-extractor-maven3-2.5.4-20160205.203000-1.jar"
}
Another option is using the latest version search REST API which allows searching for the latest artifact version by groupId and artifactId.
For example:
$ curl -uadmin:password "http://localhost:8081/artifactory/api/search/latestVersion?g=org.jfrog.buildinfo&a=build-info-extractor-maven3&v=2.5.4-SNAPSHOT&repos=libs-snapshot-local"
2.5.4-20160205.203000-1
I created a new project in Eclipse from these helpful spring examples (Import Getting Started Content). It is called "gs-accessing-data-rest-complete"
Reference and full Code can be found: spring-guides/gs-accessing-data-rest
When leaving the example unchanged, except using WAR instead of JAR packaging, everything works well. When calling $ curl http://localhost:8080/, I'll get an exposure of usable resources.
$ curl http://localhost:8080/
{
"_links" : {
"people" : {
"href" : "http://localhost:8080/name{?page,size,sort}",
"templated" : true
},
"profile" : {
"href" : "http://localhost:8080/alps"
}
}
But when moving the PersonRepository into another package, e.g. myRepos via Eclipse's Refactor-->Move command, a resource is not accessible anymore.
The response from curl is then:
$ curl http://localhost:8080/
{
"_links" : {
"profile" : {
"href" : "http://localhost:8080/alps"
}
}
}
As far as I understood, Spring scans for Repositories automatically. Because the main class uses #SpringBootApplication annotation, everything should be found by spring itself.
What am I missing? Do I have to add some special XML configuration file or add another Configuration Class somewhere? Or do I have to update application.properties in order to sth.?
Perhaps somebody has some useful experiences, she or he might share with me. Thank you.
Try specifying the base package to use when scanning for repositories by using this annotation on your config class: #EnableJpaRepositories(basePackages = "your.base.repository.package")
I know it's possible to require other modules, but how can you tell aura to process a module as an extension?
Background:
For a large project I'm working on, I'm using aura extensions to modify a jQuery instance I'm keeping in the app's sandbox. A typical extension would look something like this, where plug1 and plug2 are jQuery plugins.
define({
require : {
paths : {
'jquery.plug1' : 'lib/plug1',
'jquery.plug2' : 'lib/plug2'
},
shim : {
'jquery.plug1' : {
exports : 'jQuery'
},
'jquery.plug2' : {
deps : ['jquery.plug1'],
exports : 'jQuery'
}
}
},
initialize : function(app) {
var $ = app.sandbox.$;
$ = require('jquery.plug1');
app.sandbox.$ = require('jquery.plug2');
}
});
For tightly coupled plugins I can specify dependencies as shown here, but I'd rather avoid this for more loosely coupled components.