Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion org.eclipse.m2e.pde.target/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Bundle-Version: 2.1.1.qualifier
Automatic-Module-Name: org.eclipse.m2e.pde.target
Bundle-RequiredExecutionEnvironment: JavaSE-21
Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.27.0,4.0.0)",
org.eclipse.pde.core;bundle-version="3.14.0",
org.eclipse.pde.core;bundle-version="3.16.100",
org.eclipse.equinox.frameworkadmin;bundle-version="2.1.400",
org.eclipse.m2e.maven.runtime;bundle-version="[3.8.0,4.0.0)",
org.eclipse.m2e.core;bundle-version="[2.0.0,3.0.0)",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,53 +1,31 @@
/*******************************************************************************
* Copyright (c) 2020, 2023 Christoph Läubrich and others
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* https://www.eclipse.org/legal/epl-2.0.
* Copyright (c) 2020, 2022 Christoph Läubrich
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-v20.html
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Christoph Läubrich - initial API and implementation
* Christoph Läubrich - initial API and implementation
*******************************************************************************/
package org.eclipse.m2e.pde.target;

import java.io.File;
import java.util.Objects;
import java.util.jar.JarFile;
import java.util.jar.Manifest;

import org.eclipse.aether.artifact.Artifact;
import org.eclipse.equinox.frameworkadmin.BundleInfo;
import org.eclipse.m2e.pde.target.shared.MavenBundleWrapper;
import org.eclipse.pde.core.target.TargetBundle;

public class MavenSourceBundle extends TargetBundle {

public MavenSourceBundle(BundleInfo sourceTarget, Artifact artifact, CacheManager cacheManager) throws Exception {
public MavenSourceBundle(BundleInfo sourceTarget, Artifact artifact) throws Exception {
this.fSourceTarget = sourceTarget;
String symbolicName = sourceTarget.getSymbolicName();
String version = sourceTarget.getVersion();
fInfo.setSymbolicName(MavenBundleWrapper.getSourceBundleName(symbolicName));
fInfo.setVersion(version);
Manifest manifest;
fInfo.setSymbolicName(sourceTarget.getSymbolicName() + ".source");
fInfo.setVersion(sourceTarget.getVersion());
File sourceFile = artifact.getFile();
try (JarFile jar = new JarFile(sourceFile)) {
manifest = Objects.requireNonNullElseGet(jar.getManifest(), Manifest::new);
}
if (MavenBundleWrapper.isValidSourceManifest(manifest)) {
fInfo.setLocation(sourceFile.toURI());
} else {
File generatedSourceBundle = cacheManager.accessArtifactFile(artifact, file -> {
if (CacheManager.isOutdated(file, sourceFile)) {
MavenBundleWrapper.addSourceBundleMetadata(manifest, symbolicName, version);
MavenBundleWrapper.transferJarEntries(sourceFile, manifest, file);
}
return file;
});
fInfo.setLocation(generatedSourceBundle.toURI());
}
fInfo.setLocation(sourceFile.toURI());
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@
String classifier = artifact.getClassifier();
return classifier != null && !classifier.isEmpty();
}

Check warning on line 288 in org.eclipse.m2e.pde.target/src/org/eclipse/m2e/pde/target/MavenTargetLocation.java

View check run for this annotation

Jenkins - M2E / Compiler

Unnecessary Code

NORMAL: Unnecessary @SuppressWarnings("deprecation")
private boolean isPomType(Artifact artifact) {
return POM_PACKAGE_TYPE.equals(artifact.getExtension());
}
Expand Down Expand Up @@ -373,11 +373,10 @@
if (includeSource) {
try {
List<ArtifactRepository> repositories = getAvailableArtifactRepositories(maven);
Artifact sourceArtifact = RepositoryUtils.toArtifact(
maven.resolve(artifact.getGroupId(), artifact.getArtifactId(), artifact.getBaseVersion(),
artifact.getExtension(), "sources", repositories, new NullProgressMonitor()));
MavenSourceBundle sourceBundle = new MavenSourceBundle(bundle.getBundleInfo(), sourceArtifact,
cacheManager);
Artifact sourceArtifact = RepositoryUtils.toArtifact(maven.resolve(artifact.getGroupId(),
artifact.getArtifactId(), artifact.getBaseVersion(), artifact.getExtension(), "sources",
repositories, new NullProgressMonitor()));
MavenSourceBundle sourceBundle = new MavenSourceBundle(bundle.getBundleInfo(), sourceArtifact);
targetBundles.addBundle(sourceArtifact, sourceBundle);
targetBundles.addSourceBundle(artifact, sourceBundle);
} catch (Exception e) {
Expand Down
Loading