2009/4/22 Walter Di Carlo <[email protected]>:
> Hi,
>
>
> So, it seems I am not using the correct pattern for the build-resolver

I have solved it by using the following section

subprojects {
        usePlugin('java')

        mainRepo = new File("/$rootDir/repo")

        // define common dependencies
        dependencies {
                
getBuildResolver().addArtifactPattern(mainRepo.path+'/[artifact].[ext]')
                addFlatDirResolver('repo',
"$mainRepo").addArtifactPattern(mainRepo.path+'/[artifact].[ext]')
                testCompile('junit:junit:4.4')
        }
        .......
}

Regards,

Walter


>
> -----------------------------------------------------------------------------------------------------------------
>
> I am having problems to setup a multi-project scenario with
> conditional dependencies.
>
> The structure I am tring to use is the following
>
> root
> -- build.gradle
> -- settings.gradle
> -- repo
> ------ main-prj-jar1.jar
> ------ main-prj-jar2.jar
> ------ sub-prj1.jar
> ------ sub-prj2.jar
> ------ sub-prj3.jar
> ------ lib1.jar
> ------ lib2.jar
> -- main-prj
> ----- src
> -- sub-prj1
> ----- src
> -- sub-prj2
> ----- src
> -- sub-prj3
> ----- src
>
> The assumption (perhaps not correct) is to use the flat repository for
> all the steps of the building procedure. I mean every generated jar
> should be uploaded in the flat local repository and used to build the
> other projects. Furthermore, some sub-project could not be checked
> out. In this case the procedure must use the jar present in the flat
> repository.
>
>
> Note that:
> - I am tring to use a flat local repository (repo) and the artifact
> names are without version numbers.
> - I use just one build.gradle file
> - many jars are derived from the main project
> - to check if a sub-project has been checked out I am using the
> following function
> ------------------------------
> --------------------------------------------------------------------------------------------------------------------------------
>
> boolean isProjectPresent( String name ) {
>     isPresent = true
>     prj_path = new File( "$rootDir/$name" )
>     if( prj_path.exists() == true ) {
>         isPresent = true
>     } else {
>         isPresent = false
>     }
>     isPresent
> }
> --------------------------------------------------------------------------------------------------------------------------------------------------------------
>
>
> So, in order to use a flat repository and to copy all generated jars I
> have used the following subproject section
> --------------------------------------------------------------------------------------------------------------------------------------------------------------
> subprojects {
>     usePlugin('java')
>
>     mainRepo = new File("/$rootDir/repo")
>
>     // define common dependencies
>     dependencies {
>         addFlatDirResolver('repo',
> "$mainRepo").addArtifactPattern(mainRepo.path+'/[artifact].[ext]')
>         testCompile('junit:junit:4.4')
>     }
>     sourceCompatibility = 1.5
>     targetCompatibility = 1.5
>
>     classesDirName = 'bin'
>     distsDirName = 'dists'
>     srcRootName = '.'
>     srcDirNames = ['src']
>     testSrcDirNames = ['test']
>
>     // do not use version number in the filename
>     archive_jar.customName = project.archivesBaseName+'.jar' //
> change the name of the generated jar
>
>     task('uploadLibs').doLast { task ->
>         ant.copy( file:
> task.project.buildDir.path+"/"+task.project.archive_jar.archiveName,
> todir: mainRepo.path, overwrite:true)
>     }
> }
>
> -------------------------------------------------------------------------------------------------------------------------------------------
>
> for the main project I have used the following section
> -------------------------------------------------------------------------------------------------------------------------------------------
>
> project(':main-prj') {
>     createTask('archive_jar', overwrite: true, dependsOn: 'test' ) { task ->
>         ant.jar(destfile: task.project.buildDir.path+"/common.jar",
> compress: true, index: false ) {
>             fileset(dir: task.project.buildDir.path+"/bin", includes:
> "com/main-prj//common/**")
>         }
>         ant.jar(destfile: task.project.buildDir.path+"/core.jar",
> compress: true, index: false ) {
>             fileset(dir: task.project.buildDir.path+"/bin", includes:
> "com/main-prj/core/**")
>         }
>     }
>     createTask('uploadLibs', overwrite: true, dependsOn: 'libs' ) { task ->
>         ant.copy( file: task.project.buildDir.path+"/common.jar",
> todir: mainRepo.path, overwrite:true)
>         ant.copy( file: task.project.buildDir.path+"/core.jar", todir:
> mainRepo.path, overwrite:true)
>     }
>     dependencies {
>         if( isProjectPresent( "sub-prj1" ) == true )
>             compile project(':sub-prj1')
>         else
>             compile "sub-prj1:sub-prj1:jar"
>         if( isProjectPresent( "sub-prj2" ) == true )
>             compile project(':sub-prj2')
>         else
>             compile "sub-prj2:sub-prj2:jar"
>         compile "lib1:lib1:jar"
>     }
> }
>
> -------------------------------------------------------------------------------------------------------------------------------------------
> for the other sub project I have created a section for each of them to
> list the dependencies
>
> -------------------------------------------------------------------------------------------------------------------------------------------
>
> project(':sub-prj1') {
>     dependencies {
>         compile "sub-prj2:sub-prj2:jar", \
>             "slf4j-api:slf4j-api:1.5.6"
>        compile "lib1:lib1:jar"
>     }
> }
> -------------------------------------------------------------------------------------------------------------------------------------------
>
> Using such configuration I get the following error
>
> -------------------------------------------------------------------------------------------------------------------------------------------
>
> :: problems summary ::
> :::: WARNINGS
>                 [NOT FOUND  ] main-prj#sub-prj1;2.0!sub-prj1.jar (0ms)
>
>         ==== build-resolver: tried
>
>           ......\.gradle\build-resolver/main-prj/sub-prj1/2.0/jars/sub-prj.jar
>
>                 ::::::::::::::::::::::::::::::::::::::::::::::
>
>                 ::              FAILED DOWNLOADS            ::
>
>                 :: ^ see resolution messages for details  ^ ::
>
>                 ::::::::::::::::::::::::::::::::::::::::::::::
>
>                 :: main-prj#sub-prj1;2.0!sub-prj1.jar
>
>                 ::::::::::::::::::::::::::::::::::::::::::::::
>
> -------------------------------------------------------------------------------------------------------------------------------------------
>
> So, the question is:  How to force gradle to use my flat local
> repository to handle dependencies? In other words is ther a way to say
> that the builder-resolver must find the jars in a specified folder.
>
> Thank you for any help
>
> Regards,
>
> Walter
>

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply via email to