Do I have to have a separate directory structure for each artifact that I want to publish?

I’m working on publishing database sql scripts to artifactory.

I have a large directory structure like this:

I want an artifact for each db type/component/version combination…

Is there a way that I could use the same directory structure as shown in the image but publish each subdirectory as artifacts? (e.g. oracle.analysis.v20.jar, mssql.analysis.v45.jar

thanks for any tips phil

You’d have to scan the directory hierarchy and add corresponding publications.

Thanks for the reply, Peter. But could you expand on this? How would I “add corresponding publications?”

First you’ll need to learn how to publish a single artifact, using either the old ‘maven’ or the new ‘maven-publish’ plugin (see Gradle User Guide). Then you’ll need to make the code more generic, in order to publish an artifact for each directory. The latter will require some coding, but nothing Gradle specific.

Peter is correct, you only need to create a task for each artifact you want to publish. For example I have a single project with 40 or 50 Jars in a single dir. Using groovy method it dynamically builds a gradle task for each Jar to be published separately.

Ok, I’m finally back to this issue…

So yes, I need to do exactly what Casey is describing. @Casey - could you paste in some code as to how this works? Do you dynamically create sub-projects? What is the gradle construct that I need to create dynamically? A project?

I’ll study up on the gradle DSL, maybe the answer will be obvious…

thanks phil

why do you say “maven”? I’m using artifactory with the artifactory gradle plugin in my case, not a maven repo

I tried doing this in settings.gradle:

def analysisProject = project('mssql:analysis:20').projDir =
new File("/Users/philswenson/dev/sag/cdc/scripts/mssql/analysis/20")

however I get this error:

* Where:
Settings file '/Users/philswenson/dev/sag/cdc_pub/settings.gradle' line: 24
  * What went wrong:
A problem occurred evaluating settings 'CdcPublish'.
> Project with path 'mssql:analysis:20' could not be found.

This code seems to be working so far:

include (':mssql:analysis:20')
def analysisProject = project(':mssql:analysis:20').projectDir =
new File("/Users/philswenson/dev/sag/cdc/scripts/mssql/analysis/20")

think I’m on the right track… we’ll see

I got it working:

in settings.gradle:

include (':mssql:analysis:20')
project(':mssql:analysis:20').projectDir =
new File("/Users/philswenson/dev/sag/cdc/scripts/mssql/analysis/20")

and in the root project build.gradle I put this:

proj = findProject(":mssql:analysis:20")
assert proj != null
proj.sourceSets {
    main {
        resources {
            srcDir "/Users/philswenson/dev/sag/cdc/scripts/mssql/analysis/20"