Java Code Examples for org.netbeans.api.java.project.JavaProjectConstants#ARTIFACT_TYPE_JAR

The following examples show how to use org.netbeans.api.java.project.JavaProjectConstants#ARTIFACT_TYPE_JAR . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JavaProjectGeneratorTest.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public void testGuessSubprojects() throws Exception {
    AntProjectHelper helper = createEmptyProject("proj1", "proj1", false);
    FileObject base = helper.getProjectDirectory();
    Project p = ProjectManager.getDefault().findProject(base);
    assertNotNull("Project was not created", p);
    assertEquals("Project folder is incorrect", base, p.getProjectDirectory());
    ArrayList exports = new ArrayList();
    JavaProjectGenerator.Export e = new JavaProjectGenerator.Export();
    e.type = JavaProjectConstants.ARTIFACT_TYPE_JAR;
    e.location = "libs/some.jar"; // this jar is created in createEmptyProject() so let's use it as export
    e.buildTarget = "build_target";
    exports.add(e);
    JavaProjectGenerator.putExports(helper, exports);
    ProjectManager.getDefault().saveAllProjects();
    String lib1path = lib1.getAbsolutePath();
    String proj1path = FileUtil.toFile(base).getAbsolutePath();
    
    AntProjectHelper helper2 = createEmptyProject("proj2", "proj2", false);
    FileObject base2 = helper.getProjectDirectory();
    File projBase = FileUtil.toFile(base2);
    Project p2 = ProjectManager.getDefault().findProject(base2);
    assertNotNull("Project was not created", p2);
    assertEquals("Project folder is incorrect", base2, p.getProjectDirectory());
    
    PropertyEvaluator evaluator = PropertyUtils.sequentialPropertyEvaluator(null, new PropertyProvider[]{
        PropertyUtils.fixedPropertyProvider(
        Collections.singletonMap("lib1", lib1path))});
        
    ArrayList units = new ArrayList();
    JavaProjectGenerator.JavaCompilationUnit cu = new JavaProjectGenerator.JavaCompilationUnit();
    JavaProjectGenerator.JavaCompilationUnit.CP cp = new JavaProjectGenerator.JavaCompilationUnit.CP();
    cp.mode = "compile";
    cp.classpath = "../something.jar;${lib1};";
    cu.classpath = new ArrayList();
    cu.classpath.add(cp);
    units.add(cu);
    cu = new JavaProjectGenerator.JavaCompilationUnit();
    cp = new JavaProjectGenerator.JavaCompilationUnit.CP();
    cp.mode = "compile";
    cp.classpath = lib1path+";";
    cu.classpath = new ArrayList();
    cu.classpath.add(cp);
    units.add(cu);
    
    List l = JavaProjectGenerator.guessSubprojects(evaluator, units, projBase, projBase);
    assertEquals("one subproject", 1, l.size());
    assertEquals("project1 is subproject", /*proj1path*/ ".", l.get(0));
}
 
Example 2
Source File: AntArtifactProviderImpl.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public String getType() {
    return JavaProjectConstants.ARTIFACT_TYPE_JAR;
}