Package org.apache.maven.dotnet.compiler

Examples of org.apache.maven.dotnet.compiler.DotnetCompilerConfig$Factory


        {
            vendor = Vendor.getDefaultVendorForOS();
        }

        getLog().info( ".NET Vendor: " + vendor );
        DotnetCompilerConfig compilerConfig = DotnetCompilerConfig.Factory.createDefaultCompilerConfig();
        compilerConfig.setArtifactType( ArtifactType.LIBRARY );
        compilerConfig.setCompilerPlatformVersion( DotnetCompilerPlatformVersion.valueFromVersion( frameworkVersion ) );

        compilerConfig.setLocalRepository( localRepository );
        compilerConfig.setProgrammingLanguage( ProgrammingLanguage.C_SHARP );
        compilerConfig.setTestCompile( true );
        compilerConfig.setCompilerSourceDirectory( sourceDir );
        compilerConfig.setVendor( vendor );
        compilerConfig.setTargetDirectory( new File( project.getBuild().getDirectory() ) );
        compilerConfig.setArtifactFileName(
            project.getBuild().getFinalName() + "-test" + "." + compilerConfig.getArtifactType().getExtension() );

        try
        {
            compilerContext.init( project, compilerConfig );
        }
View Full Code Here


        {
            vendor = Vendor.getDefaultVendorForOS();
        }

        getLog().info( ".NET Vendor: " + vendor );
        DotnetCompilerConfig compilerConfig = DotnetCompilerConfig.Factory.createDefaultCompilerConfig();

        String packaging = project.getPackaging();
       
        // If this is a dotnet type, remove the "dotnet:" portion
        if ( packaging.contains( ":" ) )
        {
            packaging = packaging.split( "[:]" )[1];
        }

        compilerConfig.setArtifactType( ArtifactType.valueOf( packaging.toUpperCase() ) );
        compilerConfig.setCompilerPlatformVersion( DotnetCompilerPlatformVersion.valueFromVersion( frameworkVersion ) );

        KeyInfo keyInfo = KeyInfo.Factory.createDefaultKeyInfo();
        if ( keyfile != null )
        {
            keyInfo.setKeyFileUri( keyfile.toURI() );
        }

        keyInfo.setKeyContainerName( keycontainer );
        compilerConfig.setKeyInfo( keyInfo );

        compilerConfig.setLocalRepository( localRepository );
        compilerConfig.setProgrammingLanguage( ProgrammingLanguage.C_SHARP );
        compilerConfig.setCompilerSourceDirectory( sourceDir );
        compilerConfig.setVendor( vendor );
        compilerConfig.setTargetDirectory( new File( project.getBuild().getDirectory() ) );
        compilerConfig.setArtifactFileName(
            project.getBuild().getFinalName() + "." + compilerConfig.getArtifactType().getExtension() );

        try
        {
            dotnetCompilerContext.init( project, compilerConfig );
        }
View Full Code Here

        return compilerContext.getCompilerConfig().getVendor().equals( Vendor.MICROSOFT );
    }

    public List<String> getCommands()
    {
        DotnetCompilerConfig config = (DotnetCompilerConfig) compilerContext.getCompilerConfig();

        Set<Artifact> references;
        if ( compilerContext.getCompilerConfig().isTestCompile() )
        {
            references = compilerContext.getLibraryDependenciesFor( ArtifactScope.TEST );
            references.add( compilerContext.getMavenProject().getArtifact() );
        }
        else
        {
            references = compilerContext.getLibraryDependenciesFor( ArtifactScope.COMPILE );
        }
        Set<Artifact> modules = compilerContext.getDirectModuleDependencies();

        File sourceDirectory = config.getCompilerDirectory();

        String targetArtifactType = config.getArtifactType().getTargetCompileType();

        List<String> commands = new ArrayList<String>();
        commands.add( "/out:" + compiledArtifact.getAbsolutePath() );
        commands.add( "/target:" + targetArtifactType );
        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();
                commands.add( "/reference:" + path );
            }
        }

        for ( File file : compilerContext.getEmbeddedResources() )
        {
            commands.add( "/resource:" + file.getAbsolutePath() );
        }
        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 ( config.getVendor().equals( Vendor.MICROSOFT ) )
        {
            commands.add( "/nologo" );
        }

        if ( config.getVendor().equals( Vendor.MICROSOFT ) &&
            config.getCompilerPlatformVersion().equals( DotnetCompilerPlatformVersion.VERSION_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 ( config.getKeyInfo() != null )
        {
            if ( config.getKeyInfo().getKeyFileUri() != null )
            {
                commands.add( "/keyfile:" + new File( config.getKeyInfo().getKeyFileUri() ).getAbsolutePath() );
            }
            else if ( config.getKeyInfo().getKeyContainerName() != null )
            {
                commands.add( "/keycontainer:" + config.getKeyInfo().getKeyContainerName() );
            }
        }

        /*
         * if ( config.getCommands() != null ) { commands.addAll( config.getCommands() ); }
         */
        commands.add( "/warnaserror-" );
        if ( config.getVendor().equals( Vendor.NOVELL ) )
        {
            commands.add( "/reference:System.Drawing" );
            commands.add( "/reference:System.Windows.Forms" );
            commands.add( "/reference:System.Web.Services" );
        }
        if ( !config.isTestCompile() )
        {
            commands.add( "/doc:" + new File( config.getTargetDirectory(), "comments.xml" ).getAbsolutePath() );
        }
        return commands;
    }
View Full Code Here

    @Test(expected = IllegalArgumentException.class)
    public void init_WithNullProject()
        throws InitializationException, IOException
    {
        DotnetCompilerContextImpl ctx = new DotnetCompilerContextImpl();
        DotnetCompilerConfig compilerConfig = DotnetCompilerConfig.Factory.createDefaultCompilerConfig();

        ctx.init( null, compilerConfig );

    }
View Full Code Here

        Build build = new Build();
        build.setDirectory( "" );
        project.setBuild( build );

        ctx.turnOffAssemblyExistsCheck();
        DotnetCompilerConfig compilerConfig = getDefaultDotnetCompilerConfig();
        compilerConfig.setVendor( Vendor.NOVELL );

        ctx.turnOffCompilerExistsCheck();
        ctx.init( project, compilerConfig );

        Set<Artifact> libraries = ctx.getLibraryDependenciesFor( ArtifactScope.COMPILE );
View Full Code Here

        Build build = new Build();
        build.setDirectory( "" );
        project.setBuild( build );

        ctx.turnOffAssemblyExistsCheck();
        DotnetCompilerConfig compilerConfig = getDefaultDotnetCompilerConfig();
        compilerConfig.setVendor( Vendor.NOVELL );

        ctx.turnOffCompilerExistsCheck();
        ctx.init( project, compilerConfig );

        Set<Artifact> libraries = ctx.getLibraryDependenciesFor( ArtifactScope.COMPILE );
View Full Code Here

        ClassCompiler compiler = ctx.getClassCompiler();
    }

    private static DotnetCompilerConfig getDefaultDotnetCompilerConfig()
    {
        DotnetCompilerConfig config = DotnetCompilerConfig.Factory.createDefaultCompilerConfig();
        config.setArtifactType( ArtifactType.LIBRARY );
        config.setCompilerPlatformVersion( DotnetCompilerPlatformVersion.VERSION_2_0_50727 );
        config.setLocalRepository( new File( "." ) );
        config.setProgrammingLanguage( ProgrammingLanguage.C_SHARP );
        config.setCompilerSourceDirectory( new File( "." ) );
        config.setTargetDirectory( new File( "." ) );
        config.setTestCompile( false );
        config.setVendor( Vendor.MICROSOFT );

        return config;
    }
View Full Code Here

TOP

Related Classes of org.apache.maven.dotnet.compiler.DotnetCompilerConfig$Factory

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.