View | Details | Raw Unified | Return to bug 137235 | Differences between
and this patch

Collapse All | Expand All

(-)testsrc/org/aspectj/tools/ajc/AjcTestCase.java (-1 / +7 lines)
Lines 558-564 Link Here
558
		lastRunResult = null;
558
		lastRunResult = null;
559
		StringBuffer cp = new StringBuffer();
559
		StringBuffer cp = new StringBuffer();
560
		if (classpath != null) {
560
		if (classpath != null) {
561
			cp.append(classpath);
561
			// allow replacing this special variable, rather than copying all files to allow tests of jars that don't end in .jar
562
			cp.append(substituteSandbox(classpath));
562
			cp.append(File.pathSeparator);
563
			cp.append(File.pathSeparator);
563
		}
564
		}
564
		cp.append(ajc.getSandboxDirectory().getAbsolutePath());
565
		cp.append(ajc.getSandboxDirectory().getAbsolutePath());
Lines 622-627 Link Here
622
		}
623
		}
623
		return lastRunResult;
624
		return lastRunResult;
624
	}
625
	}
626
627
	private String substituteSandbox(String classpath) {
628
		return classpath.replace("$sandbox", ajc.getSandboxDirectory().getAbsolutePath());
629
	}
625
    
630
    
626
    /**
631
    /**
627
     * Any central pre-processing of args.
632
     * Any central pre-processing of args.
Lines 639-644 Link Here
639
        		args[i] = adaptToPlatform(args[i]);
644
        		args[i] = adaptToPlatform(args[i]);
640
            if ("-classpath".equals(args[i])) {
645
            if ("-classpath".equals(args[i])) {
641
                cpIndex = i;
646
                cpIndex = i;
647
                args[i+1] = substituteSandbox(args[i+1]);
642
                String next = args[i+1];
648
                String next = args[i+1];
643
                hasruntime = ((null != next) 
649
                hasruntime = ((null != next) 
644
                        && (-1 != next.indexOf("aspectjrt.jar")));
650
                        && (-1 != next.indexOf("aspectjrt.jar")));
(-)src/org/aspectj/ajdt/ajc/BuildArgParser.java (-7 / +7 lines)
Lines 397-410 Link Here
397
					while (st.hasMoreTokens()) {
397
					while (st.hasMoreTokens()) {
398
						String filename = st.nextToken();
398
						String filename = st.nextToken();
399
						File file = makeFile(filename);
399
						File file = makeFile(filename);
400
						if (file.exists() && FileUtil.hasZipSuffix(filename)) {
400
						if (FileUtil.isZipFile(file)) {
401
							inPath.add(file);    
401
							inPath.add(file);    
402
						} else {
402
						} else {
403
							if (file.isDirectory()) {
403
							if (file.isDirectory()) {
404
								inPath.add(file);
404
								inPath.add(file);
405
							} else 
405
							} else 
406
		            		
406
		            		
407
							showError("bad inpath component: " + filename);  
407
							showWarning("skipping missing, empty or corrupt inpath entry: " + filename);  
408
						}
408
						}
409
					}
409
					}
410
					buildConfig.setInPath(inPath);
410
					buildConfig.setInPath(inPath);
Lines 420-426 Link Here
420
		            while (st.hasMoreTokens()) {
420
		            while (st.hasMoreTokens()) {
421
		            	String filename = st.nextToken();
421
		            	String filename = st.nextToken();
422
		            	File jarFile = makeFile(filename);
422
		            	File jarFile = makeFile(filename);
423
		            	if (jarFile.exists() && FileUtil.hasZipSuffix(filename)) {
423
		            	if (FileUtil.isZipFile(jarFile)) {
424
			            	buildConfig.getInJars().add(jarFile);    
424
			            	buildConfig.getInJars().add(jarFile);    
425
		            	} else {
425
		            	} else {
426
		            		File dirFile = makeFile(filename);
426
		            		File dirFile = makeFile(filename);
Lines 428-434 Link Here
428
		            			buildConfig.getInJars().add(dirFile);
428
		            			buildConfig.getInJars().add(dirFile);
429
		            		} else 
429
		            		} else 
430
		            		
430
		            		
431
                            showError("bad injar: " + filename);  
431
                            showWarning("skipping missing, empty or corrupt injar: " + filename);  
432
		            	}
432
		            	}
433
		            }
433
		            }
434
					
434
					
Lines 442-451 Link Here
442
		            while (st.hasMoreTokens()) {
442
		            while (st.hasMoreTokens()) {
443
		            	String filename = st.nextToken();
443
		            	String filename = st.nextToken();
444
		            	File jarFile = makeFile(filename);
444
		            	File jarFile = makeFile(filename);
445
                        if (jarFile.exists() && (FileUtil.hasZipSuffix(filename) || jarFile.isDirectory())) {
445
                        if (FileUtil.isZipFile(jarFile) || jarFile.isDirectory()) {
446
			            	buildConfig.getAspectpath().add(jarFile);    
446
			            	buildConfig.getAspectpath().add(jarFile);    
447
		            	} else {
447
		            	} else {
448
                            showError("bad aspectpath: " + filename);
448
                            showWarning("skipping missing, empty or corrupt aspectpath entry: " + filename);  
449
		            	}
449
		            	}
450
		            }
450
		            }
451
					
451
					
Lines 476-482 Link Here
476
				if (args.size() > nextArgIndex) {
476
				if (args.size() > nextArgIndex) {
477
//					buildConfig.getAjOptions().put(AjCompilerOptions.OPTION_OutJAR, CompilerOptions.GENERATE);
477
//					buildConfig.getAjOptions().put(AjCompilerOptions.OPTION_OutJAR, CompilerOptions.GENERATE);
478
					File jarFile = makeFile(((ConfigParser.Arg)args.get(nextArgIndex)).getValue());
478
					File jarFile = makeFile(((ConfigParser.Arg)args.get(nextArgIndex)).getValue());
479
					if (FileUtil.hasZipSuffix(jarFile)) {
479
					if (!jarFile.isDirectory()) {
480
						try {
480
						try {
481
							if (!jarFile.exists()) {
481
							if (!jarFile.exists()) {
482
                                jarFile.createNewFile();
482
                                jarFile.createNewFile();
(-)testsrc/org/aspectj/ajdt/ajc/BuildArgParserTestCase.java (+66 lines)
Lines 115-120 Link Here
115
		String FILE_PATH =   "@" + TEST_DIR + "configWithClasspathExtdirsBootCPArgs.lst";
115
		String FILE_PATH =   "@" + TEST_DIR + "configWithClasspathExtdirsBootCPArgs.lst";
116
		AjBuildConfig config = genBuildConfig(new String[] { FILE_PATH }, messageWriter);
116
		AjBuildConfig config = genBuildConfig(new String[] { FILE_PATH }, messageWriter);
117
		List classpath = config.getFullClasspath();
117
		List classpath = config.getFullClasspath();
118
		// note that empty or corrupt jars are NOT included in the classpath
118
		// should have three entries, resolved relative to location of .lst file
119
		// should have three entries, resolved relative to location of .lst file
119
		assertEquals("Three entries in classpath",3,classpath.size());
120
		assertEquals("Three entries in classpath",3,classpath.size());
120
		Iterator cpIter = classpath.iterator();
121
		Iterator cpIter = classpath.iterator();
Lines 507-512 Link Here
507
		assertEquals("Wrong outxml","custom/aop.xml",config.getOutxmlName());
508
		assertEquals("Wrong outxml","custom/aop.xml",config.getOutxmlName());
508
		assertTrue("Following option currupted",config.getShowWeavingInformation());
509
		assertTrue("Following option currupted",config.getShowWeavingInformation());
509
	}
510
	}
511
512
	public void testNonstandardInjars() {
513
		AjBuildConfig config = setupNonstandardPath("-injars");
514
		assertEquals("bad path: " + config.getInJars(), 3, config.getInJars().size());
515
	}
516
	
517
	public void testNonstandardInpath() {
518
		AjBuildConfig config = setupNonstandardPath("-inpath");
519
		assertEquals("bad path: " + config.getInpath(), 3, config.getInpath().size());
520
	}
521
	
522
	public void testNonstandardAspectpath() {
523
		AjBuildConfig config = setupNonstandardPath("-aspectpath");
524
		assertEquals("bad path: " + config.getAspectpath(), 3, config.getAspectpath().size());
525
	}
526
527
	public void testNonstandardClasspath() throws IOException {
528
		AjBuildConfig config = setupNonstandardPath("-classpath");
529
		checkPathSubset(config.getClasspath());
530
	}
531
	
532
	public void testNonstandardBootpath() throws IOException {
533
		AjBuildConfig config = setupNonstandardPath("-bootclasspath");
534
		checkPathSubset(config.getBootclasspath());
535
	}
536
	
537
	private void checkPathSubset(List path) throws IOException {
538
		String files[] = { "aspectjJar.file", "jarChild", "parent.zip" };
539
		for (int i = 0; i < files.length; i++) {
540
			File file = new File(NONSTANDARD_JAR_DIR+files[i]);
541
			assertTrue("bad path: " + path, path.contains(file.getCanonicalPath()));			
542
		}
543
	}
544
545
	public void testNonstandardOutjar() {
546
		final String OUT_JAR = NONSTANDARD_JAR_DIR + File.pathSeparator + "outputFile";
547
		
548
		AjBuildConfig config = genBuildConfig(new String[] { 
549
			"-outjar", OUT_JAR }, 
550
			messageWriter);
551
552
		File newJar = new File(OUT_JAR);
553
		assertEquals(
554
			getCanonicalPath(newJar),config.getOutputJar().getAbsolutePath()); 
555
	
556
		newJar.delete();
557
	}
558
559
	public void testNonstandardOutputDirectorySetting() throws InvalidInputException {
560
		String filePath = AjdtAjcTests.TESTDATA_PATH + File.separator + "ajc.jar" + File.separator;
561
		File testDir = new File(filePath);
562
		AjBuildConfig config = genBuildConfig(new String[] {  "-d", filePath }, messageWriter);
563
		
564
		assertEquals(testDir.getAbsolutePath(), config.getOutputDir().getAbsolutePath());	
565
	}
566
	
567
	private static final String NONSTANDARD_JAR_DIR = AjdtAjcTests.TESTDATA_PATH + "/OutjarTest/folder.jar/";
568
	
569
	private AjBuildConfig setupNonstandardPath(String pathType) {
570
		String NONSTANDARD_PATH_ENTRY = NONSTANDARD_JAR_DIR+"aspectjJar.file" + File.pathSeparator + NONSTANDARD_JAR_DIR+"aspectJar.file" + File.pathSeparator + NONSTANDARD_JAR_DIR+"jarChild" + File.pathSeparator + NONSTANDARD_JAR_DIR+"parent.zip";		
571
		
572
		return genBuildConfig(new String[] { 
573
			pathType, NONSTANDARD_PATH_ENTRY }, 
574
			messageWriter);
575
	}
510
	
576
	
511
	protected void setUp() throws Exception {
577
	protected void setUp() throws Exception {
512
		super.setUp();
578
		super.setUp();

Return to bug 137235