Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate diagrams under build directory instead #7

Open
TAGC opened this issue Jun 14, 2015 · 1 comment
Open

Generate diagrams under build directory instead #7

TAGC opened this issue Jun 14, 2015 · 1 comment

Comments

@TAGC
Copy link

TAGC commented Jun 14, 2015

I think it would be better to generate UML files under a subfolder of the build/ directory rather than under src/main/java, considering these are generated artifacts and not source files.

I've added this code to my Gradle build script and it seems to be working:

/**
* Moves UML files generated by :plantuml to subdirectories of the build/ folder.
*/
project.tasks.plantuml.doLast {
    def sourceBase = file(plantuml.sourcePath).absolutePath + File.separator
    def buildBase = file("$buildDir/docs/uml").absolutePath + File.separator
    def umlFileExtension = "$plantuml.fileFormat".toLowerCase()

    /*
    * Iterate for each file operated on by :plantuml.
    */
    plantuml.sources.each { File sourceFile ->      
        def sourceFileBase = sourceFile.name.split("\\.")[0]
        def fileDir = sourceFile.getParentFile()

        /*
        * Iterate for each file in the parent directory and move discovered UML files
        * under build/.
        */
        fileDir.eachFile (groovy.io.FileType.FILES) { File possibleUmlFile ->
            if (possibleUmlFile.name.startsWith(sourceFileBase) && possibleUmlFile.name.endsWith(umlFileExtension)) {
                def newUmlPath = file(buildBase + (possibleUmlFile.absolutePath - sourceBase))

                newUmlPath.getParentFile().mkdirs()
                possibleUmlFile.renameTo(newUmlPath)
            }
        }
    }
}
@gallardo
Copy link

gallardo commented Nov 3, 2015

👍 For the feature request.

But your implementation assumes that every source file is under sourceBase, by default src/main/java. Furthermore, it also assumes that all files under sourceBase ending in png were generated by plantuml. I'd rather had something more in the gradle spirit (supporting source sets, in contrast to one specific dir)*.

By the way, how does it cope with javadoc generation? Are these pngs included in the generated javadoc?


* I have spent a few hours trying to implement this myself, but it's proving to require better gradle skills than those that I have at the moment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants