Package npanday.executable.compiler

Examples of npanday.executable.compiler.CompilerConfig


    {
        if ( compilerContext == null )
        {
            throw new ExecutionException( "NPANDAY-068-000: Compiler has not been initialized with a context" );
        }
        CompilerConfig config = compilerContext.getNetCompilerConfig();
       
        compilerContext.getCompilerRequirement().getFrameworkVersion();

        List<String> commands = new ArrayList<String>();

       
        if ( config.getCommands() != null )
        {
            commands.addAll( config.getCommands() );
        }
       
        CommandFilter filter = compilerContext.getCommandFilter();
        return filter.filter( commands );
    }
View Full Code Here


    {
        if ( compilerContext == null )
        {
            throw new ExecutionException( "NPANDAY-069-000: Compiler has not been initialized with a context" );
        }
        CompilerConfig config = compilerContext.getNetCompilerConfig();
        List<Artifact> resources = compilerContext.getLibraryDependencies();
        List<Artifact> modules = compilerContext.getDirectModuleDependencies();

        String sourceDirectory = compilerContext.getSourceDirectoryName();
        String artifactFilePath = compilerContext.getArtifact().getAbsolutePath();
        String targetArtifactType = config.getArtifactType().getTargetCompileType();

        List<String> commands = new ArrayList<String>();
        commands.add( "/out:" + artifactFilePath );
        commands.add( "/target:" + targetArtifactType );
        commands.add( "/recurse:" + sourceDirectory + File.separator + "**" );
        if ( !modules.isEmpty() )
        {
            StringBuffer sb = new StringBuffer();
            for ( Iterator i = modules.iterator(); i.hasNext(); )
            {
                Artifact artifact = (Artifact) i.next();
                String path = artifact.getFile().getAbsolutePath();
                sb.append( path );
                if ( i.hasNext() )
                {
                    sb.append( ";" );
                }
            }
        }
        if ( !resources.isEmpty() )
        {
            for ( Artifact artifact : resources )
            {
                String path = artifact.getFile().getAbsolutePath();
                commands.add( "/reference:" + path );
            }
        }

        for ( File file : compilerContext.getEmbeddedResources() )
        {
            commands.add( "/resource:" + file.getAbsolutePath() );
        }
        if ( config.getCommands() != null )
        {
            commands.addAll( config.getCommands() );
        }
        //TODO: Apply command filter
        return commands;
    }
View Full Code Here

        {
            throw new ExecutionException( "NPANDAY-068-000: Compiler has not been initialized with a context" );
        }
        List<String> commands = new ArrayList<String>();

        CompilerConfig config = compilerContext.getNetCompilerConfig();
        String sourceDirectory = compilerContext.getSourceDirectoryName();
        File srcDir = new File( sourceDirectory );
        commands.add( "--" + config.getArtifactType().getExtension() );
        for ( String command : config.getCommands() )
        {
            if ( command.startsWith( "main:" ) )
            {   String className = command.split( "[:]" )[1];
                File classFile = new File("target/build-sources/" + className);
                commands.add( "'" + classFile.getAbsolutePath() + "'");
View Full Code Here

    }

    public List<String> getCommands()
        throws ExecutionException
    {
        CompilerConfig config = compilerContext.getNetCompilerConfig();
        List<Artifact> resources = compilerContext.getLibraryDependencies();

        String sourceDirectory = compilerContext.getSourceDirectoryName();
        String artifactFilePath = compilerContext.getArtifact().getAbsolutePath();
        String targetArtifactType = config.getArtifactType().getTargetCompileType();

        List<String> commands = new ArrayList<String>();
        commands.add( "/out:" + artifactFilePath );
        commands.add( "/target:" + targetArtifactType );
View Full Code Here

         *
         * @return a default instance of the executable config
         */
        public static ExecutableConfig createDefaultExecutableConfig()
        {
            return new CompilerConfig()
            {
                private KeyInfo keyInfo;

                private List<String> commands;

View Full Code Here

        File tmpDestDir = new File( tmpDir, "dest" );
        tmpDestDir.mkdirs();

        CompilerRequirement compilerRequirement = createCompilerRequirement();

        CompilerConfig compilerConfig = createCompilerConfig( tmpSourceDir.getAbsolutePath(), tmpDestDir.getAbsolutePath() );

        try
        {
            CompilerExecutable compilerExecutable =
                netExecutableFactory.getCompilerExecutableFor( compilerRequirement, compilerConfig, project,
View Full Code Here

        }
    }
   
    private CompilerConfig createCompilerConfig(String source, String destination) throws MojoExecutionException
    {
        CompilerConfig compilerConfig = (CompilerConfig) CompilerConfig.Factory.createDefaultExecutableConfig();
        compilerConfig.setLocalRepository( localRepository );
        compilerConfig.setCommands( getCommands( source, destination ) );

        String artifactTypeName = project.getArtifact().getType();
        ArtifactType artifactType = ArtifactType.getArtifactTypeForPackagingName( artifactTypeName );
        if ( artifactType.equals( ArtifactType.NULL ) )
        {
            throw new MojoExecutionException( "NPANDAY-900-002: Unrecognized artifact type: Language = " + language +
                ", Vendor = " + vendor + ", ArtifactType = " + artifactTypeName );
        }
        compilerConfig.setArtifactType( artifactType );

        return compilerConfig;
    }
View Full Code Here

    }

    public List<String> getCommands()
        throws ExecutionException
    {
        CompilerConfig config = compilerContext.getNetCompilerConfig();
        List<Artifact> resources = compilerContext.getLibraryDependencies();
        List<Artifact> modules = compilerContext.getDirectModuleDependencies();

        String sourceDirectory = compilerContext.getSourceDirectoryName();
        String artifactFilePath = compilerContext.getArtifact().getAbsolutePath();
        String targetArtifactType = config.getArtifactType().getTargetCompileType();

        List<String> commands = new ArrayList<String>();
        commands.add( "/out:" + artifactFilePath );
        commands.add( "/target:" + targetArtifactType );

        if ( !modules.isEmpty() )
        {
            StringBuffer sb = new StringBuffer();
            for ( Artifact artifact : modules )
            {
                String path = artifact.getFile().getAbsolutePath();
                sb.append( path ).append( ";" );
            }
            commands.add( "/addmodule:" + sb.toString() );
        }
        if ( !resources.isEmpty() )
        {
            for ( Artifact artifact : resources )
            {
                String path = artifact.getFile().getAbsolutePath();
                commands.add( "/reference:" + path );
            }
        }
        String[] files = FileUtils.getFilesFromExtension( sourceDirectory, new String[]{"n"} );
        for ( String file : files )
        {
            commands.add( file );
        }
        commands.addAll( config.getCommands() );
        return commands;
    }
View Full Code Here

    {
        if ( compilerContext == null )
        {
            throw new ExecutionException( "NPANDAY-068-000: Compiler has not been initialized with a context" );
        }
        CompilerConfig config = compilerContext.getNetCompilerConfig();
        // references uses directLibraryDependencies for non transitive dependencies
        List<Artifact> references = compilerContext.getDirectLibraryDependencies();
        List<Artifact> modules = compilerContext.getDirectModuleDependencies();

        String sourceDirectory = compilerContext.getSourceDirectoryName();
        String artifactFilePath = compilerContext.getArtifact().getAbsolutePath();
        String targetArtifactType = config.getArtifactType().getTargetCompileType();

        compilerContext.getCompilerRequirement().getFrameworkVersion();

        List<String> commands = new ArrayList<String>();



        if(config.getOutputDirectory() != null)
        {
            File f = new File(config.getOutputDirectory(), compilerContext.getArtifact().getName());
            artifactFilePath = f.getAbsolutePath();
        }

        if(artifactFilePath!=null && artifactFilePath.toLowerCase().endsWith(".zip"))
        {
          artifactFilePath = artifactFilePath.substring(0, artifactFilePath.length() - 3) + "dll";
        }
       
        commands.add( "/out:" + artifactFilePath);
   

        commands.add( "/target:" + targetArtifactType );
        if(config.getIncludeSources() == null || config.getIncludeSources().isEmpty() )
        {
            commands.add( "/recurse:" + sourceDirectory + File.separator + "**");
        }
        if ( modules != null && !modules.isEmpty() )
        {
            StringBuffer sb = new StringBuffer();
            for ( Iterator i = modules.iterator(); i.hasNext(); )
            {
                Artifact artifact = (Artifact) i.next();
                String path = artifact.getFile().getAbsolutePath();
                sb.append( path );
                if ( i.hasNext() )
                {
                    sb.append( ";" );
                }
            }
            commands.add( "/addmodule:" + sb.toString() );
        }
        if ( !references.isEmpty() )
        {
        
            for ( Artifact artifact : references )
            {
                String path = artifact.getFile().getAbsolutePath();
         
                if( !path.contains( ".jar" ) )
                {
                    commands.add( "/reference:" + path );
                }
            }
        }
        for ( String arg : compilerContext.getEmbeddedResourceArgs() )
        {
            if (logger.isDebugEnabled())
            {
                logger.debug( "NPANDAY-168-001 add resource: " + arg );
            }
       
            commands.add( "/resource:" + arg );
        }
        for ( File file : compilerContext.getLinkedResources() )
        {
            commands.add( "/linkresource:" + file.getAbsolutePath() );
        }
        for ( File file : compilerContext.getWin32Resources() )
        {
            commands.add( "/win32res:" + file.getAbsolutePath() );
        }
        if ( compilerContext.getWin32Icon() != null )
        {
            commands.add( "/win32icon:" + compilerContext.getWin32Icon().getAbsolutePath() );
        }

        if ( compilerContext.getCompilerRequirement().getVendor().equals( Vendor.MICROSOFT ) )
        {
            commands.add( "/nologo" );
        }

        if ( compilerContext.getCompilerRequirement().getVendor().equals( Vendor.MICROSOFT ) &&
            compilerContext.getCompilerRequirement().getFrameworkVersion().equals( "3.0" ) )
        {
            String wcfRef = "/reference:" + System.getenv( "SystemRoot" ) +
                "\\Microsoft.NET\\Framework\\v3.0\\Windows Communication Foundation\\";
            //TODO: This is a hard-coded path: Don't have a registry value either.
            //commands.add( wcfRef + "System.ServiceModel.dll" );
            commands.add( wcfRef + "Microsoft.Transactions.Bridge.dll" );
            commands.add( wcfRef + "Microsoft.Transactions.Bridge.Dtc.dll" );
            commands.add( wcfRef + "System.ServiceModel.Install.dll" );
            commands.add( wcfRef + "System.ServiceModel.WasHosting.dll" );
            //commands.add( wcfRef + "System.Runtime.Serialization.dll" );
            commands.add( wcfRef + "SMDiagnostics.dll" );
        }

        if ( compilerContext.getCompilerRequirement().getVendor().equals( Vendor.MICROSOFT ) &&
            compilerContext.getCompilerRequirement().getFrameworkVersion().equals( "3.5" ) )
        {
            String wcfRef = "/reference:" + System.getenv( "SystemRoot" ) +
                "\\Microsoft.NET\\Framework\\v3.5\\";
            //TODO: This is a hard-coded path: Don't have a registry value either.
            commands.add( wcfRef + "Microsoft.Build.Tasks.v3.5.dll" );

            String cfBuildTasks = wcfRef + "Microsoft.CompactFramework.Build.Tasks.dll";
            if (new File( cfBuildTasks ).exists())
            {
                commands.add( cfBuildTasks );
            }

            commands.add( wcfRef + "Microsoft.Data.Entity.Build.Tasks.dll" );
            commands.add( wcfRef + "Microsoft.VisualC.STLCLR.dll" );
        }
        if ( compilerContext.getCompilerRequirement().getVendor().equals( Vendor.MICROSOFT ) &&
            compilerContext.getCompilerRequirement().getFrameworkVersion().equals( "4.0" ) )
        {
            String wcfRef = "/reference:" + System.getenv( "SystemRoot" ) +
                "\\Microsoft.NET\\Framework\\v4.0.30319\\";
            //TODO: This is a hard-coded path: Don't have a registry value either.
            commands.add( wcfRef + "Microsoft.Build.Tasks.v4.0.dll" );
            commands.add( wcfRef + "Microsoft.Data.Entity.Build.Tasks.dll" );
            commands.add( wcfRef + "Microsoft.VisualC.STLCLR.dll" );
        }
        if ( compilerContext.getKeyInfo().getKeyFileUri() != null )
        {
            commands.add( "/keyfile:" + compilerContext.getKeyInfo().getKeyFileUri() );
        }
        else if ( compilerContext.getKeyInfo().getKeyContainerName() != null )
        {
            commands.add( "/keycontainer:" + compilerContext.getKeyInfo().getKeyContainerName() );
        }

        if ( config.getCommands() != null )
        {
            commands.addAll( config.getCommands() );
        }
        commands.add( "/warnaserror-" );
        //commands.add( "/nowarn" );
        if ( compilerContext.getCompilerRequirement().getVendor().equals( Vendor.MONO ) )
        {
            commands.add( "/nostdlib" );
            commands.add( "/noconfig" );
            commands.add( "/reference:mscorlib" );
            commands.add( "/reference:System.Data" );
            commands.add( "/reference:System" );
            commands.add( "/reference:System.Drawing" );
            commands.add( "/reference:System.Messaging" );
            commands.add( "/reference:System.Web.Services" );
            commands.add( "/reference:System.Windows.Forms" );
            commands.add( "/reference:System.Xml" );
            commands.add( "/reference:System.Core" );
            commands.add( "/reference:System.Data.DataSetExtensions" );
            commands.add( "/reference:System.Xml.Linq" );
        }
        if ( !compilerContext.getNetCompilerConfig().isTestCompile() )
        {
            commands.add(
                "/doc:" + new File( compilerContext.getTargetDirectory(), "comments.xml" ).getAbsolutePath() );
        }

        CommandFilter filter = compilerContext.getCommandFilter();
       
        List<String> filteredCommands = filter.filter( commands );
        //Include Sources code is being copied to temporary folder for the recurse option
       
        String fileExt = "";
        String frameWorkVer = ""+compilerContext.getCompilerRequirement().getFrameworkVersion();
        String TempDir = "";
        String targetDir = ""+compilerContext.getTargetDirectory();
       
        Date date = new Date();
        String Now =""+date.getDate()+date.getHours()+date.getMinutes()+date.getSeconds();
              
        TempDir = targetDir+File.separator+Now;
       
        try
        {
            FileUtils.deleteDirectory( TempDir );
        }
        catch(Exception e)
        {
            //Does Precautionary delete for tempDir
        }
       
        FileUtils.mkdir(TempDir);
       
        if(config.getIncludeSources() != null && !config.getIncludeSources().isEmpty() )
        {
            int folderCtr=0;
            for(String includeSource : config.getIncludeSources())
            {
               
                String[] sourceTokens = includeSource.replace('\\', '/').split("/");
               
                String lastToken = sourceTokens[sourceTokens.length-1];
View Full Code Here

TOP

Related Classes of npanday.executable.compiler.CompilerConfig

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.