Skip to content

Commit

Permalink
Code clean-up
Browse files Browse the repository at this point in the history
  • Loading branch information
guidospadotto-profesia committed Mar 31, 2024
1 parent d7575d6 commit 8610674
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 36 deletions.
1 change: 1 addition & 0 deletions carbon-p2-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ License. -->
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-plugin-plugin</artifactId>
<version>${maven-plugin-plugin.version}</version>
</dependency>
<dependency>
<groupId>org.apache.maven.plugin-tools</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,6 @@ public class PublishProductMojo extends AbstractMojo {
@Parameter(property = "productConfiguration")
private File productConfigurationFile;

// /**
// * Parsed product configuration file
// */
// private ProductConfiguration productConfiguration;

@Component
private IProvisioningAgent agent;

Expand All @@ -92,31 +87,22 @@ public void execute() throws MojoExecutionException, MojoFailureException {
}
}

private void publishProduct() throws Exception{

//productConfiguration = ProductConfiguration.read( productConfigurationFile );

private void publishProduct() throws Exception{
ProductPublisherApplication application = new ProductPublisherApplication();
Object result = application.run(getPublishProductConfigurations(productConfigurationFile.getCanonicalPath()));
Object result = application.run(getPublishProductConfigurations());
if (result != IApplication.EXIT_OK ) {
throw new MojoFailureException("P2 publisher return code was " + result);
}
}

private String[] getPublishProductConfigurations(String confFileCanonicalPath) throws Exception {
private String[] getPublishProductConfigurations() throws Exception {
String[] result = new String[] {
"-ar",
String.format("%s", metadataRepository.toURI()),
"-mr",
String.format("%s", metadataRepository.toURI()),
"-productFile",
confFileCanonicalPath,
"-executables",
executable.toString(),
"-configs",
"gtk.linux.x86",
"-flavor",
"tooling",
"-ar",String.format("%s", metadataRepository.toURI()),
"-mr",String.format("%s", metadataRepository.toURI()),
"-productFile",productConfigurationFile.getCanonicalPath(),
"-executables",executable.toString(),
"-configs","gtk.linux.x86",
"-flavor","tooling",
"-append"
};
return result;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -367,8 +367,7 @@ private void updateRepositoryWithCategories() throws Exception {
if (!isCategoriesAvailable()) {
return;
} else {
P2Utils.createCategoryFile(getProject(), categories, categoryDefinitionFile,
repoSystem, repoSession, remotePluginRepos /*remoteRepositories*/);
P2Utils.createCategoryFile(getProject(), categories, categoryDefinitionFile);

CategoryPublisherApplication application = new CategoryPublisherApplication();
Object result = application.run(getUpdateRepositoryConfigurations());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,10 @@ public static void setupLauncherLocation(P2Profile p2Profile, File p2LauncherDir
}

//TODO: Where is this static method called from?
public static ArrayList getProcessedP2LanucherFiles(ArrayList processedP2LauncherFiles, EquinoxLauncher equinoxLauncher, MavenProject project,RepositorySystem repoSystem, RepositorySystemSession repoSession, List<RemoteRepository> remoteRepositories) throws MojoExecutionException {
public static ArrayList<Bundle> getProcessedP2LanucherFiles(ArrayList<Bundle> processedP2LauncherFiles, EquinoxLauncher equinoxLauncher, MavenProject project,RepositorySystem repoSystem, RepositorySystemSession repoSession, List<RemoteRepository> remoteRepositories) throws MojoExecutionException {
if (processedP2LauncherFiles != null)
return processedP2LauncherFiles;
processedP2LauncherFiles = new ArrayList();
processedP2LauncherFiles = new ArrayList<Bundle>();
RepoSystemHolder repoRefs = new RepoSystemHolder(repoSystem, repoSession, remoteRepositories);
Iterator iter = equinoxLauncher.getLauncherFiles().iterator();
while (iter.hasNext()) {
Expand Down Expand Up @@ -161,10 +161,11 @@ public static String getEquinoxLauncherJarLocation(File p2AgentDir) throws Excep
}

for (File file : listFiles) {
JarFile jarFile = new JarFile(file);
String symbolicName = jarFile.getManifest().getMainAttributes().getValue(Bundle.BUNDLE_SYMBOLIC_NAME);
if (symbolicName != null && symbolicName.equals("org.eclipse.equinox.launcher")) {
return file.getAbsolutePath();
try (JarFile jarFile = new JarFile(file)){
String symbolicName = jarFile.getManifest().getMainAttributes().getValue(Bundle.BUNDLE_SYMBOLIC_NAME);
if (symbolicName != null && symbolicName.equals("org.eclipse.equinox.launcher")) {
return file.getAbsolutePath();
}
}
}
//launcher jar is not found.
Expand Down Expand Up @@ -195,9 +196,9 @@ public static boolean isPatch(String matchStr){
return matchStr.equalsIgnoreCase("patch");
}

public static void createCategoryFile(MavenProject project, ArrayList categories, File categoryFile, RepositorySystem repoSystem, RepositorySystemSession repoSession, List<RemoteRepository> remoteRepositories )throws Exception {
public static void createCategoryFile(MavenProject project, ArrayList categories, File categoryFile) throws MojoExecutionException {

Map featureCategories=new HashMap();
Map<String, List<CatFeature>> featureCategories=new HashMap<>();

Document doc = MavenUtils.getManifestDocument();
Element rootElement = doc.getDocumentElement();
Expand All @@ -219,13 +220,19 @@ public static void createCategoryFile(MavenProject project, ArrayList categories
categoryDef.appendChild(descriptionElement);
ArrayList<CatFeature> processedFeatures = cat.getProcessedFeatures(project);
for (CatFeature feature : processedFeatures) {
List<CatFeature> list = null;
if (!featureCategories.containsKey(feature.getId()+feature.getVersion())){
ArrayList list = new ArrayList();
//No value for "feature.getId()+feature.getVersion()",
//Add the value as a List containing only the current CatFeature
list = new ArrayList<>();
list.add(feature);
featureCategories.put((feature.getId()+feature.getVersion()), list);
} else {
//Value found for "feature.getId()+feature.getVersion()",
//Add the current CatFeature to the existing CatFeatures
list = featureCategories.get(feature.getId()+feature.getVersion());
list.add(feature);
}
ArrayList list = (ArrayList)featureCategories.get(feature.getId()+feature.getVersion());
list.add(cat.getId());
}
}
}
Expand Down

0 comments on commit 8610674

Please sign in to comment.