Package org.codehaus.mojo.appassembler.model

Examples of org.codehaus.mojo.appassembler.model.Daemon


    // -----------------------------------------------------------------------

    public void generate( DaemonGenerationRequest request )
        throws DaemonGeneratorException
    {
        Daemon daemon = request.getDaemon();

        try
        {
            FileUtils.forceMkdir( request.getOutputDirectory() );
        }
        catch ( IOException e )
        {
            throw new DaemonGeneratorException( "Error creating output directory: " + request.getOutputDirectory(), e );
        }

        File envDir = new File( request.getOutputDirectory(), "env" );
        envDir.mkdir();

        copyEnvFile( "JAVA_HOME", envDir );
        copyEnvFile( "USER", envDir );

        File logDir = new File( request.getOutputDirectory(), "logs" );
        logDir.mkdir();

        File serviceDir = new File( request.getOutputDirectory(), "service" );
        serviceDir.mkdir();

        // -----------------------------------------------------------------------
        //
        // -----------------------------------------------------------------------

        InputStream in = this.getClass().getResourceAsStream( "run.sh.template" );

        if ( in == null )
        {
            throw new DaemonGeneratorException( "Could not load template." );
        }

        InputStreamReader reader = new InputStreamReader( in );

        Map context = new HashMap();
        context.put( "MAINCLASS", daemon.getMainClass() );
        context.put( "NAME", daemon.getId() );

        InterpolationFilterReader interpolationFilterReader = new InterpolationFilterReader( reader, context,
                                                                                             "@", "@" );

        File runFile = new File( request.getOutputDirectory(), "run" );
View Full Code Here


        //
        // -----------------------------------------------------------------------

        DaemonGeneratorService daemonGeneratorService = (DaemonGeneratorService) lookup( DaemonGeneratorService.ROLE );

        Daemon model = daemonGeneratorService.loadModel( getTestFile( descriptor ) );

        generator.generate( new DaemonGenerationRequest( model, project, localRepository, outputDir ) );
    }
View Full Code Here

    {
        // -----------------------------------------------------------------------
        // Create the daemon from the Maven project
        // -----------------------------------------------------------------------

        Daemon createdDaemon = createDaemon( request.getMavenProject(), request.getRepositoryLayout() );

        // -----------------------------------------------------------------------
        // Merge the given stub daemon and the generated
        // -----------------------------------------------------------------------

        Daemon mergedDaemon = daemonMerger.mergeDaemons( request.getDaemon(), createdDaemon );

        // -----------------------------------------------------------------------
        // Write out the project
        // -----------------------------------------------------------------------

        OutputStreamWriter writer = null;

        try
        {

            FileUtils.forceMkdir( request.getOutputDirectory() );

            File outputFile = new File( request.getOutputDirectory(), mergedDaemon.getId() + ".xml" );

            FileOutputStream fos = new FileOutputStream( outputFile );

            writer = new OutputStreamWriter( fos, "UTF-8" );
View Full Code Here

    // Protected
    // -----------------------------------------------------------------------

    protected Daemon createDaemon( MavenProject project, ArtifactRepositoryLayout layout )
    {
        Daemon complete = new Daemon();

        complete.setClasspath( new Classpath() );

        // -----------------------------------------------------------------------
        // Add the project itself as a dependency.
        // -----------------------------------------------------------------------
        Dependency projectDependency = new Dependency();
        Artifact projectArtifact = project.getArtifact();
        if ( ! "pom".equalsIgnoreCase(projectArtifact.getType()) ){
          projectArtifact.isSnapshot();
          projectDependency.setGroupId( projectArtifact.getGroupId() );
          projectDependency.setArtifactId( projectArtifact.getArtifactId() );
          projectDependency.setVersion( projectArtifact.getVersion() );
          projectDependency.setClassifier( projectArtifact.getClassifier() );
          projectDependency.setRelativePath( layout.pathOf( projectArtifact ) );
          complete.getClasspath().addDependency( projectDependency );
        }

        // -----------------------------------------------------------------------
        // Add all the dependencies from the project.
        // -----------------------------------------------------------------------
        for ( Iterator it = project.getRuntimeArtifacts().iterator(); it.hasNext(); )
        {
            Artifact artifact = (Artifact) it.next();
           
            artifact.isSnapshot();

            Dependency dependency = new Dependency();
            dependency.setGroupId( artifact.getGroupId() );
            dependency.setArtifactId( artifact.getArtifactId() );
            dependency.setVersion( artifact.getVersion() );

            dependency.setClassifier( artifact.getClassifier() );
            dependency.setRelativePath( layout.pathOf( artifact ) );

            complete.getClasspath().addDependency( dependency );
        }

        return complete;
    }
View Full Code Here

TOP

Related Classes of org.codehaus.mojo.appassembler.model.Daemon

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.