-
Notifications
You must be signed in to change notification settings - Fork 194
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Maintaining a manifest manually and keeping it up-to-date is a cumbersome task. This adds a new mojo that helps to manage traditional manifest first projects by organizing the manifest by updating version bounds and removes obsolete imports.
- Loading branch information
Showing
20 changed files
with
564 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
...pendency-tools-plugin/src/main/java/org/eclipse/tycho/extras/pde/organize/BundleInfo.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 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 accompanies this distribution, and is available at | ||
* https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
*******************************************************************************/ | ||
package org.eclipse.tycho.extras.pde.organize; | ||
|
||
import java.util.jar.Manifest; | ||
|
||
import org.osgi.framework.Constants; | ||
import org.osgi.framework.Version; | ||
|
||
public class BundleInfo { | ||
|
||
private Version version; | ||
private Manifest manifest; | ||
|
||
public BundleInfo(Manifest manifest) { | ||
this.manifest = manifest; | ||
} | ||
|
||
public Manifest manifest() { | ||
return manifest; | ||
} | ||
|
||
public Version version() { | ||
if (version == null) { | ||
String v = manifest().getMainAttributes().getValue(Constants.BUNDLE_VERSION); | ||
if (v == null) { | ||
v = "0"; | ||
} | ||
version = Version.parseVersion(v); | ||
} | ||
return version; | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
...cy-tools-plugin/src/main/java/org/eclipse/tycho/extras/pde/organize/ExportedPackages.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 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 accompanies this distribution, and is available at | ||
* https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
*******************************************************************************/ | ||
package org.eclipse.tycho.extras.pde.organize; | ||
|
||
public class ExportedPackages { | ||
|
||
public ExportedPackages(String manifestValue) { | ||
// TODO Auto-generated constructor stub | ||
} | ||
|
||
} |
59 changes: 59 additions & 0 deletions
59
...ncy-tools-plugin/src/main/java/org/eclipse/tycho/extras/pde/organize/ImportedPackage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 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 accompanies this distribution, and is available at | ||
* https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
*******************************************************************************/ | ||
package org.eclipse.tycho.extras.pde.organize; | ||
|
||
import org.eclipse.equinox.p2.metadata.VersionRange; | ||
import org.osgi.framework.Constants; | ||
|
||
import aQute.bnd.header.Attrs; | ||
|
||
public class ImportedPackage { | ||
|
||
private ImportedPackages packages; | ||
private String packageName; | ||
private Attrs attrs; | ||
private VersionRange version; | ||
|
||
public ImportedPackage(ImportedPackages packages, String packageName, Attrs attrs) { | ||
this.packages = packages; | ||
this.packageName = packageName; | ||
this.attrs = attrs; | ||
} | ||
|
||
public String getPackageName() { | ||
return packageName; | ||
} | ||
|
||
public VersionRange getVersionRange() { | ||
if (version == null) { | ||
String string = attrs.get(Constants.VERSION_ATTRIBUTE); | ||
if (string == null) { | ||
version = VersionRange.emptyRange; | ||
} else { | ||
version = VersionRange.create(string); | ||
} | ||
} | ||
return version; | ||
} | ||
|
||
public boolean isJava() { | ||
return packageName.startsWith("java."); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
VersionRange version = getVersionRange(); | ||
if (version.equals(VersionRange.emptyRange)) { | ||
return getPackageName(); | ||
} | ||
return getPackageName() + " " + getVersionRange(); | ||
} | ||
|
||
} |
40 changes: 40 additions & 0 deletions
40
...cy-tools-plugin/src/main/java/org/eclipse/tycho/extras/pde/organize/ImportedPackages.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 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 accompanies this distribution, and is available at | ||
* https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
*******************************************************************************/ | ||
package org.eclipse.tycho.extras.pde.organize; | ||
|
||
import java.util.Map; | ||
import java.util.Map.Entry; | ||
import java.util.TreeMap; | ||
import java.util.stream.Stream; | ||
|
||
import aQute.bnd.header.Attrs; | ||
import aQute.bnd.header.OSGiHeader; | ||
import aQute.bnd.header.Parameters; | ||
|
||
public class ImportedPackages { | ||
|
||
//import package order is not important so we can sort here by name | ||
private Map<String, ImportedPackage> packages = new TreeMap<>(); | ||
|
||
public ImportedPackages(String manifestValue) { | ||
if (manifestValue != null) { | ||
Parameters header = OSGiHeader.parseHeader(manifestValue); | ||
for (Entry<String, Attrs> entry : header.entrySet()) { | ||
packages.put(entry.getKey(), new ImportedPackage(this, entry.getKey(), entry.getValue())); | ||
} | ||
} | ||
} | ||
|
||
public Stream<ImportedPackage> packages() { | ||
return packages.values().stream(); | ||
|
||
} | ||
|
||
} |
Oops, something went wrong.