I am setting up the CI model for one project.This project is almost having 500 modules approx.We just update the workspace everytime through our CI tool and build modules which is actually changed.We are using gradle to build all modules my requirement is to publish only those modules which are changed in the current build to nexus snapshot repository.I know there is gradle task to publish the artifacts but only to publish to changed modules is the requirement.
Below is the example.
A
B
C
D
E
F
If there is a change in B and F then I want to publish only B and F modules in nexus and if change is in A and F then publish only A and F module.
Something similar to
class IncrementalReverseTask extends DefaultTask {
@InputDirectory
def File inputDir
@OutputDirectory
def File outputDir
@TaskAction
void execute(IncrementalTaskInputs inputs) {
if (!inputs.incremental)
project.delete(outputDir.listFiles())
inputs.outOfDate { change ->
def targetFile = project.file("$outputDir/${change.file.name}")
targetFile.text = change.file.text.reverse()
}
inputs.removed { change ->
def targetFile = project.file("$outputDir/${change.file.name}")
if (targetFile.exists()) {
targetFile.delete()
}
}
}
}
I tried in below way and getting this issue
publishing {
publications {
maven(MavenPublication) {
groupId 'com.example'
artifactId 'core'
version '1.0-SNAPSHOT'
from components.java
}
}
repositories {
maven {
credentials {
username "abcde"
password "***********"
}
url "https://nexus.test.com/content/repositories/snapshots"
}
}
}
task incrementalPublishToMavenRepository(type: IncrementalPublishToMavenRepository) {
inputDir = file('.')
publication = project.tasks.getByPath(":${project.name}:publishMavenPublicationToMavenRepository").publication
}
class IncrementalPublishToMavenRepository extends org.gradle.api.publish.maven.tasks.PublishToMavenRepository {
@InputDirectory
def File inputDir
@OutputDirectory
File generatedFileDir = project.file("${project.buildDir}/libs")
@TaskAction
void perform(IncrementalTaskInputs inputs) {
println 'hello this should be executed ones'
}
}
and getting below error
gradle jar incrementalPublishToMavenRepository
Configuration on demand is an incubating feature.
:core:compileJava UP-TO-DATE
:core:processResources NO-SOURCE
:core:classes UP-TO-DATE
:core:jar UP-TO-DATE
:app:compileJava UP-TO-DATE
:app:processResources UP-TO-DATE
:app:classes UP-TO-DATE
:app:jar UP-TO-DATE
:app:generatePomFileForMavenPublication
:app:incrementalPublishToMavenRepository FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:incrementalPublishToMavenRepository'.
> The 'repository' property is required
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
Each task in Gradle has inputs and outputs properties to enable incremental task capabilities, so this capability could be configured for publishing task to publish artifacts to repository.
Update:
Well, to implement full solution more effort is required, however here is an idea how you can use mentioned capabilities:
Now you can use
./gradlew incrementalPublishToMavenLocal
to perform incremental publishing. Hope this will help to move forward.