Package org.apache.torque.generator.configuration.paths

Examples of org.apache.torque.generator.configuration.paths.CustomProjectPaths


        else
        {
             throw new IllegalStateException("Unknown packaging" + packaging);
        }

        CustomProjectPaths projectPaths
                = new CustomProjectPaths(defaultProjectPaths);

        if (UnitDescriptor.Packaging.CLASSPATH == packaging)
        {
            if (configPackage == null)
            {
                throw new BuildException(
                    "configPackage must be set for packaging =\"classpath\"");
            }
            projectPaths.setConfigurationPackage(configPackage);
            projectPaths.setConfigurationDir(null);
        }
        else
        {
            if (configDir != null)
            {
                projectPaths.setConfigurationDir(configDir);
                log("Setting config dir to " + configDir.toString(),
                        Project.MSG_DEBUG);
            }
        }

        if (sourceDir != null)
        {
            projectPaths.setSourceDir(sourceDir);
            log("Setting source dir to " + sourceDir.toString(),
                    Project.MSG_DEBUG);
        }

        FileSourceProvider fileSourceProvider = null;
        if (sourceIncludes != null || sourceExcludes != null)
        {
            Fileset sourceFileset
                    = new Fileset(
                            projectPaths.getDefaultSourcePath(),
                            sourceIncludes,
                            sourceExcludes);
            log("Setting source includes to " + sourceIncludes,
                    Project.MSG_DEBUG);
            log("Setting source excludes to " + sourceExcludes,
                    Project.MSG_DEBUG);
            try
            {
                fileSourceProvider = new FileSourceProvider(
                        null,
                        sourceFileset,
                        combineFiles);
            }
            catch (ConfigurationException e)
            {
                throw new BuildException(
                        "The source provider cannot be instantiated", e);
            }
        }

        if (defaultOutputDir != null)
        {
            projectPaths.setOutputDirectory(null, defaultOutputDir);
            log("Setting defaultOutputDir to "
                    + defaultOutputDir.getAbsolutePath(),
                Project.MSG_DEBUG);
        }
        if (outputDirMap != null)
        {
            for (Map.Entry<String, File> dirEntry : outputDirMap.entrySet())
            {
                projectPaths.setOutputDirectory(
                        dirEntry.getKey(),
                        dirEntry.getValue());
                log("Setting output directory with key " + dirEntry.getKey()
                        + " to "
                        + dirEntry.getValue(),
                    Project.MSG_DEBUG);
            }
        }
        log("ProjectPaths = " + projectPaths, Project.MSG_DEBUG);

        OptionsConfiguration optionConfiguration = null;
        if (!options.isEmpty())
        {
            Map<String, String> optionsMap = new HashMap<String, String>();
            for (Option option : options)
            {
                optionsMap.put(option.getKey(), option.getValue());
            }
            optionConfiguration = new MapOptionsConfiguration(optionsMap);
        }
        Loglevel convertedLoglevel = null;
        if (this.loglevel != null)
        {
            convertedLoglevel = Loglevel.getByKey(loglevel);
        }
        UnitDescriptor unitDescriptor = new UnitDescriptor(
                packaging,
                projectPaths,
                new DefaultTorqueGeneratorPaths());
        unitDescriptor.setOverrideSourceProvider(fileSourceProvider);
        unitDescriptor.setOverrideOptions(optionConfiguration);
        unitDescriptor.setLoglevel(convertedLoglevel);
        unitDescriptor.setAddDebuggingInfoToOutput(addDebuggingInfoToOutput);
        unitDescriptor.setDefaultOutputEncoding(defaultOutputEncoding);
        log("unit descriptor created", Project.MSG_DEBUG);
        if (overrideConfigDir != null)
        {
            CustomProjectPaths childProjectPaths
                = new CustomProjectPaths(projectPaths);
            childProjectPaths.setConfigurationDir(overrideConfigDir);

            UnitDescriptor parentUnitDescriptor = new UnitDescriptor(
                    Packaging.DIRECTORY,
                    childProjectPaths,
                    new DefaultTorqueGeneratorPaths());
View Full Code Here


        else
        {
             throw new IllegalStateException("Unknown packaging" + packaging);
        }

        CustomProjectPaths projectPaths
                = new CustomProjectPaths(defaultProjectPaths);

        if (UnitDescriptor.Packaging.CLASSPATH == packaging)
        {
            if (configPackage == null)
            {
                throw new MojoExecutionException(
                    "configPackage must be set for packaging =\"classpath\"");
            }
            projectPaths.setConfigurationPackage(configPackage);
            projectPaths.setConfigurationDir(null);
        }
        else
        {
            if (configDir != null)
            {
                projectPaths.setConfigurationDir(configDir);
                getLog().debug("Setting config dir to " + configDir.toString());
            }
        }

        if (sourceDir != null)
        {
            projectPaths.setSourceDir(sourceDir);
            getLog().debug("Setting source dir to " + sourceDir.toString());
        }

        FileSourceProvider fileSourceProvider = null;
        if (sourceIncludes != null || sourceExcludes != null)
        {
            Fileset sourceFileset
                    = new Fileset(
                            projectPaths.getDefaultSourcePath(),
                            sourceIncludes,
                            sourceExcludes);
            getLog().debug("Setting source includes to "
                    + sourceIncludes);
            getLog().debug("Setting source excludes to "
                    + sourceExcludes);
            try
            {
                fileSourceProvider = new FileSourceProvider(
                        null,
                        sourceFileset,
                        combineFiles);
            }
            catch (ConfigurationException e)
            {
                throw new MojoExecutionException(
                        "The source provider cannot be instantiated", e);
            }
        }

        projectPaths.setOutputDirectory(null, defaultOutputDir);
        getLog().debug("Setting defaultOutputDir to "
                + defaultOutputDir.toString());
        if (outputDirMap != null)
        {
            if (outputDirMap.get(Maven2ProjectPaths.MODIFIABLE_OUTPUT_DIR_KEY)
                    == null)
            {
                outputDirMap.put(
                        Maven2ProjectPaths.MODIFIABLE_OUTPUT_DIR_KEY,
                        project.getBasedir()
                                + "/"
                                + Maven2ProjectPaths.MODIFIABLE_OUTPUT_DIR);
            }
            for (Map.Entry<String, String> outputDirMapEntry
                    : outputDirMap.entrySet())
            {
                projectPaths.setOutputDirectory(
                        outputDirMapEntry.getKey(),
                        new File(outputDirMapEntry.getValue()));
                getLog().debug("Setting output directory with key "
                        + outputDirMapEntry.getKey()
                        + " to "
                        + outputDirMapEntry.getValue());
            }
        }
        if (workDir != null)
        {
            projectPaths.setWorkDir(workDir);
            getLog().debug("Setting workDir to "
                    + workDir.toString());
        }
        getLog().debug("ProjectPaths = " + projectPaths);

        OptionsConfiguration optionConfiguration = null;
        if (options != null || optionsFile != null)
        {
            if (options == null)
            {
                options = new HashMap<String, String>();
            }
            if (optionsFile != null)
            {
                Properties optionProperties = new Properties();
                FileInputStream optionsFileInputStream = null;
                try
                {
                    optionsFileInputStream = new FileInputStream(optionsFile);
                    optionProperties.load(optionsFileInputStream);
                }
                catch (FileNotFoundException e)
                {
                    getLog().error(e);
                    throw new MojoExecutionException(e.getMessage());
                }
                catch (IOException e)
                {
                    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);
                for (Map.Entry<Object, Object> propertiesEntry
                        : optionProperties.entrySet())
                {
                    if (!options.containsKey(propertiesEntry.getKey()))
                    {
                        options.put(
                                (String) propertiesEntry.getKey(),
                                (String) propertiesEntry.getValue());
                    }
                }
            }
            getLog().debug("options = " + options);
            optionConfiguration = new MapOptionsConfiguration(options);
        }
        Loglevel convertedLoglevel = null;
        if (this.loglevel != null)
        {
            convertedLoglevel = Loglevel.getByKey(loglevel);
        }
        String encoding = defaultOutputEncoding;
        if (encoding == null)
        {
            encoding = project.getProperties().getProperty(
                    "project.build.sourceEncoding");
        }
        UnitDescriptor unitDescriptor = new UnitDescriptor(
                packaging,
                projectPaths,
                new DefaultTorqueGeneratorPaths());
        unitDescriptor.setOverrideSourceProvider(fileSourceProvider);
        unitDescriptor.setOverrideOptions(optionConfiguration);
        unitDescriptor.setLoglevel(convertedLoglevel);
        unitDescriptor.setDefaultOutputEncoding(encoding);
        unitDescriptor.setAddDebuggingInfoToOutput(addDebuggingInfoToOutput);
        getLog().debug("unit descriptor created");
        if (overrideConfigDir != null)
        {
            CustomProjectPaths childProjectPaths
                = new CustomProjectPaths(projectPaths);
            childProjectPaths.setConfigurationDir(overrideConfigDir);

            UnitDescriptor parentUnitDescriptor = new UnitDescriptor(
                    Packaging.DIRECTORY,
                    childProjectPaths,
                    new DefaultTorqueGeneratorPaths());
            parentUnitDescriptor.setInheritsFrom(unitDescriptor);
            parentUnitDescriptor.setOverrideSourceProvider(fileSourceProvider);
            parentUnitDescriptor.setOverrideOptions(optionConfiguration);
            parentUnitDescriptor.setLoglevel(convertedLoglevel);
            parentUnitDescriptor.setDefaultOutputEncoding(encoding);
            getLog().debug("child unit descriptor created from directory");
            unitDescriptor = parentUnitDescriptor;
        }
        else if (overrideConfigPackage != null)
        {
            CustomProjectPaths childProjectPaths
                = new CustomProjectPaths(projectPaths);
            childProjectPaths.setConfigurationPackage(overrideConfigPackage);

            UnitDescriptor parentUnitDescriptor = new UnitDescriptor(
                    Packaging.CLASSPATH,
                    childProjectPaths,
                    new DefaultTorqueGeneratorPaths());
View Full Code Here

    {
        File targetDir = new File("target/test/site/gettingStarted");
        FileUtils.deleteDirectory(targetDir);
        Controller controller = new Controller();
        List<UnitDescriptor> unitDescriptors = new ArrayList<UnitDescriptor>();
        CustomProjectPaths projectPaths = new CustomProjectPaths(
                new Maven2DirectoryProjectPaths(
                        new File("src/test/site/gettingStarted")));
        projectPaths.setOutputDirectory(null, targetDir);
        unitDescriptors.add(new UnitDescriptor(
                UnitDescriptor.Packaging.DIRECTORY,
                projectPaths,
                new DefaultTorqueGeneratorPaths()));
        controller.run(unitDescriptors);
View Full Code Here

    {
        File targetDir = new File("target/test/outputEncoding");
        FileUtils.deleteDirectory(targetDir);
        Controller controller = new Controller();
        List<UnitDescriptor> unitDescriptors = new ArrayList<UnitDescriptor>();
        CustomProjectPaths projectPaths = new CustomProjectPaths(
                new Maven2DirectoryProjectPaths(
                        new File("src/test/outputEncoding")));
        projectPaths.setOutputDirectory(null, targetDir);
        unitDescriptors.add(new UnitDescriptor(
                UnitDescriptor.Packaging.DIRECTORY,
                projectPaths,
                new DefaultTorqueGeneratorPaths()));
        controller.run(unitDescriptors);
View Full Code Here

        // prepare
        File targetDir = new File("target/test/propertyToJava");
        FileUtils.deleteDirectory(targetDir);
        Controller controller = new Controller();
        List<UnitDescriptor> unitDescriptors = new ArrayList<UnitDescriptor>();
        CustomProjectPaths projectPaths = new CustomProjectPaths(
                new Maven2DirectoryProjectPaths(
                        new File("src/test/propertyToJava")));
        projectPaths.setOutputDirectory(null, targetDir);
        unitDescriptors.add(new UnitDescriptor(
                UnitDescriptor.Packaging.DIRECTORY,
                projectPaths,
                new DefaultTorqueGeneratorPaths()));
View Full Code Here

    @Test
    public void testReadConfigFromClasspath() throws Exception
    {
        Map<String, File> outputDirMap = new HashMap<String, File>();
        outputDirMap.put(null, new File("generated-sources"));
        ProjectPaths projectPaths = new CustomProjectPaths(
                null,
                "org.apache.torque.generator.test.readfromclasspath",
                new File("src"),
                outputDirMap,
                new File("work"));
View Full Code Here


    @Test
    public void testInheritance() throws Exception
    {
        CustomProjectPaths projectPaths;
        UnitConfiguration unitConfiguration;
        ConfigurationHandlers configurationHandlers
                = new ConfigurationHandlers();
        {
            CustomProjectPaths parentProjectPaths
                    = new CustomProjectPaths(
                            new Maven2DirectoryProjectPaths(
                                    new File("src/test/configuration")));
            parentProjectPaths.setConfigurationDir(
                    new File("src/test/configuration/src/main/torque-gen-parent"));
            parentProjectPaths.setOutputDirectory(
                    null,
                    new File("src/test/configuration/target/parentCustom"));
            parentProjectPaths.setOutputDirectory(
                    "modifiable",
                    new File("src/test/configuration/src/main/parentCustom"));
            UnitDescriptor parentUnitDescriptor = new UnitDescriptor(
                    UnitDescriptor.Packaging.DIRECTORY,
                    parentProjectPaths,
                    new DefaultTorqueGeneratorPaths());

            projectPaths = new CustomProjectPaths(
                    new Maven2DirectoryProjectPaths(
                            new File("src/test/configuration")));
            projectPaths.setOutputDirectory(
                    null,
                    new File("src/test/configuration/target/custom"));
View Full Code Here

        // prepare
        File targetDir = new File("target/test/propertyToJava");
        FileUtils.deleteDirectory(targetDir);
        Controller controller = new Controller();
        List<UnitDescriptor> unitDescriptors = new ArrayList<UnitDescriptor>();
        CustomProjectPaths projectPaths = new CustomProjectPaths(
                new Maven2DirectoryProjectPaths(
                        new File("src/test/propertyToJava")));
        projectPaths.setOutputDirectory(null, targetDir);
        UnitDescriptor unitDescriptor = new UnitDescriptor(
                UnitDescriptor.Packaging.DIRECTORY,
                projectPaths,
                new DefaultTorqueGeneratorPaths());
        unitDescriptor.setAddDebuggingInfoToOutput(true);
View Full Code Here

    private File runGeneration(File configurationDirectory, File sourceDir)
            throws GeneratorException
    {
        Controller controller = new Controller();
        List<UnitDescriptor> unitDescriptors = new ArrayList<UnitDescriptor>();
        CustomProjectPaths projectPaths = new CustomProjectPaths(
                new Maven2DirectoryProjectPaths(configurationDirectory));
        projectPaths.setOutputDirectory(null, targetDir1);
        projectPaths.setOutputDirectory("outputDirKey2", targetDir2);
        projectPaths.setWorkDir(workDir);
        if (sourceDir != null)
        {
            projectPaths.setSourceDir(sourceDir);
        }
        unitDescriptors.add(new UnitDescriptor(
                UnitDescriptor.Packaging.DIRECTORY,
                projectPaths,
                new DefaultTorqueGeneratorPaths()));
View Full Code Here

    {
        File targetDir = new File("target/test/deeplyNestedMergepoints");
        FileUtils.deleteDirectory(targetDir);
        Controller controller = new Controller();
        List<UnitDescriptor> unitDescriptors = new ArrayList<UnitDescriptor>();
        CustomProjectPaths projectPaths = new CustomProjectPaths(
                new Maven2DirectoryProjectPaths(
                        new File("src/test/deeplyNestedMergepoints")));
        projectPaths.setOutputDirectory(null, targetDir);
        unitDescriptors.add(new UnitDescriptor(
                UnitDescriptor.Packaging.DIRECTORY,
                projectPaths,
                new DefaultTorqueGeneratorPaths()));
        controller.run(unitDescriptors);
View Full Code Here

TOP

Related Classes of org.apache.torque.generator.configuration.paths.CustomProjectPaths

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.