Read properties file and return the properties as {@link Map}.

@return the options from properties file or null if not properties file found
@throws MojoExecutionException
the mojo execution exception
518238
private Map<String, String> getOptionsFromPropertiesFile(String newPropertiesFile) throws MojoExecutionException {

        this.getLog().debug("Using search path at: " + this.basedir.getAbsolutePath());
        this.resourceManager.addSearchPath(FileResourceLoader.ID, this.basedir.getAbsolutePath());

        Properties properties = new Properties();
        try {
            properties.load(this.resourceManager.getResourceAsInputStream(newPropertiesFile));
        } catch (ResourceNotFoundException e) {
            getLog().debug("Property file [" + newPropertiesFile + "] cannot be found", e);
            return new HashMap<>();
        } catch (IOException e) {
            throw new MojoExecutionException("Cannot read config file [" + newPropertiesFile + "]", e);
        }

        final Map<String, String> map = new HashMap<>();
        for (final String name : properties.stringPropertyNames()) {
            map.put(name, properties.getProperty(name));
        }
        return map;
    }
750698
@Override
    public Map<String, String> getExtensionProperties() {
        List<Node> props = extension.get("property");
        Map<String, String> properties = new HashMap<String, String>();

        for (Node prop : props) {
            properties.put(prop.getAttribute("name"), prop.getText());
        }
        return properties;
    }
69059
public ValueMap getProperties() {
    if (this.properties == null) {
      this.properties = new ValueMapDecorator(new HashMap<String, Object>());
    }
    return this.properties;
  }
1343659
@Override
    @InterfaceAudience.Public
    public Map<String, Object> getProperties() {
        Map<String, Object> properties = revisionInternal.getProperties();
        if (!checkedProperties) {
            if (properties == null) {
                if (loadProperties() == true) {
                    properties = revisionInternal.getProperties();
                }
            }
            checkedProperties = true;
        }
        return properties != null ? Collections.unmodifiableMap(properties) : null;
    }
1006375
private void extractConfigSettings(Artifact artifact) throws MojoExecutionException {// NOSONAR
        try (JarFile configSettings = new JarFile(artifact.getFile())) {
            Enumeration<JarEntry> entries = configSettings.entries();
            while (entries.hasMoreElements()) {
                JarEntry jarFileEntry = entries.nextElement();
                // Only interested in files in the /bin directory that are not properties files
                if (!jarFileEntry.isDirectory() && jarFileEntry.getName().startsWith("bin")
                        && !jarFileEntry.getName().endsWith(".properties")) {
                    File fileToCreate = new File(jmeterDirectory, jarFileEntry.getName());
                    copyInputStreamToFile(configSettings.getInputStream(jarFileEntry), fileToCreate);
                }
            }
        } catch (IOException e) {
            throw new MojoExecutionException(e.getMessage(), e);
        }
    }
213441
@SuppressFBWarnings(value = "DMI_COLLECTION_OF_URLS", justification = "Only local URLs involved")
    private Map<ConfigurationKey, Object> readFileProperties(Set<URL> files) {
        Map<ConfigurationKey, Object> found = new EnumMap<ConfigurationKey, Object>(ConfigurationKey.class);
        for (URL file : files) {
            ConfigurationLogger.LOG.readingPropertiesFile(file);
            Properties fileProperties = loadProperties(file);
            for (String name : fileProperties.stringPropertyNames()) {
                processKeyValue(found, name, fileProperties.getProperty(name));
            }
        }
        return found;
    }
863645
private String[] propertiesReader() {
        InputStream inputstream = null;
        try {
            inputstream = Runtime.getRuntime().exec("getprop").getInputStream();
        } catch (IOException e) {
            Log.e(TAG, "Error reading properties", e);
        }
        if (inputstream == null) {
            return new String[0];
        }

        String allProperties = "";
        try {
            allProperties = new Scanner(inputstream).useDelimiter("\\A").next();
        } catch (NoSuchElementException e) {
            Log.e(TAG, "Error reading properties", e);
        }
        return allProperties.split("\n");
    }
344506
public Map<String, Object> getProperties() {
        Map<String, Object> result = null;
        if (body != null) {
            Map<String, Object> prop;
            try {
                prop = body.getProperties();
            } catch (IllegalStateException e) {
                // handle when both object and json are null for this body
                return null;
            }
            if (result == null) {
                result = new HashMap<String, Object>();
            }
            result.putAll(prop);
        }
        return result;
    }
1004749
private static Properties loadSecretProperties() throws Exception {
        Properties properties = new Properties();
        InputStream propertiesStream = GetUserProfile.class.getClassLoader().getResourceAsStream("secrets.properties");
        if (propertiesStream == null) {
            // Fallback to file access in the case of running from certain IDEs.
            File buildPropertiesFile = new File("src/main/resources/secrets.properties");
            if (buildPropertiesFile.exists()) {
                properties.load(new FileReader(buildPropertiesFile));
            } else {
                buildPropertiesFile = new File("samples/cmdline-sample/src/main/resources/secrets.properties");
                if (buildPropertiesFile.exists()) {
                    properties.load(new FileReader(buildPropertiesFile));
                } else {
                    throw new IllegalStateException("Could not find secrets.properties");
                }
            }
        } else {
            properties.load(propertiesStream);
        }
        return properties;
    }
504743
@SuppressWarnings("unchecked") public Map<String, Object> getCustomProperties()
   {
      return (Map<String, Object>) getCachedValue(ProjectField.CUSTOM_PROPERTIES);
   }
997917
public Map getProperties() {
        if (tc.isEntryEnabled())
            SibTr.entry(this, tc, "getProperties");
        if (tc.isEntryEnabled())
            SibTr.exit(this, tc, "getProperties");
        return null;
    }
462247
@Override
	public synchronized Map<Object, Object> getProperties()
	{

		if (properties == null || this.isAlwaysReload())
		{
			loadProperties();
		}

		// return copy

		return new HashMap<Object, Object>(properties);
	}
308242
public static Properties loadProperties(final File file) {
        checkNotNull("file", file);
        checkValidFile(file);
        final Properties props = new Properties();
        try (final InputStream inStream = new FileInputStream(file)) {
            props.load(inStream);
        } catch (final IOException ex) {
            throw new RuntimeException(ex);
        }
        return props;
    }
131015
protected Collection<ResourceFile> getAllResourceFiles()
        throws MojoExecutionException
    {
        try
        {
            Set<ResourceFile> sourcesAndResources = new HashSet<ResourceFile>();
            Set<String> sourcesAndResourcesPath = new HashSet<String>();
            sourcesAndResourcesPath.addAll( getProject().getCompileSourceRoots() );
            for ( Resource resource : getProject().getResources() )
            {
                sourcesAndResourcesPath.add( resource.getDirectory() );
            }

            for ( String name : getModules() )
            {
                GwtModule module = readModule( name );

                sourcesAndResources.add( getDescriptor( module, sourcesAndResourcesPath ) );
                int count = 1;

                for ( String source : module.getSources() )
                {
                    getLog().debug( "GWT sources from " + name + '.' + source );
                    Collection<ResourceFile> files = getAsResources( module, source, sourcesAndResourcesPath,
                                                                     "**/*.java" );
                    sourcesAndResources.addAll( files );
                    count += files.size();

                    Collection<ResourceFile> uifiles = getAsResources( module, source, sourcesAndResourcesPath,
                            "**/*.ui.xml" );
                    sourcesAndResources.addAll( uifiles );
                    count += uifiles.size();
                }
                for ( String source : module.getSuperSources() )
                {
                    getLog().debug( "GWT super-sources from " + name + '.' + source );
                    Collection<ResourceFile> files = getAsResources( module, source, sourcesAndResourcesPath,
                                                                     "**/*.java" );
                    sourcesAndResources.addAll( files );
                    count += files.size();

                    Collection<ResourceFile> uifiles = getAsResources( module, source, sourcesAndResourcesPath,
                            "**/*.ui.xml" );
                    sourcesAndResources.addAll( uifiles );
                    count += uifiles.size();
                }
                getLog().info( count + " source files from GWT module " + name );
            }
            return sourcesAndResources;
        }
        catch ( GwtModuleReaderException e )
        {
            throw new MojoExecutionException( e.getMessage(), e );
        }
    }
1237548
protected List<File> getClassPath() throws MojoExecutionException {
		if (this.bufferedClasspath == null) {
			final Set<String> classPath = new LinkedHashSet<>();
			final MavenProject project = getProject();
			classPath.add(project.getBuild().getSourceDirectory());
			try {
				classPath.addAll(project.getCompileClasspathElements());
			} catch (DependencyResolutionRequiredException e) {
				throw new MojoExecutionException(e.getLocalizedMessage(), e);
			}
			for (final Artifact dep : project.getArtifacts()) {
				classPath.add(dep.getFile().getAbsolutePath());
			}
			classPath.remove(project.getBuild().getOutputDirectory());
			final List<File> files = new ArrayList<>();
			for (final String filename : classPath) {
				final File file = new File(filename);
				if (file.exists()) {
					files.add(file);
				} else {
					getLog().warn(MessageFormat.format(Messages.AbstractSarlBatchCompilerMojo_10, filename));
				}
			}
			this.bufferedClasspath = files;
		}
		return this.bufferedClasspath;
	}
231202
private Model readModel(final InputStream pomStream) throws MojoExecutionException {
        Reader reader = null;
        try {
            reader = ReaderFactory.newXmlReader(pomStream);
            return new MavenXpp3Reader().read(reader);
        } catch (FileNotFoundException e) {
            throw new MojoExecutionException("File not found " + pomFile, e);
        } catch (IOException e) {
            throw new MojoExecutionException("Error reading POM " + pomFile, e);
        } catch (XmlPullParserException e) {
            throw new MojoExecutionException("Error parsing POM " + pomFile, e);
        } finally {
            IOUtil.close(reader);
        }
    }
990670
@NotNull
    public Map<String, String> getXmpProperties()
    {
        Map<String, String> propertyValueByPath = new HashMap<String, String>();

        if (_xmpMeta != null)
        {
            try {
                IteratorOptions options = new IteratorOptions().setJustLeafnodes(true);
                for (Iterator i = _xmpMeta.iterator(options); i.hasNext(); ) {
                    XMPPropertyInfo prop = (XMPPropertyInfo)i.next();
                    String path = prop.getPath();
                    String value = prop.getValue();
                    if (path != null && value != null) {
                        propertyValueByPath.put(path, value);
                    }
                }
            } catch (XMPException ignored) {
            }
        }

        return Collections.unmodifiableMap(propertyValueByPath);
    }