db-torque-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tfisc...@apache.org
Subject svn commit: r1377198 - /db/torque/torque4/trunk/torque-maven-plugin/src/main/java/org/apache/torque/generator/maven/TorqueGeneratorMojo.java
Date Sat, 25 Aug 2012 04:19:15 GMT
Author: tfischer
Date: Sat Aug 25 04:19:15 2012
New Revision: 1377198

URL: http://svn.apache.org/viewvc?rev=1377198&view=rev
Log:
fix findbugs problems:
- create a setter for every field
- do not null-check injected maps any more
- close opened stream

Modified:
    db/torque/torque4/trunk/torque-maven-plugin/src/main/java/org/apache/torque/generator/maven/TorqueGeneratorMojo.java

Modified: db/torque/torque4/trunk/torque-maven-plugin/src/main/java/org/apache/torque/generator/maven/TorqueGeneratorMojo.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-maven-plugin/src/main/java/org/apache/torque/generator/maven/TorqueGeneratorMojo.java?rev=1377198&r1=1377197&r2=1377198&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-maven-plugin/src/main/java/org/apache/torque/generator/maven/TorqueGeneratorMojo.java
(original)
+++ db/torque/torque4/trunk/torque-maven-plugin/src/main/java/org/apache/torque/generator/maven/TorqueGeneratorMojo.java
Sat Aug 25 04:19:15 2012
@@ -87,7 +87,7 @@ public class TorqueGeneratorMojo extends
         NONE("none");
 
         /** The usage key. */
-        private String key;
+        private final String key;
 
         /**
          * Constructor.
@@ -551,9 +551,11 @@ public class TorqueGeneratorMojo extends
             if (optionsFile != null)
             {
                 Properties optionProperties = new Properties();
+                FileInputStream optionsFileInputStream = null;
                 try
                 {
-                    optionProperties.load(new FileInputStream(optionsFile));
+                    optionsFileInputStream = new FileInputStream(optionsFile);
+                    optionProperties.load(optionsFileInputStream);
                 }
                 catch (FileNotFoundException e)
                 {
@@ -565,6 +567,20 @@ public class TorqueGeneratorMojo extends
                     getLog().error(e);
                     throw new MojoExecutionException(e.getMessage());
                 }
+                finally
+                {
+                    if (optionsFileInputStream != null)
+                    {
+                        try
+                        {
+                            optionsFileInputStream.close();
+                        }
+                        catch (IOException e)
+                        {
+                            getLog().error(e);
+                        }
+                    }
+                }
                 getLog().debug("loaded options file from "
                         + optionsFile.getAbsolutePath() + ", contents: "
                         + optionProperties);
@@ -679,86 +695,73 @@ public class TorqueGeneratorMojo extends
                 + " does not exist, not applying defaultOutputDirUsage");
         }
 
-        if (outputDirUsageMap == null)
+        if (outputDirUsageConvertedMap.get(
+                Maven2ProjectPaths.MODIFIABLE_OUTPUT_DIR_KEY)
+                  == null
+            && outputDirMap.get(
+                Maven2ProjectPaths.MODIFIABLE_OUTPUT_DIR_KEY)
+                    != null)
         {
-            getLog().debug("no output directory usages other than the default "
-                    + "are defined");
-        }
-        else if (outputDirMap == null)
-        {
-            getLog().debug("no output directories other than the default "
-                    + "are defined, ignoring outputDirUsageMap");
+            outputDirUsageConvertedMap.put(
+                    Maven2ProjectPaths.MODIFIABLE_OUTPUT_DIR_KEY,
+                    OutputDirUsage.COMPILE);
         }
-        else
+        for (Map.Entry<String, OutputDirUsage> usageEntry
+                : outputDirUsageConvertedMap.entrySet())
         {
-            if (outputDirUsageConvertedMap.get(
-                    Maven2ProjectPaths.MODIFIABLE_OUTPUT_DIR_KEY)
-                      == null
-                && outputDirMap.get(
-                    Maven2ProjectPaths.MODIFIABLE_OUTPUT_DIR_KEY)
-                        != null)
+            String outputDirPath = outputDirMap.get(usageEntry.getKey());
+            if (outputDirPath == null)
             {
-                outputDirUsageConvertedMap.put(
-                        Maven2ProjectPaths.MODIFIABLE_OUTPUT_DIR_KEY,
-                        OutputDirUsage.COMPILE);
+                getLog().info("outputDirPath set for key "
+                        + usageEntry.getKey()
+                        + " ignoring this outputDirUsageMap entry");
+                continue;
             }
-            for (Map.Entry<String, OutputDirUsage> usageEntry
-                    : outputDirUsageConvertedMap.entrySet())
-            {
-                String outputDirPath = outputDirMap.get(usageEntry.getKey());
-                if (outputDirPath == null)
-                {
-                    getLog().info("outputDirPath set for key "
-                            + usageEntry.getKey()
-                            + " ignoring this outputDirUsageMap entry");
-                    continue;
-                }
 
-                File outputDirFile = new File(outputDirPath);
-                if (!outputDirFile.exists())
-                {
-                    getLog().info("outputDirPath "
-                            + outputDirFile.getAbsolutePath()
-                            + " for outputDirUsageMap with key "
-                            + usageEntry.getKey()
-                            + " does not exist,"
-                            + " ignoring this outputDirUsageMap entry");
-                    continue;
-                }
-                switch (usageEntry.getValue())
-                {
-                case COMPILE:
-                    project.addCompileSourceRoot(outputDirPath.toString());
-                    getLog().debug("Added "
-                            + outputDirPath.toString()
-                            + " as compile source root");
-                    break;
-                case TEST_COMPILE:
-                    project.addTestCompileSourceRoot(
-                            outputDirPath.toString());
-                    getLog().debug("Added "
-                            + outputDirPath.toString()
-                            + " as test compile source root");
-                    break;
-                case RESOURCE:
-                    Resource resource = new Resource();
-                    resource.setDirectory(outputDirPath.toString());
-                    project.addResource(resource);
-                    getLog().debug("Added "
-                            + outputDirPath.toString()
-                            + " to the project resources");
-                    break;
-                case TEST_RESOURCE:
-                    resource = new Resource();
-                    resource.setDirectory(outputDirPath.toString());
-                    project.addTestResource(resource);
-                    getLog().debug("Added "
-                            + outputDirPath.toString()
-                            + " to the project test resources");
-                    break;
-                case NONE:
-                default:
-                }
+            File outputDirFile = new File(outputDirPath);
+            if (!outputDirFile.exists())
+            {
+                getLog().info("outputDirPath "
+                        + outputDirFile.getAbsolutePath()
+                        + " for outputDirUsageMap with key "
+                        + usageEntry.getKey()
+                        + " does not exist,"
+                        + " ignoring this outputDirUsageMap entry");
+                continue;
+            }
+            switch (usageEntry.getValue())
+            {
+            case COMPILE:
+                project.addCompileSourceRoot(outputDirPath.toString());
+                getLog().debug("Added "
+                        + outputDirPath.toString()
+                        + " as compile source root");
+                break;
+            case TEST_COMPILE:
+                project.addTestCompileSourceRoot(
+                        outputDirPath.toString());
+                getLog().debug("Added "
+                        + outputDirPath.toString()
+                        + " as test compile source root");
+                break;
+            case RESOURCE:
+                Resource resource = new Resource();
+                resource.setDirectory(outputDirPath.toString());
+                project.addResource(resource);
+                getLog().debug("Added "
+                        + outputDirPath.toString()
+                        + " to the project resources");
+                break;
+            case TEST_RESOURCE:
+                resource = new Resource();
+                resource.setDirectory(outputDirPath.toString());
+                project.addTestResource(resource);
+                getLog().debug("Added "
+                        + outputDirPath.toString()
+                        + " to the project test resources");
+                break;
+            case NONE:
+            default:
             }
         }
     }
@@ -953,4 +956,37 @@ public class TorqueGeneratorMojo extends
     {
         this.options = options;
     }
+
+    /**
+     * Sets whether all source files should be combined into one single graph-
+     *
+     * @param combineFiles whether the source file should be combined.
+     */
+    public void setCombineFiles(Boolean combineFiles)
+    {
+        this.combineFiles = combineFiles;
+    }
+
+    /**
+     * Sets the work dir for e.g. merging sources.
+     *
+     * @param workDir the new workdir.
+     */
+    public void setWorkDir(File workDir)
+    {
+        this.workDir = workDir;
+    }
+
+    /**
+     * Sets a options file by which generation parameters can be set.
+     *
+     * @param optionsFile the path to the file containing the generation
+     *        options.
+     */
+    public void setOptionsFile(File optionsFile)
+    {
+        this.optionsFile = optionsFile;
+    }
+
+
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: torque-dev-unsubscribe@db.apache.org
For additional commands, e-mail: torque-dev-help@db.apache.org


Mime
View raw message