diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml new file mode 100644 index 00000000..8acd6f6c --- /dev/null +++ b/.github/workflows/docs.yml @@ -0,0 +1,73 @@ +name: Documentation and Eclipse update site + +on: + push: + branches: [master] + paths: + - 'README.md' + - 'docs/**' + - 'tools/docs/**' + - 'updatesite/**' + - 'mkdocs.yml' + - '.github/workflows/docs.yml' + pull_request: + paths: + - 'README.md' + - 'docs/**' + - 'tools/docs/**' + - 'updatesite/**' + - 'mkdocs.yml' + - '.github/workflows/docs.yml' + workflow_dispatch: + +permissions: + contents: read + +concurrency: + group: docs-${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: ${{ github.event_name == 'pull_request' }} + +jobs: + build: + runs-on: ubuntu-latest + permissions: + contents: read + pages: read + steps: + - uses: actions/checkout@v7 + with: + persist-credentials: false + - uses: actions/setup-python@v7 + with: + python-version: '3.13' + cache: pip + cache-dependency-path: tools/docs/requirements.txt + - name: Install documentation dependencies + run: python -m pip install -r tools/docs/requirements.txt + - name: Test homepage and published resources + run: python -m unittest discover -s tools/docs -p 'test_*.py' + - name: Build documentation and validate Eclipse update site + run: python -m mkdocs build --strict + - name: Configure Pages + if: github.ref == 'refs/heads/master' && github.event_name != 'pull_request' + uses: actions/configure-pages@v6 + - name: Upload Pages artifact + if: github.ref == 'refs/heads/master' && github.event_name != 'pull_request' + uses: actions/upload-pages-artifact@v5 + with: + path: site + + deploy: + if: github.ref == 'refs/heads/master' && github.event_name != 'pull_request' + needs: build + runs-on: ubuntu-latest + permissions: + pages: write + id-token: write + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + steps: + - name: Deploy GitHub Pages + id: deployment + uses: actions/deploy-pages@v5 diff --git a/.gitignore b/.gitignore index 82a47a1d..90f3d7ca 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,6 @@ !docs/dev/import-and-junit-verification.md .metals .vscode +/site/ +/.venv-docs/ +__pycache__/ diff --git a/Makefile b/Makefile index 06258c8d..ed3ee808 100644 --- a/Makefile +++ b/Makefile @@ -31,6 +31,6 @@ package: clean: $(MVN) clean -# REUSE license check +# REUSE license check. If missing, install using `pipx install reuse` reuse: - pipx run reuse lint \ No newline at end of file + reuse lint \ No newline at end of file diff --git a/README.md b/README.md index 42c23458..9299c103 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,14 @@ Features Requirements ------------ -It is required to install latest Eclipse IDE for plugin. Plugin is backward compatible with IDE at least 6 months old since plugin version release date. +Use the latest Eclipse IDE. The current development version requires Java 21 to run Eclipse. +Plugin releases are backward compatible with IDE versions at least 6 months old at the time of release. + +Documentation +------------- + +Read the [project documentation](https://sap.github.io/hybris-commerce-eclipse-plugin/) +for user guides, troubleshooting, and developer documentation. The documentation sources are maintained in this README and [docs/](docs/). Contributing & Code of Conduct -------------- @@ -39,7 +46,11 @@ Download & Installation ---------- This GitHub repository is for managing the source code of the plugin. -To install the plugin visit the [Eclipse Marketplace](https://marketplace.eclipse.org/content/sap-hybris-commerce-development-tools-eclipse) and for up to date documentation, the Application Lifecycle Framework for Commerce: [SAP Commerce development tools for Eclipse](https://wiki.hybris.com/display/hybrisALF/SAP+Hybris+Commerce+development+tools+for+Eclipse). +To install the plugin visit the [Eclipse Marketplace](https://marketplace.eclipse.org/content/sap-hybris-commerce-development-tools-eclipse). +Alternatively, add `https://sap.github.io/hybris-commerce-eclipse-plugin/updates/latest/` +in Eclipse under **Help → Install New Software…**. See the [installation guide](docs/installation.md) +for details and the hosted release policy. +For usage and development guidance, see the [project documentation](https://sap.github.io/hybris-commerce-eclipse-plugin/). Compile and Install From Source ------------------------------- @@ -60,4 +71,3 @@ Deprecated Features ------------------- Some features have been already deprecated as there are currently supported by Eclipse functionality, little usage, or just no time to maintenance. More details can be found on [Deprecation List](docs/deprecation/deprecation.md) page. - diff --git a/REUSE.toml b/REUSE.toml index 20b1e1ae..ab2f28d4 100644 --- a/REUSE.toml +++ b/REUSE.toml @@ -119,7 +119,7 @@ SPDX-FileCopyrightText = "2006 SAP SE or an SAP affiliate company and *Eclipse P SPDX-License-Identifier = "Apache-2.0" [[annotations]] -path = ["docs/**", ".github/**", "com.hybris.hyeclipse.site/**", ".gitignore", ".project", ".settings/**", ".travis", "CHANGELOG.md", "CODE_OF_CONDUCT.md", "README.md", "docs.code-workspace", "pom.xml", "CONTRIBUTING.md", "CONTRIBUTING_USING_GENAI.md", "REUSE.toml", ".travis.yml"] +path = ["docs/**", ".github/**", "com.hybris.hyeclipse.site/**", ".gitignore", ".project", ".settings/**", ".travis", "CHANGELOG.md", "CODE_OF_CONDUCT.md", "README.md", "docs.code-workspace", "pom.xml", "CONTRIBUTING.md", "CONTRIBUTING_USING_GENAI.md", "REUSE.toml", ".travis.yml", "mkdocs.yml"] precedence = "aggregate" SPDX-FileCopyrightText = "2006 SAP SE or an SAP affiliate company and *Eclipse Plugin for SAP Commerce* contributors" SPDX-License-Identifier = "Apache-2.0" diff --git a/com.hybris.hyeclipse.commons/src/com/hybris/hyeclipse/commons/typesystem/GeneratedModelScanner.java b/com.hybris.hyeclipse.commons/src/com/hybris/hyeclipse/commons/typesystem/GeneratedModelScanner.java index cd238569..63b4eb46 100644 --- a/com.hybris.hyeclipse.commons/src/com/hybris/hyeclipse/commons/typesystem/GeneratedModelScanner.java +++ b/com.hybris.hyeclipse.commons/src/com/hybris/hyeclipse/commons/typesystem/GeneratedModelScanner.java @@ -90,8 +90,7 @@ public TypeSystemSnapshot scan(final IProject platform, final IProgressMonitor m final Map models = new TreeMap<>(); folder.accept(resource -> { checkCanceled(monitor); - if (resource instanceof IFile && "java".equals(resource.getFileExtension())) { - final IFile file = (IFile) resource; + if (resource instanceof IFile file && "java".equals(resource.getFileExtension())) { try (final InputStream input = file.getContents(true)) { addSource(file.getFullPath().toPortableString(), new String(input.readAllBytes(), Charset.forName(file.getCharset())), models, monitor); @@ -137,8 +136,8 @@ private static void addSource(final String path, final String source, final Map< } } for (final Object declaration : unit.types()) { - if (declaration instanceof TypeDeclaration) { - addDeclaration((TypeDeclaration) declaration, unit, path, models); + if (declaration instanceof TypeDeclaration typeDeclaration) { + addDeclaration(typeDeclaration, unit, path, models); } } } @@ -247,8 +246,7 @@ private static YAttributeDescriptor descriptor(final String name, final String t private static void addAccessor(final List modifiers, final String javaType, final boolean getter, final int line, final List accessors) { for (final Object modifier : modifiers) { - if (modifier instanceof NormalAnnotation) { - final NormalAnnotation annotation = (NormalAnnotation) modifier; + if (modifier instanceof NormalAnnotation annotation) { for (final Object value : annotation.values()) { final MemberValuePair pair = (MemberValuePair) value; if (TypeSystemConstants.QUALIFIER_MEMBER.equals(pair.getName().getIdentifier())) { @@ -404,7 +402,7 @@ private SourceModel(final TypeDeclaration declaration, final CompilationUnit uni && !"void".equals(method.getReturnType2().toString()); if (getter || method.parameters().size() == 1) { final String javaType = getter ? method.getReturnType2().toString() - : ((SingleVariableDeclaration) method.parameters().get(0)).getType().toString(); + : ((SingleVariableDeclaration) method.parameters().getFirst()).getType().toString(); addAccessor(method.modifiers(), javaType, getter, unit.getLineNumber(method.getStartPosition()), accessors); } @@ -442,17 +440,16 @@ private ConstantValue(final String literal, final String reference, final List parts = new ArrayList<>(); parts.add(from(infix.getLeftOperand())); diff --git a/com.hybris.hyeclipse.commons/src/com/hybris/hyeclipse/commons/utils/EclipseFileUtils.java b/com.hybris.hyeclipse.commons/src/com/hybris/hyeclipse/commons/utils/EclipseFileUtils.java index b7307175..40d413a2 100644 --- a/com.hybris.hyeclipse.commons/src/com/hybris/hyeclipse/commons/utils/EclipseFileUtils.java +++ b/com.hybris.hyeclipse.commons/src/com/hybris/hyeclipse/commons/utils/EclipseFileUtils.java @@ -69,8 +69,7 @@ public static IFile getActiveEditorFile() { public static IFile getSelectedFile(final ISelection selection) { IFile file = null; - if (selection instanceof IStructuredSelection) { - final IStructuredSelection ssel = (IStructuredSelection) selection; + if (selection instanceof IStructuredSelection ssel) { final Object obj = ssel.getFirstElement(); file = Platform.getAdapterManager().getAdapter(obj, IFile.class); } else if (selection instanceof TextSelection) { @@ -90,8 +89,7 @@ public static IFile getSelectedFile(final ISelection selection) { public static Set getSelectedFiles(final ISelection selection) { final Set files = new HashSet<>(); - if (selection instanceof IStructuredSelection) { - final IStructuredSelection structuredSelection = (IStructuredSelection) selection; + if (selection instanceof IStructuredSelection structuredSelection) { structuredSelection.toList().forEach( file -> files.add(Platform.getAdapterManager().getAdapter(file, IFile.class))); @@ -114,11 +112,10 @@ public static Optional getCurrentTextSelection() { final IEditorPart editorPart = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage() .getActiveEditor(); - if (editorPart instanceof ITextEditor) { - final ITextEditor editor = (ITextEditor) editorPart; + if (editorPart instanceof ITextEditor editor) { final ISelection selection = editor.getSelectionProvider().getSelection(); - if (selection instanceof TextSelection) { - currentTextSelection = Optional.of((TextSelection) selection); + if (selection instanceof TextSelection textSelection) { + currentTextSelection = Optional.of(textSelection); } } diff --git a/com.hybris.hyeclipse.commons/src/com/hybris/hyeclipse/commons/validation/ValidationService.java b/com.hybris.hyeclipse.commons/src/com/hybris/hyeclipse/commons/validation/ValidationService.java index 570a55c2..87f87f74 100644 --- a/com.hybris.hyeclipse.commons/src/com/hybris/hyeclipse/commons/validation/ValidationService.java +++ b/com.hybris.hyeclipse.commons/src/com/hybris/hyeclipse/commons/validation/ValidationService.java @@ -354,8 +354,8 @@ private ValidationResult error(final File file, final Exception failure) { int line = 1; Throwable cause = failure; while (cause != null) { - if (cause instanceof SAXParseException) { - line = ((SAXParseException) cause).getLineNumber(); + if (cause instanceof SAXParseException exception) { + line = exception.getLineNumber(); } cause = cause.getCause(); } diff --git a/com.hybris.hyeclipse.commons/src/com/hybris/hyeclipse/commons/validation/ValidationXml.java b/com.hybris.hyeclipse.commons/src/com/hybris/hyeclipse/commons/validation/ValidationXml.java index 7bf3e845..8985b951 100644 --- a/com.hybris.hyeclipse.commons/src/com/hybris/hyeclipse/commons/validation/ValidationXml.java +++ b/com.hybris.hyeclipse.commons/src/com/hybris/hyeclipse/commons/validation/ValidationXml.java @@ -110,14 +110,14 @@ public void characters(final char[] chars, final int offset, final int length) { */ public static int line(final Node node) { final Object line = node.getUserData(LINE_KEY); - return line instanceof Integer ? ((Integer) line).intValue() : 1; + return line instanceof Integer i ? i.intValue() : 1; } static List children(final Element parent, final String name) { final List result = new ArrayList<>(); for (Node node = parent.getFirstChild(); node != null; node = node.getNextSibling()) { - if (node instanceof Element && name.equals(node.getNodeName())) { - result.add((Element) node); + if (node instanceof Element element && name.equals(node.getNodeName())) { + result.add(element); } } return result; @@ -125,7 +125,7 @@ static List children(final Element parent, final String name) { static Element child(final Element parent, final String name) { final List values = children(parent, name); - return values.isEmpty() ? null : values.get(0); + return values.isEmpty() ? null : values.getFirst(); } static void checkCanceled(final IProgressMonitor monitor) { diff --git a/com.hybris.hyeclipse.emf.beans.editor/src/com/hybris/hyeclipse/emf/beans/presentation/BeansActionBarContributor.java b/com.hybris.hyeclipse.emf.beans.editor/src/com/hybris/hyeclipse/emf/beans/presentation/BeansActionBarContributor.java index 2f4e7cca..d6e281b6 100644 --- a/com.hybris.hyeclipse.emf.beans.editor/src/com/hybris/hyeclipse/emf/beans/presentation/BeansActionBarContributor.java +++ b/com.hybris.hyeclipse.emf.beans.editor/src/com/hybris/hyeclipse/emf/beans/presentation/BeansActionBarContributor.java @@ -109,8 +109,8 @@ public boolean isEnabled() { @Override public void run() { - if (activeEditorPart instanceof IViewerProvider) { - Viewer viewer = ((IViewerProvider)activeEditorPart).getViewer(); + if (activeEditorPart instanceof IViewerProvider provider) { + Viewer viewer = provider.getViewer(); if (viewer != null) { viewer.refresh(); } @@ -272,8 +272,8 @@ public void selectionChanged(SelectionChangedEvent event) { Collection newSiblingDescriptors = null; ISelection selection = event.getSelection(); - if (selection instanceof IStructuredSelection && ((IStructuredSelection)selection).size() == 1) { - Object object = ((IStructuredSelection)selection).getFirstElement(); + if (selection instanceof IStructuredSelection structuredSelection && structuredSelection.size() == 1) { + Object object = structuredSelection.getFirstElement(); EditingDomain domain = ((IEditingDomainProvider)activeEditorPart).getEditingDomain(); @@ -372,8 +372,8 @@ protected void depopulateManager(IContributionManager manager, Collection selectedElements = ((IStructuredSelection)selection).iterator(); + if (currentViewerPane != null && !selection.isEmpty() && selection instanceof IStructuredSelection structuredSelection) { + Iterator selectedElements = structuredSelection.iterator(); if (selectedElements.hasNext()) { // Get the first selected element. // @@ -1564,7 +1564,7 @@ public void doSaveAs() { * @generated */ protected void doSaveAs(URI uri, IEditorInput editorInput) { - (editingDomain.getResourceSet().getResources().get(0)).setURI(uri); + (editingDomain.getResourceSet().getResources().getFirst()).setURI(uri); setInputWithNotify(editorInput); setPartName(editorInput.getName()); IProgressMonitor progressMonitor = @@ -1673,8 +1673,8 @@ public void setStatusLineManager(ISelection selection) { contentOutlineStatusLineManager : getActionBars().getStatusLineManager(); if (statusLineManager != null) { - if (selection instanceof IStructuredSelection) { - Collection collection = ((IStructuredSelection)selection).toList(); + if (selection instanceof IStructuredSelection structuredSelection) { + Collection collection = structuredSelection.toList(); switch (collection.size()) { case 0: { statusLineManager.setMessage(getString("_UI_NoObjectSelected")); diff --git a/com.hybris.hyeclipse.emf.beans.editor/src/com/hybris/hyeclipse/emf/beans/presentation/platformdependent/BeansModelWizard.java b/com.hybris.hyeclipse.emf.beans.editor/src/com/hybris/hyeclipse/emf/beans/presentation/platformdependent/BeansModelWizard.java index aa805c39..d44a1073 100644 --- a/com.hybris.hyeclipse.emf.beans.editor/src/com/hybris/hyeclipse/emf/beans/presentation/platformdependent/BeansModelWizard.java +++ b/com.hybris.hyeclipse.emf.beans.editor/src/com/hybris/hyeclipse/emf/beans/presentation/platformdependent/BeansModelWizard.java @@ -174,8 +174,7 @@ protected Collection getInitialObjectNames() { for (EStructuralFeature eStructuralFeature : ExtendedMetaData.INSTANCE.getAllElements(ExtendedMetaData.INSTANCE.getDocumentRoot(beansPackage))) { if (eStructuralFeature.isChangeable()) { EClassifier eClassifier = eStructuralFeature.getEType(); - if (eClassifier instanceof EClass) { - EClass eClass = (EClass)eClassifier; + if (eClassifier instanceof EClass eClass) { if (!eClass.isAbstract()) { initialObjectNames.add(eStructuralFeature.getName()); } @@ -263,12 +262,12 @@ protected void execute(IProgressMonitor progressMonitor) { IWorkbenchWindow workbenchWindow = workbench.getActiveWorkbenchWindow(); IWorkbenchPage page = workbenchWindow.getActivePage(); final IWorkbenchPart activePart = page.getActivePart(); - if (activePart instanceof ISetSelectionTarget) { + if (activePart instanceof ISetSelectionTarget target) { final ISelection targetSelection = new StructuredSelection(modelFile); getShell().getDisplay().asyncExec (new Runnable() { public void run() { - ((ISetSelectionTarget)activePart).selectReveal(targetSelection); + target.selectReveal(targetSelection); } }); } @@ -361,7 +360,7 @@ public void addPages() { newFileCreationPage = new BeansModelWizardNewFileCreationPage("Whatever", selection); newFileCreationPage.setTitle(BeansEditorPlugin.INSTANCE.getString("_UI_BeansModelWizard_label")); newFileCreationPage.setDescription(BeansEditorPlugin.INSTANCE.getString("_UI_BeansModelWizard_description")); - newFileCreationPage.setFileName(BeansEditorPlugin.INSTANCE.getString("_UI_BeansEditorFilenameDefaultBase") + "." + FILE_EXTENSIONS.get(0)); + newFileCreationPage.setFileName(BeansEditorPlugin.INSTANCE.getString("_UI_BeansEditorFilenameDefaultBase") + "." + FILE_EXTENSIONS.getFirst()); addPage(newFileCreationPage); // Try and get the resource selection to determine a current directory for the file dialog. @@ -370,10 +369,7 @@ public void addPages() { // Get the resource... // Object selectedElement = selection.iterator().next(); - if (selectedElement instanceof IResource) { - // Get the resource parent, if its a file. - // - IResource selectedResource = (IResource)selectedElement; + if (selectedElement instanceof IResource selectedResource) { if (selectedResource.getType() == IResource.FILE) { selectedResource = selectedResource.getParent(); } @@ -388,7 +384,7 @@ public void addPages() { // Make up a unique new name here. // String defaultModelBaseFilename = BeansEditorPlugin.INSTANCE.getString("_UI_BeansEditorFilenameDefaultBase"); - String defaultModelFilenameExtension = FILE_EXTENSIONS.get(0); + String defaultModelFilenameExtension = FILE_EXTENSIONS.getFirst(); String modelFilename = defaultModelBaseFilename + "." + defaultModelFilenameExtension; for (int i = 1; ((IContainer)selectedResource).findMember(modelFilename) != null; ++i) { modelFilename = defaultModelBaseFilename + i + "." + defaultModelFilenameExtension; diff --git a/com.hybris.hyeclipse.emf.beans/src/com/hybris/hyeclipse/emf/beans/impl/BeansPackageImpl.java b/com.hybris.hyeclipse.emf.beans/src/com/hybris/hyeclipse/emf/beans/impl/BeansPackageImpl.java index 78b536a9..29ba3e05 100644 --- a/com.hybris.hyeclipse.emf.beans/src/com/hybris/hyeclipse/emf/beans/impl/BeansPackageImpl.java +++ b/com.hybris.hyeclipse.emf.beans/src/com/hybris/hyeclipse/emf/beans/impl/BeansPackageImpl.java @@ -168,7 +168,7 @@ public EClass getAbstractPojo() { * @generated */ public EAttribute getAbstractPojo_Class() { - return (EAttribute)abstractPojoEClass.getEStructuralFeatures().get(0); + return (EAttribute)abstractPojoEClass.getEStructuralFeatures().getFirst(); } /** @@ -195,7 +195,7 @@ public EClass getAbstractPojos() { * @generated */ public EAttribute getAbstractPojos_Group() { - return (EAttribute)abstractPojosEClass.getEStructuralFeatures().get(0); + return (EAttribute)abstractPojosEClass.getEStructuralFeatures().getFirst(); } /** @@ -231,7 +231,7 @@ public EClass getBean() { * @generated */ public EAttribute getBean_Description() { - return (EAttribute)beanEClass.getEStructuralFeatures().get(0); + return (EAttribute)beanEClass.getEStructuralFeatures().getFirst(); } /** @@ -285,7 +285,7 @@ public EClass getDocumentRoot() { * @generated */ public EAttribute getDocumentRoot_Mixed() { - return (EAttribute)documentRootEClass.getEStructuralFeatures().get(0); + return (EAttribute)documentRootEClass.getEStructuralFeatures().getFirst(); } /** @@ -330,7 +330,7 @@ public EClass getEnum() { * @generated */ public EAttribute getEnum_Description() { - return (EAttribute)enumEClass.getEStructuralFeatures().get(0); + return (EAttribute)enumEClass.getEStructuralFeatures().getFirst(); } /** @@ -366,7 +366,7 @@ public EClass getProperty() { * @generated */ public EAttribute getProperty_Description() { - return (EAttribute)propertyEClass.getEStructuralFeatures().get(0); + return (EAttribute)propertyEClass.getEStructuralFeatures().getFirst(); } /** diff --git a/com.hybris.hyeclipse.emf.beans/src/com/hybris/hyeclipse/emf/beans/util/BeansAdapterFactory.java b/com.hybris.hyeclipse.emf.beans/src/com/hybris/hyeclipse/emf/beans/util/BeansAdapterFactory.java index 252a83a3..e7fec5ec 100644 --- a/com.hybris.hyeclipse.emf.beans/src/com/hybris/hyeclipse/emf/beans/util/BeansAdapterFactory.java +++ b/com.hybris.hyeclipse.emf.beans/src/com/hybris/hyeclipse/emf/beans/util/BeansAdapterFactory.java @@ -79,8 +79,8 @@ public boolean isFactoryForType(Object object) { if (object == modelPackage) { return true; } - if (object instanceof EObject) { - return ((EObject)object).eClass().getEPackage() == modelPackage; + if (object instanceof EObject eObject) { + return eObject.eClass().getEPackage() == modelPackage; } return false; } diff --git a/com.hybris.hyeclipse.extgen/src/com/hybris/hyeclipse/extgen/utils/ExtensionUtils.java b/com.hybris.hyeclipse.extgen/src/com/hybris/hyeclipse/extgen/utils/ExtensionUtils.java index 7689b9f8..baaf1781 100644 --- a/com.hybris.hyeclipse.extgen/src/com/hybris/hyeclipse/extgen/utils/ExtensionUtils.java +++ b/com.hybris.hyeclipse.extgen/src/com/hybris/hyeclipse/extgen/utils/ExtensionUtils.java @@ -18,7 +18,6 @@ import java.io.File; import java.io.IOException; import java.lang.reflect.InvocationTargetException; -import java.nio.file.Paths; import java.util.Arrays; import java.util.HashMap; import java.util.HashSet; @@ -112,7 +111,7 @@ public static void moveExtension(File destination, String extensionName) throws */ public static void importExtension(IProgressMonitor monitor, File source, String extensionName) throws CoreException { IProjectDescription description; - String path = Paths.get(source.getAbsolutePath(), extensionName, Constants.DOT_PROJECT).toAbsolutePath().toString(); + String path = java.nio.file.Path.of(source.getAbsolutePath(), extensionName, Constants.DOT_PROJECT).toAbsolutePath().toString(); description = ResourcesPlugin.getWorkspace().loadProjectDescription(new Path(path)); IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(description.getName()); project.create(description, null); diff --git a/com.hybris.hyeclipse.extgen/src/com/hybris/hyeclipse/extgen/wizards/NewExtensionWizardPage.java b/com.hybris.hyeclipse.extgen/src/com/hybris/hyeclipse/extgen/wizards/NewExtensionWizardPage.java index 14b96002..141eff0b 100644 --- a/com.hybris.hyeclipse.extgen/src/com/hybris/hyeclipse/extgen/wizards/NewExtensionWizardPage.java +++ b/com.hybris.hyeclipse.extgen/src/com/hybris/hyeclipse/extgen/wizards/NewExtensionWizardPage.java @@ -119,7 +119,7 @@ public void setDefaultExtensionLocation(String location) // prefs are automatically flushed during a plugin's "super.stop()". prefs.flush(); } catch (BackingStoreException e) { - Activator.logError("Couldn't save default location for custom extensions", e);; + Activator.logError("Couldn't save default location for custom extensions", e); } } /** diff --git a/com.hybris.hyeclipse.impexed/.project b/com.hybris.hyeclipse.impexed/.project index 53837b85..1670dad2 100644 --- a/com.hybris.hyeclipse.impexed/.project +++ b/com.hybris.hyeclipse.impexed/.project @@ -29,7 +29,6 @@ org.eclipse.m2e.core.maven2Nature org.eclipse.pde.PluginNature - org.eclipse.jdt.core.javanature diff --git a/com.hybris.hyeclipse.impexed/src/com/hybris/impexformatter/DocumentProvider.java b/com.hybris.hyeclipse.impexed/src/com/hybris/impexformatter/DocumentProvider.java index 83cb4615..7a20c02e 100755 --- a/com.hybris.hyeclipse.impexed/src/com/hybris/impexformatter/DocumentProvider.java +++ b/com.hybris.hyeclipse.impexed/src/com/hybris/impexformatter/DocumentProvider.java @@ -33,8 +33,7 @@ protected IDocument createDocument(Object element) throws CoreException { //IDocumentPartitioner partitioner = createDocumentPartitioner(); IDocumentPartitioner partitioner = new ImpexDocumentPartitioner(); - if ((document instanceof IDocumentExtension3)) { - IDocumentExtension3 extension3 = (IDocumentExtension3) document; + if ((document instanceof IDocumentExtension3 extension3)) { extension3.setDocumentPartitioner(Activator.IMPEX_PARTITIONING, partitioner); } else { diff --git a/com.hybris.hyeclipse.impexed/src/com/hybris/impexformatter/actions/Formatter.java b/com.hybris.hyeclipse.impexed/src/com/hybris/impexformatter/actions/Formatter.java index 5343c7eb..841bb789 100755 --- a/com.hybris.hyeclipse.impexed/src/com/hybris/impexformatter/actions/Formatter.java +++ b/com.hybris.hyeclipse.impexed/src/com/hybris/impexformatter/actions/Formatter.java @@ -154,18 +154,18 @@ public static String formatData(BufferedReader reader, StringWriter writer, Stri public static void formatLines(ArrayList columnMaxWidth, StringWriter writer, List dataBlock) throws IOException { - int firstItemLength = dataBlock.get(0).colData.get(0).length(); + int firstItemLength = dataBlock.getFirst().colData.getFirst().length(); for (LineData row : dataBlock) { if (row != null) { String format = FIRST_LFT_FORMATTER + firstItemLength + STR_FORMATTER; // if row starts with ; - if (row.colData.get(0).toString().startsWith(SEMICOLON_MARK)) { + if (row.colData.getFirst().toString().startsWith(SEMICOLON_MARK)) { // remove semicolon from first value - row.colData.set(0, row.colData.get(0).substring(0, row.colData.get(0).length() - 1)); + row.colData.set(0, row.colData.getFirst().substring(0, row.colData.getFirst().length() - 1)); format = PERCENT_MARK + firstItemLength + COL_STR_FORMATTER; } else if (row.numberOfCol > 1) { // if row at the beginning has end of long value - if (row.colData.get(0).toString().endsWith(SEMICOLON_MARK)) { - row.colData.set(0, row.colData.get(0).substring(0, row.colData.get(0).length() - 1)); + if (row.colData.getFirst().toString().endsWith(SEMICOLON_MARK)) { + row.colData.set(0, row.colData.getFirst().substring(0, row.colData.getFirst().length() - 1)); } if (row.longValueColIndex <= 0) { format = FIRST_LFT_FORMATTER + firstItemLength + COL_STR_FORMATTER; diff --git a/com.hybris.hyeclipse.impexed/src/com/hybris/impexformatter/editors/ImpexPageEditor.java b/com.hybris.hyeclipse.impexed/src/com/hybris/impexformatter/editors/ImpexPageEditor.java index 47fdb9f3..a1d18601 100755 --- a/com.hybris.hyeclipse.impexed/src/com/hybris/impexformatter/editors/ImpexPageEditor.java +++ b/com.hybris.hyeclipse.impexed/src/com/hybris/impexformatter/editors/ImpexPageEditor.java @@ -135,8 +135,8 @@ public void run() { } static void formatText(IEditorPart editorPart) { - if(editorPart instanceof ImpexPageEditor) { - String unformattedText = ((ImpexPageEditor)editorPart).editor.getDocumentProvider().getDocument(editorPart.getEditorInput()).get(); + if(editorPart instanceof ImpexPageEditor pageEditor) { + String unformattedText = pageEditor.editor.getDocumentProvider().getDocument(editorPart.getEditorInput()).get(); try (BufferedReader reader = new BufferedReader(new StringReader(unformattedText)); StringWriter writer = new StringWriter()) { @@ -155,7 +155,7 @@ static void formatText(IEditorPart editorPart) { } } - ((ImpexPageEditor)editorPart).editor.getDocumentProvider().getDocument(editorPart.getEditorInput()).set(writer.toString()); + pageEditor.editor.getDocumentProvider().getDocument(editorPart.getEditorInput()).set(writer.toString()); } catch (final IOException e) { diff --git a/com.hybris.hyeclipse.impexed/src/com/hybris/impexformatter/editors/MultiPageEditorContributor.java b/com.hybris.hyeclipse.impexed/src/com/hybris/impexformatter/editors/MultiPageEditorContributor.java index c64b527e..df86659a 100755 --- a/com.hybris.hyeclipse.impexed/src/com/hybris/impexformatter/editors/MultiPageEditorContributor.java +++ b/com.hybris.hyeclipse.impexed/src/com/hybris/impexformatter/editors/MultiPageEditorContributor.java @@ -65,7 +65,7 @@ public void setActivePage(IEditorPart part) { IActionBars actionBars = getActionBars(); if (actionBars != null) { - ITextEditor editor = (part instanceof ITextEditor) ? (ITextEditor) part : null; + ITextEditor editor = (part instanceof ITextEditor ite) ? ite : null; actionBars.setGlobalActionHandler(ActionFactory.DELETE.getId(), getAction(editor, ITextEditorActionConstants.DELETE)); diff --git a/com.hybris.hyeclipse.impexed/src/com/hybris/impexformatter/rules/RuleFactory.java b/com.hybris.hyeclipse.impexed/src/com/hybris/impexformatter/rules/RuleFactory.java index 5fc1c56d..68928595 100755 --- a/com.hybris.hyeclipse.impexed/src/com/hybris/impexformatter/rules/RuleFactory.java +++ b/com.hybris.hyeclipse.impexed/src/com/hybris/impexformatter/rules/RuleFactory.java @@ -22,36 +22,22 @@ public class RuleFactory { - public enum ImpexRules {KEYWORD, VARIABLE, REFERENCE, SEMICOLON, COMMA}; + public enum ImpexRules {KEYWORD, VARIABLE, REFERENCE, SEMICOLON, COMMA} public static WordRule buildRule(ImpexRules ruleType, IToken token) { - WordRule result = null; - switch (ruleType) { - case KEYWORD: - result = buildKeywordRule(token); - break; - case VARIABLE: - result = buildVariableRule('$', token); - break; - case REFERENCE: - result = buildVariableRule('&', token); - break; - case SEMICOLON: - result = buildCharRule(';', token); - break; - case COMMA: - result = buildCharRule(',', token); - break; - default: - result = null; - break; - } - return result; + return switch (ruleType) { + case KEYWORD -> buildKeywordRule(token); + case VARIABLE -> buildVariableRule('$', token); + case REFERENCE -> buildVariableRule('&', token); + case SEMICOLON -> buildCharRule(';', token); + case COMMA -> buildCharRule(',', token); + default -> null; + }; } private static WordRule buildCharRule(final char startChar, IToken token) { if (token == null) {token = Token.UNDEFINED;} - WordRule rule = new WordRule(new IWordDetector() { + return new WordRule(new IWordDetector() { @Override public boolean isWordStart(char c) { @@ -63,12 +49,11 @@ public boolean isWordPart(char c) { return false; } }, token); - return rule; } private static WordRule buildKeywordRule(IToken token) { if (token == null) {token = Token.UNDEFINED;} - WordRule rule = new WordRule(new IWordDetector() { + return new WordRule(new IWordDetector() { public boolean isWordStart(char c) { return Character.isJavaIdentifierStart(c); } @@ -77,12 +62,11 @@ public boolean isWordPart(char c) { return Character.isJavaIdentifierPart(c); } }, token); - return rule; } private static WordRule buildVariableRule(final char startChar, IToken token) { if (token == null) {token = Token.UNDEFINED;} - WordRule rule = new WordRule(new IWordDetector() { + return new WordRule(new IWordDetector() { public boolean isWordStart(char c) { return c == startChar; } @@ -91,6 +75,5 @@ public boolean isWordPart(char c) { return Character.isJavaIdentifierPart(c); } }, token); - return rule; } } diff --git a/com.hybris.hyeclipse.impexed/src/com/hybris/impexformatter/wizards/NewImpexWizardPage.java b/com.hybris.hyeclipse.impexed/src/com/hybris/impexformatter/wizards/NewImpexWizardPage.java index 7cdf13c7..11e4af58 100755 --- a/com.hybris.hyeclipse.impexed/src/com/hybris/impexformatter/wizards/NewImpexWizardPage.java +++ b/com.hybris.hyeclipse.impexed/src/com/hybris/impexformatter/wizards/NewImpexWizardPage.java @@ -97,21 +97,19 @@ public void modifyText(ModifyEvent e) { } private void initialize() { - if (selection != null && selection.isEmpty() == false && selection instanceof IStructuredSelection) { - IStructuredSelection ssel = (IStructuredSelection) selection; + if (selection != null && selection.isEmpty() == false && selection instanceof IStructuredSelection ssel) { if (ssel.size() > 1) return; Object obj = ssel.getFirstElement(); if (obj instanceof IResource) { IContainer container; - if (obj instanceof IContainer) - container = (IContainer) obj; + if (obj instanceof IContainer iContainer) + container = iContainer; else container = ((IResource) obj).getParent(); containerText.setText(container.getFullPath().toString()); } - else if (ssel instanceof TreeSelection) { - TreeSelection treeSelection = (TreeSelection) ssel; + else if (ssel instanceof TreeSelection treeSelection) { TreePath[] treePaths = treeSelection.getPaths(); TreePath treePath = treePaths[0]; Object lastSegmentObj = treePath.getLastSegment(); diff --git a/com.hybris.hyeclipse.importer/plugin.xml b/com.hybris.hyeclipse.importer/plugin.xml index b129cd56..ffd4398d 100755 --- a/com.hybris.hyeclipse.importer/plugin.xml +++ b/com.hybris.hyeclipse.importer/plugin.xml @@ -201,6 +201,11 @@ id="com.hybris.yps.hyeclipse.handlers.help.OpenSAPDownloadCenterHandler" name="openDownloadCenterHandler"> + + + + - - - - - - - - - - - - - - diff --git a/com.hybris.hyeclipse.importer/src/com/hybris/yps/hyeclipse/ExtensionPropertyTester.java b/com.hybris.hyeclipse.importer/src/com/hybris/yps/hyeclipse/ExtensionPropertyTester.java index 422818c5..b3c26ac8 100644 --- a/com.hybris.hyeclipse.importer/src/com/hybris/yps/hyeclipse/ExtensionPropertyTester.java +++ b/com.hybris.hyeclipse.importer/src/com/hybris/yps/hyeclipse/ExtensionPropertyTester.java @@ -43,11 +43,11 @@ private boolean testExtension(Object receiver) { if (receiver instanceof List) { @SuppressWarnings("unchecked") List list = (List) receiver; - if (list.size() == 1 && list.get(0) instanceof IProject) { - final IProject project = (IProject) list.get(0); + if (list.size() == 1 && list.getFirst() instanceof IProject) { + final IProject project = (IProject) list.getFirst(); return project.exists(); - } else if (list.size() == 1 && list.get(0) instanceof IJavaProject) { - final IJavaProject project = (IJavaProject) list.get(0); + } else if (list.size() == 1 && list.getFirst() instanceof IJavaProject) { + final IJavaProject project = (IJavaProject) list.getFirst(); return project.exists(); } } diff --git a/com.hybris.hyeclipse.importer/src/com/hybris/yps/hyeclipse/extensionmods/ExtensionLabelProvider.java b/com.hybris.hyeclipse.importer/src/com/hybris/yps/hyeclipse/extensionmods/ExtensionLabelProvider.java index 1ed1ec32..092d8d5b 100644 --- a/com.hybris.hyeclipse.importer/src/com/hybris/yps/hyeclipse/extensionmods/ExtensionLabelProvider.java +++ b/com.hybris.hyeclipse.importer/src/com/hybris/yps/hyeclipse/extensionmods/ExtensionLabelProvider.java @@ -67,18 +67,13 @@ private Image getImage(boolean isSelected) { @Override public Image getColumnImage(Object element, int columnIndex) { ExtensionHolder extension = (ExtensionHolder) element; - switch (columnIndex) { - case 0: // NAME_COLUMN - return null; - case 1 : - return getImage(extension.isCoreModule()); - case 2 : - return getImage(extension.isWebModule()); - case 3 : - return getImage(extension.isHmcModule()); - default : - return null; - } + return switch (columnIndex) { + case 0 -> null; + case 1 -> getImage(extension.isCoreModule()); + case 2 -> getImage(extension.isWebModule()); + case 3 -> getImage(extension.isHmcModule()); + default -> null; + }; } diff --git a/com.hybris.hyeclipse.importer/src/com/hybris/yps/hyeclipse/handlers/ExtensionBuildHandler.java b/com.hybris.hyeclipse.importer/src/com/hybris/yps/hyeclipse/handlers/ExtensionBuildHandler.java index 9b502ec0..b07ef197 100644 --- a/com.hybris.hyeclipse.importer/src/com/hybris/yps/hyeclipse/handlers/ExtensionBuildHandler.java +++ b/com.hybris.hyeclipse.importer/src/com/hybris/yps/hyeclipse/handlers/ExtensionBuildHandler.java @@ -42,7 +42,7 @@ public class ExtensionBuildHandler extends AbstractHandler { @Override public Object execute(ExecutionEvent event) throws ExecutionException { project = getSelectedExtension(HandlerUtil.getCurrentSelection(event)); - Job job = new Job(" Build") { + Job job = new Job("Build") { @Override protected IStatus run(IProgressMonitor monitor) { try { @@ -77,8 +77,8 @@ private IProject getSelectedExtension(ISelection selection) { return null; IStructuredSelection structuredSelection = (IStructuredSelection) selection; Object element = structuredSelection.getFirstElement(); - if (element instanceof IProject) - return (IProject) element; + if (element instanceof IProject iProject) + return iProject; if (!(element instanceof IAdaptable)) return null; IAdaptable adaptable = (IAdaptable) element; diff --git a/com.hybris.hyeclipse.importer/src/com/hybris/yps/hyeclipse/handlers/ExtensionCleanBuildHandler.java b/com.hybris.hyeclipse.importer/src/com/hybris/yps/hyeclipse/handlers/ExtensionCleanBuildHandler.java index bf142e26..d304cc5f 100644 --- a/com.hybris.hyeclipse.importer/src/com/hybris/yps/hyeclipse/handlers/ExtensionCleanBuildHandler.java +++ b/com.hybris.hyeclipse.importer/src/com/hybris/yps/hyeclipse/handlers/ExtensionCleanBuildHandler.java @@ -77,8 +77,8 @@ private IProject getSelectedExtension(ISelection selection) { return null; IStructuredSelection structuredSelection = (IStructuredSelection) selection; Object element = structuredSelection.getFirstElement(); - if (element instanceof IProject) - return (IProject) element; + if (element instanceof IProject iProject) + return iProject; if (!(element instanceof IAdaptable)) return null; IAdaptable adaptable = (IAdaptable) element; diff --git a/com.hybris.hyeclipse.importer/src/com/hybris/yps/hyeclipse/handlers/help/OpenESAHandler.java b/com.hybris.hyeclipse.importer/src/com/hybris/yps/hyeclipse/handlers/help/OpenESAHandler.java index 9bb9b3a0..6cfa6ef6 100644 --- a/com.hybris.hyeclipse.importer/src/com/hybris/yps/hyeclipse/handlers/help/OpenESAHandler.java +++ b/com.hybris.hyeclipse.importer/src/com/hybris/yps/hyeclipse/handlers/help/OpenESAHandler.java @@ -20,7 +20,7 @@ public class OpenESAHandler extends AbstractOpenInExternalBrowserHandler { @Override protected String getURL() { - return "https://support.sap.com/en/offerings-programs/enterprise-support/enterprise-support-academy.html?anchorId=section_1490173645_c"; + return "https://support.sap.com/en/offerings-programs/enterprise-support/enterprise-support-academy.html?anchorId=section_1490173645_c&refId=eclipse-sap-commerce-plugin"; } } diff --git a/com.hybris.hyeclipse.importer/src/com/hybris/yps/hyeclipse/handlers/help/OpenExpertsForumHandler.java b/com.hybris.hyeclipse.importer/src/com/hybris/yps/hyeclipse/handlers/help/OpenExpertsForumHandler.java index 4048fd0a..b2c2efac 100644 --- a/com.hybris.hyeclipse.importer/src/com/hybris/yps/hyeclipse/handlers/help/OpenExpertsForumHandler.java +++ b/com.hybris.hyeclipse.importer/src/com/hybris/yps/hyeclipse/handlers/help/OpenExpertsForumHandler.java @@ -20,7 +20,7 @@ public class OpenExpertsForumHandler extends AbstractOpenInExternalBrowserHandle @Override protected String getURL() { - return "https://community.sap.com/topics/commerce-cloud"; + return "https://community.sap.com/topics/commerce-cloud?refId=eclipse-sap-commerce-plugin"; } } diff --git a/com.hybris.hyeclipse.importer/src/com/hybris/yps/hyeclipse/handlers/help/OpenHelpDotComHandler.java b/com.hybris.hyeclipse.importer/src/com/hybris/yps/hyeclipse/handlers/help/OpenHelpDotComHandler.java index f77621ef..051a3af5 100644 --- a/com.hybris.hyeclipse.importer/src/com/hybris/yps/hyeclipse/handlers/help/OpenHelpDotComHandler.java +++ b/com.hybris.hyeclipse.importer/src/com/hybris/yps/hyeclipse/handlers/help/OpenHelpDotComHandler.java @@ -20,7 +20,7 @@ public class OpenHelpDotComHandler extends AbstractOpenInExternalBrowserHandler @Override protected String getURL() { - return "https://help.sap.com/viewer/product/SAP_COMMERCE_CLOUD/SHIP/en-US"; + return "https://help.sap.com/docs/SAP_COMMERCE_CLOUD_PUBLIC_CLOUD?refId=eclipse-sap-commerce-plugin"; } } diff --git a/com.hybris.hyeclipse.importer/src/com/hybris/yps/hyeclipse/handlers/help/OpenSAPCommunityCommHandler.java b/com.hybris.hyeclipse.importer/src/com/hybris/yps/hyeclipse/handlers/help/OpenSAPCommunityCommHandler.java new file mode 100644 index 00000000..0fe06fac --- /dev/null +++ b/com.hybris.hyeclipse.importer/src/com/hybris/yps/hyeclipse/handlers/help/OpenSAPCommunityCommHandler.java @@ -0,0 +1,26 @@ +/******************************************************************************* + * Copyright 2020 SAP + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy + * of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + ******************************************************************************/ +package com.hybris.yps.hyeclipse.handlers.help; + +public class OpenSAPCommunityCommHandler extends AbstractOpenInExternalBrowserHandler { + + + @Override + protected String getURL() { + return "https://community.sap.com/t5/c-khhcw49343/SAP+Commerce+Cloud/pd-p/73555000100800001224?refId=eclipse-sap-commerce-plugin"; + } + +} \ No newline at end of file diff --git a/com.hybris.hyeclipse.importer/src/com/hybris/yps/hyeclipse/handlers/help/OpenSAPDownloadCenterHandler.java b/com.hybris.hyeclipse.importer/src/com/hybris/yps/hyeclipse/handlers/help/OpenSAPDownloadCenterHandler.java index 55dcfd81..c2351b73 100644 --- a/com.hybris.hyeclipse.importer/src/com/hybris/yps/hyeclipse/handlers/help/OpenSAPDownloadCenterHandler.java +++ b/com.hybris.hyeclipse.importer/src/com/hybris/yps/hyeclipse/handlers/help/OpenSAPDownloadCenterHandler.java @@ -20,7 +20,7 @@ public class OpenSAPDownloadCenterHandler extends AbstractOpenInExternalBrowserH @Override protected String getURL() { - return "https://support.sap.com/swdc"; + return "https://support.sap.com/swdc?refId=eclipse-sap-commerce-plugin"; } } diff --git a/com.hybris.hyeclipse.importer/src/com/hybris/yps/hyeclipse/preferences/AntJavaRuntime.java b/com.hybris.hyeclipse.importer/src/com/hybris/yps/hyeclipse/preferences/AntJavaRuntime.java index a7957df0..5f87b94f 100644 --- a/com.hybris.hyeclipse.importer/src/com/hybris/yps/hyeclipse/preferences/AntJavaRuntime.java +++ b/com.hybris.hyeclipse.importer/src/com/hybris/yps/hyeclipse/preferences/AntJavaRuntime.java @@ -64,8 +64,8 @@ public static String[][] getJdkChoices() { for (final IVMInstall vm : installations) { final String id = JavaRuntime.getCompositeIdFromVM(vm); String version = StringUtils.EMPTY; - if (vm instanceof IVMInstall2) { - version = ((IVMInstall2) vm).getJavaVersion(); + if (vm instanceof IVMInstall2 install2) { + version = install2.getJavaVersion(); } final String label = vm.getName() + (StringUtils.isNotBlank(version) ? " - " + version : StringUtils.EMPTY) + " (" + vm.getInstallLocation().getAbsolutePath() + ")"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ diff --git a/com.hybris.hyeclipse.importer/src/com/hybris/yps/hyeclipse/utils/AntImporter.java b/com.hybris.hyeclipse.importer/src/com/hybris/yps/hyeclipse/utils/AntImporter.java index 05a3e759..cd28ac59 100644 --- a/com.hybris.hyeclipse.importer/src/com/hybris/yps/hyeclipse/utils/AntImporter.java +++ b/com.hybris.hyeclipse.importer/src/com/hybris/yps/hyeclipse/utils/AntImporter.java @@ -2,7 +2,6 @@ import java.io.File; import java.nio.file.Path; -import java.nio.file.Paths; import org.apache.tools.ant.BuildEvent; import org.apache.tools.ant.BuildException; @@ -138,7 +137,7 @@ public boolean executeAntTask(String buildXmlFileFullPath) { project.setBasedir(buildXmlFileFullPath); project.setNewProperty("PLATFORM_HOME", buildXmlFileFullPath); project.setJavaVersionProperty(); - Path buildPath = Paths.get(buildXmlFileFullPath, "build.xml"); + Path buildPath = Path.of(buildXmlFileFullPath, "build.xml"); File buildFile = buildPath.toFile(); diff --git a/com.hybris.hyeclipse.importer/src/com/hybris/yps/hyeclipse/utils/FixProjectsUtils.java b/com.hybris.hyeclipse.importer/src/com/hybris/yps/hyeclipse/utils/FixProjectsUtils.java index 174a4dc4..6a90c991 100755 --- a/com.hybris.hyeclipse.importer/src/com/hybris/yps/hyeclipse/utils/FixProjectsUtils.java +++ b/com.hybris.hyeclipse.importer/src/com/hybris/yps/hyeclipse/utils/FixProjectsUtils.java @@ -19,7 +19,6 @@ import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; -import java.nio.file.Paths; import java.nio.file.StandardCopyOption; import java.util.Arrays; import java.util.HashSet; @@ -91,8 +90,8 @@ public static Set getProjectsNotInLocalExtensionsFile() { boolean found = false; for (ExtensionHolder ext : exts) { - Path projectLocation = Paths.get(project.getLocation().toFile().getAbsolutePath()); - Path extLocation = Paths.get(ext.getPath()); + Path projectLocation = Path.of(project.getLocation().toFile().getAbsolutePath()); + Path extLocation = Path.of(ext.getPath()); try { if (Files.isSameFile(projectLocation, extLocation) || (project.getName().equals(Constants.PLATFROM) || (project.getName().equals(CONFIG_DIR)))) { @@ -128,8 +127,8 @@ public static Set getExtensionsNotInWorkspace(String platformHo boolean found = false; for (IProject project : allHybrisProjects) { - Path projectLocation = Paths.get(project.getLocation().toFile().getAbsolutePath()); - Path extLocation = Paths.get(ext.getPath()); + Path projectLocation = Path.of(project.getLocation().toFile().getAbsolutePath()); + Path extLocation = Path.of(ext.getPath()); try { if (Files.isSameFile(projectLocation, extLocation)) { // Match in workspace and localextensions.xml: between extension & project @@ -199,7 +198,7 @@ public static boolean isAHybrisExtension(IProject project) { return true; } else { - return Files.exists(Paths.get(project.getLocation().toFile().getAbsolutePath(), Constants.EXTENSION_INFO_XML)); + return Files.exists(Path.of(project.getLocation().toFile().getAbsolutePath(), Constants.EXTENSION_INFO_XML)); } } @@ -336,19 +335,12 @@ public static void removeFromClassPath(IResource res, IJavaProject javaProject, public static void addToClassPath(IResource res, int type, IJavaProject javaProject, IProgressMonitor monitor) throws JavaModelException { Set entries = new HashSet<>(Arrays.asList(javaProject.getRawClasspath())); - IClasspathEntry entry = null; - switch (type) { - case IClasspathEntry.CPE_LIBRARY: - entry = JavaCore.newLibraryEntry(res.getFullPath(), null, null, true); - break; - case IClasspathEntry.CPE_PROJECT: - entry = JavaCore.newProjectEntry(res.getFullPath(), true); - break; + IClasspathEntry entry = switch (type) { + case IClasspathEntry.CPE_LIBRARY: yield JavaCore.newLibraryEntry(res.getFullPath(), null, null, true); + case IClasspathEntry.CPE_PROJECT: yield JavaCore.newProjectEntry(res.getFullPath(), true); case IClasspathEntry.CPE_SOURCE: - default: - entry = JavaCore.newSourceEntry(res.getFullPath()); - break; - } + default: yield JavaCore.newSourceEntry(res.getFullPath()); + }; entries.add(entry); setClasspath(entries.toArray(new IClasspathEntry[entries.size()]), javaProject, monitor); @@ -362,7 +354,7 @@ public static void setClasspath(IClasspathEntry[] classpath, IJavaProject javaPr { File classPathFile = javaProject.getProject().getFile(".classpath").getLocation().toFile(); try { - Files.copy(Paths.get(classPathFile.getAbsolutePath()), Paths.get(classPathFileBak.getAbsolutePath()), StandardCopyOption.REPLACE_EXISTING); + Files.copy(Path.of(classPathFile.getAbsolutePath()), Path.of(classPathFileBak.getAbsolutePath()), StandardCopyOption.REPLACE_EXISTING); } catch (IOException e) { // can't back up file but we should continue anyway diff --git a/com.hybris.hyeclipse.importer/src/com/hybris/yps/hyeclipse/utils/Importer.java b/com.hybris.hyeclipse.importer/src/com/hybris/yps/hyeclipse/utils/Importer.java index 944b5c4b..2fab27c7 100755 --- a/com.hybris.hyeclipse.importer/src/com/hybris/yps/hyeclipse/utils/Importer.java +++ b/com.hybris.hyeclipse.importer/src/com/hybris/yps/hyeclipse/utils/Importer.java @@ -21,7 +21,6 @@ import java.io.IOException; import java.io.InputStream; import java.nio.file.Files; -import java.nio.file.Paths; import java.text.MessageFormat; import java.util.ArrayList; import java.util.Arrays; @@ -438,7 +437,7 @@ private void fixSpringBeans(final IProgressMonitor monitor) { // We don't care about the existing one. Just overwrite it // bluntly - try (FileWriter fw = new FileWriter(springBeansFileNew);) { + try (FileWriter fw = new FileWriter(springBeansFileNew)) { fw.write("\n"); fw.write("\n"); fw.write("\t1\n"); @@ -812,7 +811,7 @@ private void fixModules(final IProgressMonitor monitor, final ExtensionHolder ex } // remove broken wst settings file if (BROKEN_WST_SETTINGS_FILE_EXT.equals(extension.getName())) { - final java.nio.file.Path brokenConfig = Paths.get(extension.getPath(), BROKEN_WST_SETTINGS_FILE); + final java.nio.file.Path brokenConfig = java.nio.file.Path.of(extension.getPath(), BROKEN_WST_SETTINGS_FILE); if (Files.exists(brokenConfig)) { try { Files.delete(brokenConfig); diff --git a/com.hybris.hyeclipse.importer/src/com/hybris/yps/hyeclipse/utils/ProjectJavaRuntime.java b/com.hybris.hyeclipse.importer/src/com/hybris/yps/hyeclipse/utils/ProjectJavaRuntime.java index 80f721c2..53aeb577 100644 --- a/com.hybris.hyeclipse.importer/src/com/hybris/yps/hyeclipse/utils/ProjectJavaRuntime.java +++ b/com.hybris.hyeclipse.importer/src/com/hybris/yps/hyeclipse/utils/ProjectJavaRuntime.java @@ -109,7 +109,7 @@ public void close() { */ public static String compilerCompliance(final IVMInstall vm) throws IOException { final File home = AntJavaRuntime.getJavaHome(vm); - String version = vm instanceof IVMInstall2 ? ((IVMInstall2) vm).getJavaVersion() : null; + String version = vm instanceof IVMInstall2 ivmi ? ivmi.getJavaVersion() : null; if (StringUtils.isBlank(version)) { // Some VM types do not expose a version, but JDK installations provide it in their release metadata. final Properties release = new Properties(); diff --git a/com.hybris.hyeclipse.importer/src/com/hybris/yps/hyeclipse/utils/ShellImporter.java b/com.hybris.hyeclipse.importer/src/com/hybris/yps/hyeclipse/utils/ShellImporter.java index 512c6866..9d714ab4 100644 --- a/com.hybris.hyeclipse.importer/src/com/hybris/yps/hyeclipse/utils/ShellImporter.java +++ b/com.hybris.hyeclipse.importer/src/com/hybris/yps/hyeclipse/utils/ShellImporter.java @@ -166,8 +166,8 @@ private MessageConsole findConsole(String name) { IConsole[] existing = conMan.getConsoles(); MessageConsole myConsole = null; for (int i = 0; i < existing.length; i++) { - if (name.equals(existing[i].getName()) && existing[i] instanceof MessageConsole) { - myConsole = (MessageConsole) existing[i]; + if (name.equals(existing[i].getName()) && existing[i] instanceof MessageConsole console) { + myConsole = console; break; } } diff --git a/com.hybris.hyeclipse.importer/src/com/hybris/yps/hyeclipse/utils/SkipJarScanningUtils.java b/com.hybris.hyeclipse.importer/src/com/hybris/yps/hyeclipse/utils/SkipJarScanningUtils.java index 310f05fe..c8c27efc 100644 --- a/com.hybris.hyeclipse.importer/src/com/hybris/yps/hyeclipse/utils/SkipJarScanningUtils.java +++ b/com.hybris.hyeclipse.importer/src/com/hybris/yps/hyeclipse/utils/SkipJarScanningUtils.java @@ -20,7 +20,6 @@ import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.Path; -import java.nio.file.Paths; import java.util.ArrayList; import java.util.Collections; import java.util.HashSet; @@ -69,7 +68,7 @@ private SkipJarScanningUtils() { public static void skipJarScanning(File platformHome) { - Path catalinaPropPath = Paths.get(platformHome.getAbsolutePath(), "..", "..", "config", "tomcat", "conf", "catalina.properties"); + Path catalinaPropPath = Path.of(platformHome.getAbsolutePath(), "..", "..", "config", "tomcat", "conf", "catalina.properties"); File catalinaFile = catalinaPropPath.toFile(); List jarNameList = new ArrayList<>(); @@ -91,7 +90,7 @@ public static void skipJarScanning(File platformHome) { } sb.append(System.lineSeparator()).append(System.lineSeparator()); - String content = new String(Files.readAllBytes(Paths.get(catalinaFile.getAbsolutePath()))); + String content = new String(Files.readAllBytes(Path.of(catalinaFile.getAbsolutePath()))); Pattern regex = Pattern.compile(REGEX_TO_REPLACE, Pattern.DOTALL); Matcher regexMatcher = regex.matcher(content); @@ -111,7 +110,7 @@ private static void skipJarsByExtension(List jarNames, File extDir) { try { for (String dirToCheck : dirsToCheck) { - File libDir = Paths.get(extDir.getAbsolutePath(), dirToCheck).toFile(); + File libDir = Path.of(extDir.getAbsolutePath(), dirToCheck).toFile(); includeJarToSkip(jarNames, libDir); } } catch (Exception e) { diff --git a/com.hybris.hyeclipse.junit/src/com/hybris/hyeclipse/junit/HybrisJUnitIntegrationTestLoader.java b/com.hybris.hyeclipse.junit/src/com/hybris/hyeclipse/junit/HybrisJUnitIntegrationTestLoader.java index 47ab6b06..3717ba16 100644 --- a/com.hybris.hyeclipse.junit/src/com/hybris/hyeclipse/junit/HybrisJUnitIntegrationTestLoader.java +++ b/com.hybris.hyeclipse.junit/src/com/hybris/hyeclipse/junit/HybrisJUnitIntegrationTestLoader.java @@ -58,7 +58,7 @@ private Description getRootDescription(Runner runner, DescriptionMatcher matcher List children= current.getChildren(); if (children.size() != 1 || matcher.matches(current)) return current; - current= children.get(0); + current= children.getFirst(); } } @@ -112,7 +112,6 @@ private boolean isJUnit3SetUpTest(Class clazz, String testName) { if (setup.getReturnType() == Test.class && Modifier.isPublic(modifiers) && Modifier.isStatic(modifiers)) return true; } catch (SecurityException | NoSuchMethodException e1) { - ; } return false; } diff --git a/com.hybris.hyeclipse.tests/src/com/hybris/hyeclipse/tests/UseMultiThreadUtilsTest.java b/com.hybris.hyeclipse.tests/src/com/hybris/hyeclipse/tests/UseMultiThreadUtilsTest.java index 974711a3..e0cb013c 100644 --- a/com.hybris.hyeclipse.tests/src/com/hybris/hyeclipse/tests/UseMultiThreadUtilsTest.java +++ b/com.hybris.hyeclipse.tests/src/com/hybris/hyeclipse/tests/UseMultiThreadUtilsTest.java @@ -18,7 +18,6 @@ import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; -import java.nio.file.Paths; import java.nio.file.StandardCopyOption; import java.util.UUID; @@ -48,11 +47,11 @@ public class UseMultiThreadUtilsTest { @Before public void before() throws IOException { - Path cp = java.nio.file.Paths.get("").toAbsolutePath(); + Path cp = Path.of("").toAbsolutePath(); Path serverxml = cp.resolve(SERVER_XML_PATH); UUID value = UUID.randomUUID(); String copyTo = SERVER_XML_PATH.concat(value.toString()); - copyxml = Paths.get(copyTo); + copyxml = Path.of(copyTo); Files.copy(serverxml, copyxml, StandardCopyOption.REPLACE_EXISTING); } @@ -60,7 +59,7 @@ public void before() throws IOException { @Test public void testUseMultiThread() throws ParserConfigurationException, SAXException, IOException { - Path cp = java.nio.file.Paths.get("").toAbsolutePath(); + Path cp = Path.of("").toAbsolutePath(); Path yplatform = cp.resolve(RESOURCES_BIN_PLATFORM); Path serverxml = cp.resolve(SERVER_XML_PATH); @@ -84,7 +83,7 @@ public void testUseMultiThread() throws ParserConfigurationException, SAXExcepti @After public void tearDown() throws IOException { // copy back original file - Path cp = java.nio.file.Paths.get("").toAbsolutePath(); + Path cp = Path.of("").toAbsolutePath(); Path serverxml = cp.resolve(SERVER_XML_PATH); Files.copy(copyxml, serverxml, StandardCopyOption.REPLACE_EXISTING); Assert.assertEquals(Files.readAllLines(copyxml), Files.readAllLines(serverxml)); diff --git a/com.hybris.hyeclipse.tests/src/com/hybris/yps/hyeclipse/config/SystemConfigRepositoryTest.java b/com.hybris.hyeclipse.tests/src/com/hybris/yps/hyeclipse/config/SystemConfigRepositoryTest.java index fb86eba1..610fd067 100644 --- a/com.hybris.hyeclipse.tests/src/com/hybris/yps/hyeclipse/config/SystemConfigRepositoryTest.java +++ b/com.hybris.hyeclipse.tests/src/com/hybris/yps/hyeclipse/config/SystemConfigRepositoryTest.java @@ -19,7 +19,6 @@ import java.io.ByteArrayOutputStream; import java.io.File; import java.io.IOException; -import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.util.Arrays; import java.util.Properties; @@ -104,7 +103,7 @@ public void rejectsCorruptSnapshotsAndCanRecoverThroughImport() throws Exception final File[] files = new File(state, "system-configs").listFiles(); Assert.assertNotNull(files); Assert.assertEquals(1, files.length); - Files.writeString(files[0].toPath(), "not XML", StandardCharsets.UTF_8); + Files.writeString(files[0].toPath(), "not XML"); final SystemConfigRepository reopened = new SystemConfigRepository(state); Assert.assertThrows(CoreException.class, () -> reopened.find(platform)); reopened.save(config(platform, "2211.1")); diff --git a/com.hybris.hyeclipse.tests/src/com/hybris/yps/hyeclipse/typesystem/GeneratedModelScannerTest.java b/com.hybris.hyeclipse.tests/src/com/hybris/yps/hyeclipse/typesystem/GeneratedModelScannerTest.java index f62e2933..92b02d6a 100644 --- a/com.hybris.hyeclipse.tests/src/com/hybris/yps/hyeclipse/typesystem/GeneratedModelScannerTest.java +++ b/com.hybris.hyeclipse.tests/src/com/hybris/yps/hyeclipse/typesystem/GeneratedModelScannerTest.java @@ -44,15 +44,17 @@ public void extractsCodesInheritedQualifiersAndGetterTypesWithoutLoadingCommerce + "@Accessor(qualifier=CODE) public abstract String getCode(); " + "@Accessor(qualifier=\"ignoredSetter\") public abstract void notAnAccessor();")); sources.put("/platform/bootstrap/gensrc/DealerModel.java", source("DealerModel", "ParentModel", - "public static final String _TYPECODE = (\"Deal\" + \"er\"); " - + "public static final String DEALER = \"dealer\"; public static final String NOISE=\"notAnAttribute\"; " - + "// @Accessor(qualifier=\"comment\")\n" - + "@Accessor(qualifier=DEALER) public abstract void setDealer(Object value); " - + "@Accessor(qualifier=DealerModel.DEALER) public abstract String getDealer(); " - + "@Accessor(qualifier=CODE) public abstract Integer getCode(); " - + "@Accessor(qualifier=\"members\") public abstract java.util.List getMembers(); " - + "@Accessor(qualifier=\"field\") private boolean enabled; " - + "public abstract String getUnannotated();")); + """ + public static final String _TYPECODE = ("Deal" + "er"); \ + public static final String DEALER = "dealer"; public static final String NOISE="notAnAttribute"; \ + // @Accessor(qualifier="comment") + @Accessor(qualifier=DEALER) public abstract void setDealer(Object value); \ + @Accessor(qualifier=DealerModel.DEALER) public abstract String getDealer(); \ + @Accessor(qualifier=CODE) public abstract Integer getCode(); \ + @Accessor(qualifier="members") public abstract java.util.List getMembers(); \ + @Accessor(qualifier="field") private boolean enabled; \ + public abstract String getUnannotated();\ + """)); final TypeSystemSnapshot snapshot = scan(sources); Assert.assertEquals(Arrays.asList("Dealer", "Item", "Parent"), snapshot.getAllTypeNames()); final YType dealer = snapshot.getType("Dealer"); diff --git a/com.hybris.hyeclipse.tests/src/com/hybris/yps/hyeclipse/utils/AntProcessRunnerTest.java b/com.hybris.hyeclipse.tests/src/com/hybris/yps/hyeclipse/utils/AntProcessRunnerTest.java index 101d7e4e..c552abf9 100644 --- a/com.hybris.hyeclipse.tests/src/com/hybris/yps/hyeclipse/utils/AntProcessRunnerTest.java +++ b/com.hybris.hyeclipse.tests/src/com/hybris/yps/hyeclipse/utils/AntProcessRunnerTest.java @@ -64,7 +64,7 @@ public void propagatesNonzeroExitAfterDrainingOutput() throws Exception { Assert.fail("Expected failed Ant status"); } catch (IOException e) { Assert.assertTrue(e.getMessage().contains("7")); - Assert.assertEquals("failed", errors.get(0)); + Assert.assertEquals("failed", errors.getFirst()); } assertReadersStopped(); } diff --git a/com.hybris.hyeclipse.tests/src/com/hybris/yps/hyeclipse/utils/ShellImporterJavaRuntimeTest.java b/com.hybris.hyeclipse.tests/src/com/hybris/yps/hyeclipse/utils/ShellImporterJavaRuntimeTest.java index e9826892..f26bf98e 100644 --- a/com.hybris.hyeclipse.tests/src/com/hybris/yps/hyeclipse/utils/ShellImporterJavaRuntimeTest.java +++ b/com.hybris.hyeclipse.tests/src/com/hybris/yps/hyeclipse/utils/ShellImporterJavaRuntimeTest.java @@ -17,7 +17,6 @@ import java.io.File; import java.io.IOException; -import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.util.ArrayList; import java.util.Arrays; @@ -131,9 +130,11 @@ public void selectedJdkSurvivesShellStartupAndCommerceEnvironmentChanges() throw executable(new File(oldJava, "java"), "#!/bin/sh\necho wrong-java-17\n"); executable(new File(oldJava, "ant"), "#!/bin/sh\necho \"ant-java-home=$JAVA_HOME\"\njava\n"); Files.writeString(new File(platform, "setantenv.sh").toPath(), - "test \"$JAVA_HOME\" = \"$HYECLIPSE_ANT_JAVA_HOME\" || return 19\n" - + "export JAVA_HOME=/wrong-java-17\nexport PATH=\"$PWD/old-java-bin:$PATH\"\n", - StandardCharsets.UTF_8); + """ + test "$JAVA_HOME" = "$HYECLIPSE_ANT_JAVA_HOME" || return 19 + export JAVA_HOME=/wrong-java-17 + export PATH="$PWD/old-java-bin:$PATH" + """); final ShellImporter importer = new ShellImporter() { @Override String defaultShell() { @@ -175,7 +176,7 @@ private void select(final IVMInstall vm) { } private void executable(final File file, final String contents) throws IOException { - Files.writeString(file.toPath(), contents, StandardCharsets.UTF_8); + Files.writeString(file.toPath(), contents); Assert.assertTrue(file.setExecutable(true)); } } diff --git a/com.hybris.hyeclipse.tests/src/com/hybris/yps/hyeclipse/validation/ValidationServiceTest.java b/com.hybris.hyeclipse.tests/src/com/hybris/yps/hyeclipse/validation/ValidationServiceTest.java index 568fbb67..cf9363eb 100644 --- a/com.hybris.hyeclipse.tests/src/com/hybris/yps/hyeclipse/validation/ValidationServiceTest.java +++ b/com.hybris.hyeclipse.tests/src/com/hybris/yps/hyeclipse/validation/ValidationServiceTest.java @@ -58,9 +58,12 @@ public void adoptsAllNineSourceRules() { @Test public void preservesXPathChecksAndSourceLinesWithoutJaxb() throws Exception { final File file = temporary.newFile("custom-items.xml"); - Files.writeString(file.toPath(), "\n\n" - + "" - + ""); + Files.writeString(file.toPath(), """ + + + \ + \ + """); final List results = service.analyze(file, monitor); Assert.assertEquals(State.FAIL, result(results, "wrong", "TypeNameMustStartWithUppercaseLetter").getState()); Assert.assertEquals(3, result(results, "wrong", "TypeNameMustStartWithUppercaseLetter").getLine()); diff --git a/com.hybris.hyeclipse.tsv.extended/plugin.xml b/com.hybris.hyeclipse.tsv.extended/plugin.xml index 5c323251..d6d62508 100644 --- a/com.hybris.hyeclipse.tsv.extended/plugin.xml +++ b/com.hybris.hyeclipse.tsv.extended/plugin.xml @@ -8,7 +8,7 @@ defaultHandler="com.hybris.hyeclipse.tsvextended.handlers.TSVExtendedHandlerWrapper"/> - + diff --git a/com.hybris.hyeclipse.tsv.extended/src-platform-dependent/com/hybris/hyeclipse/tsvextended/ui/ExtensionCellModifier.java b/com.hybris.hyeclipse.tsv.extended/src-platform-dependent/com/hybris/hyeclipse/tsvextended/ui/ExtensionCellModifier.java index c749f478..8d66e308 100644 --- a/com.hybris.hyeclipse.tsv.extended/src-platform-dependent/com/hybris/hyeclipse/tsvextended/ui/ExtensionCellModifier.java +++ b/com.hybris.hyeclipse.tsv.extended/src-platform-dependent/com/hybris/hyeclipse/tsvextended/ui/ExtensionCellModifier.java @@ -55,7 +55,7 @@ public Object getValue(Object element, String property) { result = extension.getName(); break; case 1 : // CORE_COLUMN - result = new Boolean(extension.isSelected()); + result = Boolean.valueOf(extension.isSelected()); break; default : result = ""; diff --git a/com.hybris.hyeclipse.tsv.extended/src-platform-dependent/com/hybris/hyeclipse/tsvextended/ui/ExtensionLabelProvider.java b/com.hybris.hyeclipse.tsv.extended/src-platform-dependent/com/hybris/hyeclipse/tsvextended/ui/ExtensionLabelProvider.java index 07e810a8..27c8b0ca 100644 --- a/com.hybris.hyeclipse.tsv.extended/src-platform-dependent/com/hybris/hyeclipse/tsvextended/ui/ExtensionLabelProvider.java +++ b/com.hybris.hyeclipse.tsv.extended/src-platform-dependent/com/hybris/hyeclipse/tsvextended/ui/ExtensionLabelProvider.java @@ -68,12 +68,10 @@ private Image getImage(boolean isSelected) { @Override public Image getColumnImage(Object element, int columnIndex) { ExtensionHolder extension = (ExtensionHolder) element; - switch (columnIndex) { - case 1 : - return getImage(extension.isSelected()); - default : - return null; - } + return switch (columnIndex) { + case 1 -> getImage(extension.isSelected()); + default -> null; + }; } diff --git a/com.hybris.hyeclipse.tsv.extended/src/com/hybris/hyeclipse/tsv/editors/TSVEditor.java b/com.hybris.hyeclipse.tsv.extended/src/com/hybris/hyeclipse/tsv/editors/TSVEditor.java index 3be27b69..6e2a8dec 100644 --- a/com.hybris.hyeclipse.tsv.extended/src/com/hybris/hyeclipse/tsv/editors/TSVEditor.java +++ b/com.hybris.hyeclipse.tsv.extended/src/com/hybris/hyeclipse/tsv/editors/TSVEditor.java @@ -132,8 +132,8 @@ public void doubleClick(DoubleClickEvent event) { Object selection = structuredSelection.getFirstElement(); - if (selection instanceof TSVResult) { - openResultSource((TSVResult) selection); + if (selection instanceof TSVResult result) { + openResultSource(result); } } @@ -166,8 +166,7 @@ private void openResultSource(final TSVResult result) { } else if (source.isFile()) { final IEditorPart opened = IDE.openEditorOnFileStore(getSite().getPage(), EFS.getLocalFileSystem().getStore(source.toURI())); - if (opened instanceof ITextEditor) { - final ITextEditor text = (ITextEditor) opened; + if (opened instanceof ITextEditor text) { final IDocument document = text.getDocumentProvider().getDocument(text.getEditorInput()); final IRegion line = document.getLineInformation(Math.max(0, result.getLineNumber() - 1)); text.selectAndReveal(line.getOffset(), line.getLength()); @@ -182,8 +181,8 @@ private void openResultSource(final TSVResult result) { private Object createModel() { IEditorInput editorInput = editor.getEditorInput(); - if (editorInput instanceof IFileEditorInput) { - String reportFile = ((IFileEditorInput)editorInput).getFile().getLocation().toOSString(); + if (editorInput instanceof IFileEditorInput input1) { + String reportFile = input1.getFile().getLocation().toOSString(); File file = new File(reportFile); if (file.exists() && file.length() > 0) { try (final InputStream input = new FileInputStream(file)) { @@ -196,9 +195,9 @@ private Object createModel() { } } } - else if (editorInput instanceof IStorageEditorInput) { + else if (editorInput instanceof IStorageEditorInput input) { try { - IStorage tsvStorage = (IStorage) ((IStorageEditorInput)editorInput).getStorage(); + IStorage tsvStorage = (IStorage) input.getStorage(); try (final InputStream resultsStream = tsvStorage.getContents()) { TSVResults results = TSVResults.read(resultsStream); resultMap.putAll(parseResults(results, resultMap)); diff --git a/com.hybris.hyeclipse.tsv.extended/src/com/hybris/hyeclipse/tsv/editors/TSVResultsContentProvider.java b/com.hybris.hyeclipse.tsv.extended/src/com/hybris/hyeclipse/tsv/editors/TSVResultsContentProvider.java index 797494e3..2a426aa3 100644 --- a/com.hybris.hyeclipse.tsv.extended/src/com/hybris/hyeclipse/tsv/editors/TSVResultsContentProvider.java +++ b/com.hybris.hyeclipse.tsv.extended/src/com/hybris/hyeclipse/tsv/editors/TSVResultsContentProvider.java @@ -45,8 +45,8 @@ public Object[] getChildren(Object parent) { @Override public Object[] getElements(Object object) { - if (object instanceof HashMap) { - return ((HashMap) object).keySet().toArray(); + if (object instanceof HashMap map) { + return map.keySet().toArray(); } else if (object instanceof String) { return resultMap.get(object).toArray(); diff --git a/com.hybris.hyeclipse.tsv.extended/src/com/hybris/hyeclipse/tsv/editors/TSVResultsLabelProvider.java b/com.hybris.hyeclipse.tsv.extended/src/com/hybris/hyeclipse/tsv/editors/TSVResultsLabelProvider.java index cd1cdfbc..750869aa 100644 --- a/com.hybris.hyeclipse.tsv.extended/src/com/hybris/hyeclipse/tsv/editors/TSVResultsLabelProvider.java +++ b/com.hybris.hyeclipse.tsv.extended/src/com/hybris/hyeclipse/tsv/editors/TSVResultsLabelProvider.java @@ -48,13 +48,12 @@ public Image getColumnImage(Object element, int columnIndex) { @Override public String getColumnText(Object element, int columnIndex) { - if (element instanceof String) { + if (element instanceof String string) { if (columnIndex == 0) { - return (String) element; + return string; } } - else if (element instanceof TSVResult) { - TSVResult result = (TSVResult)element; + else if (element instanceof TSVResult result) { switch(columnIndex) { case 0: return result.getElement(); @@ -77,8 +76,7 @@ public Color getBackground(Object element, int columnIndex) { @Override public Color getForeground(Object element, int columnIndex) { - if (element instanceof TSVResult) { - TSVResult result = (TSVResult)element; + if (element instanceof TSVResult result) { if (result.getRulePriority().equalsIgnoreCase("H")) { diff --git a/com.hybris.hyeclipse.tsv/src/com/hybris/hyeclipse/tsv/builder/AddRemoveHybrisNatureHandler.java b/com.hybris.hyeclipse.tsv/src/com/hybris/hyeclipse/tsv/builder/AddRemoveHybrisNatureHandler.java index b800113e..7ed6ec06 100644 --- a/com.hybris.hyeclipse.tsv/src/com/hybris/hyeclipse/tsv/builder/AddRemoveHybrisNatureHandler.java +++ b/com.hybris.hyeclipse.tsv/src/com/hybris/hyeclipse/tsv/builder/AddRemoveHybrisNatureHandler.java @@ -40,15 +40,15 @@ public Object execute(ExecutionEvent event) throws ExecutionException { // TODO Auto-generated method stub ISelection selection = HandlerUtil.getCurrentSelection(event); // - if (selection instanceof IStructuredSelection) { - for (Iterator it = ((IStructuredSelection) selection).iterator(); it + if (selection instanceof IStructuredSelection structuredSelection) { + for (Iterator it = structuredSelection.iterator(); it .hasNext();) { Object element = it.next(); IProject project = null; - if (element instanceof IProject) { - project = (IProject) element; - } else if (element instanceof IAdaptable) { - project = (IProject) ((IAdaptable) element) + if (element instanceof IProject iProject) { + project = iProject; + } else if (element instanceof IAdaptable adaptable) { + project = (IProject) adaptable .getAdapter(IProject.class); } if (project != null) { diff --git a/com.hybris.hyeclipse.tsv/src/com/hybris/hyeclipse/tsv/builder/TsvBuilder.java b/com.hybris.hyeclipse.tsv/src/com/hybris/hyeclipse/tsv/builder/TsvBuilder.java index 6d27aa12..2e41e356 100644 --- a/com.hybris.hyeclipse.tsv/src/com/hybris/hyeclipse/tsv/builder/TsvBuilder.java +++ b/com.hybris.hyeclipse.tsv/src/com/hybris/hyeclipse/tsv/builder/TsvBuilder.java @@ -53,8 +53,7 @@ public boolean visit(final IResourceDelta delta) throws CoreException { @Override public boolean visit(final IResource resource) throws CoreException { - if (resource instanceof IFile) { - final IFile file = (IFile) resource; + if (resource instanceof IFile file) { if (file.getName().endsWith("items.xml")) { files.add(file); return false; diff --git a/com.hybris.hyeclipse.ytypesystem/src/com/hybris/hyeclipse/ytypesystem/BundlePackager.java b/com.hybris.hyeclipse.ytypesystem/src/com/hybris/hyeclipse/ytypesystem/BundlePackager.java deleted file mode 100644 index 633dff46..00000000 --- a/com.hybris.hyeclipse.ytypesystem/src/com/hybris/hyeclipse/ytypesystem/BundlePackager.java +++ /dev/null @@ -1,95 +0,0 @@ -/******************************************************************************* - * Copyright 2020 SAP - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy - * of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - ******************************************************************************/ -package com.hybris.hyeclipse.ytypesystem; - -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.util.List; -import java.util.zip.Deflater; -import java.util.zip.ZipEntry; -import java.util.zip.ZipOutputStream; - -public class BundlePackager { - - public static ByteArrayOutputStream buildZip(List filesToZip) throws IOException { - - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - ZipOutputStream zOutStream = new ZipOutputStream(baos); - zOutStream.setLevel(Deflater.DEFAULT_COMPRESSION); - - for (File fileToZip : filesToZip) { - if (fileToZip.isDirectory()) { - dirZip(zOutStream, "", fileToZip); - } - else { - fileZip(zOutStream, "", fileToZip); - } - } - zOutStream.flush(); - zOutStream.close(); - - return baos; - } - - private static void dirZip(ZipOutputStream zOutputStream, String filePath, File fileDir) throws IOException { - if (!fileDir.canRead()) { - return; - } - - File[] filesToZip = fileDir.listFiles(); - filePath = computeFilePath(filePath, fileDir.getName()); - - for (File fileToZip : filesToZip) { - if (fileToZip.isDirectory()) { - dirZip(zOutputStream, filePath, fileToZip); - } - else { - fileZip(zOutputStream, filePath, fileToZip); - } - } - } - - private static void fileZip(ZipOutputStream zOutputStream, String filePath, File fileDir) throws IOException { - if (!fileDir.canRead()) { - return; - } - - zOutputStream.putNextEntry(new ZipEntry(computeFilePath(filePath, fileDir.getName()))); - FileInputStream fInputStream = new FileInputStream(fileDir); - try { - byte[] bufferArray = new byte[4092]; - int count = 0; - while ((count = fInputStream.read(bufferArray)) != -1) { - zOutputStream.write(bufferArray, 0, count); - } - } finally { - fInputStream.close(); - } - zOutputStream.closeEntry(); - } - - private static String computeFilePath(String filePath, String fileName) { - if (filePath == null || filePath.isEmpty()) { - return fileName; - } - else { - return filePath + "/" + fileName; - } - } - -} diff --git a/docs/beangen/beangen.md b/docs/beangen/beangen.md index 428db9eb..6c981fd5 100644 --- a/docs/beangen/beangen.md +++ b/docs/beangen/beangen.md @@ -34,4 +34,4 @@ Feature introduction. Possibility to add new file from File -> New.. -> Other (& | Eclipse | SAP Commerce | | ------- | ------------ | -| (2018-12, 2019-*, 2020-*) | 6.6+, 1808+, 1905+ | \ No newline at end of file +| (2026-*) | 2211+ | \ No newline at end of file diff --git a/docs/deprecation/deprecation.md b/docs/deprecation/deprecation.md index 6850abda..203556a7 100644 --- a/docs/deprecation/deprecation.md +++ b/docs/deprecation/deprecation.md @@ -2,11 +2,6 @@ This article holds log of all removed features from plugin code base. -## Type-System Verification - -Type-System-Verification (aka TSV) has been removed due to missing source-code for binary jar file, which was used as sub-process. There was plan for re-implementation with Open Source licence, in the meantime there were some moves on SAP to open source code. It was for some time available, but at the end disappeared from Github. Functionality has been removed from version [1.5.7](https://github.com/SAP/hybris-commerce-eclipse-plugin/releases/tag/v1.5.7). It was still working in [1.5.6](https://github.com/SAP/hybris-commerce-eclipse-plugin/releases/tag/v1.5.6). - ## Copyright Extension Copyright extension was responsible for bulk package comment placement to follow enterprise security rule to have comment with copyright added to all files. Functionality was available in version [22.08](https://github.com/SAP/hybris-commerce-eclipse-plugin/releases/tag/v22.8) and removed in **22.09** because it can be replaced by [Eclipse Copyright Tool](https://wiki.eclipse.org/Development_Resources/How_to_Use_Eclipse_Copyright_Tool). - diff --git a/docs/dev/development.md b/docs/dev/development.md index e8824acf..0470add3 100644 --- a/docs/dev/development.md +++ b/docs/dev/development.md @@ -1,5 +1,63 @@ # Development +## Documentation website + +The documentation site uses MkDocs with Material. `README.md` supplies the homepage; +the remaining pages and images come from `docs/`. Do not maintain a separate `docs/index.md`. +Navigation and site settings are in the root `mkdocs.yml`. + +From the repository root, use Python 3.13 and an isolated environment: + +```bash +python3 -m venv .venv-docs +source .venv-docs/bin/activate +python -m pip install -r tools/docs/requirements.txt +python -m unittest discover -s tools/docs -p 'test_*.py' +python -m mkdocs serve --strict +``` + +Open the local URL printed by MkDocs. README and documentation changes trigger a rebuild. +For a production build and internal link/image validation, run: + +```bash +python -m mkdocs build --strict +``` + +The generated `site/` directory and virtual environment are ignored by Git. +Operational files such as Sonar scripts and Docker configuration are not published. +External links are not checked by the strict build. + +### GitHub Pages deployment + +In repository **Settings → Pages**, select **GitHub Actions** as the source. +The Documentation and Eclipse update site workflow validates pull requests without deploying them and publishes +documentation or `updatesite/` changes pushed to `master`. To rebuild manually, run the workflow from +the Actions tab with `master` selected. Other branches cannot deploy. + +The public site is https://sap.github.io/hybris-commerce-eclipse-plugin/. +The same deployment also hosts the Eclipse p2 repository at +https://sap.github.io/hybris-commerce-eclipse-plugin/updates/latest/. + +### Eclipse p2 hosting + +The post-build hook copies the committed `updatesite/latest` repository (currently a +symlink to `updatesite/neon`) into `site/updates/latest/` as ordinary files. +It validates compressed metadata consistency, referenced artifacts, sizes, and available +SHA-256/SHA-512 checksums before publishing. Artifact bytes and signatures are preserved. +Finder files and other files not referenced by the repository are excluded. + +Documentation and p2 files are uploaded as one Pages artifact. Do not add a second +Pages deployment workflow: deploying only one of them would remove the other. +No Java build runs during Pages publication; updating Java source does not publish +an unsigned snapshot. Follow the release steps below to update the committed repository. + +To preview the repository locally, run `python -m mkdocs serve --strict` and use +the printed local base URL followed by `updates/latest/` in Eclipse's installer. +Run the documentation test command above to verify the combined artifact before merging. + +Material for MkDocs receives critical fixes and security updates until May 5, 2027. +Reassess the theme/toolchain before that date; Markdown sources remain independent of it. + ## Continuous Integration folder contains docker configuration for sonarqube installation. @@ -27,6 +85,70 @@ mvn clean verify sonar:sonar Results will be available on your local website +## Java Upgrades with OpenRewrite + +[OpenRewrite](https://docs.openrewrite.org/) is used for automated refactoring and source migrations when upgrading target Java versions or applying modern Java recipes across the codebase. + +### Running OpenRewrite via Maven + +The `rewrite-maven-plugin` can be invoked directly on-demand using the Maven wrapper without modifying `pom.xml`. + +#### 1. Dry Run (Preview Changes) + +To preview proposed refactorings and generate a patch without modifying files on disk: + +```bash +./mvnw org.openrewrite.maven:rewrite-maven-plugin:dryRun \ + -Drewrite.recipeArtifactCoordinates=org.openrewrite.recipe:rewrite-migrate-java:RELEASE \ + -Drewrite.activeRecipes=org.openrewrite.java.migrate.UpgradeToJava21 \ + -Drewrite.exclusions="**/com.hybris.hyeclipse.emf.beans/**" +``` + +The dry run prints a summary of modified files and writes a patch file to `target/site/rewrite/rewrite.patch`. + +#### 2. Apply Changes + +To apply recipes directly to the source code: + +```bash +./mvnw org.openrewrite.maven:rewrite-maven-plugin:run \ + -Drewrite.recipeArtifactCoordinates=org.openrewrite.recipe:rewrite-migrate-java:RELEASE \ + -Drewrite.activeRecipes=org.openrewrite.java.migrate.UpgradeToJava21 \ + -Drewrite.exclusions="**/com.hybris.hyeclipse.emf.beans/**" +``` + +#### 3. Common Recipes + +- **Java 21 migration:** `org.openrewrite.java.migrate.UpgradeToJava21` +- **Java 17 migration:** `org.openrewrite.java.migrate.UpgradeToJava17` +- **Java version best practices:** `org.openrewrite.java.migrate.JavaVersionBestPractices` + +### Important Considerations for this Repository + +1. **Exclude EMF Generated Code**: + Do **not** apply automated transformations to `com.hybris.hyeclipse.emf.beans/src/`. This code is generated from `model/beans.ecore` and `model/beans.genmodel`. Always pass: + ```bash + -Drewrite.exclusions="**/com.hybris.hyeclipse.emf.beans/**" + ``` +2. **Review Code Style and Project Conventions**: + Always inspect the diff (`git diff`) after running recipes. This repository enforces conservative Java features: + - Do **not** use `var` (retain explicit types) + - Do **not** use pattern matching `instanceof` (use traditional cast-after-check) + - Do **not** use records, sealed classes, or text blocks (`"""`) + - Preserve 4-space tab indentation and K&R braces + Reformat modified files using `eclipse-formatter.xml` or `docs/dev/eclipse-code-style.xml`. +3. **Update OSGi and Tycho Metadata**: + OpenRewrite only modifies Java source files. When upgrading the Java target version, manually update: + - Root `pom.xml`: ``, ``, ``, and `` + - `META-INF/MANIFEST.MF` across all bundles: `Bundle-RequiredExecutionEnvironment: JavaSE-` (e.g. `JavaSE-21`) + - `Makefile`: `JAVA_HOME` auto-detection logic if bumping minimum runtime version +4. **Build and Test Verification**: + Verify that all OSGi bundles compile and pass tests: + ```bash + make test + make build + ``` + ## Generating Release Notes Release notes are generated thanks to [gren](https://github.com/github-tools/github-release-notes). @@ -58,14 +180,56 @@ make test make build ``` -### 4. Update In-Repo Update Site (if maintained) +This local build is an unsigned candidate. Do not use its ZIP as the delivered +release artifact until the signing step below has completed. + +### 4. Sign Deliverable Eclipse Artifacts +Where technically sensible, downloadable Eclipse artifacts should be signed +with an Eclipse Foundation certificate ([Eclipse Project Handbook: Signed +Artifacts](https://www.eclipse.org/projects/handbook/#resources-signing)). Sign +the plug-in and feature JARs contained in the p2 repository; signing only the +outer ZIP does not sign the installable Eclipse artifacts. + +The Eclipse Foundation CBI signing service is available to authorized project +builds. Configure the +[CBI Maven `eclipse-jarsigner-plugin`](https://github.com/eclipse-cbi/cbi/wiki/Signing) +in a dedicated Maven profile (for example, `sign`) and enable that profile only +in the authorized Eclipse signing Jenkins job. The signing profile must run +before the p2 repository and release ZIP are assembled, so the p2 metadata +checksums describe the signed JARs. Keep signing credentials and service access +out of the repository and local developer builds. + +Run the release build in the authorized signing environment, for example: +```bash +./mvnw clean install -Psign +``` + +Verify the resulting plug-in and feature JAR signatures (including the expected +Eclipse Foundation signer), then install from the signed p2 repository in a +clean Eclipse instance. Use the ZIP produced by this signed build for the +update-site snapshot and GitHub release. Do not deliver the unsigned local ZIP +if signing was required but unavailable. + +> **Current setup:** This repository has no CBI signing profile or configured +> Eclipse signing Jenkins job. These must be established with the authorized +> build administrators before a signed release can be produced; the local +> `make build` alone does not sign artifacts. + +### 5. Update In-Repo Update Site (if maintained) Sync the built p2 repository into `updatesite/neon`: ```bash rm -rf updatesite/neon/* cp -R com.hybris.hyeclipse.site/target/repository/* updatesite/neon/ ``` -### 5. Commit and Tag Release +Use the repository generated by the signed build above. + +`updatesite/latest` points to `neon`, so updating this directory also updates the +repository published by GitHub Pages. Commit the complete metadata and artifact set +together. Once merged into `master`, the Pages workflow publishes it at the stable +`updates/latest/` URL without rebuilding or re-signing it. + +### 6. Commit and Tag Release ```bash git add pom.xml */pom.xml */META-INF/MANIFEST.MF */feature.xml updatesite/neon/ git commit -m "chore(release): bump version to VERSION.RELEASE" @@ -73,12 +237,12 @@ git tag -a vVERSION -m "Release vVERSION" # e.g., git tag -a v22.9.0 -m "Relea git push origin release/VERSION --tags ``` -### 6. Create Pull Request and Merge to Master +### 7. Create Pull Request and Merge to Master 1. Open a pull request from `release/VERSION` into `master` on GitHub. 2. Ensure GitHub Actions CI passes. 3. Merge the pull request. -### 7. Publish GitHub Release on github.com +### 8. Publish GitHub Release on github.com 1. Go to the GitHub repository: **Releases -> Draft a new release** (or use the GitHub CLI `gh`). 2. Select the existing tag (e.g. `v22.9.0`). 3. Set the release title: `SAP Commerce Cloud - Eclipse Plugin v22.9.0`. @@ -87,7 +251,7 @@ git push origin release/VERSION --tags - File: `com.hybris.hyeclipse.site/target/com.hybris.hyeclipse.site-VERSION.RELEASE.zip` 6. Click **Publish release**. -### 8. Prepare Next Development Iteration +### 9. Prepare Next Development Iteration Bump the codebase to the next `-SNAPSHOT` version on `master`: ```bash git checkout master diff --git a/docs/import-jdk.md b/docs/import-jdk.md index ec38cc4a..1060615c 100644 --- a/docs/import-jdk.md +++ b/docs/import-jdk.md @@ -8,13 +8,6 @@ JDK. JDKs must be registered under **Java > Installed JREs** and contain `javac` ## Import behaviour -`ImportJob` captures the selected VM and validates its compiler level before Ant -or workspace project changes. The captured VM is passed to both `ShellImporter` -and `Importer`; changing the preference while Ant is running does not switch the -JDK halfway through the import. The JDK installation home is checked again after -Ant, so an installation edited during Ant execution does not silently produce -inconsistent project settings. - Each newly imported Java project gets: - A JRE container referencing the captured registered VM. @@ -24,22 +17,8 @@ Each newly imported Java project gets: - Preserved non-JRE classpath entries and runtime-container access rules, attributes and exported flag. Duplicate JRE references are consolidated. -This happens even when **Fix classpaths** is disabled. The old platform-version -logic that globally forced Java 8 compiler options was removed. Workspace default -VM and workspace compiler options are not changed by import or the update job. - -Existing projects keep their configured runtime during optional missing-runtime -repair; a missing runtime is repaired using the saved preference. Consequently, -declining a workspace-wide update does not silently replace existing SDK choices -during that repair phase. - ## Preference changes -The importer bundle listens for committed changes to `antJdk`. Saving the same -value or changing an unrelated preference does not prompt. When the preference -uses the workspace default, a change to that default VM also prompts; initial VM -registration does not. - JDK/version validation runs in a background Job. A confirmation question then runs on the display thread: diff --git a/docs/importer/imgs/importing-p.gif b/docs/importer/imgs/importing-p.gif index f880fa55..3ad0e3f1 100644 Binary files a/docs/importer/imgs/importing-p.gif and b/docs/importer/imgs/importing-p.gif differ diff --git a/docs/importer/imgs/sap-preferences.png b/docs/importer/imgs/sap-preferences.png new file mode 100644 index 00000000..159db2f0 Binary files /dev/null and b/docs/importer/imgs/sap-preferences.png differ diff --git a/docs/importer/importer.md b/docs/importer/importer.md index e6834209..1b15c3d9 100644 --- a/docs/importer/importer.md +++ b/docs/importer/importer.md @@ -15,12 +15,12 @@ There you can find category `SAP` and there `Import SAP Platform`. Next wizard step shows list of checkboxes available during import and available directory field. It is required to point valid `hybris/bin/platform` folder for your project. +### Custom JDK Selection +It is possible to select proper JDK version for project import, which is required for running build process for SAP Commerce projects. Proper selection of JDK can be done via: `Window -> Settings -> Preferences -> SAP Commerce -> Import settings`. -# Roadmap +By default, the plugin uses JDK used by IDE. In order to pin specific JDK version for Ant build process, you can change it in plugin preference page. Same JDK will be used for setting SAP Commerce extension project settings. -That is default approach with importing projects for SAP Commerce till version 1808. With that version Gradle support has been introduced as an experimental functionality and it is possible to use that option to play with. +![SAP Preference Page](imgs/sap-preferences.png) -That approach is supported by most IDEs on market. - -Project Importer functionality will be supported and fixes will be provided, but implementation will be focused on other areas of SAP Commerce plugin. +For more info about custom JDK selection see [Custom JDK Selection](../import-jdk.md). diff --git a/docs/installation.md b/docs/installation.md new file mode 100644 index 00000000..f4c20820 --- /dev/null +++ b/docs/installation.md @@ -0,0 +1,40 @@ +# Installation and Eclipse update site + +Install the plugin through the +[Eclipse Marketplace](https://marketplace.eclipse.org/content/sap-hybris-commerce-development-tools-eclipse) +or use the hosted Eclipse p2 repository: + +```text +https://sap.github.io/hybris-commerce-eclipse-plugin/updates/latest/ +``` + +## Install from the update site + +1. In Eclipse, select **Help → Install New Software…**. +2. Choose **Add…**, name the repository **SAP Commerce development tools**, and paste the URL above. +3. Select **SAP Commerce, development tools for Eclipse** and follow the installation wizard. +4. Review the license and any trust/signature prompts, then restart Eclipse when requested. + +Keep **Contact all update sites during install to find required software** enabled +so Eclipse can resolve dependencies from its own repositories. +To update an existing installation, use **Help → Check for Updates** with this repository enabled. + +## What is published + +The hosted repository mirrors the committed `updatesite/latest` repository on `master`. +That path currently points to `updatesite/neon`; the directory name is historical and +does not by itself determine Eclipse compatibility. Consult the release notes and +the install wizard for the requirements of the version offered by the repository. + +This is not a snapshot of the current Java sources. A source change or documentation +deployment does not produce a new plugin release. New versions are published only +when maintainers update the committed p2 repository and merge it into `master`. +The repository metadata determines the available plugin version. + +GitHub Pages serves the p2 metadata, feature JARs, and plugin JARs without modifying +their bytes. Hosting does not sign artifacts or change their existing signatures. +See the [release process](dev/development.md#4-sign-deliverable-eclipse-artifacts) +for signing requirements. + +The update URL is for Eclipse's installer, not a browsable documentation page. +If it is not yet accessible, the Pages workflow must first be deployed from `master`. diff --git a/docs/system-config.md b/docs/internal/system-config.md similarity index 100% rename from docs/system-config.md rename to docs/internal/system-config.md diff --git a/docs/tsv-source-migration.md b/docs/internal/tsv-source-migration.md similarity index 90% rename from docs/tsv-source-migration.md rename to docs/internal/tsv-source-migration.md index 645a381e..4c7e81c3 100644 --- a/docs/tsv-source-migration.md +++ b/docs/internal/tsv-source-migration.md @@ -1,14 +1,9 @@ # Source-built TSV migration -## Reference project - -The implementation was informed by the supplied `consultant-toolbox/tsv-extended` -source project, version **3.0.1**, particularly: +This page describes the current development implementation. It does not imply that +all changes are available in the latest published plugin release. -- `rules/TypeSystemRule.java`: inherited indexes and redeclaration handling. -- `utils/TypeSystemEvalUtils.java`: known platform-type index exemptions. -- `src/main/resources/extended-ruleset.xml`: the nine updated schema rules. -- The sibling `tsv` project: XPath selection, test and source-location conventions. +## Reference project The source fixes the old system-classloader cast and declares JAXB providers, but still uses SAP `SystemConfig`/`PlatformConfig`/`YTypeSystem`, Spring and Groovy. @@ -29,7 +24,7 @@ Both TSV plugins now compile against commons rather than prebuilt toolbox jars. TSV no longer packages or loads `tsv-2.1.0-jar-with-dependencies.jar`, `tsv-extended-0.0.1-SNAPSHOT.jar`, `platform-dependent.jar` or `ybootstrap.jar`. The three unused TSV jar files have also been removed from the plugin `lib/` -directories. Historical releases under `updatesite/neon/` remain unchanged. +directories. No Spring, Groovy, JAXB or customer class loading is used by the new TSV code. The separate toolbox checkout was not changed. diff --git a/docs/type-system-repository.md b/docs/internal/type-system-repository.md similarity index 100% rename from docs/type-system-repository.md rename to docs/internal/type-system-repository.md diff --git a/docs/kb/imgs/jvm-incompatibility.png b/docs/kb/imgs/jvm-incompatibility.png deleted file mode 100644 index 0afebc38..00000000 Binary files a/docs/kb/imgs/jvm-incompatibility.png and /dev/null differ diff --git a/docs/kb/info.md b/docs/kb/info.md index 3fcca90f..b0480fca 100644 --- a/docs/kb/info.md +++ b/docs/kb/info.md @@ -2,11 +2,14 @@ Document collects known issues related to plugin and solutions for them. -## JVM 11/17 Compatibility +## JVM Compatibility -Eclipse IDE should be run on the same or newer JVM version like SAP Commerce. That is caused due to dynamic JAR binding to IDE class loader to be able to run Commerce core functionality for project import and project build. Having older JVM will cause error shown below: +The current development version of the plugin requires Java 21 to run Eclipse. +See [JDK selection](../import-jdk.md) for the separate Commerce project and Ant JDK settings. +The following class-loading guidance and compatibility table describe historical versions. +For current Commerce patch requirements, consult SAP Help's "Third-Party Compatibility" page. -![Incompatible JVM](imgs/jvm-incompatibility.png) +Eclipse IDE can run independently on diferent JVM version than imported SAP Commerce Cloud project. JDK version can be changed in Eclipse Setting Preference Page. Details how to set up JVM for Eclipse IDE can be found on page https://wiki.eclipse.org/Eclipse.ini @@ -14,11 +17,11 @@ Information about SAP Commerce JVM compatibility is available on SAP Help page " Milestone JVM changes for SAP Commerce: -| SAP Commerce Version | Java Version | -| -------------------- | -------------| -| <= 5.5.0 | Java 7 (1.7) | -| 5.5.1 - 6.7 | Java 8 (1.8) | -| 1808 - 1811 | Java 8 (1.8) | -| 1905 - 2207 | Java 11 | -| 2211 | Java 17 | - +| SAP Commerce Version | Java Version | Notes | +| -------------------- | -------------|-------| +| <= 5.5.0 | Java 7 (1.7) | not supported | +| 5.5.1 - 6.7 | Java 8 (1.8) | not supported | +| 1808 - 1811 | Java 8 (1.8) | not supported | +| 1905 - 2207 | Java 11 | not supported | +| 2211 | Java 17 | not supported | +| 2211-jdk21 | Java 21 | supported | diff --git a/mkdocs.yml b/mkdocs.yml new file mode 100644 index 00000000..dd248165 --- /dev/null +++ b/mkdocs.yml @@ -0,0 +1,69 @@ +site_name: Eclipse Plugin for SAP Commerce +site_description: User and developer documentation for the SAP Commerce Eclipse plugin. +site_url: https://sap.github.io/hybris-commerce-eclipse-plugin/ +repo_url: https://github.com/SAP/hybris-commerce-eclipse-plugin +repo_name: SAP/hybris-commerce-eclipse-plugin +edit_uri: edit/master/docs/ +docs_dir: docs +site_dir: site + +theme: + name: material + font: false + features: + - navigation.sections + - navigation.top + - content.action.edit + - content.code.copy + - search.highlight + +plugins: + - search + +hooks: + - tools/docs/hooks.py + +watch: + - README.md + - tools/docs + - updatesite + +exclude_docs: | + docker-compose.yml + start-sonar.sh + dev/eclipse-code-style.xml + internal/*.* + +validation: + nav: + omitted_files: warn + not_found: warn + links: + not_found: warn + anchors: warn + unrecognized_links: warn + +markdown_extensions: + - admonition + - toc: + permalink: true + - pymdownx.highlight + - pymdownx.superfences + +nav: + - Home: index.md + - User guide: + - Installation and update site: installation.md + - Project importer: importer/importer.md + - Beans generation: beangen/beangen.md + - JDK selection: import-jdk.md + - Troubleshooting: + - Knowledge database: kb/info.md + - Developer guide: + - Development and releases: dev/development.md + - Regression verification: dev/import-and-junit-verification.md + - Project information: + - Deprecations: deprecation/deprecation.md + - Contributing: https://github.com/SAP/hybris-commerce-eclipse-plugin/blob/master/CONTRIBUTING.md + - Code of conduct: https://github.com/SAP/hybris-commerce-eclipse-plugin/blob/master/CODE_OF_CONDUCT.md + - License: https://github.com/SAP/hybris-commerce-eclipse-plugin/blob/master/LICENSE diff --git a/pom.xml b/pom.xml index 9f733d18..b9d2c29d 100644 --- a/pom.xml +++ b/pom.xml @@ -20,6 +20,7 @@ + 21 5.0.4 diff --git a/tools/docs/hooks.py b/tools/docs/hooks.py new file mode 100644 index 00000000..c24fe86e --- /dev/null +++ b/tools/docs/hooks.py @@ -0,0 +1,107 @@ +# SPDX-FileCopyrightText: 2026 SAP SE or an SAP affiliate company and contributors +# SPDX-License-Identifier: Apache-2.0 +"""Build documentation and publish the committed Eclipse p2 repository.""" + +import hashlib +import lzma +import re +import shutil +import xml.etree.ElementTree as ET +import zipfile +from pathlib import Path + +from mkdocs.exceptions import PluginError +from mkdocs.structure.files import File + + +def homepage_markdown(markdown, repo_url): + """Rebase the README's inline links from the repository root to docs/.""" + # Keep the directory browser on GitHub; it is not a documentation page. + markdown = markdown.replace("](docs/)", f"]({repo_url}/tree/master/docs/)") + # Rebase inline Markdown destinations without changing absolute URLs. + markdown = markdown.replace("](docs/", "](") + for filename in ("CODE_OF_CONDUCT.md", "CONTRIBUTING.md", "LICENSE"): + markdown = markdown.replace( + f"]({filename})", f"]({repo_url}/blob/master/{filename})" + ) + return markdown + + +def on_files(files, config): + root = Path(config.config_file_path).parent + markdown = homepage_markdown( + (root / "README.md").read_text(encoding="utf-8"), config.repo_url.rstrip("/") + ) + homepage = File.generated(config, "index.md", content=markdown) + homepage.edit_uri = f"{config.repo_url.rstrip('/')}/edit/master/README.md" + files.append(homepage) + return files + + +def repository_metadata(source, name): + """Read p2 descriptors and reject inconsistent compressed alternatives.""" + descriptors = [] + paths = [] + for suffix in (".xml.xz", ".xml", ".jar"): + path = source / (name + suffix) + if not path.is_file(): + continue + if suffix == ".jar": + with zipfile.ZipFile(path) as archive: + content = archive.read(name + ".xml") + elif suffix == ".xml.xz": + content = lzma.decompress(path.read_bytes()) + else: + content = path.read_bytes() + descriptors.append(ET.fromstring(content)) + paths.append(path) + if not descriptors: + raise ValueError(f"Missing p2 {name} metadata in {source}") + if any(ET.tostring(item) != ET.tostring(descriptors[0]) for item in descriptors[1:]): + raise ValueError(f"Inconsistent p2 {name} metadata in {source}") + return descriptors[0], paths + + +def publish_update_site(source, destination): + """Validate and copy p2 bytes unchanged, without publishing source symlinks.""" + source = source.resolve() + content, content_paths = repository_metadata(source, "content") + artifacts, artifact_paths = repository_metadata(source, "artifacts") + paths = [source / "p2.index", *content_paths, *artifact_paths] + keys = set() + directories = {"osgi.bundle": "plugins", "org.eclipse.update.feature": "features"} + for artifact in artifacts.findall("./artifacts/artifact"): + classifier, identifier, version = (artifact.get(key, "") for key in ("classifier", "id", "version")) + if classifier not in directories or not all(re.fullmatch(r"[\w.-]+", value) for value in (identifier, version)): + raise ValueError(f"Unsupported p2 artifact: {classifier}/{identifier}/{version}") + path = source / directories[classifier] / f"{identifier}_{version}.jar" + data = path.read_bytes() + properties = {item.get("name"): item.get("value") for item in artifact.findall("./properties/property")} + if "download.size" in properties and len(data) != int(properties["download.size"]): + raise ValueError(f"Incorrect p2 artifact size: {path}") + for algorithm in ("sha-256", "sha-512"): + expected = properties.get("download.checksum." + algorithm) + if expected and hashlib.new(algorithm.replace("-", ""), data).hexdigest() != expected: + raise ValueError(f"Incorrect p2 artifact checksum: {path}") + keys.add((classifier, identifier, version)) + paths.append(path) + if not keys: + raise ValueError(f"Empty p2 artifact repository: {source}") + for artifact in content.findall("./units/unit/artifacts/artifact"): + key = tuple(artifact.get(name) for name in ("classifier", "id", "version")) + if key not in keys: + raise ValueError(f"Missing p2 artifact referenced by content metadata: {key}") + # Copy only metadata and referenced artifacts. Finder files and the `latest` + # source symlink must not end up in the GitHub Pages artifact. + for path in paths: + target = destination / path.relative_to(source) + target.parent.mkdir(parents=True, exist_ok=True) + shutil.copyfile(path, target) + + +def on_post_build(config): + root = Path(config.config_file_path).parent + try: + publish_update_site(root / "updatesite/latest", Path(config.site_dir) / "updates/latest") + except (OSError, ValueError, KeyError, ET.ParseError, zipfile.BadZipFile, lzma.LZMAError) as error: + raise PluginError(f"Cannot publish Eclipse p2 update site: {error}") from error diff --git a/tools/docs/requirements.txt b/tools/docs/requirements.txt new file mode 100644 index 00000000..b9689135 --- /dev/null +++ b/tools/docs/requirements.txt @@ -0,0 +1,4 @@ +# SPDX-FileCopyrightText: 2026 SAP SE or an SAP affiliate company and contributors +# SPDX-License-Identifier: Apache-2.0 +mkdocs==1.6.1 +mkdocs-material==9.8.1 diff --git a/tools/docs/test_hooks.py b/tools/docs/test_hooks.py new file mode 100644 index 00000000..a85667be --- /dev/null +++ b/tools/docs/test_hooks.py @@ -0,0 +1,53 @@ +# SPDX-FileCopyrightText: 2026 SAP SE or an SAP affiliate company and contributors +# SPDX-License-Identifier: Apache-2.0 +"""Regression tests for the generated documentation homepage.""" + +import unittest +from pathlib import Path + +from mkdocs.config import load_config +from mkdocs.structure.files import Files + +from hooks import homepage_markdown + + +class HomepageTest(unittest.TestCase): + def test_document_links_preserve_fragments(self): + self.assertEqual( + "[Import](importer/importer.md#features)", + homepage_markdown("[Import](docs/importer/importer.md#features)", "https://example.com/repo"), + ) + + def test_repository_links(self): + for filename in ("LICENSE", "CODE_OF_CONDUCT.md", "CONTRIBUTING.md"): + with self.subTest(filename=filename): + self.assertEqual( + f"[Link](https://example.com/repo/blob/master/{filename})", + homepage_markdown(f"[Link]({filename})", "https://example.com/repo"), + ) + + def test_docs_directory_links_go_to_repository(self): + self.assertEqual( + "[Sources](https://example.com/repo/tree/master/docs/)", + homepage_markdown("[Sources](docs/)", "https://example.com/repo"), + ) + + def test_absolute_links_and_prose_are_unchanged(self): + markdown = "Use docs/importer. [External](https://example.com/docs/importer.md) ![Image](image.gif)" + self.assertEqual(markdown, homepage_markdown(markdown, "https://example.com/repo")) + + def test_homepage_is_generated_from_readme(self): + root = Path(__file__).resolve().parents[2] + config = load_config(str(root / "mkdocs.yml")) + files = config.plugins.on_files(Files([]), config=config) + homepage = files.get_file_from_path("index.md") + self.assertEqual( + homepage_markdown((root / "README.md").read_text(encoding="utf-8"), config.repo_url), + homepage.content_string, + ) + self.assertEqual(f"{config.repo_url}/edit/master/README.md", homepage.edit_uri) + self.assertFalse((root / "docs" / "index.md").exists()) + + +if __name__ == "__main__": + unittest.main() diff --git a/tools/docs/test_p2.py b/tools/docs/test_p2.py new file mode 100644 index 00000000..4aa20a62 --- /dev/null +++ b/tools/docs/test_p2.py @@ -0,0 +1,83 @@ +# SPDX-FileCopyrightText: 2026 SAP SE or an SAP affiliate company and contributors +# SPDX-License-Identifier: Apache-2.0 +"""Regression tests for byte-preserving p2 publication and validation.""" + +import lzma +import shutil +import tempfile +import unittest +import xml.etree.ElementTree as ET +import zipfile +from pathlib import Path + +from hooks import publish_update_site, repository_metadata + + +class UpdateSiteTest(unittest.TestCase): + def setUp(self): + self.temporary = tempfile.TemporaryDirectory(prefix="commerce-p2-") + self.addCleanup(self.temporary.cleanup) + root = Path(__file__).resolve().parents[2] + self.source = Path(self.temporary.name) / "source" + self.destination = Path(self.temporary.name) / "published" + shutil.copytree(root / "updatesite/latest", self.source) + + def test_publishes_regular_files_without_changing_bytes(self): + (self.source / ".DS_Store").write_bytes(b"Finder metadata") + publish_update_site(self.source, self.destination) + self.assertFalse((self.destination / ".DS_Store").exists()) + for published in self.destination.rglob("*"): + self.assertFalse(published.is_symlink()) + if published.is_file(): + self.assertEqual( + (self.source / published.relative_to(self.destination)).read_bytes(), + published.read_bytes(), + ) + + def test_missing_artifact_fails(self): + next((self.source / "plugins").glob("*.jar")).unlink() + with self.assertRaises(FileNotFoundError): + publish_update_site(self.source, self.destination) + + def test_corrupted_artifact_checksum_fails(self): + path = next((self.source / "plugins").glob("*.jar")) + data = path.read_bytes() + path.write_bytes(bytes([data[0] ^ 1]) + data[1:]) + with self.assertRaisesRegex(ValueError, "checksum"): + publish_update_site(self.source, self.destination) + + def test_truncated_artifact_size_fails(self): + path = next((self.source / "plugins").glob("*.jar")) + path.write_bytes(b"truncated") + with self.assertRaisesRegex(ValueError, "size"): + publish_update_site(self.source, self.destination) + + def test_inconsistent_metadata_fails(self): + path = self.source / "content.xml.xz" + metadata = ET.fromstring(lzma.decompress(path.read_bytes())) + metadata.set("name", "inconsistent") + path.write_bytes(lzma.compress(ET.tostring(metadata))) + with self.assertRaisesRegex(ValueError, "Inconsistent"): + publish_update_site(self.source, self.destination) + + def test_missing_metadata_fails(self): + (self.source / "content.xml.xz").unlink() + (self.source / "content.jar").unlink() + with self.assertRaisesRegex(ValueError, "Missing p2 content metadata"): + publish_update_site(self.source, self.destination) + + def test_missing_content_artifact_reference_fails(self): + metadata, unused_paths = repository_metadata(self.source, "content") + artifact = metadata.find("./units/unit/artifacts/artifact") + self.assertIsNotNone(artifact) + artifact.set("id", "missing.bundle") + content = ET.tostring(metadata) + (self.source / "content.xml.xz").write_bytes(lzma.compress(content)) + with zipfile.ZipFile(self.source / "content.jar", "w") as archive: + archive.writestr("content.xml", content) + with self.assertRaisesRegex(ValueError, "referenced by content"): + publish_update_site(self.source, self.destination) + + +if __name__ == "__main__": + unittest.main() diff --git a/tools/docs/test_site.py b/tools/docs/test_site.py new file mode 100644 index 00000000..3fe7ffcb --- /dev/null +++ b/tools/docs/test_site.py @@ -0,0 +1,73 @@ +# SPDX-FileCopyrightText: 2026 SAP SE or an SAP affiliate company and contributors +# SPDX-License-Identifier: Apache-2.0 +"""Check the published artifact, including project-prefix URLs and images.""" + +import json +import tempfile +import unittest +from html.parser import HTMLParser +from pathlib import Path +from urllib.parse import unquote, urlsplit + +from mkdocs.commands.build import build +from mkdocs.config import load_config + + +class ResourceParser(HTMLParser): + def __init__(self): + super().__init__() + self.urls = [] + + def handle_starttag(self, tag, attrs): + for name, value in attrs: + if name in ("src", "href") and value: + self.urls.append(value) + + +class SiteTest(unittest.TestCase): + def test_published_resources(self): + root = Path(__file__).resolve().parents[2] + with tempfile.TemporaryDirectory(prefix="commerce-docs-") as directory: + site = Path(directory) / "site" + config = load_config(str(root / "mkdocs.yml"), site_dir=str(site), strict=True) + build(config) + prefix = urlsplit(config.site_url).path + for page in site.rglob("*.html"): + parser = ResourceParser() + parser.feed(page.read_text(encoding="utf-8")) + for url in parser.urls: + with self.subTest(page=str(page.relative_to(site)), url=url): + parsed = urlsplit(url) + if parsed.scheme or parsed.netloc or not parsed.path: + continue + path = unquote(parsed.path) + if path.startswith("/"): + self.assertTrue(path.startswith(prefix), "URL escapes project prefix") + target = site / path[len(prefix):] + else: + target = page.parent / path + if target.is_dir(): + target = target / "index.html" + self.assertTrue(target.is_file(), f"Missing published resource: {target}") + + for image in (root / "docs").rglob("*"): + if image.suffix in (".gif", ".png"): + self.assertEqual(image.read_bytes(), (site / image.relative_to(root / "docs")).read_bytes()) + for excluded in ("docker-compose.yml", "start-sonar.sh", "dev/eclipse-code-style.xml"): + self.assertFalse((site / excluded).exists()) + search = json.loads((site / "search/search_index.json").read_text(encoding="utf-8")) + self.assertTrue(search["docs"], "Search index must contain documentation") + repository = site / "updates/latest" + self.assertTrue((repository / "p2.index").is_file()) + self.assertTrue((repository / "content.xml.xz").is_file()) + self.assertTrue((repository / "artifacts.xml.xz").is_file()) + self.assertFalse((repository / ".DS_Store").exists()) + for published in repository.rglob("*"): + self.assertFalse(published.is_symlink()) + if published.is_file(): + source = root / "updatesite/latest" / published.relative_to(repository) + self.assertEqual(source.read_bytes(), published.read_bytes()) + + +if __name__ == "__main__": + unittest.main()