|
1 | 1 | /******************************************************************************* |
2 | | - * Copyright (c) 2020, 2023 Christoph Läubrich and others |
3 | | - * |
4 | | - * This program and the accompanying materials are made available under the |
5 | | - * terms of the Eclipse Public License 2.0 which is available at |
6 | | - * https://www.eclipse.org/legal/epl-2.0. |
| 2 | + * Copyright (c) 2020, 2022 Christoph Läubrich |
| 3 | + * All rights reserved. This program and the accompanying materials |
| 4 | + * are made available under the terms of the Eclipse Public License v2.0 |
| 5 | + * which accompanies this distribution, and is available at |
| 6 | + * https://www.eclipse.org/legal/epl-v20.html |
7 | 7 | * |
8 | 8 | * SPDX-License-Identifier: EPL-2.0 |
9 | 9 | * |
10 | 10 | * Contributors: |
11 | | - * Christoph Läubrich - initial API and implementation |
| 11 | + * Christoph Läubrich - initial API and implementation |
12 | 12 | *******************************************************************************/ |
13 | 13 | package org.eclipse.m2e.pde.target; |
14 | 14 |
|
15 | 15 | import java.io.File; |
16 | | -import java.util.Objects; |
17 | | -import java.util.jar.JarFile; |
18 | | -import java.util.jar.Manifest; |
19 | 16 |
|
20 | 17 | import org.eclipse.aether.artifact.Artifact; |
21 | 18 | import org.eclipse.equinox.frameworkadmin.BundleInfo; |
22 | | -import org.eclipse.m2e.pde.target.shared.MavenBundleWrapper; |
23 | 19 | import org.eclipse.pde.core.target.TargetBundle; |
24 | 20 |
|
25 | 21 | public class MavenSourceBundle extends TargetBundle { |
26 | 22 |
|
27 | | - public MavenSourceBundle(BundleInfo sourceTarget, Artifact artifact, CacheManager cacheManager) throws Exception { |
| 23 | + public MavenSourceBundle(BundleInfo sourceTarget, Artifact artifact) throws Exception { |
28 | 24 | this.fSourceTarget = sourceTarget; |
29 | | - String symbolicName = sourceTarget.getSymbolicName(); |
30 | | - String version = sourceTarget.getVersion(); |
31 | | - fInfo.setSymbolicName(MavenBundleWrapper.getSourceBundleName(symbolicName)); |
32 | | - fInfo.setVersion(version); |
33 | | - Manifest manifest; |
| 25 | + fInfo.setSymbolicName(sourceTarget.getSymbolicName() + ".source"); |
| 26 | + fInfo.setVersion(sourceTarget.getVersion()); |
34 | 27 | File sourceFile = artifact.getFile(); |
35 | | - try (JarFile jar = new JarFile(sourceFile)) { |
36 | | - manifest = Objects.requireNonNullElseGet(jar.getManifest(), Manifest::new); |
37 | | - } |
38 | | - if (MavenBundleWrapper.isValidSourceManifest(manifest)) { |
39 | | - fInfo.setLocation(sourceFile.toURI()); |
40 | | - } else { |
41 | | - File generatedSourceBundle = cacheManager.accessArtifactFile(artifact, file -> { |
42 | | - if (CacheManager.isOutdated(file, sourceFile)) { |
43 | | - MavenBundleWrapper.addSourceBundleMetadata(manifest, symbolicName, version); |
44 | | - MavenBundleWrapper.transferJarEntries(sourceFile, manifest, file); |
45 | | - } |
46 | | - return file; |
47 | | - }); |
48 | | - fInfo.setLocation(generatedSourceBundle.toURI()); |
49 | | - } |
| 28 | + fInfo.setLocation(sourceFile.toURI()); |
50 | 29 | } |
51 | 30 |
|
52 | | - |
53 | 31 | } |
0 commit comments