diff --git a/platform/util/src/com/intellij/openapi/diagnostic/Attachment.java b/platform/util/src/com/intellij/openapi/diagnostic/Attachment.java index fd016ebb9cd2..849823459a6e 100644 --- a/platform/util/src/com/intellij/openapi/diagnostic/Attachment.java +++ b/platform/util/src/com/intellij/openapi/diagnostic/Attachment.java @@ -1,16 +1,16 @@ -// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.openapi.diagnostic; import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.vfs.CharsetToolkit; import com.intellij.util.ArrayUtil; -import com.intellij.util.Base64; import com.intellij.util.ExceptionUtil; import com.intellij.util.PathUtilRt; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.io.*; +import java.util.Base64; public class Attachment { private static final Logger LOG = Logger.getInstance(Attachment.class); @@ -65,7 +65,7 @@ public class Attachment { @NotNull public String getEncodedBytes() { - return Base64.encode(getBytes()); + return Base64.getEncoder().encodeToString(getBytes()); } @NotNull diff --git a/platform/util/src/com/intellij/util/io/URLUtil.java b/platform/util/src/com/intellij/util/io/URLUtil.java index 1decf1ec0464..b8139d555074 100644 --- a/platform/util/src/com/intellij/util/io/URLUtil.java +++ b/platform/util/src/com/intellij/util/io/URLUtil.java @@ -1,10 +1,9 @@ -// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.util.io; import com.intellij.openapi.util.Pair; import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vfs.CharsetToolkit; -import com.intellij.util.Base64; import com.intellij.util.ThreeState; import gnu.trove.TIntArrayList; import org.jetbrains.annotations.NotNull; @@ -15,6 +14,8 @@ import java.net.MalformedURLException; import java.net.URISyntaxException; import java.net.URL; import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; +import java.util.Base64; import java.util.regex.Matcher; import java.util.regex.Pattern; import java.util.zip.ZipEntry; @@ -245,8 +246,8 @@ public class URLUtil { try { String content = matcher.group(4); return ";base64".equalsIgnoreCase(matcher.group(3)) - ? Base64.decode(content) - : content.getBytes(CharsetToolkit.UTF8_CHARSET); + ? Base64.getDecoder().decode(content) + : content.getBytes(StandardCharsets.UTF_8); } catch (IllegalArgumentException e) { return null; diff --git a/plugins/gradle/jps-plugin/src/org/jetbrains/jps/gradle/build/GradleArtifactBuildTaskProvider.java b/plugins/gradle/jps-plugin/src/org/jetbrains/jps/gradle/build/GradleArtifactBuildTaskProvider.java index a0bf779c03eb..1489581a4831 100644 --- a/plugins/gradle/jps-plugin/src/org/jetbrains/jps/gradle/build/GradleArtifactBuildTaskProvider.java +++ b/plugins/gradle/jps-plugin/src/org/jetbrains/jps/gradle/build/GradleArtifactBuildTaskProvider.java @@ -1,9 +1,8 @@ -// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package org.jetbrains.jps.gradle.build; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.util.io.FileUtil; -import com.intellij.util.Base64; import com.intellij.util.containers.ContainerUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -17,6 +16,7 @@ import org.jetbrains.jps.model.artifact.JpsArtifact; import org.jetbrains.jps.model.artifact.elements.JpsArtifactRootElement; import java.io.File; +import java.util.Base64; import java.util.Collections; import java.util.List; import java.util.Map; @@ -73,7 +73,7 @@ public class GradleArtifactBuildTaskProvider extends ArtifactBuildTaskProvider { if (myProperties.manifest != null) { try { File output = new File(myArtifact.getOutputPath(), JarFile.MANIFEST_NAME); - FileUtil.writeToFile(output, Base64.decode(myProperties.manifest)); + FileUtil.writeToFile(output, Base64.getDecoder().decode(myProperties.manifest)); } // do not fail the whole 'Make' if there is an invalid manifest cached catch (Exception e) { @@ -97,7 +97,7 @@ public class GradleArtifactBuildTaskProvider extends ArtifactBuildTaskProvider { for (Map.Entry entry : myProperties.additionalFiles.entrySet()) { try { File output = new File(entry.getKey()); - FileUtil.writeToFile(output, Base64.decode(entry.getValue())); + FileUtil.writeToFile(output, Base64.getDecoder().decode(entry.getValue())); } // do not fail the whole 'Make' if there is an invalid file cached catch (Exception e) { diff --git a/plugins/maven/jps-plugin/src/org/jetbrains/jps/maven/compiler/MavenManifestGenerationBuildTaskProvider.java b/plugins/maven/jps-plugin/src/org/jetbrains/jps/maven/compiler/MavenManifestGenerationBuildTaskProvider.java index a596b97593ec..f5b78aeb08d5 100644 --- a/plugins/maven/jps-plugin/src/org/jetbrains/jps/maven/compiler/MavenManifestGenerationBuildTaskProvider.java +++ b/plugins/maven/jps-plugin/src/org/jetbrains/jps/maven/compiler/MavenManifestGenerationBuildTaskProvider.java @@ -1,18 +1,4 @@ -/* - * Copyright 2000-2015 JetBrains s.r.o. - * - * 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. - */ +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package org.jetbrains.jps.maven.compiler; import com.intellij.openapi.diagnostic.Logger; @@ -20,9 +6,6 @@ import com.intellij.openapi.util.Pair; import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.util.io.StreamUtil; import com.intellij.openapi.util.text.StringUtil; -import com.intellij.util.Base64; -import com.intellij.util.Function; -import com.intellij.util.Processor; import com.intellij.util.containers.ContainerUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -31,7 +14,6 @@ import org.jetbrains.jps.builders.storage.BuildDataPaths; import org.jetbrains.jps.incremental.BuildTask; import org.jetbrains.jps.incremental.CompileContext; import org.jetbrains.jps.incremental.FSOperations; -import org.jetbrains.jps.incremental.ProjectBuildException; import org.jetbrains.jps.incremental.artifacts.impl.JpsArtifactUtil; import org.jetbrains.jps.incremental.fs.CompilationRound; import org.jetbrains.jps.maven.model.JpsMavenExtensionService; @@ -41,17 +23,13 @@ import org.jetbrains.jps.model.artifact.JpsArtifact; import org.jetbrains.jps.model.artifact.elements.JpsArtifactRootElement; import org.jetbrains.jps.model.artifact.elements.JpsDirectoryPackagingElement; import org.jetbrains.jps.model.artifact.elements.JpsFileCopyPackagingElement; -import org.jetbrains.jps.model.artifact.elements.JpsPackagingElement; import org.jetbrains.jps.model.ex.JpsElementBase; import java.io.ByteArrayInputStream; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; -import java.util.Collections; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; +import java.util.*; import java.util.jar.Attributes; import java.util.jar.JarFile; import java.util.jar.Manifest; @@ -81,7 +59,7 @@ public class MavenManifestGenerationBuildTaskProvider extends ArtifactBuildTaskP } @Override - public void build(CompileContext context) throws ProjectBuildException { + public void build(CompileContext context) { BuildDataPaths dataPaths = context.getProjectDescriptor().dataManager.getDataPaths(); MavenProjectConfiguration projectConfiguration = JpsMavenExtensionService.getInstance().getMavenProjectConfiguration(dataPaths); if (projectConfiguration == null) return; @@ -90,7 +68,7 @@ public class MavenManifestGenerationBuildTaskProvider extends ArtifactBuildTaskP if (moduleResourceConfiguration != null && StringUtil.isNotEmpty(moduleResourceConfiguration.manifest)) { try { File output = new File(myArtifact.getOutputPath(), JarFile.MANIFEST_NAME); - FileUtil.writeToFile(output, Base64.decode(moduleResourceConfiguration.manifest)); + FileUtil.writeToFile(output, Base64.getDecoder().decode(moduleResourceConfiguration.manifest)); handleSkinnyWars(context, projectConfiguration, moduleResourceConfiguration); } // do not fail the whole 'Make' if there is an invalid manifest cached (e.g. non encoded string generated by previous IDEA version) @@ -128,7 +106,7 @@ public class MavenManifestGenerationBuildTaskProvider extends ArtifactBuildTaskP if (warConfiguration == null || warConfiguration.classpath == null) return true; try { - final byte[] warManifestData = Base64.decode(warConfiguration.manifest); + final byte[] warManifestData = Base64.getDecoder().decode(warConfiguration.manifest); Manifest warManifest = new Manifest(new ByteArrayInputStream(warManifestData)); List skinnyWarClasspath = ContainerUtil.newArrayList();