I have a maven project A that has profiles in it as:
0.0.1
.
.
dev
${bigquery.version}
screwdriver-v3
true
screwdriver3
release
${bigquery.version}.${maven.build.timestamp}
I have created a version of A at : 0.0.1.20180424-0042
I have another gradle project B that I want to add A as a dependency as:
compile group:'com.bq', name:'bigquery', version:'0.0.1.20180424-0042'
When I build gradle with ./gradlew clean build, it is complaining as:
Could not resolve all files for configuration ':compileClasspath'.
> Could not resolve com.bq:bigquery:0.0.1.20180424-0042.
Required by:
project :
> Could not resolve com.bq:bigquery:0.0.1.20180424-0042.
> inconsistent module metadata found. Descriptor: com.bq:bigquery:0.0.1.${maven.build.timestamp} Errors: bad version: expected='0.0.1.20180424-0042' found='0.0.1.${maven.build.timestamp}'
How do I go about fixing the dependency?
解决方案
Using maven profiles like this is considered an anti-pattern, further reading here
Gradle does not have full support for maven profile activation. Read the blog post here to see that the two supported profile activation triggers are
Profiles that are active by default (available with Gradle 1.12 and higher)
Profiles that are active on the absence of a system property (available with Gradle 2.0 and higher)
As a workaround, you could do the following:
Use a local folder as a hacked maven repository
Order the local folder repository first so it takes precedence over the remote repository
Copy / paste / tweak the pom in the local file repo so that it hard codes the version
Do not copy the artifact(s) (eg jar) to the local folder repository
Then gradle should take the pom from the local repo and the jars etc from the remote repository
Eg:
repositories {
maven {
url = file('local-repo')
}
mavenCentral()
}
You would then put the "tweaked" pom at
$projectDir/local-repo/$group.replace('.','/')/$artifact/$version/$artifactId-$version.pom