Package org.aspectj.ajdt.internal.core.builder

Examples of org.aspectj.ajdt.internal.core.builder.AjBuildConfig


      }

      CompilationAndWeavingContext.reset();

      if (fullBuild) { // FULL BUILD
        AjBuildConfig buildConfig = generateAjBuildConfig();
        if (buildConfig == null) {
          return;
        }
        ajBuildManager.batchBuild(buildConfig, msgHandlerAdapter);
      } else { // INCREMENTAL BUILD
        // Only rebuild the config object if the configuration has changed
        AjBuildConfig buildConfig = null;
        ICompilerConfiguration compilerConfig = compiler.getCompilerConfiguration();
        int changes = compilerConfig.getConfigurationChanges();
        if (changes != ICompilerConfiguration.NO_CHANGES) {

          // What configuration changes can we cope with? And besides just repairing the config object
          // what does it mean for any existing state that we have?

          buildConfig = generateAjBuildConfig();
          if (buildConfig == null) {
            return;
          }
        } else {
          buildConfig = ajBuildManager.getState().getBuildConfig();
          buildConfig.setChanged(changes); // pass it through for the state to use it when making decisions
          buildConfig.setModifiedFiles(compilerConfig.getProjectSourceFilesChanged());
          buildConfig.setClasspathElementsWithModifiedContents(compilerConfig.getClasspathElementsWithModifiedContents());
          compilerConfig.configurationRead();
        }
        ajBuildManager.incrementalBuild(buildConfig, msgHandlerAdapter);
      }
      IncrementalStateManager.recordSuccessfulBuild(compiler.getId(), ajBuildManager.getState());
View Full Code Here


      }
    }

    BuildArgParser parser = new BuildArgParser(handler);

    AjBuildConfig config = new AjBuildConfig();

    parser.populateBuildConfig(config, args, false, configFile);

    // Process the CLASSPATH
    String propcp = compilerConfig.getClasspath();
    if (propcp != null && propcp.length() != 0) {
      StringTokenizer st = new StringTokenizer(propcp, File.pathSeparator);
      List configClasspath = config.getClasspath();
      ArrayList toAdd = new ArrayList();
      while (st.hasMoreTokens()) {
        String entry = st.nextToken();
        if (!configClasspath.contains(entry)) {
          toAdd.add(entry);
        }
      }
      if (0 < toAdd.size()) {
        ArrayList both = new ArrayList(configClasspath.size() + toAdd.size());
        both.addAll(configClasspath);
        both.addAll(toAdd);
        config.setClasspath(both);
      }
    }

    // Process the OUTJAR
    if (config.getOutputJar() == null) {
      String outJar = compilerConfig.getOutJar();
      if (outJar != null && outJar.length() != 0) {
        config.setOutputJar(new File(outJar));
      }
    }

    // Process the OUTPUT LOCATION MANAGER
    IOutputLocationManager outputLocationManager = compilerConfig.getOutputLocationManager();
    if (config.getCompilationResultDestinationManager() == null && outputLocationManager != null) {
      config.setCompilationResultDestinationManager(new OutputLocationAdapter(outputLocationManager));
    }

    // Process the INPATH
    mergeInto(config.getInpath(), compilerConfig.getInpath());
    // bug 168840 - calling 'setInPath(..)' creates BinarySourceFiles which
    // are used to see if there have been changes in classes on the inpath
    if (config.getInpath() != null) {
      config.setInPath(config.getInpath());
    }

    // Process the SOURCE PATH RESOURCES
    config.setSourcePathResources(compilerConfig.getSourcePathResources());

    // Process the ASPECTPATH
    mergeInto(config.getAspectpath(), compilerConfig.getAspectPath());

    // Process the JAVA OPTIONS MAP
    Map jom = compilerConfig.getJavaOptionsMap();
    if (jom != null) {
      String version = (String) jom.get(CompilerOptions.OPTION_Compliance);
      if (version != null && (version.equals(CompilerOptions.VERSION_1_5) || version.equals(CompilerOptions.VERSION_1_6))) {
        config.setBehaveInJava5Way(true);
      }
      config.getOptions().set(jom);
    }

    // Process the NON-STANDARD COMPILER OPTIONS
    configureNonStandardOptions(config);

    compilerConfig.configurationRead();

    ISourceLocation location = null;
    if (config.getConfigFile() != null) {
      location = new SourceLocation(config.getConfigFile(), 0);
    }

    String message = parser.getOtherMessages(true);
    if (null != message) {
      IMessage m = new Message(message, IMessage.ERROR, null, location);
      handler.handleMessage(m);
    }

    // always force model generation in AJDE
    config.setGenerateModelMode(true);
    // always be in incremental mode in AJDE
    config.setIncrementalMode(true);
    // always force proceedOnError in AJDE
    config.setProceedOnError(true);
    return config;
  }
View Full Code Here

    String[] args = (String[]) tokens.toArray(new String[] {});

    // set the non-standard options in an alternate build config
    // (we don't want to lose the settings we already have)
    CountingMessageHandler counter = CountingMessageHandler.makeCountingMessageHandler(msgHandlerAdapter);
    AjBuildConfig altConfig = AjdtCommand.genBuildConfig(args, counter);
    if (counter.hasErrors()) {
      return;
    }
    // copy globals where local is not set
    config.installGlobals(altConfig);
View Full Code Here

   *
   * @param args the String[] arguments for the build configuration
   * @return AjBuildConfig per args, which will be invalid unless there are no handler errors.
   */
  public AjBuildConfig genBuildConfig(String[] args) {
    AjBuildConfig config = new AjBuildConfig();
    populateBuildConfig(config, args, true, null);
    return config;
  }
View Full Code Here

        System.out.println( "Compiling " + sourceFiles.length + " " + "source file"
            + ( sourceFiles.length == 1 ? "" : "s" ) + " to " + destinationDir.getAbsolutePath() );

        //        String[] args = buildCompilerArguments( config, sourceFiles );
        AjBuildConfig buildConfig = buildCompilerConfig( config );
        return compileInProcess( buildConfig );
    }
View Full Code Here

    }

    private AjBuildConfig buildCompilerConfig( CompilerConfiguration config )
        throws CompilerException
    {
        AjBuildConfig buildConfig = new AjBuildConfig();
        buildConfig.setIncrementalMode( false );

        String[] files = getSourceFiles( config );
        if ( files != null )
        {
            buildConfig.setFiles( buildFileList( Arrays.asList( files ) ) );
        }

        setSourceVersion( buildConfig, config.getSourceVersion() );

        if ( config.isDebug() )
        {
            buildConfig.getOptions().produceDebugAttributes = CompilerOptions.Source + CompilerOptions.Lines
                + CompilerOptions.Vars;
        }

        Map javaOpts = config.getCustomCompilerArguments();
        if ( javaOpts != null && !javaOpts.isEmpty() )
        {
            // TODO support customCompilerArguments
            // buildConfig.setJavaOptions( javaOpts );
        }

        List cp = new LinkedList( config.getClasspathEntries() );

        File javaHomeDir = new File( System.getProperty( "java.home" ) );
        File[] jars = new File( javaHomeDir, "lib" ).listFiles();
        if ( jars != null )
        {
            for ( int i = 0; i < jars.length; i++ )
            {
                File jar = jars[i];
                if ( jar.getName().endsWith( ".jar" ) || jar.getName().endsWith( ".zip" ) )
                {
                    cp.add( 0, jar.getAbsolutePath() );
                }
            }
        }
        jars = new File( javaHomeDir, "../Classes" ).listFiles();
        if ( jars != null )
        {
            for ( int i = 0; i < jars.length; i++ )
            {
                File jar = jars[i];
                if ( jar.getName().endsWith( ".jar" ) || jar.getName().endsWith( ".zip" ) )
                {
                    cp.add( 0, jar.getAbsolutePath() );
                }
            }
        }

        checkForAspectJRT( cp );
        if ( cp != null && !cp.isEmpty() )
        {
            List elements = new ArrayList( cp.size() );
            for ( Iterator i = cp.iterator(); i.hasNext(); )
            {
                elements.add( ( new File( (String) i.next() ) ).getAbsolutePath() );
            }

            buildConfig.setClasspath( elements );
        }

        String outputLocation = config.getOutputLocation();
        if ( outputLocation != null )
        {
            File outDir = new File( outputLocation );
            if ( !outDir.exists() )
            {
                outDir.mkdirs();
            }

            buildConfig.setOutputDir( outDir );
        }

        if ( config instanceof AspectJCompilerConfiguration )
        {
            AspectJCompilerConfiguration ajCfg = (AspectJCompilerConfiguration) config;

            Map sourcePathResources = ajCfg.getSourcePathResources();
            if ( sourcePathResources != null && !sourcePathResources.isEmpty() )
            {
                buildConfig.setSourcePathResources( sourcePathResources );
            }

            Map ajOptions = ajCfg.getAJOptions();
            if ( ajOptions != null && !ajOptions.isEmpty() )
            {
                // TODO not supported
                //buildConfig.setAjOptions( ajCfg.getAJOptions() );
            }

            List aspectPath = buildFileList( ajCfg.getAspectPath() );
            if ( aspectPath != null && !aspectPath.isEmpty() )
            {
                buildConfig.setAspectpath( buildFileList( ajCfg.getAspectPath() ) );
            }

            List inJars = buildFileList( ajCfg.getInJars() );
            if ( inJars != null && !inJars.isEmpty() )
            {
                buildConfig.setInJars( buildFileList( ajCfg.getInJars() ) );
            }

            List inPaths = buildFileList( ajCfg.getInPath() );
            if ( inPaths != null && !inPaths.isEmpty() )
            {
                buildConfig.setInPath( buildFileList( ajCfg.getInPath() ) );
            }

            String outJar = ajCfg.getOutputJar();
            if ( outJar != null )
            {
                buildConfig.setOutputJar( new File( ajCfg.getOutputJar() ) );
            }
        }

        return buildConfig;
    }
View Full Code Here

TOP

Related Classes of org.aspectj.ajdt.internal.core.builder.AjBuildConfig

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.