Java Code Examples for org.netbeans.spi.project.support.ant.PropertyUtils#sequentialPropertyEvaluator()
The following examples show how to use
org.netbeans.spi.project.support.ant.PropertyUtils#sequentialPropertyEvaluator() .
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: MultiModuleBinaryForSourceQueryImpl.java From netbeans with Apache License 2.0 | 6 votes |
R( @NonNull final URL url, @NonNull final MultiModule modules, @NonNull final String moduleName, @NonNull final String[] templates) { Parameters.notNull("url", url); //NOI18N Parameters.notNull("modules", modules); //NOI18N Parameters.notNull("moduleName", moduleName); //NOI18N Parameters.notNull("templates", templates); //NOI18N this.url = url; this.pp = new EvaluatorPropertyProvider(MultiModuleBinaryForSourceQueryImpl.this.evaluator); this.evaluator = PropertyUtils.sequentialPropertyEvaluator( PropertyUtils.fixedPropertyProvider(Collections.singletonMap("module.name",moduleName)), //NOI18N pp); this.modules = modules; this.moduleName = moduleName; this.templates = templates; this.cache = new AtomicReference(); this.listeners = new ChangeSupport(this); this.propsCache = new AtomicReference<>(); this.scp = new AtomicReference<>(); MultiModuleBinaryForSourceQueryImpl.this.evaluator.addPropertyChangeListener(WeakListeners.propertyChange(this, MultiModuleBinaryForSourceQueryImpl.this.evaluator)); this.modules.addPropertyChangeListener(WeakListeners.propertyChange(this, this.modules)); }
Example 2
Source File: AntServices.java From netbeans with Apache License 2.0 | 6 votes |
@Override public Values createEvaluator(CommonProjectHelper aph, FileObject dir) { AntProjectHelperImpl impl = (AntProjectHelperImpl) aph; org.netbeans.spi.project.support.ant.AntProjectHelper h = impl.delegate; org.netbeans.spi.project.support.ant.PropertyEvaluator baseEval2 = PropertyUtils.sequentialPropertyEvaluator( h.getStockPropertyPreprovider(), h.getPropertyProvider(org.netbeans.spi.project.support.ant.AntProjectHelper.PRIVATE_PROPERTIES_PATH)); org.netbeans.spi.project.support.ant.PropertyEvaluator pe = PropertyUtils.sequentialPropertyEvaluator( h.getStockPropertyPreprovider(), h.getPropertyProvider(org.netbeans.spi.project.support.ant.AntProjectHelper.PRIVATE_PROPERTIES_PATH), PropertyUtils.userPropertiesProvider(baseEval2, "user.properties.file", FileUtil.toFile(dir)), // NOI18N h.getPropertyProvider(org.netbeans.spi.project.support.ant.AntProjectHelper.PROJECT_PROPERTIES_PATH)); return new PropertyEvaluatorImpl(pe); }
Example 3
Source File: SuiteProject.java From netbeans with Apache License 2.0 | 6 votes |
private PropertyEvaluator createEvaluator() { PropertyProvider predefs = helper.getStockPropertyPreprovider(); File dir = getProjectDirectoryFile(); List<PropertyProvider> providers = new ArrayList<PropertyProvider>(); providers.add(helper.getPropertyProvider("nbproject/private/platform-private.properties")); // NOI18N providers.add(helper.getPropertyProvider("nbproject/platform.properties")); // NOI18N PropertyEvaluator baseEval = PropertyUtils.sequentialPropertyEvaluator(predefs, providers.toArray(new PropertyProvider[providers.size()])); providers.add(new ApisupportAntUtils.UserPropertiesFileProvider(baseEval, dir)); baseEval = PropertyUtils.sequentialPropertyEvaluator(predefs, providers.toArray(new PropertyProvider[providers.size()])); providers.add(new DestDirProvider(baseEval)); providers.add(helper.getPropertyProvider(AntProjectHelper.PRIVATE_PROPERTIES_PATH)); providers.add(helper.getPropertyProvider(AntProjectHelper.PROJECT_PROPERTIES_PATH)); Map<String,String> fixedProps = new HashMap<String,String>(); // synchronize with suite.xml fixedProps.put(SuiteProperties.ENABLED_CLUSTERS_PROPERTY, ""); fixedProps.put(SuiteProperties.DISABLED_CLUSTERS_PROPERTY, ""); fixedProps.put(SuiteProperties.DISABLED_MODULES_PROPERTY, ""); fixedProps.put(SuiteBrandingModel.BRANDING_DIR_PROPERTY, "branding"); // NOI18N fixedProps.put("suite.build.dir", "build"); // NOI18N fixedProps.put("cluster", "${suite.build.dir}/cluster"); // NOI18N fixedProps.put("dist.dir", "dist"); // NOI18N fixedProps.put("test.user.dir", "${suite.build.dir}/testuserdir"); // NOI18N providers.add(PropertyUtils.fixedPropertyProvider(fixedProps)); return PropertyUtils.sequentialPropertyEvaluator(predefs, providers.toArray(new PropertyProvider[providers.size()])); }
Example 4
Source File: ModuleList.java From netbeans with Apache License 2.0 | 6 votes |
private static PropertyEvaluator parseSuiteProperties(File root) throws IOException { Properties p = System.getProperties(); Map<String,String> predefs; synchronized (p) { predefs = NbCollections.checkedMapByCopy(p, String.class, String.class, false); } predefs.put("basedir", root.getAbsolutePath()); // NOI18N PropertyProvider predefsProvider = PropertyUtils.fixedPropertyProvider(predefs); List<PropertyProvider> providers = new ArrayList<PropertyProvider>(); providers.add(loadPropertiesFile(new File(root, "nbproject" + File.separatorChar + "private" + File.separatorChar + "platform-private.properties"))); // NOI18N providers.add(loadPropertiesFile(new File(root, "nbproject" + File.separatorChar + "platform.properties"))); // NOI18N PropertyEvaluator eval = PropertyUtils.sequentialPropertyEvaluator(predefsProvider, providers.toArray(new PropertyProvider[providers.size()])); String buildS = eval.getProperty("user.properties.file"); // NOI18N if (buildS != null) { providers.add(loadPropertiesFile(PropertyUtils.resolveFile(root, buildS))); } else { // Never been opened, perhaps - so fake it. providers.add(PropertyUtils.globalPropertyProvider()); } providers.add(loadPropertiesFile(new File(root, "nbproject" + File.separatorChar + "private" + File.separatorChar + "private.properties"))); // NOI18N providers.add(loadPropertiesFile(new File(root, "nbproject" + File.separatorChar + "project.properties"))); // NOI18N eval = PropertyUtils.sequentialPropertyEvaluator(predefsProvider, providers.toArray(new PropertyProvider[providers.size()])); providers.add(new DestDirProvider(eval)); return PropertyUtils.sequentialPropertyEvaluator(predefsProvider, providers.toArray(new PropertyProvider[providers.size()])); }
Example 5
Source File: ModuleList.java From netbeans with Apache License 2.0 | 6 votes |
public static Map<String,String> getClusterProperties(File nbroot) throws IOException { Map<String, String> clusterDefs = null; synchronized (clusterPropertiesFiles) { clusterDefs = clusterPropertiesFiles.get(nbroot); if (clusterDefs == null) { PropertyProvider pp = loadPropertiesFile(getClusterPropertiesFile(nbroot)); // NOI18N PropertyEvaluator clusterEval = PropertyUtils.sequentialPropertyEvaluator( PropertyUtils.fixedPropertyProvider(Collections.<String, String>emptyMap()), pp); clusterDefs = clusterEval.getProperties(); if (clusterDefs == null) { // Definition failure of some sort. clusterDefs = Collections.emptyMap(); } clusterPropertiesFiles.put(nbroot, clusterDefs); } } return clusterDefs; }
Example 6
Source File: PhpProject.java From netbeans with Apache License 2.0 | 6 votes |
private PropertyEvaluator createEvaluator() { // It is currently safe to not use the UpdateHelper for PropertyEvaluator; UH.getProperties() delegates to APH // Adapted from APH.getStandardPropertyEvaluator (delegates to ProjectProperties): PropertyEvaluator baseEval1 = PropertyUtils.sequentialPropertyEvaluator( helper.getStockPropertyPreprovider(), helper.getPropertyProvider(PhpConfigurationProvider.CONFIG_PROPS_PATH)); PropertyEvaluator baseEval2 = PropertyUtils.sequentialPropertyEvaluator( helper.getStockPropertyPreprovider(), helper.getPropertyProvider(AntProjectHelper.PRIVATE_PROPERTIES_PATH)); return PropertyUtils.sequentialPropertyEvaluator( helper.getStockPropertyPreprovider(), helper.getPropertyProvider(PhpConfigurationProvider.CONFIG_PROPS_PATH), new ConfigPropertyProvider(baseEval1, "nbproject/private/configs", helper), // NOI18N helper.getPropertyProvider(AntProjectHelper.PRIVATE_PROPERTIES_PATH), helper.getProjectLibrariesPropertyProvider(), PropertyUtils.userPropertiesProvider(baseEval2, "user.properties.file", FileUtil.toFile(getProjectDirectory())), // NOI18N new ConfigPropertyProvider(baseEval1, "nbproject/configs", helper), // NOI18N helper.getPropertyProvider(AntProjectHelper.PROJECT_PROPERTIES_PATH)); }
Example 7
Source File: JavaProjectGeneratorTest.java From netbeans with Apache License 2.0 | 5 votes |
public void testGuessBuildFolders() throws Exception { File base = new File(getWorkDir(), "folder"); File proj1 = new File(base, "proj1"); proj1.mkdir(); File base2 = new File(getWorkDir(), "folder2"); base2.mkdir(); JavaProjectGenerator.JavaCompilationUnit cu = new JavaProjectGenerator.JavaCompilationUnit(); cu.output = new ArrayList(); cu.output.add("${outputfile}"); ArrayList units = new ArrayList(); units.add(cu); Map m = new HashMap(); m.put("outputfile", "out.jar"); PropertyEvaluator evaluator = PropertyUtils.sequentialPropertyEvaluator(null, new PropertyProvider[]{ PropertyUtils.fixedPropertyProvider(m)}); List buildFolders = JavaProjectGenerator.guessBuildFolders(evaluator, units, proj1, proj1); assertEquals("no build folder", 0, buildFolders.size()); cu.output.add(base2.getAbsolutePath()); buildFolders = JavaProjectGenerator.guessBuildFolders(evaluator, units, proj1, proj1); assertEquals("one build-folder created", 1, buildFolders.size()); assertEquals("export is properly configured", base2.getAbsolutePath(), buildFolders.get(0)); cu.output.add(getWorkDir().getAbsolutePath()); buildFolders = JavaProjectGenerator.guessBuildFolders(evaluator, units, proj1, proj1); assertEquals("one build-folder created", 1, buildFolders.size()); assertEquals("export is properly configured", getWorkDir().getAbsolutePath(), buildFolders.get(0)); // check that root of this is handled correctly File diskRoot = getWorkDir(); while (diskRoot.getParentFile() != null) { diskRoot = diskRoot.getParentFile(); } cu.output.add(diskRoot.getAbsolutePath()); buildFolders = JavaProjectGenerator.guessBuildFolders(evaluator, units, proj1, proj1); assertEquals("one build-folder created", 1, buildFolders.size()); assertEquals("export is properly configured", diskRoot.getAbsolutePath(), buildFolders.get(0)); }
Example 8
Source File: ProjectModelTest.java From netbeans with Apache License 2.0 | 5 votes |
public void testCreateEmptyModel() throws Exception { File baseFolder = new File(getWorkDir(), "somefolder/"); File nbProjectFolder = new File(getWorkDir(), "nbprojfolder/"); Map<String,String> p = new HashMap<String,String>(); p.put("key", "value"); PropertyEvaluator evaluator = PropertyUtils.sequentialPropertyEvaluator(null, PropertyUtils.fixedPropertyProvider(p)); ProjectModel pm = ProjectModel.createEmptyModel(baseFolder, nbProjectFolder, evaluator); assertNotNull(pm); assertEquals("Base folder incorrect", baseFolder, pm.getBaseFolder()); assertEquals("NB project folder incorrect", nbProjectFolder, pm.getNBProjectFolder()); assertEquals("Evaluator incorrect", evaluator, pm.getEvaluator()); assertEquals("Evaluator is different", 1, pm.getEvaluator().getProperties().size()); }
Example 9
Source File: ProjectModelTest.java From netbeans with Apache License 2.0 | 5 votes |
private ProjectModel createEmptyProjectModel() throws Exception { File baseFolder = new File(getWorkDir(), "somefolder/"); File nbProjectFolder = new File(getWorkDir(), "nbprojfolder/"); Map<String,String> p = new HashMap<String,String>(); p.put("key", "value"); PropertyEvaluator evaluator = PropertyUtils.sequentialPropertyEvaluator(null, PropertyUtils.fixedPropertyProvider(p)); return ProjectModel.createEmptyModel(baseFolder, nbProjectFolder, evaluator); }
Example 10
Source File: ProjectConfigurations.java From netbeans with Apache License 2.0 | 5 votes |
/** * Creates a {@link PropertyEvaluator} with {@link ProjectConfiguration} support. * @param project the project to create {@link PropertyEvaluator} for * @param helper the {@link Project}'s {@link AntProjectHelper} * @param additionalPropertyProviders the additional {@link PropertyProvider}s * @return a new {@link PropertyEvaluator} */ @NonNull public static PropertyEvaluator createPropertyEvaluator( @NonNull final Project project, @NonNull final AntProjectHelper helper, @NonNull final PropertyProvider... additionalPropertyProviders) { Parameters.notNull("project", project); //NOI18N Parameters.notNull("helper", helper); //NOI18N Parameters.notNull("additionalPropertyProviders", additionalPropertyProviders); //NOI18N PropertyEvaluator baseEval1 = PropertyUtils.sequentialPropertyEvaluator( helper.getStockPropertyPreprovider(), helper.getPropertyProvider(ProjectConfigurations.CONFIG_PROPS_PATH)); PropertyEvaluator baseEval2 = PropertyUtils.sequentialPropertyEvaluator( helper.getStockPropertyPreprovider(), helper.getPropertyProvider(AntProjectHelper.PRIVATE_PROPERTIES_PATH)); final Queue<PropertyProvider> providers = new ArrayDeque<>(additionalPropertyProviders.length + 7); providers.offer(helper.getPropertyProvider(ProjectConfigurations.CONFIG_PROPS_PATH)); providers.offer(new ConfigPropertyProvider(baseEval1, "nbproject/private/configs", helper)); //NOI18N providers.offer(helper.getPropertyProvider(AntProjectHelper.PRIVATE_PROPERTIES_PATH)); providers.offer(helper.getProjectLibrariesPropertyProvider()); providers.offer(PropertyUtils.userPropertiesProvider(baseEval2, "user.properties.file", FileUtil.toFile(project.getProjectDirectory()))); //NOI18N providers.offer(new ConfigPropertyProvider(baseEval1, "nbproject/configs", helper)); //NOI18N providers.offer(helper.getPropertyProvider(AntProjectHelper.PROJECT_PROPERTIES_PATH)); Collections.addAll(providers, additionalPropertyProviders); return PropertyUtils.sequentialPropertyEvaluator( helper.getStockPropertyPreprovider(), providers.toArray(new PropertyProvider[providers.size()])); }
Example 11
Source File: MultiModuleAntArtifactProvider.java From netbeans with Apache License 2.0 | 5 votes |
@Override public AntArtifact[] getBuildArtifacts() { final List<AntArtifact> artifacts = new ArrayList<>(); final EvaluatorPropertyProvider pp = new EvaluatorPropertyProvider(eval); for (String modName : srcModules.getModuleNames()) { final String moduleDistJarKey = String.format( "module.%s.dist.jar", //NOI18N modName); final String moduleDistJarVal = String.format( "${%s}/%s.jar", //NOI18N ProjectProperties.DIST_DIR, modName); final PropertyEvaluator extEval = PropertyUtils.sequentialPropertyEvaluator( null, pp, PropertyUtils.fixedPropertyProvider(Collections.singletonMap( moduleDistJarKey, moduleDistJarVal))); final AntArtifact artifact = helper.createSimpleAntArtifact( JavaProjectConstants.ARTIFACT_TYPE_JAR, moduleDistJarKey, extEval, buildTarget, cleanTarget, ProjectProperties.BUILD_SCRIPT); artifacts.add(new ModuleIdDecorator(modName, artifact)); } return artifacts.toArray(new AntArtifact[artifacts.size()]); }
Example 12
Source File: BuildUtils.java From netbeans with Apache License 2.0 | 5 votes |
public static File findTargetJavaHome(FileObject file) { File buildDir = getBuildTargetDir(file); if (buildDir != null) { File candidate = new File(buildDir, "images/j2sdk-image"); if (candidate.isDirectory()) { return candidate; } else { return new File(buildDir, "jdk"); } } Project prj = FileOwnerQuery.getOwner(file); File projectDirFile = FileUtil.toFile(prj.getProjectDirectory()); File userHome = new File(System.getProperty("user.home")); List<PropertyProvider> properties = new ArrayList<>(); properties.add(PropertyUtils.propertiesFilePropertyProvider(new File(projectDirFile, "build.properties"))); properties.add(PropertyUtils.propertiesFilePropertyProvider(new File(userHome, ".openjdk/langtools-build.properties"))); properties.add(PropertyUtils.propertiesFilePropertyProvider(new File(userHome, ".openjdk/build.properties"))); properties.add(PropertyUtils.propertiesFilePropertyProvider(new File(projectDirFile, "make/build.properties"))); PropertyEvaluator evaluator = PropertyUtils.sequentialPropertyEvaluator(PropertyUtils.globalPropertyProvider(), properties.toArray(new PropertyProvider[0])); return new File(evaluator.evaluate("${target.java.home}")); }
Example 13
Source File: WebProject.java From netbeans with Apache License 2.0 | 5 votes |
private PropertyEvaluator createEvaluator() { // XXX might need to add a custom evaluator to handle active platform substitutions... TBD helper.getStandardPropertyEvaluator();//workaround for issue for #181253, need to call before custom creation PropertyEvaluator baseEval2 = PropertyUtils.sequentialPropertyEvaluator( helper.getStockPropertyPreprovider(), helper.getPropertyProvider(AntProjectHelper.PRIVATE_PROPERTIES_PATH)); return PropertyUtils.sequentialPropertyEvaluator( helper.getStockPropertyPreprovider(), helper.getPropertyProvider(AntProjectHelper.PRIVATE_PROPERTIES_PATH), helper.getProjectLibrariesPropertyProvider(), PropertyUtils.userPropertiesProvider(baseEval2, "user.properties.file", FileUtil.toFile(getProjectDirectory())), // NOI18N helper.getPropertyProvider(AntProjectHelper.PROJECT_PROPERTIES_PATH), UPDATE_PROPERTIES); }
Example 14
Source File: JavaProjectGeneratorTest.java From netbeans with Apache License 2.0 | 4 votes |
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)); }