Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge branch 'develop'

  • Loading branch information...
commit 2fa0a9ad77e9a1d0792fba34eafbdd0a15142ae8 2 parents a622252 + 9ad4a7f
@SlevinBE SlevinBE authored
Showing with 5,145 additions and 349 deletions.
  1. +6 −1 .gitignore
  2. +18 −0 CHANGELOG.textile
  3. +12 −20 README.textile
  4. +53 −39 build.gradle
  5. +2 −2 buildSrc/wrapper/gradle.properties
  6. +6 −0 gradle.properties
  7. 0  gradlew
  8. +32 −3 src/main/groovy/org/gradlefx/FlexType.groovy
  9. +71 −0 src/main/groovy/org/gradlefx/FrameworkLinkage.groovy
  10. +6 −0 src/main/groovy/org/gradlefx/configuration/FlexAntTasksConfigurator.groovy
  11. +3 −10 src/main/groovy/org/gradlefx/configuration/FlexUnitAntTasksConfigurator.groovy
  12. +39 −21 src/main/groovy/org/gradlefx/conventions/GradleFxConvention.groovy
  13. +218 −0 src/main/groovy/org/gradlefx/conventions/GradleFxDerivedProperties.groovy
  14. +37 −0 src/main/groovy/org/gradlefx/ide/plugins/FDTPlugin.groovy
  15. +40 −0 src/main/groovy/org/gradlefx/ide/plugins/FlashBuilderPlugin.groovy
  16. +36 −0 src/main/groovy/org/gradlefx/ide/plugins/FlashDevelopPlugin.groovy
  17. +36 −0 src/main/groovy/org/gradlefx/ide/plugins/FlexBuilderPlugin.groovy
  18. +34 −0 src/main/groovy/org/gradlefx/ide/plugins/IDEPlugin.groovy
  19. +36 −0 src/main/groovy/org/gradlefx/ide/plugins/IdeaPlugin.groovy
  20. +113 −0 src/main/groovy/org/gradlefx/ide/tasks/AbstractIDEProject.groovy
  21. +27 −0 src/main/groovy/org/gradlefx/ide/tasks/CleanTask.groovy
  22. +37 −0 src/main/groovy/org/gradlefx/ide/tasks/FDTProject.groovy
  23. +71 −0 src/main/groovy/org/gradlefx/ide/tasks/FlashBuilderClean.groovy
  24. +330 −0 src/main/groovy/org/gradlefx/ide/tasks/FlashBuilderProject.groovy
  25. +25 −0 src/main/groovy/org/gradlefx/ide/tasks/FlashBuilderUtil.groovy
  26. +37 −0 src/main/groovy/org/gradlefx/ide/tasks/FlashDevelopProject.groovy
  27. +37 −0 src/main/groovy/org/gradlefx/ide/tasks/FlexBuilderProject.groovy
  28. +37 −0 src/main/groovy/org/gradlefx/ide/tasks/IdeaProject.groovy
  29. +27 −0 src/main/groovy/org/gradlefx/ide/tasks/ProjectTask.groovy
  30. +47 −0 src/main/groovy/org/gradlefx/options/CompilerOption.groovy
  31. +61 −0 src/main/groovy/org/gradlefx/plugins/AbstractGradleFxPlugin.groovy
  32. +40 −62 src/main/groovy/org/gradlefx/{ → plugins}/GradleFxPlugin.groovy
  33. +138 −0 src/main/groovy/org/gradlefx/tasks/ASDoc.groovy
  34. +15 −7 src/main/groovy/org/gradlefx/tasks/AirPackage.groovy
  35. +6 −1 src/main/groovy/org/gradlefx/tasks/CopyResources.groovy
  36. +17 −12 src/main/groovy/org/gradlefx/tasks/HtmlWrapper.groovy
  37. +8 −3 src/main/groovy/org/gradlefx/tasks/Publish.groovy
  38. +1 −2  src/main/groovy/org/gradlefx/tasks/Tasks.groovy
  39. +102 −23 src/main/groovy/org/gradlefx/tasks/Test.groovy
  40. +59 −10 src/main/groovy/org/gradlefx/tasks/compile/AbstractCompileTask.groovy
  41. +12 −5 src/main/groovy/org/gradlefx/tasks/compile/AbstractMxmlc.groovy
  42. +13 −3 src/main/groovy/org/gradlefx/tasks/compile/Amxmlc.groovy
  43. +51 −25 src/main/groovy/org/gradlefx/tasks/compile/Compc.groovy
  44. +52 −7 src/main/groovy/org/gradlefx/tasks/compile/Mxmlc.groovy
  45. +0 −81 src/main/groovy/org/gradlefx/tasks/compile/TestCompile.groovy
  46. +6 −11 src/main/groovy/org/gradlefx/tasks/compile/factory/CompileTaskClassFactoryImpl.groovy
  47. +30 −0 src/main/groovy/org/gradlefx/templates/plugins/CreatorPlugin.groovy
  48. +30 −0 src/main/groovy/org/gradlefx/templates/plugins/ScaffoldPlugin.groovy
  49. +31 −0 src/main/groovy/org/gradlefx/templates/plugins/TemplatesPlugin.groovy
  50. +117 −0 src/main/groovy/org/gradlefx/templates/tasks/Scaffold.groovy
  51. +75 −0 src/main/groovy/org/gradlefx/util/TemplateUtil.groovy
  52. +36 −0 src/main/groovy/org/gradlefx/validators/AbstractCompilerPropertiesValidator.groovy
  53. +58 −0 src/main/groovy/org/gradlefx/validators/AbstractProjectPropertyValidator.groovy
  54. +36 −0 src/main/groovy/org/gradlefx/validators/AirPackagePropertiesValidator.groovy
  55. +54 −0 src/main/groovy/org/gradlefx/validators/CompcAdditionalPropertiesValidator.groovy
  56. +70 −0 src/main/groovy/org/gradlefx/validators/FlexSDKSpecifiedValidator.groovy
  57. +47 −0 src/main/groovy/org/gradlefx/validators/FrameworkLinkageValidator.groovy
  58. +61 −0 src/main/groovy/org/gradlefx/validators/MxmlcAdditionalPropertiesValidator.groovy
  59. +34 −0 src/main/groovy/org/gradlefx/validators/ProjectPropertyValidator.groovy
  60. +35 −0 src/main/groovy/org/gradlefx/validators/actions/ValidateAirPackageTaskPropertiesAction.groovy
  61. +35 −0 src/main/groovy/org/gradlefx/validators/actions/ValidateCompcTaskPropertiesAction.groovy
  62. +35 −0 src/main/groovy/org/gradlefx/validators/actions/ValidateMxmlcTaskPropertiesAction.groovy
  63. +58 −0 src/main/groovy/org/gradlefx/validators/runner/FailOnErrorValidatorRunner.groovy
  64. +22 −0 src/main/groovy/org/gradlefx/validators/runner/ValidatorRunner.groovy
  65. +1 −0  src/main/resources/META-INF/gradle-plugins/creator.properties
  66. +1 −0  src/main/resources/META-INF/gradle-plugins/fdt.properties
  67. +1 −0  src/main/resources/META-INF/gradle-plugins/flashbuilder.properties
  68. +1 −0  src/main/resources/META-INF/gradle-plugins/flashdevelop.properties
  69. +1 −0  src/main/resources/META-INF/gradle-plugins/flexbuilder.properties
  70. +1 −1  src/main/resources/META-INF/gradle-plugins/gradlefx.properties
  71. +1 −0  src/main/resources/META-INF/gradle-plugins/ide.properties
  72. +1 −0  src/main/resources/META-INF/gradle-plugins/ideafx.properties
  73. +1 −0  src/main/resources/META-INF/gradle-plugins/scaffold.properties
  74. +1 −0  src/main/resources/META-INF/gradle-plugins/templates.properties
  75. +232 −0 src/main/resources/templates/air-app.xml
  76. +14 −0 src/main/resources/templates/air.as
  77. +7 −0 src/main/resources/templates/air.mxml
  78. +80 −0 src/main/resources/templates/flashbuilder/air-as.actionScriptProperties
  79. +23 −0 src/main/resources/templates/flashbuilder/air-as.project
  80. +60 −0 src/main/resources/templates/flashbuilder/air-fx.actionScriptProperties
  81. +24 −0 src/main/resources/templates/flashbuilder/air-fx.project
  82. +116 −0 src/main/resources/templates/flashbuilder/mobile-as.actionScriptProperties
  83. +25 −0 src/main/resources/templates/flashbuilder/mobile-as.project
  84. +105 −0 src/main/resources/templates/flashbuilder/mobile-fx.actionScriptProperties
  85. +25 −0 src/main/resources/templates/flashbuilder/mobile-fx.project
  86. +66 −0 src/main/resources/templates/flashbuilder/swc-as.actionScriptProperties
  87. +18 −0 src/main/resources/templates/flashbuilder/swc-as.project
  88. +46 −0 src/main/resources/templates/flashbuilder/swc-fx.actionScriptProperties
  89. +18 −0 src/main/resources/templates/flashbuilder/swc-fx.project
  90. +65 −0 src/main/resources/templates/flashbuilder/swf-as.actionScriptProperties
  91. +17 −0 src/main/resources/templates/flashbuilder/swf-as.project
  92. +46 −0 src/main/resources/templates/flashbuilder/swf-fx.actionScriptProperties
  93. +18 −0 src/main/resources/templates/flashbuilder/swf-fx.project
  94. +6 −0 src/main/resources/templates/flashbuilder/template.flexLibProperties
  95. +2 −0  src/main/resources/templates/flashbuilder/template.flexProperties
  96. +268 −0 src/main/resources/templates/mobile-app.xml
  97. +20 −0 src/main/resources/templates/mobile.as
  98. +8 −0 src/main/resources/templates/mobile.mxml
  99. +14 −0 src/main/resources/templates/swf.as
  100. +7 −0 src/main/resources/templates/swf.mxml
  101. +52 −0 src/test/groovy/org/gradlefx/FlexTypeTest.groovy
  102. +244 −0 src/test/groovy/org/gradlefx/FrameworkLinkageTest.groovy
  103. +79 −0 src/test/groovy/org/gradlefx/conventions/GradleFxConventionTest.groovy
  104. +236 −0 src/test/groovy/org/gradlefx/conventions/GradleFxDerivedPropertiesTest.groovy
  105. +55 −0 src/test/groovy/org/gradlefx/validators/CompcAdditionalPropertiesValidatorTest.groovy
  106. +90 −0 src/test/groovy/org/gradlefx/validators/FlexSDKSpecifiedValidatorTest.groovy
  107. +127 −0 src/test/groovy/org/gradlefx/validators/FrameworkLinkageValidatorTest.groovy
  108. 0  src/test/resources/flex-sdk-no-config/frameworks/libs/some.swc
  109. 0  src/test/resources/flex-sdk-no-libs/frameworks/flex-config.xml
  110. 0  src/test/resources/invalid-flex-sdk/frameworks/libs/dummy.txt
  111. +4 −0 src/test/resources/valid-flex-sdk/ant/flexTasks.tasks
  112. BIN  src/test/resources/valid-flex-sdk/ant/lib/flexTasks.jar
  113. 0  src/test/resources/valid-flex-sdk/frameworks/flex-config.xml
  114. 0  src/test/resources/valid-flex-sdk/frameworks/libs/some.swc
View
7 .gitignore
@@ -1,7 +1,12 @@
.gradle
.idea
+.settings
+.classpath
+bin
build
GradleFx.iml
+gradlefx.ipr
+gradlefx.iws
+/target
.orig
/.project
-gradle.properties
View
18 CHANGELOG.textile
@@ -1,5 +1,23 @@
h2. GradleFx changelog
+h3. v0.5
+
+h5. New features
+* asdoc generation feature (+ 'fatSwc' convention property for fat swc generation)
+* added 'frameworkLinkage' property: defines how the Flex SDK will be linked. defaults to external for swc-based Flex projects, rsl for swf-based projects and none for pure actionscript projects
+* added the 'templates' plugin with a subplugin 'scaffold': generates project directory structure and main file. See documentation for more info: https://github.com/GradleFx/GradleFx/wiki/Templates-plugin
+* added the 'ide' plugin with a subplugin 'flashbuilder': allows you to generate the Adobe Flash Builder project files based on your build configuration. See documentation for more info: https://github.com/GradleFx/GradleFx/wiki/IDE-plugin
+
+h5. Improvements
+* Gradle 1.0 RC3 compatibility
+* Major rework of the FlexUnit integration (greatly simplified the required setup). See documentation for more information: https://github.com/GradleFx/GradleFx/wiki/Flexunit
+* 'mainClass' package notation is now also allowed (org.gradlefx.MainApp or org/gradlefx/MainApp.mxml)
+* Improved the error/warning/info messages
+
+h5. Bug fixes
+* Fixed issue 37: resources aren't added correctly to the swc
+* various other bug fixes
+
h3. v0.4.2
ATTENTION: Gradle 1.0 milestone 8 is required from now on.
View
32 README.textile
@@ -6,24 +6,16 @@ All compiler arguments are supported. Some are automatically filled in by the pl
dependencies) and other more specific arguments can be provided to the plugin by adding them on the
additionalCompilerOptions convention property.
-It adds the following tasks:
-* compile
-* compileTest
-* package
-* test
-* createHtmlWrapper
-* build
-* publish
-* clean
-* copyresources
-
-The plugin has support for the following dependency scopes:
-* internal
-* external
-* merged
-* rsl
-* test
-* theme
+Features:
+* convention-over-configuration
+* dependency management
+* multi-project support
+* source file change detection
+* SWC, SWF and AIR project support
+* FlexUnit support
+* AsDoc support
+* Adobe Flash Builder project generation
+* project scaffolding
h2. Useful links
* Documentation: "https://github.com/GradleFx/GradleFx/wiki":https://github.com/GradleFx/GradleFx/wiki
@@ -33,6 +25,6 @@ h2. Useful links
* Changelog: "https://github.com/GradleFx/GradleFx/blob/master/CHANGELOG.textile":https://github.com/GradleFx/GradleFx/blob/master/CHANGELOG.textile
h2. Upcoming features
-* IDEA and Eclipse project generation support
-* AS3Doc generation
+* IDEA project generation support
* Mobile support
+* Automatic downloading of the Flex SDK
View
92 build.gradle
@@ -20,10 +20,11 @@ import org.gradle.api.artifacts.maven.MavenDeployment
apply plugin: 'groovy'
apply plugin: 'maven'
apply plugin: 'signing'
+apply plugin: 'idea'
group = 'org.gradlefx'
-version = '0.4.2'
-packaging = 'jar'
+version = '0.5'
+ext.packaging = 'jar'
repositories {
mavenCentral()
@@ -31,6 +32,8 @@ repositories {
dependencies {
compile gradleApi()
+ compile group: 'commons-lang', name: 'commons-lang', version: '2.6'
+ testCompile "org.spockframework:spock-core:0.6-groovy-1.8"
groovy group: 'org.codehaus.groovy', name: 'groovy', version: '1.8.6'
}
@@ -53,56 +56,67 @@ artifacts {
task wrapper(type: Wrapper) {
group = 'Buildmaster'
description = 'Generates gradlew and gradlew.bat bootstrap scripts'
- gradleVersion = '1.0-milestone-8'
+ gradleVersion = '1.0-rc-3'
// place jar file and properties into a subdirectory to avoid root dir clutter
jarFile = 'buildSrc/wrapper/gradle.jar'
}
//********* artifact signing *********
-signing {
- sign configurations.archives
+if(gradle.startParameter.taskNames.contains("uploadArchives")) {
+ signing {
+ sign configurations.archives
+ }
+} else {
+ task signArchives {
+ // do nothing
+ }
}
uploadArchives {
repositories {
- mavenDeployer {
- beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
-
- repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") {
- authentication(userName: sonatypeUsername, password: sonatypePassword)
- }
-
- pom.project {
- name 'GradleFx'
- packaging 'jar'
- description 'GradleFx is a Gradle plugin for building Flex and Actionscript applications'
- url 'http://gradlefx.github.com/'
-
- scm {
- url 'scm:git@github.com:GradleFx/GradleFx.git'
- connection 'scm:git@github.com:GradleFx/GradleFx.git'
- developerConnection 'scm:git@github.com:GradleFx/GradleFx.git'
- }
-
- licenses {
- license {
- name 'The Apache Software License, Version 2.0'
- url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
- distribution 'repo'
+ if (version.contains("SNAPSHOT")) {
+ mavenLocal()
+ }
+ else {
+ mavenDeployer {
+ beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
+
+ repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") {
+ authentication(userName: sonatypeUsername, password: sonatypePassword)
+ }
+
+ pom.project {
+ name 'GradleFx'
+ packaging 'jar'
+ description 'GradleFx is a Gradle plugin for building Flex and Actionscript applications'
+ url 'http://gradlefx.github.com/'
+
+ scm {
+ url 'scm:git@github.com:GradleFx/GradleFx.git'
+ connection 'scm:git@github.com:GradleFx/GradleFx.git'
+ developerConnection 'scm:git@github.com:GradleFx/GradleFx.git'
}
- }
-
- developers {
- developer {
- id 'yennicktrevels'
- name 'Yennick Trevels'
+
+ licenses {
+ license {
+ name 'The Apache Software License, Version 2.0'
+ url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
+ distribution 'repo'
+ }
}
- developer {
- id 'stevendick'
- name 'Steven Dick'
+
+ developers {
+ developer {
+ id 'yennicktrevels'
+ name 'Yennick Trevels'
+ }
+ developer {
+ id 'stevendick'
+ name 'Steven Dick'
+ }
}
}
- }
+ }
}
}
}
View
4 buildSrc/wrapper/gradle.properties
@@ -1,6 +1,6 @@
-#Wed Feb 29 22:59:37 CET 2012
+#Sat May 05 19:37:19 CEST 2012
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
-distributionUrl=http\://services.gradle.org/distributions/gradle-1.0-milestone-8-bin.zip
+distributionUrl=http\://services.gradle.org/distributions/gradle-1.0-rc-3-bin.zip
View
6 gradle.properties
@@ -0,0 +1,6 @@
+signing.keyId=
+signing.password=
+signing.secretKeyRingFile=
+
+sonatypeUsername=
+sonatypePassword=
View
0  gradlew 100644 → 100755
File mode changed
View
35 src/main/groovy/org/gradlefx/FlexType.groovy
@@ -17,7 +17,36 @@
package org.gradlefx
enum FlexType {
- swf,
- swc,
- air
+ swf('flex'),
+ swc('flex'),
+ air('air'),
+ mobile('airmobile')
+
+ private String configName
+
+
+ public FlexType(String configName) {
+ this.configName = configName
+ }
+
+ public String getConfigName() {
+ return configName
+ }
+
+ public boolean isApp() {
+ return isWebApp() || isNativeApp()
+ }
+
+ public boolean isLib() {
+ return this == swc
+ }
+
+ public boolean isWebApp() {
+ return this == swf
+ }
+
+ public boolean isNativeApp() {
+ return this == air || this == mobile
+ }
+
}
View
71 src/main/groovy/org/gradlefx/FrameworkLinkage.groovy
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 2011 the original author or authors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * 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.gradlefx
+
+import org.gradlefx.options.CompilerOption;
+
+public enum FrameworkLinkage {
+ external(CompilerOption.EXTERNAL_LIBRARY_PATH),
+ rsl(CompilerOption.RUNTIME_SHARED_LIBRARY_PATH),
+ merged(CompilerOption.LIBRARY_PATH),
+ none
+
+ private CompilerOption compilerOption
+
+ private FrameworkLinkage() {}
+
+ private FrameworkLinkage(CompilerOption compilerOption) {
+ this.compilerOption = compilerOption;
+ }
+
+ public CompilerOption getCompilerOption() {
+ return compilerOption
+ }
+
+ public boolean usesFlex() {
+ return this != none
+ }
+
+ public boolean isCompilerDefault(FlexType type) {
+ FrameworkLinkage compilerDefault = getCompilerDefault(type)
+ return this == compilerDefault || (this == none && compilerDefault == merged)
+ }
+
+ public FrameworkLinkage getCompilerDefault(FlexType type) {
+ return getCompilerDefault(this, type)
+ }
+
+ /**
+ * The framework linkage defaults to 'RSL' for Flex application projects ('swf', 'air' or 'mobile' {@link FlexType}),
+ * 'merged' for pure ActionScript application projects
+ * and 'external' for library projects ('swc' {@link FlexType}).
+ *
+ * @return The default framework linkage
+ */
+ public static FrameworkLinkage getCompilerDefault(FrameworkLinkage linkage, FlexType type) {
+ if ((linkage == external && type.isApp()) || (linkage == rsl && type.isLib()))
+ throw new Exception('Applications cannot link externally')
+
+ return getCompilerDefault(linkage.usesFlex(), type)
+ }
+
+ public static FrameworkLinkage getCompilerDefault(boolean useFlex, FlexType type) {
+ if (type.isLib()) return external
+ return useFlex ? rsl : merged
+ }
+
+}
View
6 src/main/groovy/org/gradlefx/configuration/FlexAntTasksConfigurator.groovy
@@ -17,6 +17,8 @@
package org.gradlefx.configuration
import org.gradle.api.Project
+import org.gradlefx.validators.runner.FailOnErrorValidatorRunner
+import org.gradlefx.validators.FlexSDKSpecifiedValidator
class FlexAntTasksConfigurator {
@@ -27,6 +29,10 @@ class FlexAntTasksConfigurator {
}
public void configure() {
+ new FailOnErrorValidatorRunner(project)
+ .add(new FlexSDKSpecifiedValidator())
+ .run()
+
project.ant.property(name: 'FLEX_HOME', value: project.flexHome)
project.ant.property(name: 'FLEX_LIB', value: '${FLEX_HOME}/frameworks/libs')
project.ant.property(name: 'FLEX_ANT', value: '${FLEX_HOME}/ant')
View
13 src/main/groovy/org/gradlefx/configuration/FlexUnitAntTasksConfigurator.groovy
@@ -19,7 +19,7 @@ package org.gradlefx.configuration
import org.gradle.api.Project
class FlexUnitAntTasksConfigurator {
-
+
private Project project
FlexUnitAntTasksConfigurator(Project project) {
@@ -27,14 +27,7 @@ class FlexUnitAntTasksConfigurator {
}
public void configure() {
- if (project.flexUnit.home == null) return
-
- project.ant.taskdef(resource: 'flexUnitTasks.tasks') {
- classpath {
- fileset(dir: project.flexUnit.home) {
- include(name: project.flexUnit.antTasksJar)
- }
- }
- }
+ project.ant.taskdef(resource: 'flexUnitTasks.tasks',
+ classpath: project.configurations.test.asPath)
}
}
View
60 src/main/groovy/org/gradlefx/conventions/GradleFxConvention.groovy
@@ -18,17 +18,27 @@ package org.gradlefx.conventions
import org.gradle.api.Project
import org.gradlefx.FlexType
+import org.gradlefx.FrameworkLinkage
+
+@Mixin(GradleFxDerivedProperties)
class GradleFxConvention {
private Project project
String output
-
- def testOutput = 'TestRunner'
+
+ public String getOutput() {
+ return output ?: project.name
+ }
// the home directory of the Flex SDK
- def flexHome = System.getenv()['FLEX_HOME'] //default to FLEX_HOME environment variable
+ String flexHome = System.getenv()['FLEX_HOME'] //default to FLEX_HOME environment variable
+
+ public void setFlexHome(String flexHome) {
+ //convert relative paths to absolute ones to prevent ANT from freaking out
+ this.flexHome = flexHome ? new File(flexHome).absolutePath : null
+ }
// which directories to look into for source code
def srcDirs = ['src/main/actionscript']
@@ -54,17 +64,25 @@ class GradleFxConvention {
//equivalent of the include-sources compiler option
List includeSources;
- // what type of Flex project are we? either SWF or SWC
+ // what type of Flex project are we? either SWF, SWC or AIR
FlexType type
+
+ //how the Flex framework will be linked in the project: external, RSL, merged or none
+ //default: RSL for swf, external for swc
+ FrameworkLinkage frameworkLinkage
+
+ public FrameworkLinkage getFrameworkLinkage() {
+ return frameworkLinkage ?: FrameworkLinkage.getCompilerDefault(true, type)
+ }
+
+ //Whether the asdocs should be merged into the swc for use in Flash Builder
+ Boolean fatSwc
// the directory where we should publish the build artifacts
String publishDir = 'publish'
//the root class which is used by the mxmlc compiler to create a swf
- def mainClass = 'Main.mxml'
-
- //the root class for unit testing
- def testClass = null
+ def mainClass = 'Main'
//array of additional compiler options as defined by the compc or mxmlc compiler
def additionalCompilerOptions = []
@@ -83,6 +101,9 @@ class GradleFxConvention {
// AIR packaging properties
def air
+ // ASDoc properties
+ def asdoc
+
def GradleFxConvention(Project project) {
this.project = project
@@ -101,13 +122,10 @@ class GradleFxConvention {
]
flexUnit = [
- home: System.getenv()['FLEXUNIT_HOME'],
- antTasksJar: 'flexUnitTasks-4.1.0-8.jar',
player: 'flash',
command: System.getenv()['FLASH_PLAYER_EXE'],
- swf: "${project.buildDirName}/${testOutput}.swf",
- toDir: "${project.buildDirName}/reports",
- workingDir: project.path,
+ toDir: "${project.buildDir}/reports",
+ workingDir: project.buildDir,
haltonfailure: 'false',
verbose: 'false',
localTrusted: 'true',
@@ -116,7 +134,9 @@ class GradleFxConvention {
timeout: '60000', //60 seconds
failureproperty: 'flexUnitFailed',
headless: 'false',
- display: '99'
+ display: '99',
+ includes: ['**/*Test.as'],
+ excludes: []
]
air = [
@@ -125,14 +145,12 @@ class GradleFxConvention {
applicationDescriptor: "/src/main/actionscript/${project.name}.xml",
includeFileTrees: null
]
-
- project.afterEvaluate {
- initializeEmptyProperties()
- }
- }
- public def initializeEmptyProperties() {
- output = output ?: project.name
+ asdoc = [
+ outputDir: 'doc',
+ additionalASDocOptions: []
+ ]
}
+
}
View
218 src/main/groovy/org/gradlefx/conventions/GradleFxDerivedProperties.groovy
@@ -0,0 +1,218 @@
+/*
+* Copyright (c) 2011 the original author or authors
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* 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.gradlefx.conventions
+
+import static java.util.UUID.randomUUID
+import java.io.File;
+import java.util.List;
+import org.gradle.api.artifacts.ProjectDependency;
+import org.gradlefx.FlexType;
+import org.gradlefx.FrameworkLinkage;
+import org.gradlefx.options.CompilerOption;
+
+
+class GradleFxDerivedProperties {
+
+ /** A generated unique ID for this project */
+ String uuid
+
+ public String getUuid() {
+ if (!uuid) uuid = uuid ?: randomUUID().toString()
+ return uuid
+ }
+
+ /** A unique identifier for air and mobile applications */
+ String applicationId
+
+ public String getApplicationId() {
+ if (!applicationId) applicationId = (getPackageName() ? getPackageName() + '.' : '') + project.name
+ return applicationId
+ }
+
+ /** A version number for air and mobile applications */
+ String version
+
+ public String getVersion() {
+ if (!version) version = toVersionNumber project.version
+ return version
+ }
+
+ /** The class name of the main class */
+ String className
+
+ public String getClassName() {
+ if (!className) className = toClassName new File(getMainClassPath())
+ return className
+ }
+
+ /** The package of the main class */
+ String packageName
+
+ public String getPackageName() {
+ if (!packageName) packageName = toPackage new File(getMainClassPath())
+ return packageName
+ }
+
+ /** The default file extension for this configuration */
+ String defaultExtension
+
+ public String getDefaultExtension() {
+ if (!defaultExtension) defaultExtension = getFrameworkLinkage().usesFlex() ? '.mxml' : '.as'
+ return defaultExtension
+ }
+
+ /** The physical path of the main class relative to src dirs */
+ String mainClassPath
+
+ public String getMainClassPath() {
+ if (!mainClassPath) mainClassPath = createMainClassPath getMainClass(), getDefaultExtension()
+ return mainClassPath
+ }
+
+ /** The path to the Flex SDK's configuration file */
+ String configPath
+
+ public String getConfigPath() {
+ if (!configPath) configPath = "${getFlexHome()}/frameworks/${getType().configName}-config.xml"
+ return configPath
+ }
+
+ /** A collection of all source directories */
+ List allSrcDirs
+
+ public List getAllSrcDirs() {
+ if (!allSrcDirs) allSrcDirs = createAllSrcDirs()
+ return allSrcDirs
+ }
+
+ /** A collection of additional compiler arguments for the IDE */
+ List compilerArgs
+
+ public List getCompilerArgs() {
+ if (!compilerArgs) compilerArgs = createCompilerArgs()
+ return compilerArgs
+ }
+
+ /** The default framework linkage for this project */
+ FrameworkLinkage defaultFrameworkLinkage
+
+ public getDefaultFrameworkLinkage() {
+ if (!defaultFrameworkLinkage) defaultFrameworkLinkage = FrameworkLinkage.getCompilerDefault getFrameworkLinkage(), getType()
+ return defaultFrameworkLinkage
+ }
+
+ /** A collection of {@link Project}s that are dependencies for this project */
+ def dependencyProjects
+
+ public getDependencyProjects() {
+ if (!dependencyProjects) dependencyProjects = createDependencyProjects()
+ return dependencyProjects
+ }
+
+
+ /**
+ * Creates a List of additional compiler arguments that the IDE will need in order to compile
+ *
+ * @return A List of additional compiler arguments for the IDE
+ */
+ private List createCompilerArgs() {
+ List args = []
+
+ if (getLocales().size()) {
+ args.add "${CompilerOption.LOCALE}=${getLocales().join(',')}"
+ args.add "${CompilerOption.SOURCE_PATH}=${getLocaleDir()}/{locale}"
+ }
+
+ args.addAll getAdditionalCompilerOptions()
+
+ return args;
+ }
+
+ /**
+ * Distills a class name from a {@link File}'s name
+ *
+ * @param file The File we want a class name from
+ * @return A class name
+ */
+ private String toClassName(File file) {
+ //\.(mxml|as)$ : remove .as or .mxml extension
+ return file.name.replaceAll(/\.(mxml|as)$/, '')
+ }
+
+ /**
+ * Distills a package name from a {@link File}'s parent directory
+ *
+ * @param file The File we want a package name from
+ * @return A package name
+ */
+ private String toPackage(File file) {
+ //replace back- and forward slashes with dots
+ return file.parent ? file.parent.replaceAll(/\//, '.').replaceAll('\\\\', '.') : ''
+ }
+
+ /**
+ * If mainClass already is a path, just returns that,
+ * otherwise it converts the package notation into a path.
+ *
+ * @return The physical path of the main class relative to src dirs
+ */
+ private static String createMainClassPath(String mainClass, String defaultExtension) {
+ //^[\w\.]+$ : only dots and word characters allowed
+ //^\w+\.(mxml|as)$ : Main.as or Main.mxml (without dir slashes) looks like a package notation, so we filter them out
+ return mainClass.matches(/^[\w\.]+$/) && !mainClass.matches(/^\w+\.(mxml|as)$/) ?
+ mainClass.replaceAll(/\./, '/') + defaultExtension : mainClass
+ }
+
+ /**
+ * Creates an AIR descriptor compatible version (format <0-999>.<0-999>.<0-999>) number
+ * from any kind of version string
+ *
+ * @param version The original version string
+ * @return The version string formatted according to the <0-999>.<0-999>.<0-999> pattern
+ */
+ private String toVersionNumber(String version) {
+ //[^\.\d] : remove anything that is not a dot or a number
+ return !version || version == 'unspecified' ? '0.0.0' : version.replaceAll(/[^\.\d]/, '')
+ }
+
+ /**
+ * Creates a collection of all source directories
+ */
+ private List createAllSrcDirs() {
+ return [
+ getSrcDirs(),
+ getResourceDirs(),
+ getTestDirs(),
+ getTestResourceDirs()
+ ].flatten()
+ }
+
+ /**
+ * Creates a collection of {@link Project}s that are dependencies for this project
+ */
+ private createDependencyProjects() {
+ return (
+ project.configurations.internal.getDependencies() +
+ project.configurations.merged.getDependencies() +
+ project.configurations.external.getDependencies() +
+ project.configurations.rsl.getDependencies() +
+ project.configurations.theme.getDependencies()
+ ).findAll { it instanceof ProjectDependency }
+ .collect { it.getDependencyProject() }
+ }
+
+}
View
37 src/main/groovy/org/gradlefx/ide/plugins/FDTPlugin.groovy
@@ -0,0 +1,37 @@
+
+/*
+* Copyright (c) 2011 the original author or authors
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* 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.gradlefx.ide.plugins
+
+import org.gradlefx.ide.tasks.FDTProject;
+import org.gradlefx.plugins.AbstractGradleFxPlugin;
+
+
+class FDTPlugin extends AbstractGradleFxPlugin {
+
+ @Override
+ protected void applyPlugins() {
+ super.applyPlugins()
+ applyPlugin 'scaffold'
+ }
+
+ @Override
+ protected void addTasks() {
+ addTask FDTProject.NAME, FDTProject
+ }
+
+}
View
40 src/main/groovy/org/gradlefx/ide/plugins/FlashBuilderPlugin.groovy
@@ -0,0 +1,40 @@
+/*
+* Copyright (c) 2011 the original author or authors
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* 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.gradlefx.ide.plugins
+
+
+import org.gradlefx.ide.tasks.FlashBuilderClean;
+import org.gradlefx.ide.tasks.FlashBuilderProject;
+import org.gradlefx.plugins.AbstractGradleFxPlugin;
+
+
+
+class FlashBuilderPlugin extends AbstractGradleFxPlugin {
+
+ @Override
+ protected void applyPlugins() {
+ super.applyPlugins()
+ applyPlugin 'scaffold'
+ }
+
+ @Override
+ protected void addTasks() {
+ addTask FlashBuilderProject.NAME, FlashBuilderProject
+ addTask FlashBuilderClean.NAME, FlashBuilderClean
+ }
+
+}
View
36 src/main/groovy/org/gradlefx/ide/plugins/FlashDevelopPlugin.groovy
@@ -0,0 +1,36 @@
+/*
+* Copyright (c) 2011 the original author or authors
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* 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.gradlefx.ide.plugins
+
+import org.gradlefx.ide.tasks.FlashDevelopProject;
+import org.gradlefx.plugins.AbstractGradleFxPlugin;
+
+
+class FlashDevelopPlugin extends AbstractGradleFxPlugin {
+
+ @Override
+ protected void applyPlugins() {
+ super.applyPlugins()
+ applyPlugin 'scaffold'
+ }
+
+ @Override
+ protected void addTasks() {
+ addTask FlashDevelopProject.NAME, FlashDevelopProject
+ }
+
+}
View
36 src/main/groovy/org/gradlefx/ide/plugins/FlexBuilderPlugin.groovy
@@ -0,0 +1,36 @@
+/*
+* Copyright (c) 2011 the original author or authors
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* 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.gradlefx.ide.plugins
+
+import org.gradlefx.ide.tasks.FlexBuilderProject;
+import org.gradlefx.plugins.AbstractGradleFxPlugin;
+
+
+class FlexBuilderPlugin extends AbstractGradleFxPlugin {
+
+ @Override
+ protected void applyPlugins() {
+ super.applyPlugins()
+ applyPlugin 'scaffold'
+ }
+
+ @Override
+ protected void addTasks() {
+ addTask FlexBuilderProject.NAME, FlexBuilderProject
+ }
+
+}
View
34 src/main/groovy/org/gradlefx/ide/plugins/IDEPlugin.groovy
@@ -0,0 +1,34 @@
+/*
+* Copyright (c) 2011 the original author or authors
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* 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.gradlefx.ide.plugins
+
+import org.gradle.api.Plugin;
+import org.gradle.api.Project;
+
+
+class IDEPlugin implements Plugin<Project> {
+
+ @Override
+ public void apply(Project project) {
+ project.apply(plugin: 'fdt')
+ project.apply(plugin: 'flashbuilder')
+ project.apply(plugin: 'flashdevelop')
+ project.apply(plugin: 'flexbuilder')
+ project.apply(plugin: 'ideafx')
+ }
+
+}
View
36 src/main/groovy/org/gradlefx/ide/plugins/IdeaPlugin.groovy
@@ -0,0 +1,36 @@
+/*
+* Copyright (c) 2011 the original author or authors
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* 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.gradlefx.ide.plugins
+
+import org.gradlefx.ide.tasks.IdeaProject;
+import org.gradlefx.plugins.AbstractGradleFxPlugin;
+
+
+class IdeaPlugin extends AbstractGradleFxPlugin {
+
+ @Override
+ protected void applyPlugins() {
+ super.applyPlugins()
+ applyPlugin 'scaffold'
+ }
+
+ @Override
+ protected void addTasks() {
+ addTask IdeaProject.NAME, IdeaProject
+ }
+
+}
View
113 src/main/groovy/org/gradlefx/ide/tasks/AbstractIDEProject.groovy
@@ -0,0 +1,113 @@
+/*
+* Copyright (c) 2011 the original author or authors
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* 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.gradlefx.ide.tasks
+
+import org.gradle.api.DefaultTask
+import org.gradle.api.logging.LogLevel;
+import org.gradle.api.tasks.TaskAction;
+import org.gradlefx.configuration.Configurations
+import org.gradlefx.conventions.GradleFxConvention
+import org.gradlefx.templates.tasks.Scaffold
+import org.gradlefx.util.TemplateUtil;
+import org.slf4j.Logger
+import org.slf4j.LoggerFactory
+import groovy.lang.Closure
+import groovy.util.XmlParser
+import groovy.xml.XmlUtil
+
+
+@Mixin(TemplateUtil)
+abstract class AbstractIDEProject extends DefaultTask implements ProjectTask {
+
+ protected static final Logger LOG = LoggerFactory.getLogger 'gradlefx'
+
+ /** Convention properties */
+ protected GradleFxConvention flexConvention
+
+ /** The name of the targeted IDE */
+ protected String ideName
+
+ /**
+ * Constructor
+ * @param ideName The name of the targeted IDE
+ */
+ public AbstractIDEProject(String ideName) {
+ this.ideName = ideName
+ description = "Generate $ideName project"
+
+ logging.setLevel LogLevel.INFO
+ flexConvention = project.convention.plugins.flex
+
+ dependsOn(Scaffold.NAME)
+ }
+
+ @Override
+ @TaskAction
+ public void generateProject() {
+ LOG.info "Verifying project properties compatibility with $ideName"
+ invalidateConventions()
+
+ LOG.info "Creating $ideName project files"
+ createProjectConfig()
+ }
+
+ /**
+ *
+ */
+ abstract protected void invalidateConventions()
+
+ /**
+ * Creates the configuration files required by the targeted IDE
+ */
+ abstract protected void createProjectConfig()
+
+ /**
+ * Opens an XML file, allows you to edit it in a {@link Closure}, and writes the modified data to the file
+ *
+ * @param path The path to the XML file to edit
+ * @param closure A Closure in which to edit the XML data; takes the root node as an argument
+ */
+ protected void editXmlFile(String path, Closure closure) {
+ def xml = new XmlParser().parse project.projectDir.absolutePath + '/' + path
+
+ closure xml
+
+ project.file(path).withWriter { out ->
+ XmlUtil.serialize xml, out
+ }
+ }
+
+ /**
+ * Loops over all dependency files and allows you to use them through a {@link Closure}
+ *
+ * @param closure A Closure in which to use the dependency file; takes the file and its {@link Configurations} as arguments
+ */
+ protected void eachDependencyFile(Closure closure) {
+ [
+ Configurations.INTERNAL_CONFIGURATION_NAME,
+ Configurations.EXTERNAL_CONFIGURATION_NAME,
+ Configurations.MERGE_CONFIGURATION_NAME,
+ Configurations.RSL_CONFIGURATION_NAME,
+ Configurations.THEME_CONFIGURATION_NAME
+ ].each() { type ->
+ project.configurations[type].files.each() {
+ closure it, type
+ }
+ }
+ }
+
+}
View
27 src/main/groovy/org/gradlefx/ide/tasks/CleanTask.groovy
@@ -0,0 +1,27 @@
+/*
+* Copyright (c) 2011 the original author or authors
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* 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.gradlefx.ide.tasks
+
+
+public interface CleanTask {
+
+ /**
+ * Removes all IDE related files from this project
+ */
+ void cleanProject()
+
+}
View
37 src/main/groovy/org/gradlefx/ide/tasks/FDTProject.groovy
@@ -0,0 +1,37 @@
+/*
+* Copyright (c) 2011 the original author or authors
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* 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.gradlefx.ide.tasks
+
+
+class FDTProject extends AbstractIDEProject {
+ public static final String NAME = 'fdt'
+
+ public FDTProject() {
+ super('fdt')
+ }
+
+ @Override
+ protected void invalidateConventions() {
+ // TODO Auto-generated method stub
+ }
+
+ @Override
+ protected void createProjectConfig() {
+ throw new Exception('TODO implement FDTProject')
+ }
+
+}
View
71 src/main/groovy/org/gradlefx/ide/tasks/FlashBuilderClean.groovy
@@ -0,0 +1,71 @@
+/*
+* Copyright (c) 2011 the original author or authors
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* 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.gradlefx.ide.tasks
+
+import org.gradle.api.DefaultTask
+import org.gradle.api.logging.LogLevel;
+import org.gradle.api.tasks.TaskAction;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+@Mixin(FlashBuilderUtil)
+class FlashBuilderClean extends DefaultTask implements CleanTask {
+ public static final String NAME = 'flashbuilderClean'
+
+ protected static final Logger LOG = LoggerFactory.getLogger 'gradlefx'
+
+ /** The name of the targeted IDE */
+ protected String ideName
+
+ /**
+ * Constructor
+ */
+ public FlashBuilderClean() {
+ ideName = 'FlashBuilder'
+ description = "Cleans $ideName project, i.e. removes $ideName configuration files and folders"
+
+ logging.setLevel LogLevel.INFO
+ }
+
+ @Override
+ @TaskAction
+ public void cleanProject() {
+ LOG.info "Removing $ideName project files"
+
+ boolean filesDeleted = false
+ [
+ FlashBuilderUtil.eclipseProject,
+ FlashBuilderUtil.actionScriptProperties,
+ FlashBuilderUtil.flexProperties,
+ FlashBuilderUtil.flexLibProperties,
+ getOutputDir(project),
+ '.settings',
+ 'bin-release'
+ ].each {
+ File file = project.file it
+ if (file.exists()) {
+ LOG.info "\t$it"
+ filesDeleted = true
+ file.isFile() ? file.delete() : file.deleteDir()
+ }
+ }
+
+ if (!filesDeleted) LOG.info "\tNothing to remove"
+ }
+
+}
View
330 src/main/groovy/org/gradlefx/ide/tasks/FlashBuilderProject.groovy
@@ -0,0 +1,330 @@
+/*
+* Copyright (c) 2011 the original author or authors
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* 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.gradlefx.ide.tasks
+
+import org.gradle.api.Project;
+import org.gradlefx.FlexType
+import org.gradlefx.FrameworkLinkage
+import org.gradlefx.configuration.Configurations;
+import org.gradlefx.templates.tasks.Scaffold;
+
+
+@Mixin(FlashBuilderUtil)
+class FlashBuilderProject extends AbstractIDEProject {
+ public static final String NAME = 'flashbuilder'
+
+ protected static int libtype_dir = 1
+ protected static int libtype_swc = 3
+ protected static int libtype_sdk = 4
+
+ protected static int linktype_merged = 1
+ protected static int linktype_external = 2
+ protected static int linktype_rsl = 4
+
+ protected static linkTypeMap = [
+ (FrameworkLinkage.merged): linktype_merged,
+ (FrameworkLinkage.external): linktype_external,
+ (FrameworkLinkage.rsl): linktype_rsl
+ ]
+
+ protected String mainSrcDir
+
+
+ /**
+ * Constructor
+ */
+ public FlashBuilderProject() {
+ super('FlashBuilder')
+ mainSrcDir = flexConvention.srcDirs[0]
+ }
+
+ @Override
+ protected void createProjectConfig() {
+ createConfigFiles()
+ addSourceDirs()
+ addIncludedClasses()
+ addDependencies()
+ }
+
+ @Override
+ protected void invalidateConventions() {
+ boolean isValid = !isApplicationFilesInvalid()
+ if (!isValid) moveApplicationFiles()
+ isValid = isValid && validateProjectDependencies()
+
+ if (isValid) LOG.info '\tOK'
+ }
+
+ /**
+ * Validates whether the application files are in a valid location for FlashBuilder and takes action if not.
+ * Bottom line is: AIR and mobile application files must be located in the main source folder root (not in a package).
+ *
+ * @return Whether the application files are in a invalid location for FlashBuilder
+ */
+ private boolean isApplicationFilesInvalid() {
+ return flexConvention.type.isNativeApp() && !!flexConvention.packageName
+ }
+
+ private boolean validateProjectDependencies() {
+ boolean isValid = true
+
+ flexConvention.dependencyProjects.each {
+ File buildDir = it.file getOutputDir(it)
+ if (!buildDir.exists()) {
+ isValid = false
+
+ LOG.warn "\t[WARNING] Couldn't find a compiled library (.swc file) for dependency project '$it.name' " +
+ "in $buildDir.path because the project wasn't compiled with $ideName yet: " +
+ "please build '$it.name' with $ideName and run this task again to verify whether this warning disappears"
+
+ return
+ }
+
+ File swcFile = new File(buildDir, "${it.name}.${FlexType.swc}")
+ if (!swcFile.exists()) {
+ isValid = false
+
+ String msg = "Couldn't find a compiled library (.swc file) for dependency project $it.name at $swcFile.path"
+
+ File alternativeSwcFile = buildDir.listFiles().find {
+ it.name.endsWith ".$FlexType.swc"
+ }
+ if (alternativeSwcFile)
+ msg += "; however, we found '$alternativeSwcFile.name' in $buildDir.path " +
+ "and we'll use it to set up $ideName's project dependency"
+ else msg += " so we scanned for other libraries in $buildDir.path, but couldn't find any"
+
+ LOG.warn "\t[WARNING] $msg"
+ LOG.warn "\t[WARNING] Verify whether $ideName's project name matches the dependency's Gradle project name; " +
+ "$ideName caches the name of an existing project outside the project directory; " +
+ "this means GradleFx cannot alter it for you, so you may want to do it manually."
+ }
+ }
+
+ return isValid
+ }
+
+ /**
+ * Moves the application files to the main source folder root and adjusts the related conventions.
+ */
+ private void moveApplicationFiles() {
+ LOG.warn "\t[WARNING] The mainClass you defined is incompatible with $ideName"
+ LOG.warn "\t[WARNING] GradleFX will automatically move the main application file " +
+ "and the descriptor to the root of the main source directory"
+
+ //delete files generated by SkeletonProject
+ String fullMainClassPath = mainSrcDir + '/' + flexConvention.mainClassPath
+ project.file(fullMainClassPath).delete()
+ project.file(toDescriptorPath(fullMainClassPath)).delete()
+
+ //remove either the package or the path from mainClass
+ String delimiter = flexConvention.mainClass == flexConvention.mainClassPath ? '/' : '.'
+ List mainClassParts = flexConvention.mainClass.split(delimiter)
+ flexConvention.mainClass = mainClassParts[mainClassParts.size() - 1]
+
+ //reset derived properties
+ flexConvention.mainClassPath = null
+ flexConvention.className = null
+ flexConvention.packageName = null
+ flexConvention.applicationId = null
+
+ //re-execute SkeletonProject#createMainClass() with new settings
+ project.tasks.getByName(Scaffold.NAME).createMainClass()
+
+ LOG.warn "\t[WARNING] $ideName conflict resolved; " +
+ "if you wish to get rid of this message, edit the mainClass' location"
+ }
+
+ /**
+ * Creates the FlashBuilder config files based on templates for the respective project types.
+ * .project and .actionScriptProperties are always included;
+ * if it's a library project we add a .flexLibProperties file (even if it's pure ActionScript);
+ * if it's any other kind of Flex project we add a .flexProperties file
+ */
+ private void createConfigFiles() {
+ List extensions = [FlashBuilderUtil.eclipseProject, FlashBuilderUtil.actionScriptProperties]
+ if (flexConvention.type.isLib()) extensions.add FlashBuilderUtil.flexLibProperties
+ else if (flexConvention.frameworkLinkage.usesFlex()) extensions.add FlashBuilderUtil.flexProperties
+
+ extensions.each {
+ LOG.info '\t' + it
+ writeContent getTemplate(it), project.file(it), true
+ }
+ }
+
+ /**
+ * Adds all source dirs except the main source dir to the project's classpath
+ */
+ private void addSourceDirs() {
+ editXmlFile FlashBuilderUtil.actionScriptProperties, { xml ->
+ def parent = xml.compiler.compilerSourcePath[0]
+
+ flexConvention.allSrcDirs.each {
+ if (it != mainSrcDir)
+ new Node(parent, 'compilerSourcePathEntry', [
+ kind: libtype_dir,
+ linkType: linktype_merged,
+ path: it
+ ])
+ }
+ }
+ }
+
+ /**
+ * If {@link GradleFxConvention}.includeClasses is defined,
+ * add the included classes to the project configuration
+ */
+ private void addIncludedClasses() {
+ if (flexConvention.includeClasses == null) return
+
+ editXmlFile FlashBuilderUtil.flexLibProperties, { xml ->
+ def parent = xml.includeClasses[0]
+ xml.@includeAllClasses = false
+
+ flexConvention.includeClasses.each {
+ new Node(parent, 'classEntry', [path: it])
+ }
+ }
+ }
+
+ /**
+ * Sets the framework linkage and creates dependency nodes for all defined dependencies
+ */
+ private void addDependencies() {
+ editXmlFile FlashBuilderUtil.actionScriptProperties, { xml ->
+ Node libNode = xml.compiler.libraryPath[0]
+ libNode.@defaultLinkType = flexConvention.frameworkLinkage.isCompilerDefault(flexConvention.type) ? 0 : 1
+
+ eachDependencyFile { file, type ->
+ switch (type) {
+ case Configurations.INTERNAL_CONFIGURATION_NAME:
+ case Configurations.MERGE_CONFIGURATION_NAME:
+ createDependencyNode libNode, file, FrameworkLinkage.merged
+ break
+ case Configurations.EXTERNAL_CONFIGURATION_NAME:
+ createDependencyNode libNode, file, FrameworkLinkage.external
+ break
+ case Configurations.RSL_CONFIGURATION_NAME:
+ Node node = createDependencyNode libNode, file, FrameworkLinkage.rsl
+ node.@applicationDomain = 'default'
+ node.@forceLoad = false
+
+ node = new Node(node, 'crossDomainRsls')
+ node = new Node(node, 'crossDomainRslEntry', [
+ autoExtract: true,
+ policyFileUrl: '',
+ rslUrl: file.name[0..-2] + 'f'
+ ])
+ break
+ case Configurations.THEME_CONFIGURATION_NAME:
+ String themeName = file.name[0..-5]
+
+ if (!themeName.matches(/(\d|_|\w)+/)) {
+ LOG.warn "\t[WARNING] The file name $themeName is not supported by $ideName:"
+ LOG.warn "\t[WARNING] it can not contain anything else than letters, numbers and underscores."
+ LOG.warn "\t[WARNING] Because of this restriction the theme could not be imported."
+ LOG.warn "\t[WARNING] Consider renaming your theme artifact or switching to a decent IDE."
+ break
+ }
+
+ new Node(xml, 'theme', [
+ themeIsDefault: false,
+ themeIsSDK: false,
+ themeLocation: '${EXTERNAL_THEME_DIR}/' + themeName
+ ])
+
+ LOG.warn "\t[WARNING] GradleFx created a theme dependency with name '$themeName' for you; "
+ LOG.warn "\t[WARNING] however if $ideName does not know this name, it will not recognize your theme."
+ LOG.warn "\t[WARNING] Unfortunately GradleFx cannot access the list of themes stored in your $ideName installation to fix this."
+ LOG.warn "\t[WARNING] Verify that the proper theme is selected by going to 'Properties > Flex Theme':"
+ LOG.warn "\t[WARNING] if the Spark theme is selected instead of yours, you must import yours."
+ LOG.warn "\t[WARNING] Click on 'Import Theme...' and fill out the form with these data:"
+ LOG.warn "\t\tTheme file: ${toDependencyPath(file)}"
+ LOG.warn "\t\tTheme name: $themeName"
+ break
+ }
+ }
+ }
+ }
+
+ /**
+ * Creates an XML node for a dependency.
+ *
+ * @param parent The parent XML node of the node to be created
+ * @param file The dependency file (should be a swc)
+ * @param linkage How the dependency will be linked into the project
+ * @return An XML node for a dependency
+ */
+ protected Node createDependencyNode(Node parent, File file, FrameworkLinkage linkage) {
+ return new Node(parent, 'libraryPathEntry', [
+ kind: libtype_swc,
+ linkType: linkTypeMap[linkage],
+ path: toDependencyPath(file),
+ useDefaultLinkType: flexConvention.frameworkLinkage == linkage
+ ])
+ }
+
+ /**
+ * Generates a template file stream for a given dot-file.
+ * These template file are located in the 'resources' directory.
+ *
+ * @param extension The dot-file we want a template for
+ * @return A template for a dot-file
+ */
+ protected InputStream getTemplate(String extension) {
+ String asfx = flexConvention.frameworkLinkage.usesFlex() ? 'fx' : 'as'
+ String path = "/templates/${getName()}/${flexConvention.type}-${asfx}${extension}"
+
+ InputStream stream = getClass().getResourceAsStream(path)
+ if (stream) return stream
+
+ path = "/templates/${getName()}/template${extension}"
+ return getClass().getResourceAsStream(path)
+ }
+
+ /**
+ * Takes a swc {@link File} and returns a path formatted for FlashBuilder:
+ * if it's a {@link Project} dependency, a relative path to the swc compiled by FlashBuiler;
+ * in any other case, the absolute path
+ *
+ * @param swcFile A dependency swc file
+ * @return A FlashBuilder formatted path
+ */
+ protected String toDependencyPath(File swcFile) {
+ String path = swcFile.path
+
+ flexConvention.dependencyProjects.findAll {
+ swcFile.path.startsWith it.projectDir.path
+ }.each {
+ String buildDirPath = getOutputDir it
+ File buildDir = it.file buildDirPath
+ swcFile = new File(buildDir, "${it.name}.${FlexType.swc}")
+
+ if (!swcFile.exists()) {
+ File alternative = buildDir.listFiles().find {
+ it.name.endsWith ".$FlexType.swc"
+ }
+ if (alternative) swcFile = alternative
+ }
+
+ path = "/${swcFile.name[0..-5]}/$buildDirPath/$swcFile.name"
+ }
+
+ return path
+ }
+
+}
View
25 src/main/groovy/org/gradlefx/ide/tasks/FlashBuilderUtil.groovy
@@ -0,0 +1,25 @@
+package org.gradlefx.ide.tasks
+
+import org.gradle.api.Project;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+class FlashBuilderUtil {
+ public static final String eclipseProject = '.project'
+ public static final String actionScriptProperties = '.actionScriptProperties'
+ public static final String flexLibProperties = '.flexLibProperties'
+ public static final String flexProperties = '.flexProperties'
+
+ public String getOutputDir(Project project) {
+ String outputDir = project.convention.plugins.flex.type.isLib() ? 'bin' : 'bin-debug';
+
+ if (project.file(actionScriptProperties).exists()) {
+ def props = new XmlSlurper().parse(project.projectDir.path + '/' + actionScriptProperties)
+ outputDir = props.compiler.@outputFolderPath.text()
+ }
+
+ return outputDir
+ }
+
+}
View
37 src/main/groovy/org/gradlefx/ide/tasks/FlashDevelopProject.groovy
@@ -0,0 +1,37 @@
+/*
+* Copyright (c) 2011 the original author or authors
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* 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.gradlefx.ide.tasks
+
+
+class FlashDevelopProject extends AbstractIDEProject {
+ public static final String NAME = 'flashdevelop'
+
+ public FlashDevelopProject() {
+ super('FlashDevelop')
+ }
+
+ @Override
+ protected void invalidateConventions() {
+ // TODO Auto-generated method stub
+ }
+
+ @Override
+ protected void createProjectConfig() {
+ throw new Exception('TODO implement FlashDevelopProject')
+ }
+
+}
View
37 src/main/groovy/org/gradlefx/ide/tasks/FlexBuilderProject.groovy
@@ -0,0 +1,37 @@
+/*
+* Copyright (c) 2011 the original author or authors
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* 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.gradlefx.ide.tasks
+
+
+class FlexBuilderProject extends AbstractIDEProject {
+ public static final String NAME = 'flexbuilder'
+
+ public FlexBuilderProject() {
+ super('FlexBuilder')
+ }
+
+ @Override
+ protected void invalidateConventions() {
+ // TODO Auto-generated method stub
+ }
+
+ @Override
+ protected void createProjectConfig() {
+ throw new Exception('TODO implement FlexBuilderProject')
+ }
+
+}
View
37 src/main/groovy/org/gradlefx/ide/tasks/IdeaProject.groovy
@@ -0,0 +1,37 @@
+/*
+* Copyright (c) 2011 the original author or authors
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* 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.gradlefx.ide.tasks
+
+
+class IdeaProject extends AbstractIDEProject {
+ public static final String NAME = 'idea'
+
+ public IdeaProject() {
+ super('IntelliJ IDEA')
+ }
+
+ @Override
+ protected void invalidateConventions() {
+ // TODO Auto-generated method stub
+ }
+
+ @Override
+ protected void createProjectConfig() {
+ throw new Exception('TODO implement IdeaProject')
+ }
+
+}
View
27 src/main/groovy/org/gradlefx/ide/tasks/ProjectTask.groovy
@@ -0,0 +1,27 @@
+/*
+* Copyright (c) 2011 the original author or authors
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* 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.gradlefx.ide.tasks
+
+
+public interface ProjectTask {
+
+ /**
+ * Generates all files that are required for this project
+ */
+ void generateProject()
+
+}
View
47 src/main/groovy/org/gradlefx/options/CompilerOption.groovy
@@ -0,0 +1,47 @@
+package org.gradlefx.options
+
+/*
+ * Copyright (c) 2011 the original author or authors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * 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.
+ */
+public enum CompilerOption {
+
+ INCLUDE_FILE("-include-file"),
+ INCLUDE_SOURCES("-include-sources"),
+ INCLUDE_CLASSES("-include-classes"),
+ INCLUDE_LIBRARIES("-include-libraries"),
+ EXTERNAL_LIBRARY_PATH("-external-library-path"),
+ LIBRARY_PATH("-library-path"),
+ RUNTIME_SHARED_LIBRARY_PATH("-runtime-shared-library-path"),
+ SOURCE_PATH("-source-path"),
+ THEME("-theme"),
+ OUTPUT("-output"),
+ LOCALE("-locale");
+
+
+ private String optionName;
+
+ private CompilerOption(String optionName) {
+ this.optionName = optionName;
+ }
+
+ String getOptionName() {
+ return optionName
+ }
+
+ @Override
+ String toString() {
+ return optionName;
+ }
+}
View
61 src/main/groovy/org/gradlefx/plugins/AbstractGradleFxPlugin.groovy
@@ -0,0 +1,61 @@
+/*
+* Copyright (c) 2011 the original author or authors
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* 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.gradlefx.plugins
+
+import org.gradle.api.Plugin;
+import org.gradle.api.Project;
+import org.gradle.api.Task;
+import org.gradlefx.conventions.GradleFxConvention;
+
+
+abstract class AbstractGradleFxPlugin implements Plugin<Project> {
+
+ protected Project project
+ protected GradleFxConvention flexConvention
+
+
+ @Override
+ public void apply(Project project) {
+ this.project = project
+
+ applyPlugins()
+
+ if (!project.convention.plugins.flex) {
+ GradleFxConvention pluginConvention = new GradleFxConvention(project)
+ project.convention.plugins.flex = pluginConvention
+ }
+
+ flexConvention = project.convention.plugins.flex
+
+ addTasks()
+ }
+
+ protected void applyPlugins() {
+ applyPlugin 'base'
+ }
+
+ protected void applyPlugin(String name) {
+ project.apply(plugin: name)
+ }
+
+ abstract protected void addTasks()
+
+ protected Task addTask(String name, Class task) {
+ return project.tasks.add(name, task)
+ }
+
+}
View
102 src/main/groovy/org/gradlefx/GradleFxPlugin.groovy → ...groovy/org/gradlefx/plugins/GradleFxPlugin.groovy
@@ -14,74 +14,55 @@
* limitations under the License.
*/
-package org.gradlefx
+package org.gradlefx.plugins
import org.gradle.api.DefaultTask
-import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.api.Task
import org.gradle.api.artifacts.Configuration
import org.gradle.api.artifacts.ProjectDependency
import org.gradle.api.artifacts.dsl.ArtifactHandler
import org.gradle.api.internal.artifacts.publish.DefaultPublishArtifact
-import org.gradle.api.tasks.Delete
+import org.gradlefx.configuration.Configurations
+import org.gradlefx.configuration.FlexAntTasksConfigurator
import org.gradlefx.conventions.GradleFxConvention
-import org.gradlefx.tasks.CopyResources
-import org.gradlefx.tasks.HtmlWrapper
-import org.gradlefx.tasks.Publish
-import org.gradlefx.tasks.Test
-import org.gradlefx.tasks.compile.TestCompile
-
import org.gradlefx.tasks.compile.factory.CompileTaskClassFactoryImpl
-import org.slf4j.Logger
-import org.slf4j.LoggerFactory
-import org.gradlefx.tasks.AirPackage
-import org.gradlefx.configuration.FlexAntTasksConfigurator
-import org.gradlefx.configuration.FlexUnitAntTasksConfigurator
-import org.gradlefx.tasks.Tasks
-import org.gradlefx.configuration.Configurations
-
-class GradleFxPlugin implements Plugin<Project> {
-
- Logger log = LoggerFactory.getLogger('flex')
-
- private Project project
+import org.gradlefx.tasks.*
+class GradleFxPlugin extends AbstractGradleFxPlugin {
+
+ @Override
public void apply(Project project) {
- this.project = project
-
- project.apply(plugin: 'base')
-
- GradleFxConvention pluginConvention = new GradleFxConvention(project)
- project.convention.plugins.flex = pluginConvention
-
+ super.apply project
+
addDefaultConfigurations()
+
+ project.afterEvaluate {
+ configureAntWithFlex()
+ addDependsOnOtherProjects()
+ addDefaultArtifact()
+ }
+ }
+ @Override
+ protected void addTasks() {
addBuild()
addCopyResources()
addPublish()
- addTestCompile()
addTest()
//do these tasks in the afterEvaluate phase because they need property access
- project.afterEvaluate {
- configureAntWithFlex()
- configureAntWithFlexUnit()
- addCompile(pluginConvention)
- addPackage()
- addHtmlWrapper()
- addDependsOnOtherProjects()
- addDefaultArtifact()
+ project.afterEvaluate {
+ addCompile flexConvention
+ addASDoc flexConvention
+ addPackage flexConvention
+ addHtmlWrapper flexConvention
}
}
private void configureAntWithFlex() {
new FlexAntTasksConfigurator(project).configure()
}
-
- private void configureAntWithFlexUnit() {
- new FlexUnitAntTasksConfigurator(project).configure()
- }
private void addDefaultConfigurations() {
project.configurations.add(Configurations.INTERNAL_CONFIGURATION_NAME)
@@ -93,49 +74,46 @@ class GradleFxPlugin implements Plugin<Project> {
}
private void addBuild() {
- DefaultTask buildTask = project.tasks.add(Tasks.BUILD_TASK_NAME, DefaultTask)
+ DefaultTask buildTask = addTask Tasks.BUILD_TASK_NAME, DefaultTask
buildTask.setDescription("Assembles and tests this project.")
buildTask.dependsOn(Tasks.TEST_TASK_NAME)
}
private void addCompile(GradleFxConvention pluginConvention) {
- Class<Task> compileClass = new CompileTaskClassFactoryImpl().createCompileTaskClass(project.type)
- project.tasks.add(Tasks.COMPILE_TASK_NAME, compileClass)
+ Class<Task> compileClass = new CompileTaskClassFactoryImpl().createCompileTaskClass(pluginConvention.type)
+ addTask Tasks.COMPILE_TASK_NAME, compileClass
+ }
+
+ private void addASDoc(GradleFxConvention pluginConvention) {
+ if(pluginConvention.type.isLib()) {
+ addTask Tasks.ASDOC_TASK_NAME, ASDoc
+ }
}
private void addPackage(GradleFxConvention pluginConvention) {
- if(project.type == FlexType.air) {
- Task packageTask = project.tasks.add(Tasks.PACKAGE_TASK_NAME, AirPackage)
+ if(pluginConvention.type.isNativeApp()) {
+ Task packageTask = addTask Tasks.PACKAGE_TASK_NAME, AirPackage
packageTask.dependsOn(Tasks.COMPILE_TASK_NAME)
}
}
- private void addTestCompile() {
- Task testCompile = project.tasks.add(Tasks.TEST_COMPILE_TASK_NAME, TestCompile)
- testCompile.description = 'Compile the test runner SWF.'
- testCompile.dependsOn(Tasks.COMPILE_TASK_NAME)
- testCompile.onlyIf{project.testClass != null}
- }
-
private void addTest() {
- Task test = project.tasks.add(Tasks.TEST_TASK_NAME, Test)
+ Task test = addTask Tasks.TEST_TASK_NAME, Test
test.description = 'Run the FlexUnit tests.'
- test.dependsOn(Tasks.TEST_COMPILE_TASK_NAME)
- test.onlyIf{project.testClass != null}
}
- private void addHtmlWrapper() {
- if (project.type == FlexType.swf) {
- project.tasks.add(Tasks.CREATE_HTML_WRAPPER, HtmlWrapper)
+ private void addHtmlWrapper(GradleFxConvention pluginConvention) {
+ if (pluginConvention.type.isWebApp()) {
+ addTask Tasks.CREATE_HTML_WRAPPER, HtmlWrapper
}
}
private void addCopyResources() {
- project.tasks.add(Tasks.COPY_RESOURCES_TASK_NAME, CopyResources)
+ addTask Tasks.COPY_RESOURCES_TASK_NAME, CopyResources
}
private void addPublish() {
- project.tasks.add(Tasks.PUBLISH_TASK_NAME, Publish)
+ addTask Tasks.PUBLISH_TASK_NAME, Publish
}
private void addDependsOnOtherProjects() {
View
138 src/main/groovy/org/gradlefx/tasks/ASDoc.groovy
@@ -0,0 +1,138 @@
+/*
+ * Copyright (c) 2011 the original author or authors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * 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.gradlefx.tasks
+
+import org.gradle.api.tasks.TaskAction
+import org.gradlefx.tasks.compile.AbstractMxmlc
+import org.gradlefx.FrameworkLinkage
+import org.gradlefx.options.CompilerOption
+import org.gradle.api.Project
+import org.gradlefx.configuration.Configurations
+import org.gradle.api.internal.artifacts.dependencies.DefaultProjectDependency
+
+class ASDoc extends AbstractMxmlc {
+
+ private static final String ANT_RESULT_PROPERTY = 'asdocCompileResult'
+ private static final String ANT_OUTPUT_PROPERTY = 'asdocCompileOutput'
+
+ ASDoc() {
+ description = 'Generates ASDoc documentation'
+
+ addDependsOnTaskInOtherProjects(Tasks.COMPILE_TASK_NAME, Configurations.MERGE_CONFIGURATION_NAME)
+ addDependsOnTaskInOtherProjects(Tasks.COMPILE_TASK_NAME, Configurations.EXTERNAL_CONFIGURATION_NAME)
+ addDependsOnTaskInOtherProjects(Tasks.COMPILE_TASK_NAME, Configurations.INTERNAL_CONFIGURATION_NAME)
+
+ initInputDirectory()
+ initOutputDirectory()
+ }
+
+ private def initInputDirectory() {
+ flexConvention.srcDirs.each { sourceDirectory ->
+ inputs.dir sourceDirectory
+ }
+ }
+
+ private def initOutputDirectory() {
+ outputs.dir flexConvention.asdoc.outputDir
+ }
+
+ @TaskAction
+ def compileFlex() {
+ if(hasDocSources()) {
+ super.compileFlex(ANT_RESULT_PROPERTY, ANT_OUTPUT_PROPERTY, 'asdoc', createCompilerArguments())
+
+
+ }
+ }
+
+ @Override
+ def compile(antResultProperty, antOutputProperty, compilerArguments) {
+ ant.java(jar: flexConvention.flexHome + '/lib/asdoc.jar',
+ dir: flexConvention.flexHome + '/frameworks',
+ fork: true,
+ resultproperty: antResultProperty,
+ outputproperty: antOutputProperty) { javaTask ->
+
+ flexConvention.jvmArguments.each { jvmArgument ->
+ jvmarg(value: jvmArgument)
+ }
+
+ compilerArguments.each { compilerArgument ->
+ arg(value: compilerArgument)
+ }
+ }
+ }
+
+ protected FrameworkLinkage getDefaultFrameworkLinkage() {
+ return FrameworkLinkage.merged
+ }
+
+ protected List createCompilerArguments() {
+ List compilerArguments = []
+
+ //add every source directory
+ addSourcePaths(compilerArguments)
+ addDocSources(compilerArguments)
+ addLocales(compilerArguments)
+
+ //add dependencies
+ addLibraries(project.configurations.internal.files, project.configurations.internal, CompilerOption.INCLUDE_LIBRARIES, compilerArguments)
+ addLibraries(project.configurations.external.files, project.configurations.external, CompilerOption.EXTERNAL_LIBRARY_PATH, compilerArguments)
+ addLibraries(project.configurations.merged.files, project.configurations.merged, CompilerOption.LIBRARY_PATH, compilerArguments)
+ addLibraries(project.configurations.theme.files, project.configurations.theme, CompilerOption.THEME, compilerArguments)
+ addRsls(compilerArguments)
+
+ //add all the other user specified compiler options
+ flexConvention.additionalCompilerOptions.each { compilerOption ->
+ compilerArguments.add(compilerOption)
+ }
+
+ flexConvention.asdoc.additionalASDocOptions.each { asdocOption ->
+ compilerArguments.add(asdocOption)
+ }
+
+ // only generate the tempdita folder when having to create a fat swc
+