diff --git a/p2-maven-plugin/.settings/org.eclipse.jdt.ui.prefs b/p2-maven-plugin/.settings/org.eclipse.jdt.ui.prefs index 3ffec2f08f..5f093a740d 100644 --- a/p2-maven-plugin/.settings/org.eclipse.jdt.ui.prefs +++ b/p2-maven-plugin/.settings/org.eclipse.jdt.ui.prefs @@ -10,6 +10,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.always_use_blocks=true sp_cleanup.always_use_parentheses_in_expressions=false sp_cleanup.always_use_this_for_non_static_field_access=false @@ -85,7 +86,7 @@ sp_cleanup.redundant_falling_through_block_end=false sp_cleanup.remove_private_constructors=true sp_cleanup.remove_redundant_modifiers=false sp_cleanup.remove_redundant_semicolons=false -sp_cleanup.remove_redundant_type_arguments=false +sp_cleanup.remove_redundant_type_arguments=true sp_cleanup.remove_trailing_whitespaces=false sp_cleanup.remove_trailing_whitespaces_all=true sp_cleanup.remove_trailing_whitespaces_ignore_empty=false @@ -99,6 +100,7 @@ sp_cleanup.remove_unused_private_fields=true sp_cleanup.remove_unused_private_members=false sp_cleanup.remove_unused_private_methods=true sp_cleanup.remove_unused_private_types=true +sp_cleanup.replace_deprecated_calls=false sp_cleanup.return_expression=false sp_cleanup.simplify_lambda_expression_and_method_ref=false sp_cleanup.single_used_field=false @@ -110,6 +112,7 @@ sp_cleanup.strictly_equal_or_different=false sp_cleanup.stringbuffer_to_stringbuilder=false sp_cleanup.stringbuilder=false sp_cleanup.stringbuilder_for_local_vars=true +sp_cleanup.stringconcat_stringbuffer_stringbuilder=false sp_cleanup.stringconcat_to_textblock=false sp_cleanup.substring=false sp_cleanup.switch=false diff --git a/p2-maven-plugin/src/main/java/org/eclipse/tycho/p2maven/transport/URLHttpTransportFactory.java b/p2-maven-plugin/src/main/java/org/eclipse/tycho/p2maven/transport/URLHttpTransportFactory.java index 163a314f28..3b98137aac 100644 --- a/p2-maven-plugin/src/main/java/org/eclipse/tycho/p2maven/transport/URLHttpTransportFactory.java +++ b/p2-maven-plugin/src/main/java/org/eclipse/tycho/p2maven/transport/URLHttpTransportFactory.java @@ -63,7 +63,7 @@ public void setHeader(String key, String value) { public Response get() throws IOException { HttpURLConnection connection = createConnection(); connection.connect(); - return new HttpResponse(connection) { + return new HttpResponse<>(connection) { @Override public void close() { @@ -111,7 +111,7 @@ public Response head() throws IOException { HttpURLConnection connection = createConnection(); connection.setRequestMethod("HEAD"); connection.connect(); - return new HttpResponse(connection) { + return new HttpResponse<>(connection) { @Override public void close() { diff --git a/tycho-core/.settings/org.eclipse.jdt.ui.prefs b/tycho-core/.settings/org.eclipse.jdt.ui.prefs index 8a73ade26c..a73d76596e 100644 --- a/tycho-core/.settings/org.eclipse.jdt.ui.prefs +++ b/tycho-core/.settings/org.eclipse.jdt.ui.prefs @@ -2,6 +2,7 @@ eclipse.preferences.version=1 editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true formatter_profile=_Tycho formatter_settings_version=12 +sp_cleanup.add_all=false sp_cleanup.add_default_serial_version_id=true sp_cleanup.add_generated_serial_version_id=false sp_cleanup.add_missing_annotations=true @@ -11,46 +12,136 @@ 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.always_use_blocks=true sp_cleanup.always_use_parentheses_in_expressions=false sp_cleanup.always_use_this_for_non_static_field_access=false sp_cleanup.always_use_this_for_non_static_method_access=false +sp_cleanup.array_with_curly=false +sp_cleanup.arrays_fill=false +sp_cleanup.bitwise_conditional_expression=false +sp_cleanup.boolean_literal=false +sp_cleanup.boolean_value_rather_than_comparison=false +sp_cleanup.break_loop=false +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_to_enhanced_for_loop=false +sp_cleanup.convert_to_enhanced_for_loop_if_loop_var_used=false +sp_cleanup.convert_to_switch_expressions=false sp_cleanup.correct_indentation=false +sp_cleanup.do_while_rather_than_while=false +sp_cleanup.double_negation=false +sp_cleanup.else_if=false +sp_cleanup.embedded_if=false +sp_cleanup.evaluate_nullable=false +sp_cleanup.extract_increment=false sp_cleanup.format_source_code=true sp_cleanup.format_source_code_changes_only=false +sp_cleanup.hash=false +sp_cleanup.if_condition=false +sp_cleanup.insert_inferred_type_arguments=false +sp_cleanup.instanceof=false +sp_cleanup.instanceof_keyword=false +sp_cleanup.invert_equals=false +sp_cleanup.join=false +sp_cleanup.lazy_logical_operator=false sp_cleanup.make_local_variable_final=false sp_cleanup.make_parameters_final=false -sp_cleanup.make_private_fields_final=true +sp_cleanup.make_private_fields_final=false sp_cleanup.make_type_abstract_if_missing_method=false -sp_cleanup.make_variable_declarations_final=true +sp_cleanup.make_variable_declarations_final=false +sp_cleanup.map_cloning=false +sp_cleanup.merge_conditional_blocks=false +sp_cleanup.multi_catch=false sp_cleanup.never_use_blocks=false sp_cleanup.never_use_parentheses_in_expressions=true -sp_cleanup.on_save_use_additional_actions=false +sp_cleanup.no_string_creation=false +sp_cleanup.no_super=false +sp_cleanup.number_suffix=false +sp_cleanup.objects_equals=false +sp_cleanup.on_save_use_additional_actions=true +sp_cleanup.one_if_rather_than_duplicate_blocks_that_fall_through=false +sp_cleanup.operand_factorization=false sp_cleanup.organize_imports=true +sp_cleanup.overridden_assignment=false +sp_cleanup.overridden_assignment_move_decl=false +sp_cleanup.plain_replacement=false +sp_cleanup.precompile_regex=false +sp_cleanup.primitive_comparison=false +sp_cleanup.primitive_parsing=false +sp_cleanup.primitive_rather_than_wrapper=false +sp_cleanup.primitive_serialization=false +sp_cleanup.pull_out_if_from_if_else=false +sp_cleanup.pull_up_assignment=false +sp_cleanup.push_down_negation=false sp_cleanup.qualify_static_field_accesses_with_declaring_class=false -sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true -sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true -sp_cleanup.qualify_static_member_accesses_with_declaring_class=true +sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=false +sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=false +sp_cleanup.qualify_static_member_accesses_with_declaring_class=false sp_cleanup.qualify_static_method_accesses_with_declaring_class=false +sp_cleanup.reduce_indentation=false +sp_cleanup.redundant_comparator=false +sp_cleanup.redundant_falling_through_block_end=false sp_cleanup.remove_private_constructors=true +sp_cleanup.remove_redundant_modifiers=false +sp_cleanup.remove_redundant_semicolons=false +sp_cleanup.remove_redundant_type_arguments=true sp_cleanup.remove_trailing_whitespaces=false sp_cleanup.remove_trailing_whitespaces_all=true sp_cleanup.remove_trailing_whitespaces_ignore_empty=false +sp_cleanup.remove_unnecessary_array_creation=false sp_cleanup.remove_unnecessary_casts=true sp_cleanup.remove_unnecessary_nls_tags=true sp_cleanup.remove_unused_imports=false sp_cleanup.remove_unused_local_variables=false +sp_cleanup.remove_unused_method_parameters=false sp_cleanup.remove_unused_private_fields=true sp_cleanup.remove_unused_private_members=false sp_cleanup.remove_unused_private_methods=true sp_cleanup.remove_unused_private_types=true +sp_cleanup.replace_deprecated_calls=false +sp_cleanup.return_expression=false +sp_cleanup.simplify_lambda_expression_and_method_ref=false +sp_cleanup.single_used_field=false sp_cleanup.sort_members=false sp_cleanup.sort_members_all=false -sp_cleanup.use_blocks=true +sp_cleanup.standard_comparison=false +sp_cleanup.static_inner_class=false +sp_cleanup.strictly_equal_or_different=false +sp_cleanup.stringbuffer_to_stringbuilder=false +sp_cleanup.stringbuilder=false +sp_cleanup.stringbuilder_for_local_vars=false +sp_cleanup.stringconcat_stringbuffer_stringbuilder=false +sp_cleanup.stringconcat_to_textblock=false +sp_cleanup.substring=false +sp_cleanup.switch=false +sp_cleanup.system_property=false +sp_cleanup.system_property_boolean=false +sp_cleanup.system_property_file_encoding=false +sp_cleanup.system_property_file_separator=false +sp_cleanup.system_property_line_separator=false +sp_cleanup.system_property_path_separator=false +sp_cleanup.ternary_operator=false +sp_cleanup.try_with_resource=false +sp_cleanup.unlooped_while=false +sp_cleanup.unreachable_block=false +sp_cleanup.use_anonymous_class_creation=false +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_parentheses_in_expressions=false +sp_cleanup.use_string_is_blank=false sp_cleanup.use_this_for_non_static_field_access=false sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true sp_cleanup.use_this_for_non_static_method_access=false sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true +sp_cleanup.use_unboxing=false +sp_cleanup.use_var=false +sp_cleanup.useless_continue=false +sp_cleanup.useless_return=false +sp_cleanup.valueof_rather_than_instantiation=false diff --git a/tycho-core/src/test/java/org/eclipse/tycho/test/util/ArtifactRepositoryTestUtils.java b/tycho-core/src/test/java/org/eclipse/tycho/test/util/ArtifactRepositoryTestUtils.java index 6cf4e76b86..65d90db7be 100644 --- a/tycho-core/src/test/java/org/eclipse/tycho/test/util/ArtifactRepositoryTestUtils.java +++ b/tycho-core/src/test/java/org/eclipse/tycho/test/util/ArtifactRepositoryTestUtils.java @@ -41,7 +41,7 @@ public static IArtifactDescriptor canonicalDescriptorFor(IArtifactKey key) { } public static Matcher inCanonicalFormat() { - return new TypeSafeMatcher() { + return new TypeSafeMatcher<>() { @Override public void describeTo(Description description) { diff --git a/tycho-core/src/test/java/org/eclipse/tycho/test/util/InstallableUnitMatchers.java b/tycho-core/src/test/java/org/eclipse/tycho/test/util/InstallableUnitMatchers.java index 2fa0609fbd..9309ec53df 100644 --- a/tycho-core/src/test/java/org/eclipse/tycho/test/util/InstallableUnitMatchers.java +++ b/tycho-core/src/test/java/org/eclipse/tycho/test/util/InstallableUnitMatchers.java @@ -31,7 +31,7 @@ public class InstallableUnitMatchers { private static final String TYPE = "IInstallableUnit"; public static Matcher unitWithId(final String id) { - return new TypeSafeMatcher(IInstallableUnit.class) { + return new TypeSafeMatcher<>(IInstallableUnit.class) { @Override public void describeTo(Description description) { @@ -169,7 +169,7 @@ public void describeTo(Description description) { public static Matcher requirement(final String id, final String version) { final IInstallableUnit unit = InstallableUnitUtil.createIU(id, version); - return new TypeSafeMatcher() { + return new TypeSafeMatcher<>() { @Override public void describeTo(Description description) { @@ -201,7 +201,7 @@ protected boolean matchesSafely(IRequirement item) { public static Matcher configureTouchpointInstructionThat( final Matcher instructionMatcher) { - return new TypeSafeMatcher() { + return new TypeSafeMatcher<>() { @Override public void describeTo(Description description) { diff --git a/tycho-its/src/test/java/org/eclipse/tycho/test/p2Inf/VirtualUnitTest.java b/tycho-its/src/test/java/org/eclipse/tycho/test/p2Inf/VirtualUnitTest.java index 9bb5c1078b..1d7f0b79f3 100644 --- a/tycho-its/src/test/java/org/eclipse/tycho/test/p2Inf/VirtualUnitTest.java +++ b/tycho-its/src/test/java/org/eclipse/tycho/test/p2Inf/VirtualUnitTest.java @@ -10,9 +10,13 @@ package org.eclipse.tycho.test.p2Inf; import static java.util.Arrays.asList; -import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; +import java.io.File; +import java.util.List; +import java.util.Optional; +import java.util.stream.Stream; + import org.apache.maven.it.Verifier; import org.eclipse.tycho.test.AbstractTychoIntegrationTest; import org.junit.Test; @@ -21,45 +25,43 @@ import de.pdark.decentxml.Element; import de.pdark.decentxml.XMLParser; -import java.io.File; -import java.util.List; -import java.util.Optional; -import java.util.stream.Stream; - /** - * Test that a virtual IU created just with metadata in a p2.inf file can be required - * in the same p2.inf file. + * Test that a virtual IU created just with metadata in a p2.inf file can be + * required in the same p2.inf file. *

- * It used to work until 3.0.5 (using consider) - * but since 4.0.0 failed with: + * It used to work until 3.0.5 (using + * consider) but since 4.0.0 + * failed with: + * *

  * Cannot resolve project dependencies:
  *   Software being installed: pvu.bundle 1.0.0.qualifier
  *   Missing requirement: pvu.bundle 1.0.0.qualifier requires 'org.eclipse.equinox.p2.iu; configure.pvu.bundle 0.0.0' but it could not be found
  * 
* - * See https://github.com/eclipse-tycho/tycho/blob/master/RELEASE_NOTES.md#mixed-reactor-setups-require-the-new-resolver-now + * See + * https://github.com/eclipse-tycho/tycho/blob/master/RELEASE_NOTES.md#mixed-reactor-setups-require-the-new-resolver-now * and https://github.com/eclipse-tycho/tycho/issues/2977 */ public class VirtualUnitTest extends AbstractTychoIntegrationTest { @Test public void testVirtualUnitRequirementDoesNotFailBuild() throws Exception { - Verifier verifier = getVerifier("/p2Inf.virtualUnit", false); + final Verifier verifier = getVerifier("/p2Inf.virtualUnit", false); verifier.executeGoals(asList("verify")); verifier.verifyErrorFreeLog(); - String hostUnitId = "pvu.bundle"; - String configureUnitId = "configure.pvu.bundle"; + final String hostUnitId = "pvu.bundle"; + final String configureUnitId = "configure.pvu.bundle"; - File p2Content = new File(verifier.getBasedir(), "bundle/target/p2content.xml"); - Document doc = XMLParser.parse(p2Content); + final File p2Content = new File(verifier.getBasedir(), "bundle/target/p2content.xml"); + final Document doc = XMLParser.parse(p2Content); - List units = doc.getChild("units").getChildren("unit"); - Optional hostUnit = findUnit(units, hostUnitId); - Optional configureUnit = findUnit(units, configureUnitId); + final List units = doc.getChild("units").getChildren("unit"); + final Optional hostUnit = findUnit(units, hostUnitId); + final Optional configureUnit = findUnit(units, configureUnitId); - Stream hostUnitRequirements = findRequirements(hostUnit); + final Stream hostUnitRequirements = findRequirements(hostUnit); assertTrue("Host IU " + hostUnitId + " not found", hostUnit.isPresent()); assertTrue("Configure IU " + configureUnitId + " not found", configureUnit.isPresent()); @@ -67,13 +69,11 @@ public void testVirtualUnitRequirementDoesNotFailBuild() throws Exception { hostUnitRequirements.anyMatch(elem -> configureUnitId.equals(elem.getAttributeValue("name")))); } - private static Optional findUnit(List units, String hostUnitId) { - return units.stream() - .filter(elem -> hostUnitId.equals(elem.getAttributeValue("id"))) - .findFirst(); + private static Optional findUnit(final List units, final String hostUnitId) { + return units.stream().filter(elem -> hostUnitId.equals(elem.getAttributeValue("id"))).findFirst(); } - private static Stream findRequirements(Optional hostUnit) { + private static Stream findRequirements(final Optional hostUnit) { return hostUnit.stream().flatMap(elem -> elem.getChild("requires").getChildren("required").stream()); } diff --git a/tycho-testing-harness/src/main/java/org/eclipse/tycho/test/util/XMLTool.java b/tycho-testing-harness/src/main/java/org/eclipse/tycho/test/util/XMLTool.java index a8c9e20fda..49693e6dcc 100644 --- a/tycho-testing-harness/src/main/java/org/eclipse/tycho/test/util/XMLTool.java +++ b/tycho-testing-harness/src/main/java/org/eclipse/tycho/test/util/XMLTool.java @@ -27,7 +27,6 @@ import javax.xml.xpath.XPathExpressionException; import javax.xml.xpath.XPathFactory; -import org.w3c.dom.Attr; import org.w3c.dom.Document; import org.w3c.dom.Node; import org.w3c.dom.NodeList; @@ -39,22 +38,22 @@ private XMLTool() { // static use only private static final DocumentBuilderFactory FACTORY; static { - DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); + final DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); // completely disable external entities declarations: try { factory.setFeature("http://xml.org/sax/features/external-general-entities", false); factory.setFeature("http://xml.org/sax/features/external-parameter-entities", false); - } catch (ParserConfigurationException e) { + } catch (final ParserConfigurationException e) { e.printStackTrace(); } FACTORY = factory; } - public static Document parseXMLDocument(File file) throws SAXException, IOException, ParserConfigurationException { + public static Document parseXMLDocument(final File file) throws SAXException, IOException, ParserConfigurationException { return FACTORY.newDocumentBuilder().parse(file); } - public static Document parseXMLDocumentFromJar(File jarFile, String entryPath) + public static Document parseXMLDocumentFromJar(final File jarFile, final String entryPath) throws SAXException, IOException, ParserConfigurationException { try (JarFile jar = new JarFile(jarFile); // InputStream stream = jar.getInputStream(jar.getEntry(entryPath));) { @@ -65,23 +64,23 @@ public static Document parseXMLDocumentFromJar(File jarFile, String entryPath) private static final ThreadLocal XPATH_TOOL = ThreadLocal .withInitial(() -> XPathFactory.newInstance().newXPath()); - private static Object evaluateXPath(Object startingPoint, String xpathExpression, QName returnType) + private static Object evaluateXPath(final Object startingPoint, final String xpathExpression, final QName returnType) throws XPathExpressionException { return XPATH_TOOL.get().evaluate(xpathExpression, startingPoint, returnType); } - public static Node getFirstMatchingNode(Object startingPoint, String xpathExpression) + public static Node getFirstMatchingNode(final Object startingPoint, final String xpathExpression) throws XPathExpressionException { return (Node) evaluateXPath(startingPoint, xpathExpression, XPathConstants.NODE); } - public static List getMatchingNodes(Object startingPoint, String xpathExpression) + public static List getMatchingNodes(final Object startingPoint, final String xpathExpression) throws XPathExpressionException { - NodeList nodeList = (NodeList) evaluateXPath(startingPoint, xpathExpression, XPathConstants.NODESET); + final NodeList nodeList = (NodeList) evaluateXPath(startingPoint, xpathExpression, XPathConstants.NODESET); return IntStream.range(0, nodeList.getLength()).mapToObj(nodeList::item).toList(); } - public static List getMatchingNodesValue(Object startingPoint, String xpathExpression) + public static List getMatchingNodesValue(final Object startingPoint, final String xpathExpression) throws XPathExpressionException { return getMatchingNodes(startingPoint, xpathExpression).stream().map(Node::getNodeValue).toList(); }