From 2283f53c09cfaf082fd5e390085270df1ddaef9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Schalk=20W=2E=20Cronj=C3=A9?= Date: Mon, 2 Jun 2014 19:28:23 +0100 Subject: [PATCH] Fixed issues with applying the Doxygen plugin --- .../org/ysb33r/gradle/doxygen/Doxygen.groovy | 31 ++------- .../gradle/doxygen/DoxygenPlugin.groovy | 26 +++++++ .../doxygen/DoxygenTemplateFiles.groovy | 68 +++++++++++++++++++ .../gradle-plugins/doxygen.properties | 0 .../gradle/doxygen/DoxygenPluginSpec.groovy | 34 ++++++++++ 5 files changed, 133 insertions(+), 26 deletions(-) create mode 100644 doxygen/src/main/groovy/org/ysb33r/gradle/doxygen/DoxygenPlugin.groovy create mode 100644 doxygen/src/main/groovy/org/ysb33r/gradle/doxygen/DoxygenTemplateFiles.groovy rename doxygen/src/main/resources/{ => META-INF}/gradle-plugins/doxygen.properties (100%) create mode 100644 doxygen/src/test/groovy/org/ysb33r/gradle/doxygen/DoxygenPluginSpec.groovy diff --git a/doxygen/src/main/groovy/org/ysb33r/gradle/doxygen/Doxygen.groovy b/doxygen/src/main/groovy/org/ysb33r/gradle/doxygen/Doxygen.groovy index e971227..172ae94 100644 --- a/doxygen/src/main/groovy/org/ysb33r/gradle/doxygen/Doxygen.groovy +++ b/doxygen/src/main/groovy/org/ysb33r/gradle/doxygen/Doxygen.groovy @@ -192,12 +192,17 @@ class Doxygen extends SourceTask { /** Set some default values in the doxyUpdate * */ + @groovy.transform.PackageScope void setDefaults() { if (imagePaths.size()) { doxyUpdate.setProperty('IMAGE_PATH', imagePaths as File[]) } + if(source.files.empty) { + source 'src/main/cpp','src/main/headers','src/main/asm','src/main/objectiveC','src/main/objectiveCpp','src/main/c' + } + doxyUpdate.setProperty('INPUT', source) doxyUpdate.setProperty('OUTPUT_DIRECTORY', outputDir) @@ -258,31 +263,5 @@ class Doxygen extends SourceTask { } } - /* - -1) Use doxygen to generate a template configuration file: - doxygen [-s] -g [configName] - - If - is used for configName doxygen will write to standard output. - -2) Use doxygen to update an old configuration file: - doxygen [-s] -u [configName] - -3) Use doxygen to generate documentation using an existing configuration file: - doxygen [configName] - If - is used for configName doxygen will read from standard input. - -4) Use doxygen to generate a template file controlling the layout of the - generated documentation: - doxygen -l layoutFileName.xml - -5) Use doxygen to generate a template style sheet file for RTF, HTML or Latex. - RTF: doxygen -w rtf styleSheetFile - HTML: doxygen -w html headerFile footerFile styleSheetFile [configFile] - LaTeX: doxygen -w latex headerFile footerFile styleSheetFile [configFile] - -6) Use doxygen to generate an rtf extensions file - RTF: doxygen -e rtf extensionsFile - */ diff --git a/doxygen/src/main/groovy/org/ysb33r/gradle/doxygen/DoxygenPlugin.groovy b/doxygen/src/main/groovy/org/ysb33r/gradle/doxygen/DoxygenPlugin.groovy new file mode 100644 index 0000000..51a23fd --- /dev/null +++ b/doxygen/src/main/groovy/org/ysb33r/gradle/doxygen/DoxygenPlugin.groovy @@ -0,0 +1,26 @@ +// ============================================================================ +// (C) Copyright Schalk W. Cronje 2014 +// +// This software is licensed under the Apache License 2.0 +// See http://www.apache.org/licenses/LICENSE-2.0 for license details +// +// Unless required by applicable law or agreed to in writing, software distributed under the License is +// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and limitations under the License. +// +// ============================================================================ +package org.ysb33r.gradle.doxygen + +import org.gradle.api.Plugin +import org.gradle.api.Project + +/** + * Created by schalkc on 29/05/2014. + */ +class DoxygenPlugin implements Plugin { + void apply(Project project) { + project.apply(plugin: 'base') + project.task('doxygen', type: Doxygen, group: 'Documentation') + project.task('createDoxygenTemplates', type: DoxygenTemplateFiles/*, group: 'Documentation'*/) + } +} \ No newline at end of file diff --git a/doxygen/src/main/groovy/org/ysb33r/gradle/doxygen/DoxygenTemplateFiles.groovy b/doxygen/src/main/groovy/org/ysb33r/gradle/doxygen/DoxygenTemplateFiles.groovy new file mode 100644 index 0000000..6ca7ba5 --- /dev/null +++ b/doxygen/src/main/groovy/org/ysb33r/gradle/doxygen/DoxygenTemplateFiles.groovy @@ -0,0 +1,68 @@ +// ============================================================================ +// (C) Copyright Schalk W. Cronje 2014 +// +// This software is licensed under the Apache License 2.0 +// See http://www.apache.org/licenses/LICENSE-2.0 for license details +// +// Unless required by applicable law or agreed to in writing, software distributed under the License is +// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and limitations under the License. +// +// ============================================================================ +package org.ysb33r.gradle.doxygen + +import org.gradle.api.DefaultTask +import org.gradle.api.tasks.Input +import org.gradle.api.tasks.TaskAction +import org.gradle.process.ExecResult + +/** + * Allows for the creation of template files in a location. 'src/doxygen' is the default. + */ +class DoxygenTemplateFiles extends DefaultTask { + + /** Location where to generate files into. By default this will be src/doxygen. + * + */ + @Input + File location = new File(project.projectDir,'src/doxygen') + + /** Prefix used for naming files. By default it is the name of the project. + * + */ + @Input + String prefix = project.name + + /** Location of doxygen executable. By default the search path will be used to find it. + * + */ + @Input + String doxygen = 'doxygen' + + @TaskAction + void exec() { + runDoxygen '-l', new File(location,prefix+'LayoutTemplate.xml').absolutePath + runDoxygen '-w', 'rtf', new File(location,prefix+'Style.rtf').absolutePath + runDoxygen '-w', 'html', new File(location,prefix+'Header.html').absolutePath, + new File(location,prefix+'Footer.html').absolutePath, + new File(location,prefix+'.css').absolutePath + runDoxygen '-w', 'latex', new File(location,prefix+'Header.tex').absolutePath, + new File(location,prefix+'Footer.tex').absolutePath, + new File(location,prefix+'Style.tex').absolutePath + runDoxygen '-e', 'rtf', new File(location,prefix+'Extensions.rtf').absolutePath + } + + /** Runs the Doxygen executable + * + * @param cmdargs + */ + private void runDoxygen(String... cmdargs) { + + cmdargs.add(doxyfile.absolutePath) + ExecResult execResult = project.exec { + + executable doxygen + args cmdargs + } + } +} diff --git a/doxygen/src/main/resources/gradle-plugins/doxygen.properties b/doxygen/src/main/resources/META-INF/gradle-plugins/doxygen.properties similarity index 100% rename from doxygen/src/main/resources/gradle-plugins/doxygen.properties rename to doxygen/src/main/resources/META-INF/gradle-plugins/doxygen.properties diff --git a/doxygen/src/test/groovy/org/ysb33r/gradle/doxygen/DoxygenPluginSpec.groovy b/doxygen/src/test/groovy/org/ysb33r/gradle/doxygen/DoxygenPluginSpec.groovy new file mode 100644 index 0000000..c48c7cc --- /dev/null +++ b/doxygen/src/test/groovy/org/ysb33r/gradle/doxygen/DoxygenPluginSpec.groovy @@ -0,0 +1,34 @@ +// ============================================================================ +// (C) Copyright Schalk W. Cronje 2014 +// +// This software is licensed under the Apache License 2.0 +// See http://www.apache.org/licenses/LICENSE-2.0 for license details +// +// Unless required by applicable law or agreed to in writing, software distributed under the License is +// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and limitations under the License. +// +// ============================================================================ + +package org.ysb33r.gradle.doxygen + +import org.gradle.api.Project +import org.gradle.testfixtures.ProjectBuilder + +class DoxygenPluginSpec extends spock.lang.Specification { + + Project project = ProjectBuilder.builder().build() + + void setup() { + project.apply plugin:'doxygen' + } + + def "Can apply Doxygen plugin to project"() { + + expect: + project.tasks.doxygen != null + project.tasks.createDoxygenTemplates != null + } + +} +