<commit_before>package org.codehaus.mojo.castor;

/*
 * Copyright 2005 The Codehaus.
 *
 * 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.
 */

import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;

import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.project.MavenProject;
import org.codehaus.plexus.compiler.util.scan.InclusionScanException;
import org.codehaus.plexus.compiler.util.scan.SourceInclusionScanner;
import org.codehaus.plexus.compiler.util.scan.StaleSourceScanner;
import org.codehaus.plexus.compiler.util.scan.mapping.SourceMapping;
import org.codehaus.plexus.compiler.util.scan.mapping.SuffixMapping;
import org.codehaus.plexus.util.FileUtils;
import org.exolab.castor.builder.SourceGenerator;

/**
 * A mojo that uses Castor to generate a collection of javabeans from an XSD.  Detailed
 * explanations of many of these can be found in the details for the Castor 
 * <a href="http://castor.codehaus.org/sourcegen.html">SourceGenerator</a>.
 * 
 * @goal generate
 * @phase generate-sources
 * @description Castor plugin
 * @author brozow <<EMAIL>>
 * @author jesse <<EMAIL>>
 */
public class GenerateMojo
    extends AbstractMojo
{

    private static final String DISABLE_DESCRIPTORS_MSG = "Disabling generation of Class descriptors";

    private static final String DISABLE_MARSHALL_MSG = "Disabling generation of Marshalling framework methods (marshall, unmarshall, validate).";

    private static final String DEFAULT_PROPERTY_FILE_LOCATION = "src/main/castor/castorbuilder.properties";
    /**
     * The binding file to use for mapping xml to java.
     * 
     * @parameter expression="${basedir}/src/main/castor/bindings.xml"
     */
    private File bindingfile;

    /**
     * A schema file to process.  If this is not set then all .xsd files in
     * schemaDirectory will be processed.
     * 
     * @parameter
     */
    private File schema;

    /**
     * The source directory containing *.xsd files
     * 
     * @parameter expression="${basedir}/src/main/castor"
     */
    private File schemaDirectory;

    /**
     * The directory to output the generated sources to
     * 
     * @parameter expression="${project.build.directory}/generated-sources/castor"
     * @todo This would be better as outputDirectory but for backward compatibility I left it as dest
     */
    private File dest;

    /**
     * The directory to store the processed xsds.  The timestamps of these xsds
     * are used to determine if the source for that xsd need to be regenerated
     * 
     * @parameter expression="${project.build.directory}/xsds"
     * @todo timestampDirectory would be a better name for this. Used this name for backward compatibility
     */
    private File tstamp;

    /**
     * The granularity in milliseconds of the last modification
     * date for testing whether a source needs recompilation
     * 
     * @parameter expression="${lastModGranularityMs}" default-value="0"
     */
    private int staleMillis = 0;

    /**
     * Castor collection types. Allowable values are 'vector', 'arraylist', 'j2' or 'odmg'
     * 'j2' and 'arraylist' are the same.
     * @parameter default-value="arraylist";
     */
    private String types = "arraylist";

    /**
     * If true, generate descriptors
     * @parameter default-value="true"
     */
    private boolean descriptors = true;

    /**
     * Verbose output during generation
     * @parameter default-value="false"
     */
    private boolean verbose = false;

    /**
     * Enable warning messages
     * @parameter default-value="false"
     */
    private boolean warnings = false;

    /**
     * if false, don't generate the marshaller
     * @parameter default-value="true"
     */
    private boolean marshal = true;

    /**
     * The line separator to use in generated source. Can be either win, unix, or mac
     * @parameter 
     */
    private String lineSeparator;

    /**
     * The castorbuilder.properties file to use
     * @parameter expression="${basedir}/src/main/castor/castorbuilder.properties"
     */
    private File properties;

    /**
     * The package for the generated source
     * @parameter
     */
    private String packaging;
    
    /**
     * Whether to generate Java classes fro imported XML schemas or not.
     * @parameter default-value="false"
     */
    private boolean generateImportedSchemas = false;

    /**
     * @parameter expression="${project}"
     * @required
     */
    private MavenProject project;

    /**
     * {@link SourceGenerator} instance used for code generation.
     * 
     * @see SourceGenerator#generateSource(org.xml.sax.InputSource, String)
     */
    private CastorSourceGenerator sgen;

    /**
     * {@inheritDoc}
     * 
     * @see org.apache.maven.plugin.AbstractMojo#execute()
     */
    public void execute()
        throws MojoExecutionException
    {

        if ( !dest.exists() )
        {
            FileUtils.mkdir( dest.getAbsolutePath() );
        }<commit_msg>Added output directory to project as root source folder.<commit_after>package org.codehaus.mojo.castor;

/*
 * Copyright 2005 The Codehaus.
 *
 * 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.
 */

import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;

import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.project.MavenProject;
import org.codehaus.plexus.compiler.util.scan.InclusionScanException;
import org.codehaus.plexus.compiler.util.scan.SourceInclusionScanner;
import org.codehaus.plexus.compiler.util.scan.StaleSourceScanner;
import org.codehaus.plexus.compiler.util.scan.mapping.SourceMapping;
import org.codehaus.plexus.compiler.util.scan.mapping.SuffixMapping;
import org.codehaus.plexus.util.FileUtils;
import org.exolab.castor.builder.SourceGenerator;

/**
 * A mojo that uses Castor to generate a collection of javabeans from an XSD.  Detailed
 * explanations of many of these can be found in the details for the Castor 
 * <a href="http://castor.codehaus.org/sourcegen.html">SourceGenerator</a>.
 * 
 * @goal generate
 * @phase generate-sources
 * @description Castor plugin
 * @author brozow <<EMAIL>>
 * @author jesse <<EMAIL>>
 */
public class GenerateMojo
    extends AbstractMojo
{

    private static final String DISABLE_DESCRIPTORS_MSG = "Disabling generation of Class descriptors";

    private static final String DISABLE_MARSHALL_MSG = "Disabling generation of Marshalling framework methods (marshall, unmarshall, validate).";

    private static final String DEFAULT_PROPERTY_FILE_LOCATION = "src/main/castor/castorbuilder.properties";
    /**
     * The binding file to use for mapping xml to java.
     * 
     * @parameter expression="${basedir}/src/main/castor/bindings.xml"
     */
    private File bindingfile;

    /**
     * A schema file to process.  If this is not set then all .xsd files in
     * schemaDirectory will be processed.
     * 
     * @parameter
     */
    private File schema;

    /**
     * The source directory containing *.xsd files
     * 
     * @parameter expression="${basedir}/src/main/castor"
     */
    private File schemaDirectory;

    /**
     * The directory to output the generated sources to
     * 
     * @parameter expression="${project.build.directory}/generated-sources/castor"
     * @todo This would be better as outputDirectory but for backward compatibility I left it as dest
     */
    private File dest;

    /**
     * The directory to store the processed xsds.  The timestamps of these xsds
     * are used to determine if the source for that xsd need to be regenerated
     * 
     * @parameter expression="${project.build.directory}/xsds"
     * @todo timestampDirectory would be a better name for this. Used this name for backward compatibility
     */
    private File tstamp;

    /**
     * The granularity in milliseconds of the last modification
     * date for testing whether a source needs recompilation
     * 
     * @parameter expression="${lastModGranularityMs}" default-value="0"
     */
    private int staleMillis = 0;

    /**
     * Castor collection types. Allowable values are 'vector', 'arraylist', 'j2' or 'odmg'
     * 'j2' and 'arraylist' are the same.
     * @parameter default-value="arraylist";
     */
    private String types = "arraylist";

    /**
     * If true, generate descriptors
     * @parameter default-value="true"
     */
    private boolean descriptors = true;

    /**
     * Verbose output during generation
     * @parameter default-value="false"
     */
    private boolean verbose = false;

    /**
     * Enable warning messages
     * @parameter default-value="false"
     */
    private boolean warnings = false;

    /**
     * if false, don't generate the marshaller
     * @parameter default-value="true"
     */
    private boolean marshal = true;

    /**
     * The line separator to use in generated source. Can be either win, unix, or mac
     * @parameter 
     */
    private String lineSeparator;

    /**
     * The castorbuilder.properties file to use
     * @parameter expression="${basedir}/src/main/castor/castorbuilder.properties"
     */
    private File properties;

    /**
     * The package for the generated source
     * @parameter
     */
    private String packaging;
    
    /**
     * Whether to generate Java classes fro imported XML schemas or not.
     * @parameter default-value="false"
     */
    private boolean generateImportedSchemas = false;

    /**
     * @parameter expression="${project}"
     * @required
     */
    private MavenProject project;

    /**
     * {@link SourceGenerator} instance used for code generation.
     * 
     * @see SourceGenerator#generateSource(org.xml.sax.InputSource, String)
     */
    private CastorSourceGenerator sgen;

    /**
     * {@inheritDoc}
     * 
     * @see org.apache.maven.plugin.AbstractMojo#execute()
     */
    public void execute()
        throws MojoExecutionException
    {

        if ( !dest.exists() )
        {
            FileUtils.mkdir( dest.getAbsolutePath() );
            project.addCompileSourceRoot( dest.getAbsolutePath() );
        }
{'fraction_non_alphanumeric': 0.0962800875273523, 'fraction_numerical': 0.002100656455142232, 'mean_word_length': 2.9659840333217633, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 6}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1886355', 'n_tokens_mistral': 3186, 'n_tokens_neox': 3071, 'n_words': 996}