Skip to content

Commit bf9b816

Browse files
committed
Do not wrap source bundles
Currently m2e wraps source into new artifacts having performance and space implications and can be confusing because users expect the file to be on a different location. Due to the recent changes in PDE this is no longer required an we can remove this workaround. See eclipse-pde/eclipse.pde#425
1 parent 19c8f09 commit bf9b816

File tree

3 files changed

+15
-38
lines changed

3 files changed

+15
-38
lines changed

org.eclipse.m2e.pde.target/META-INF/MANIFEST.MF

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Bundle-Version: 2.1.1.qualifier
66
Automatic-Module-Name: org.eclipse.m2e.pde.target
77
Bundle-RequiredExecutionEnvironment: JavaSE-21
88
Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.27.0,4.0.0)",
9-
org.eclipse.pde.core;bundle-version="3.14.0",
9+
org.eclipse.pde.core;bundle-version="3.16.100",
1010
org.eclipse.equinox.frameworkadmin;bundle-version="2.1.400",
1111
org.eclipse.m2e.maven.runtime;bundle-version="[3.8.0,4.0.0)",
1212
org.eclipse.m2e.core;bundle-version="[2.0.0,3.0.0)",
Lines changed: 10 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,31 @@
11
/*******************************************************************************
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
77
*
88
* SPDX-License-Identifier: EPL-2.0
99
*
1010
* Contributors:
11-
* Christoph Läubrich - initial API and implementation
11+
* Christoph Läubrich - initial API and implementation
1212
*******************************************************************************/
1313
package org.eclipse.m2e.pde.target;
1414

1515
import java.io.File;
16-
import java.util.Objects;
17-
import java.util.jar.JarFile;
18-
import java.util.jar.Manifest;
1916

2017
import org.eclipse.aether.artifact.Artifact;
2118
import org.eclipse.equinox.frameworkadmin.BundleInfo;
22-
import org.eclipse.m2e.pde.target.shared.MavenBundleWrapper;
2319
import org.eclipse.pde.core.target.TargetBundle;
2420

2521
public class MavenSourceBundle extends TargetBundle {
2622

27-
public MavenSourceBundle(BundleInfo sourceTarget, Artifact artifact, CacheManager cacheManager) throws Exception {
23+
public MavenSourceBundle(BundleInfo sourceTarget, Artifact artifact) throws Exception {
2824
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());
3427
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());
5029
}
5130

52-
5331
}

org.eclipse.m2e.pde.target/src/org/eclipse/m2e/pde/target/MavenTargetLocation.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -360,11 +360,10 @@ private void addBundleForArtifact(Artifact artifact, CacheManager cacheManager,
360360
if (includeSource) {
361361
try {
362362
List<ArtifactRepository> repositories = getAvailableArtifactRepositories(maven);
363-
Artifact sourceArtifact = RepositoryUtils.toArtifact(
364-
maven.resolve(artifact.getGroupId(), artifact.getArtifactId(), artifact.getBaseVersion(),
365-
artifact.getExtension(), "sources", repositories, new NullProgressMonitor()));
366-
MavenSourceBundle sourceBundle = new MavenSourceBundle(bundle.getBundleInfo(), sourceArtifact,
367-
cacheManager);
363+
Artifact resolve = RepositoryUtils.toArtifact(maven.resolve(artifact.getGroupId(),
364+
artifact.getArtifactId(), artifact.getBaseVersion(), artifact.getExtension(), "sources",
365+
repositories, new NullProgressMonitor()));
366+
MavenSourceBundle sourceBundle = new MavenSourceBundle(bundle.getBundleInfo(), resolve);
368367
targetBundles.addBundle(sourceArtifact, sourceBundle);
369368
targetBundles.addSourceBundle(artifact, sourceBundle);
370369
} catch (Exception e) {

0 commit comments

Comments
 (0)