You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flex.apache.org by cd...@apache.org on 2016/04/17 18:15:43 UTC
git commit: [flex-falcon] [refs/heads/feature/maven-migration-test] -
- Started on some build documentation (structure.adoc) - Moved the trust
logic into a separate mojo bound to the 'process-test-classes' phase
Repository: flex-falcon
Updated Branches:
refs/heads/feature/maven-migration-test c29d135ea -> 4236c48a6
- Started on some build documentation (structure.adoc)
- Moved the trust logic into a separate mojo bound to the 'process-test-classes' phase
Project: http://git-wip-us.apache.org/repos/asf/flex-falcon/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-falcon/commit/4236c48a
Tree: http://git-wip-us.apache.org/repos/asf/flex-falcon/tree/4236c48a
Diff: http://git-wip-us.apache.org/repos/asf/flex-falcon/diff/4236c48a
Branch: refs/heads/feature/maven-migration-test
Commit: 4236c48a6be227e69dbce2002265395de3e085ba
Parents: c29d135
Author: Christofer Dutz <ch...@codecentric.de>
Authored: Sun Apr 17 18:15:23 2016 +0200
Committer: Christofer Dutz <ch...@codecentric.de>
Committed: Sun Apr 17 18:15:23 2016 +0200
----------------------------------------------------------------------
.../apache/flex/maven/flexjs/CompileMojo.java | 9 --
.../flexjs/FlashplayerSecurityHandler.java | 125 -------------------
.../flex/maven/flexjs/SecurityHandler.java | 12 --
.../org/apache/flex/maven/flexjs/TrustMojo.java | 35 ++++++
.../maven/flexjs/trust/DefaultTrustHandler.java | 125 +++++++++++++++++++
.../flex/maven/flexjs/trust/TrustHandler.java | 12 ++
.../resources/META-INF/plexus/components.xml | 9 ++
pom.xml | 48 +++++++
src/site/asciidoc/structure.adoc | 55 ++++++++
9 files changed, 284 insertions(+), 146 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/4236c48a/flexjs-maven-plugin/src/main/java/org/apache/flex/maven/flexjs/CompileMojo.java
----------------------------------------------------------------------
diff --git a/flexjs-maven-plugin/src/main/java/org/apache/flex/maven/flexjs/CompileMojo.java b/flexjs-maven-plugin/src/main/java/org/apache/flex/maven/flexjs/CompileMojo.java
index 660f222..ca2b28a 100644
--- a/flexjs-maven-plugin/src/main/java/org/apache/flex/maven/flexjs/CompileMojo.java
+++ b/flexjs-maven-plugin/src/main/java/org/apache/flex/maven/flexjs/CompileMojo.java
@@ -26,7 +26,6 @@ import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.project.MavenProject;
-import javax.inject.Inject;
import java.io.File;
/**
@@ -49,9 +48,6 @@ public class CompileMojo
@Parameter(defaultValue = "${project.artifactId}-${project.version}.swc")
private String outputFileName;
- @Inject
- private SecurityHandler securityHandler;
-
public void execute()
throws MojoExecutionException
{
@@ -67,11 +63,6 @@ public class CompileMojo
"-output=" + outputFile.getPath()};
compc.execute(args);
- // Add the output directory to the FlashPlayer trust files to prevent
- // the FlashPlayer from complaining about running untrusted content.
- // TODO: This should be handled somewhere else, but it's enough for now:
- securityHandler.trustFile(outputDirectory);
-
// Attach the file created by the compiler as artifact file to maven.
project.getArtifact().setFile(outputFile);
}
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/4236c48a/flexjs-maven-plugin/src/main/java/org/apache/flex/maven/flexjs/FlashplayerSecurityHandler.java
----------------------------------------------------------------------
diff --git a/flexjs-maven-plugin/src/main/java/org/apache/flex/maven/flexjs/FlashplayerSecurityHandler.java b/flexjs-maven-plugin/src/main/java/org/apache/flex/maven/flexjs/FlashplayerSecurityHandler.java
deleted file mode 100644
index a0be9b1..0000000
--- a/flexjs-maven-plugin/src/main/java/org/apache/flex/maven/flexjs/FlashplayerSecurityHandler.java
+++ /dev/null
@@ -1,125 +0,0 @@
-/*
- * Copyright 2001-2005 The Apache Software Foundation.
- *
- * 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.apache.flex.maven.flexjs;
-
-import org.apache.commons.io.FileUtils;
-import org.apache.commons.lang3.SystemUtils;
-
-import javax.inject.Named;
-import javax.inject.Singleton;
-import java.io.File;
-import java.io.IOException;
-import java.util.List;
-
-/**
- * Little helper that adds a directory to the FlashPlayer trust settings.
- * This prevents the FlashPlayer from complaining about running untrusted
- * code, which will prevent the tests using the FlashPlayer from succeeding.
- *
- * Created by christoferdutz on 14.04.16.
- */
-@Named
-@Singleton
-public class FlashplayerSecurityHandler implements SecurityHandler {
-
- @Override
- public void trustFile(File directory) {
- File securityTrustFile = new File(getSecuritySettingsDirectory(), "apache-flex-maven-plugin.cfg");
-
- if(!securityTrustFile.exists()) {
- System.out.println(" - Creating new FlashPlayer security trust file at: " + securityTrustFile.getPath());
- try {
- if(!securityTrustFile.createNewFile()) {
- throw new RuntimeException("Could not create FlashPlayer security trust file at: " +
- securityTrustFile.getPath());
- }
- } catch (IOException e) {
- throw new RuntimeException("Could not create FlashPlayer security trust file at: " +
- securityTrustFile.getPath(), e);
- }
- } else {
- System.out.println(" - Creating new FlashPlayer security trust file at: " + securityTrustFile.getPath());
- }
-
- // Check if the current directory is already listed in the file, if not, append it to the file.
- try {
- List<String> trustedDirectories = FileUtils.readLines(securityTrustFile, "UTF-8");
- if(!trustedDirectories.contains(directory.getAbsolutePath())) {
- FileUtils.writeStringToFile(securityTrustFile, directory.getAbsolutePath() + "\n", "UTF-8", true);
- System.out.println(" - Added directory '" + directory.getAbsolutePath() +
- "' to FlashPlayer security trust file at: " + securityTrustFile.getPath());
- } else {
- System.out.println(" - Directory '" + directory.getAbsolutePath() +
- "' already listed in FlashPlayer security trust file at: " + securityTrustFile.getPath());
- }
- } catch (IOException e) {
- throw new RuntimeException("Could not add directory '" + directory.getPath() +
- "' to FlashPlayer security trust file", e);
- }
- }
-
- private File getSecuritySettingsDirectory() {
- File userHome = new File(System.getProperty("user.home"));
- File securitySettingsDirectory;
-
- if(SystemUtils.IS_OS_WINDOWS) {
- // Try to get the location of the APPDATA directory from an environment-variable.
- File appDataDirectory;
- if(System.getenv("APPDATA") != null) {
- appDataDirectory = new File(System.getenv("APPDATA"));
- }
- // If the environment-variable was not set, try defaults, depending on the
- // detail version of Windows.
- else {
- // Vista did things differently.
- if(SystemUtils.IS_OS_WINDOWS_VISTA) {
- appDataDirectory = new File(userHome, "AppData/Roaming");
- } else {
- appDataDirectory = new File(userHome, "Application Data");
- }
- }
- securitySettingsDirectory =
- new File(appDataDirectory, "Macromedia/Flash Player/#Security/FlashPlayerTrust");
- }
-
- else if(SystemUtils.IS_OS_MAC) {
- securitySettingsDirectory = new File(userHome,
- "Library/Preferences/Macromedia/Flash Player/#Security/FlashPlayerTrust");
- }
-
- else if(SystemUtils.IS_OS_LINUX) {
- securitySettingsDirectory = new File(userHome, ".macromedia/Flash_Player/#Security/FlashPlayerTrust");
- }
-
- // As the FlashPlayer is only available on Windows, Mac and Linux, this is all we can do.
- else {
- throw new UnsupportedOperationException(
- "FlashplayerSecurityHandler not prepared for handling OS type of: " + SystemUtils.OS_NAME);
- }
-
- // If the directory didn't exist yet, create it now.
- if(!securitySettingsDirectory.exists()) {
- if(!securitySettingsDirectory.mkdirs()) {
- throw new RuntimeException("Could not create FlashPlayer security settings directory at: " +
- securitySettingsDirectory.getPath());
- }
- }
-
- return securitySettingsDirectory;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/4236c48a/flexjs-maven-plugin/src/main/java/org/apache/flex/maven/flexjs/SecurityHandler.java
----------------------------------------------------------------------
diff --git a/flexjs-maven-plugin/src/main/java/org/apache/flex/maven/flexjs/SecurityHandler.java b/flexjs-maven-plugin/src/main/java/org/apache/flex/maven/flexjs/SecurityHandler.java
deleted file mode 100644
index 577740c..0000000
--- a/flexjs-maven-plugin/src/main/java/org/apache/flex/maven/flexjs/SecurityHandler.java
+++ /dev/null
@@ -1,12 +0,0 @@
-package org.apache.flex.maven.flexjs;
-
-import java.io.File;
-
-/**
- * Created by christoferdutz on 14.04.16.
- */
-public interface SecurityHandler {
-
- void trustFile(File directory);
-
-}
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/4236c48a/flexjs-maven-plugin/src/main/java/org/apache/flex/maven/flexjs/TrustMojo.java
----------------------------------------------------------------------
diff --git a/flexjs-maven-plugin/src/main/java/org/apache/flex/maven/flexjs/TrustMojo.java b/flexjs-maven-plugin/src/main/java/org/apache/flex/maven/flexjs/TrustMojo.java
new file mode 100644
index 0000000..cf8b7e4
--- /dev/null
+++ b/flexjs-maven-plugin/src/main/java/org/apache/flex/maven/flexjs/TrustMojo.java
@@ -0,0 +1,35 @@
+package org.apache.flex.maven.flexjs;
+
+import org.apache.flex.maven.flexjs.trust.TrustHandler;
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugins.annotations.LifecyclePhase;
+import org.apache.maven.plugins.annotations.Mojo;
+import org.apache.maven.plugins.annotations.Parameter;
+
+import javax.inject.Inject;
+import java.io.File;
+
+/**
+ * This little mojo simply adds the maven build output directory to the
+ * list of trusted sources for the FlashPlayer.
+ *
+ * Created by christoferdutz on 17.04.16.
+ */
+@Mojo(name="trust",defaultPhase = LifecyclePhase.PROCESS_TEST_CLASSES)
+public class TrustMojo
+ extends AbstractMojo
+{
+
+ @Parameter(defaultValue="${project.build.directory}")
+ private File outputDirectory;
+
+ @Inject
+ private TrustHandler securityHandler;
+
+ public void execute()
+ throws MojoExecutionException {
+ securityHandler.trustDirectory(outputDirectory);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/4236c48a/flexjs-maven-plugin/src/main/java/org/apache/flex/maven/flexjs/trust/DefaultTrustHandler.java
----------------------------------------------------------------------
diff --git a/flexjs-maven-plugin/src/main/java/org/apache/flex/maven/flexjs/trust/DefaultTrustHandler.java b/flexjs-maven-plugin/src/main/java/org/apache/flex/maven/flexjs/trust/DefaultTrustHandler.java
new file mode 100644
index 0000000..858d3fd
--- /dev/null
+++ b/flexjs-maven-plugin/src/main/java/org/apache/flex/maven/flexjs/trust/DefaultTrustHandler.java
@@ -0,0 +1,125 @@
+/*
+ * Copyright 2001-2005 The Apache Software Foundation.
+ *
+ * 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.apache.flex.maven.flexjs.trust;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.lang3.SystemUtils;
+
+import javax.inject.Named;
+import javax.inject.Singleton;
+import java.io.File;
+import java.io.IOException;
+import java.util.List;
+
+/**
+ * Little helper that adds a directory to the FlashPlayer trust settings.
+ * This prevents the FlashPlayer from complaining about running untrusted
+ * code, which will prevent the tests using the FlashPlayer from succeeding.
+ *
+ * Created by christoferdutz on 14.04.16.
+ */
+@Named
+@Singleton
+public class DefaultTrustHandler implements TrustHandler {
+
+ @Override
+ public void trustDirectory(File directory) {
+ File securityTrustFile = new File(getSecuritySettingsDirectory(), "apache-flex-maven-plugin.cfg");
+
+ if(!securityTrustFile.exists()) {
+ System.out.println(" - Creating new FlashPlayer security trust file at: " + securityTrustFile.getPath());
+ try {
+ if(!securityTrustFile.createNewFile()) {
+ throw new RuntimeException("Could not create FlashPlayer security trust file at: " +
+ securityTrustFile.getPath());
+ }
+ } catch (IOException e) {
+ throw new RuntimeException("Could not create FlashPlayer security trust file at: " +
+ securityTrustFile.getPath(), e);
+ }
+ } else {
+ System.out.println(" - Creating new FlashPlayer security trust file at: " + securityTrustFile.getPath());
+ }
+
+ // Check if the current directory is already listed in the file, if not, append it to the file.
+ try {
+ List<String> trustedDirectories = FileUtils.readLines(securityTrustFile, "UTF-8");
+ if(!trustedDirectories.contains(directory.getAbsolutePath())) {
+ FileUtils.writeStringToFile(securityTrustFile, directory.getAbsolutePath() + "\n", "UTF-8", true);
+ System.out.println(" - Added directory '" + directory.getAbsolutePath() +
+ "' to FlashPlayer security trust file at: " + securityTrustFile.getPath());
+ } else {
+ System.out.println(" - Directory '" + directory.getAbsolutePath() +
+ "' already listed in FlashPlayer security trust file at: " + securityTrustFile.getPath());
+ }
+ } catch (IOException e) {
+ throw new RuntimeException("Could not add directory '" + directory.getPath() +
+ "' to FlashPlayer security trust file", e);
+ }
+ }
+
+ private File getSecuritySettingsDirectory() {
+ File userHome = new File(System.getProperty("user.home"));
+ File securitySettingsDirectory;
+
+ if(SystemUtils.IS_OS_WINDOWS) {
+ // Try to get the location of the APPDATA directory from an environment-variable.
+ File appDataDirectory;
+ if(System.getenv("APPDATA") != null) {
+ appDataDirectory = new File(System.getenv("APPDATA"));
+ }
+ // If the environment-variable was not set, try defaults, depending on the
+ // detail version of Windows.
+ else {
+ // Vista did things differently.
+ if(SystemUtils.IS_OS_WINDOWS_VISTA) {
+ appDataDirectory = new File(userHome, "AppData/Roaming");
+ } else {
+ appDataDirectory = new File(userHome, "Application Data");
+ }
+ }
+ securitySettingsDirectory =
+ new File(appDataDirectory, "Macromedia/Flash Player/#Security/FlashPlayerTrust");
+ }
+
+ else if(SystemUtils.IS_OS_MAC) {
+ securitySettingsDirectory = new File(userHome,
+ "Library/Preferences/Macromedia/Flash Player/#Security/FlashPlayerTrust");
+ }
+
+ else if(SystemUtils.IS_OS_LINUX) {
+ securitySettingsDirectory = new File(userHome, ".macromedia/Flash_Player/#Security/FlashPlayerTrust");
+ }
+
+ // As the FlashPlayer is only available on Windows, Mac and Linux, this is all we can do.
+ else {
+ throw new UnsupportedOperationException(
+ "FlashplayerSecurityHandler not prepared for handling OS type of: " + SystemUtils.OS_NAME);
+ }
+
+ // If the directory didn't exist yet, create it now.
+ if(!securitySettingsDirectory.exists()) {
+ if(!securitySettingsDirectory.mkdirs()) {
+ throw new RuntimeException("Could not create FlashPlayer security settings directory at: " +
+ securitySettingsDirectory.getPath());
+ }
+ }
+
+ return securitySettingsDirectory;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/4236c48a/flexjs-maven-plugin/src/main/java/org/apache/flex/maven/flexjs/trust/TrustHandler.java
----------------------------------------------------------------------
diff --git a/flexjs-maven-plugin/src/main/java/org/apache/flex/maven/flexjs/trust/TrustHandler.java b/flexjs-maven-plugin/src/main/java/org/apache/flex/maven/flexjs/trust/TrustHandler.java
new file mode 100644
index 0000000..9d4ab15
--- /dev/null
+++ b/flexjs-maven-plugin/src/main/java/org/apache/flex/maven/flexjs/trust/TrustHandler.java
@@ -0,0 +1,12 @@
+package org.apache.flex.maven.flexjs.trust;
+
+import java.io.File;
+
+/**
+ * Created by christoferdutz on 14.04.16.
+ */
+public interface TrustHandler {
+
+ void trustDirectory(File directory);
+
+}
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/4236c48a/flexjs-maven-plugin/src/main/resources/META-INF/plexus/components.xml
----------------------------------------------------------------------
diff --git a/flexjs-maven-plugin/src/main/resources/META-INF/plexus/components.xml b/flexjs-maven-plugin/src/main/resources/META-INF/plexus/components.xml
index a147013..766d90f 100644
--- a/flexjs-maven-plugin/src/main/resources/META-INF/plexus/components.xml
+++ b/flexjs-maven-plugin/src/main/resources/META-INF/plexus/components.xml
@@ -24,9 +24,18 @@
<process-test-resources>
org.apache.maven.plugins:maven-resources-plugin:testResources
</process-test-resources>
+ <!--generate-test-sources>
+
+ </generate-test-sources-->
+ <!--generate-test-resources>
+
+ </generate-test-resources-->
<!--test-compile>
org.apache.flex.flexjs.compiler:flexjs-maven-plugin:testCompile
</test-compile-->
+ <process-test-classes>
+ org.apache.flex.flexjs.compiler:flexjs-maven-plugin:trust
+ </process-test-classes>
<!--test>
org.apache.maven.plugins:maven-surefire-plugin:test
</test-->
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/4236c48a/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index bf03a62..7251cf0 100644
--- a/pom.xml
+++ b/pom.xml
@@ -333,6 +333,54 @@
</dependency>
</dependencies>
</plugin>
+
+ <plugin>
+ <groupId>org.asciidoctor</groupId>
+ <artifactId>asciidoctor-maven-plugin</artifactId>
+ <version>1.5.3</version>
+ <dependencies>
+ <dependency>
+ <groupId>org.asciidoctor</groupId>
+ <artifactId>asciidoctorj-diagram</artifactId>
+ <version>1.3.1</version>
+ </dependency>
+ </dependencies>
+ <configuration>
+ <requires>
+ <require>asciidoctor-diagram</require>
+ </requires>
+ <attributes>
+ <!-- Example below shows how to specify in this pom instead of System's PATH, the location of dot command of Graphviz, required by PlantUML libraries -->
+ <!-- Windows:
+ <graphvizdot>C:\Program Files (x86)\Graphviz2.38\bin\dot.exe</graphvizdot>
+ -->
+ <!-- *nix :
+ <graphvizdot>/usr/local/bin/dot</graphvizdot>
+ -->
+ </attributes>
+ </configuration>
+ <!--executions>
+ <execution>
+ <id>generate-html-doc</id>
+ <phase>generate-resources</phase>
+ <goals>
+ <goal>process-asciidoc</goal>
+ </goals>
+ <configuration>
+ <backend>html5</backend>
+ <attributes>
+ <imagesdir>./images</imagesdir>
+ <toc>left</toc>
+ <icons>font</icons>
+ <sectanchors>true</sectanchors>
+ <idprefix/>
+ <idseparator>-</idseparator>
+ </attributes>
+ </configuration>
+ </execution>
+ </executions-->
+ </plugin>
+
</plugins>
</build>
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/4236c48a/src/site/asciidoc/structure.adoc
----------------------------------------------------------------------
diff --git a/src/site/asciidoc/structure.adoc b/src/site/asciidoc/structure.adoc
new file mode 100644
index 0000000..059ee26
--- /dev/null
+++ b/src/site/asciidoc/structure.adoc
@@ -0,0 +1,55 @@
+[ditaa, "ditaa-diagram"]
+----
+
+ +----------------------+
+ | |
+ | compiler-jburg-types |
+ | |
+ +-+--------------------+
+ |
+ |
+ | +--------------------------------------+ +-------------------------------------------+
+ | | | | |
+ | | compiler-build-tools | | compiler-build-tools |
+ | | -> generate-problems-resource-bundle | | -> generate-problems-enum |
+ | | | | |
+ | +-------------------+------------------+ +---------------+---------------------------+
+ | | |
+ | | |
+ +-v-------------------+ | +----------------------------------+ | +-------------------------+
+ | | | | | | | |
+ | jburg-maven-plugin | | | compiler-build-tools | | | compiler-build-tools |
+ | | | | -> generate-unknown-tree-handler | | | -> add-class-annotation |
+ | | | | | | | |
+ +----------+----------+ | +----------------+-----------------+ | +------------+------------+
+ | | | | |
+ | | | | |
+ +----------v------------v------------------v-------------------v--------------v------------+
+ | |
+ | compiler |
+ | |
+ +---------------------------------------------+--------------------------------------------+
+ |
+ |
+ +---------------------------------------------v--------------------------------------------+
+ | |
+ | compiler-jx |
+ | |
+ +-----------------------------+------------------------------------------------------------+
+ |
+ |
+ +-----------------------------v-------------------------------+ +------------------------+
+ | | | |
+ | flexjs-maven-plugin | | compiler-build-tools |
+ | | | -> pre-process-sources |
+ +-----------------------------+-------------------------------+ | |
+ | +------------+-----------+
+ | |
+ | |
+ +-----------------------------v------------------------------------------------v-----------+
+ | |
+ | Extern Module |
+ | |
+ +------------------------------------------------------------------------------------------+
+
+----
\ No newline at end of file