Skip to content

Commit

Permalink
Various cleanups and modernizations
Browse files Browse the repository at this point in the history
Visible in my workspace (sonarlint installed), settings to enable them
by default, save actions and etc.
  • Loading branch information
akurtakov committed Dec 12, 2023
1 parent 7cc0eab commit e3a0a56
Show file tree
Hide file tree
Showing 10 changed files with 37 additions and 58 deletions.
6 changes: 3 additions & 3 deletions tycho-core/.settings/org.eclipse.jdt.ui.prefs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ sp_cleanup.add_missing_nls_tags=false
sp_cleanup.add_missing_override_annotations=true
sp_cleanup.add_missing_override_annotations_interface_methods=true
sp_cleanup.add_serial_version_id=false
sp_cleanup.also_simplify_lambda=false
sp_cleanup.also_simplify_lambda=true
sp_cleanup.always_use_blocks=true
sp_cleanup.always_use_parentheses_in_expressions=false
sp_cleanup.always_use_this_for_non_static_field_access=false
Expand All @@ -27,7 +27,7 @@ sp_cleanup.collection_cloning=false
sp_cleanup.comparing_on_criteria=false
sp_cleanup.comparison_statement=false
sp_cleanup.controlflow_merge=false
sp_cleanup.convert_functional_interfaces=false
sp_cleanup.convert_functional_interfaces=true
sp_cleanup.convert_to_enhanced_for_loop=false
sp_cleanup.convert_to_enhanced_for_loop_if_loop_var_used=false
sp_cleanup.convert_to_switch_expressions=false
Expand Down Expand Up @@ -133,7 +133,7 @@ sp_cleanup.use_autoboxing=false
sp_cleanup.use_blocks=false
sp_cleanup.use_blocks_only_for_return_and_throw=false
sp_cleanup.use_directly_map_method=false
sp_cleanup.use_lambda=false
sp_cleanup.use_lambda=true
sp_cleanup.use_parentheses_in_expressions=false
sp_cleanup.use_string_is_blank=false
sp_cleanup.use_this_for_non_static_field_access=false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -292,9 +292,7 @@ public Collection<Path> getProjectDependencies(MavenProject project) throws Exce
// again!
Optional<ResolvedArtifactKey> bundle = mavenBundleResolver.resolveMavenBundle(project, session, "org.osgi",
"org.osgi.service.component.annotations", "1.3.0");
bundle.ifPresent(key -> {
writeLocation(key.getLocation(), dependencySet);
});
bundle.ifPresent(key -> writeLocation(key.getLocation(), dependencySet));
}
return dependencySet;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,26 +38,32 @@ public ArtifactFacadeProxy(IArtifactFacade proxy) {
this.proxy = proxy;
}

@Override
public File getLocation() {
return proxy.getLocation();
}

@Override
public String getGroupId() {
return proxy.getGroupId();
}

@Override
public String getArtifactId() {
return proxy.getArtifactId();
}

@Override
public String getClassifier() {
return proxy.getClassifier();
}

@Override
public String getVersion() {
return proxy.getVersion();
}

@Override
public String getPackagingType() {
return proxy.getPackagingType();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,20 +98,11 @@ protected void createAdviceFileAdvice(BundleDescription bundleDescription, IPubl

Map<String, String> advice = new LinkedHashMap<>();

try {
InputStream is = new BufferedInputStream(new FileInputStream(adviceFile));
try {
Properties props = new Properties();
props.load(is);
for (Map.Entry<Object, Object> p : props.entrySet()) {
advice.put((String) p.getKey(), (String) p.getValue());
}
} finally {
try {
is.close();
} catch (IOException secondary) {
// secondary exception
}
try (InputStream is = new BufferedInputStream(new FileInputStream(adviceFile))) {
Properties props = new Properties();
props.load(is);
for (Map.Entry<Object, Object> p : props.entrySet()) {
advice.put((String) p.getKey(), (String) p.getValue());
}
} catch (IOException e) {
// TODO log
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ public FileTargetDefinitionContent(IProvisioningAgent agent, File location) {
artifactRepository.setLocation(location.toURI());
}

@Override
public IMetadataRepository getMetadataRepository() {
preload(null);
return metadataRepository;
Expand Down Expand Up @@ -100,6 +101,7 @@ public synchronized void preload(IProgressMonitor monitor) {
loaded = true;
}

@Override
public IArtifactRepository getArtifactRepository() {
preload(null);
return artifactRepository;
Expand All @@ -110,7 +112,7 @@ private Map<IArtifactDescriptor, IInstallableUnit> getRepositoryContent() {
}

private static void readFeatures(File path, BiConsumer<IArtifactDescriptor, IInstallableUnit> consumer,
IProgressMonitor monitor) throws ResolverException {
IProgressMonitor monitor) {
PublisherInfo publisherInfo = new PublisherInfo();
publisherInfo.setArtifactOptions(IPublisherInfo.A_INDEX);
if (path.isDirectory()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Objects;
import java.util.Set;
import java.util.TreeMap;
import java.util.function.Function;
Expand Down Expand Up @@ -220,9 +219,7 @@ public TargetPlatform computePreliminaryTargetPlatform(MavenSession session, Mav
tpConfiguration
.setIgnoreLocalArtifacts(configuration.getIgnoreLocalArtifacts() == LocalArtifactHandling.ignore);
tpConfiguration.setReferencedRepositoryMode(configuration.getReferencedRepositoryMode());
TargetPlatform result = tpFactory.createTargetPlatform(tpConfiguration, ee, reactorProjects,
reactorProject);
return result;
return tpFactory.createTargetPlatform(tpConfiguration, ee, reactorProjects, reactorProject);
});
}

Expand Down Expand Up @@ -348,10 +345,9 @@ private DependencyArtifacts doResolveDependencies(MavenSession session, MavenPro
for (String additionalBundle : additionalBundles) {
resolver.addAdditionalBundleDependency(additionalBundle);
}
projectManager.getBndTychoProject(project).ifPresent(processor -> {
AdditionalBundleRequirementsInstallableUnitProvider.getBndClasspathRequirements(processor)
.forEach(req -> resolver.addRequirement(req));
});
projectManager.getBndTychoProject(project)
.ifPresent(processor -> AdditionalBundleRequirementsInstallableUnitProvider
.getBndClasspathRequirements(processor).forEach(resolver::addRequirement));
// get reactor project with prepared optional dependencies // TODO use original IU and have the resolver create the modified IUs
ReactorProject optionalDependencyPreparedProject = getThisReactorProject(session, project, configuration);

Expand Down
6 changes: 3 additions & 3 deletions tycho-p2-director-plugin/.settings/org.eclipse.jdt.core.prefs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ org.eclipse.jdt.core.compiler.problem.discouragedReference=warning
org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore
org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=warning
org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore
org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled
org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore
Expand All @@ -44,7 +44,7 @@ org.eclipse.jdt.core.compiler.problem.missingDefaultCase=ignore
org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore
org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled
org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=ignore
org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore
org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=warning
org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled
org.eclipse.jdt.core.compiler.problem.missingSerialVersion=ignore
org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore
Expand All @@ -66,7 +66,7 @@ org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=ignore
org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning
org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=warning
org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore
org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=ignore
org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=warning
org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore
org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore
org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ private String getRepositories() {
if (repositories == null) {
return projectRepository.getAbsoluteFile().toURI().toASCIIString();
}
List<String> list = new ArrayList<String>();
List<String> list = new ArrayList<>();
for (String repo : repositories.split(",")) {
list.add(repo.trim());
}
Expand Down Expand Up @@ -441,7 +441,7 @@ private File getProjectRepository() {
}

private Map<String, String> getPropertyMap(String csvPropertiesMap, Map<String, String> properties) {
LinkedHashMap<String, String> map = new LinkedHashMap<String, String>();
LinkedHashMap<String, String> map = new LinkedHashMap<>();
if (csvPropertiesMap != null) {
for (String keyValue : csvPropertiesMap.split(",")) {
String[] split = keyValue.split("=");
Expand All @@ -458,7 +458,7 @@ private Map<String, String> getPropertyMap(String csvPropertiesMap, Map<String,
}

private List<String> getUnitParameterList(String csvlist, List<IU> units) {
List<String> list = new ArrayList<String>();
List<String> list = new ArrayList<>();
if (csvlist != null) {
for (String iu : csvlist.split(",")) {
list.add(iu.trim());
Expand All @@ -479,13 +479,6 @@ private List<String> getUnitParameterList(String csvlist, List<IU> units) {
return list;
}

private void add(String key, String value, List<String> args) {
if (metadatarepositories != null) {
args.add("-metadatarepository");
args.add(metadatarepositories);
}
}

public static final class IU {
String id;
String version;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

import org.apache.commons.compress.archivers.tar.TarArchiveEntry;
import org.apache.commons.compress.archivers.tar.TarArchiveOutputStream;
import org.apache.commons.compress.archivers.tar.TarConstants;
import org.apache.commons.compress.compressors.gzip.GzipCompressorOutputStream;
import org.apache.maven.plugin.logging.Log;
import org.apache.maven.plugin.logging.SystemStreamLog;
Expand Down Expand Up @@ -70,12 +71,11 @@ public void addDirectory(File directory) {
public void createArchive() throws IOException {
validate();
log.info("Building tar: " + destFile);
TarArchiveOutputStream tarStream = null;
try {
destFile.getAbsoluteFile().getParentFile().mkdirs();
GzipCompressorOutputStream gzipStream = new GzipCompressorOutputStream(
new BufferedOutputStream(new FileOutputStream(destFile)));
tarStream = new TarArchiveOutputStream(gzipStream, "UTF-8");
destFile.getAbsoluteFile().getParentFile().mkdirs();
try (GzipCompressorOutputStream gzipStream = new GzipCompressorOutputStream(
new BufferedOutputStream(new FileOutputStream(destFile)));
TarArchiveOutputStream tarStream = new TarArchiveOutputStream(gzipStream, "UTF-8");) {

// allow "long" file paths (> 100 chars)
tarStream.setLongFileMode(TarArchiveOutputStream.LONGFILE_POSIX);
tarStream.setBigNumberMode(TarArchiveOutputStream.BIGNUMBER_POSIX);
Expand All @@ -84,10 +84,6 @@ public void createArchive() throws IOException {
addToTarRecursively(sourceDir, child, tarStream);
}
}
} finally {
if (tarStream != null) {
tarStream.close();
}
}
}

Expand Down Expand Up @@ -123,7 +119,7 @@ private TarArchiveEntry createTarEntry(File tarRootDir, File source) throws IOEx
TarArchiveEntry tarEntry;
if (isSymbolicLink(source) && resolvesBelow(source, tarRootDir)) {
// only create symlink entry if link target is inside archive
tarEntry = new TarArchiveEntry(pathInTar, TarArchiveEntry.LF_SYMLINK);
tarEntry = new TarArchiveEntry(pathInTar, TarConstants.LF_SYMLINK);
tarEntry.setLinkName(slashify(getRelativeSymLinkTarget(source, source.getParentFile())));
} else {
tarEntry = new TarArchiveEntry(source, pathInTar);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,16 +204,13 @@ private void createSymbolicLink(File link, Path linkTarget) {
}

private Map<String, TarArchiveEntry> getTarEntries() throws IOException, FileNotFoundException {
TarArchiveInputStream tarStream = new TarArchiveInputStream(
new GzipCompressorInputStream(new FileInputStream(tarGzArchive)));
Map<String, TarArchiveEntry> entries = new HashMap<>();
try {
try (TarArchiveInputStream tarStream = new TarArchiveInputStream(
new GzipCompressorInputStream(new FileInputStream(tarGzArchive)))) {
TarArchiveEntry tarEntry = null;
while ((tarEntry = tarStream.getNextTarEntry()) != null) {
entries.put(tarEntry.getName(), tarEntry);
}
} finally {
tarStream.close();
}
return entries;
}
Expand Down

0 comments on commit e3a0a56

Please sign in to comment.