From d7575d645e683a766da2631c0385e93304437979 Mon Sep 17 00:00:00 2001 From: Guido Spadotto Date: Sun, 31 Mar 2024 12:03:27 +0200 Subject: [PATCH] Minor refactorings --- .../org/wso2/maven/p2/FeatureArtifact.java | 24 +++--- .../org/wso2/maven/p2/ProfileGenMojo.java | 2 - .../org/wso2/maven/p2/RepositoryGenMojo.java | 7 +- .../p2/generate/feature/FeatureGenMojo.java | 81 +++++++------------ .../p2/generate/utils/FileManagementUtil.java | 6 +- .../maven/p2/generate/utils/MavenUtils.java | 38 ++++----- .../wso2/maven/p2/generate/utils/P2Utils.java | 8 +- .../p2/generate/utils/RepoSystemHolder.java | 50 ++++++++++++ 8 files changed, 121 insertions(+), 95 deletions(-) create mode 100644 carbon-p2-plugin/src/main/java/org/wso2/maven/p2/generate/utils/RepoSystemHolder.java diff --git a/carbon-p2-plugin/src/main/java/org/wso2/maven/p2/FeatureArtifact.java b/carbon-p2-plugin/src/main/java/org/wso2/maven/p2/FeatureArtifact.java index e3f44911..3ea9f77f 100755 --- a/carbon-p2-plugin/src/main/java/org/wso2/maven/p2/FeatureArtifact.java +++ b/carbon-p2-plugin/src/main/java/org/wso2/maven/p2/FeatureArtifact.java @@ -17,7 +17,6 @@ */ package org.wso2.maven.p2; -import java.util.Iterator; import java.util.List; import java.util.Properties; import java.util.regex.Pattern; @@ -91,23 +90,22 @@ public static FeatureArtifact getFeatureArtifact(String featureArtifactDefinitio } public void resolveVersion(MavenProject project) throws MojoExecutionException{ if (version==null){ - List dependencies = project.getDependencies(); - for (Iterator iterator = dependencies.iterator(); iterator.hasNext();) { - Dependency dependancy = (Dependency) iterator.next(); - if (dependancy.getGroupId().equalsIgnoreCase(getGroupId())&&dependancy.getArtifactId().equalsIgnoreCase(getArtifactId())){ - setVersion(dependancy.getVersion()); + //Check direct dependencies + List projectDependencies = project.getDependencies(); + for (Dependency prjDependency : projectDependencies) { + if (prjDependency.getGroupId().equalsIgnoreCase(getGroupId())&&prjDependency.getArtifactId().equalsIgnoreCase(getArtifactId())){ + setVersion(prjDependency.getVersion()); } - } + } if (version==null) { - List dependencies = project.getDependencyManagement().getDependencies(); - for (Iterator iterator = dependencies.iterator(); iterator.hasNext();) { - Dependency dependancy = (Dependency) iterator.next(); - if (dependancy.getGroupId().equalsIgnoreCase(getGroupId())&&dependancy.getArtifactId().equalsIgnoreCase(getArtifactId())){ - setVersion(dependancy.getVersion()); + //Check inherited dependencies + List dependencies = project.getDependencyManagement().getDependencies(); + for (Dependency dmDependency: dependencies) { + if (dmDependency.getGroupId().equalsIgnoreCase(getGroupId())&&dmDependency.getArtifactId().equalsIgnoreCase(getArtifactId())){ + setVersion(dmDependency.getVersion()); } - } } if (version==null) { diff --git a/carbon-p2-plugin/src/main/java/org/wso2/maven/p2/ProfileGenMojo.java b/carbon-p2-plugin/src/main/java/org/wso2/maven/p2/ProfileGenMojo.java index 0a5ca173..4cef4e0d 100755 --- a/carbon-p2-plugin/src/main/java/org/wso2/maven/p2/ProfileGenMojo.java +++ b/carbon-p2-plugin/src/main/java/org/wso2/maven/p2/ProfileGenMojo.java @@ -116,7 +116,6 @@ public void execute() throws MojoExecutionException, MojoFailureException { } createAndSetupPaths(); rewriteEclipseIni(); -// verifySetupP2RepositoryURL(); this.getLog().info("Running Equinox P2 Director Application"); installFeatures(getIUsToInstall()); //updating profile's config.ini p2.data.area property using relative path @@ -130,7 +129,6 @@ public void execute() throws MojoExecutionException, MojoFailureException { } catch (Exception e) { throw new MojoExecutionException(e.getMessage(), e); } -// createArchive(); // deployArtifact(); performMopUp(); } diff --git a/carbon-p2-plugin/src/main/java/org/wso2/maven/p2/RepositoryGenMojo.java b/carbon-p2-plugin/src/main/java/org/wso2/maven/p2/RepositoryGenMojo.java index b32e9e83..4e4591c5 100755 --- a/carbon-p2-plugin/src/main/java/org/wso2/maven/p2/RepositoryGenMojo.java +++ b/carbon-p2-plugin/src/main/java/org/wso2/maven/p2/RepositoryGenMojo.java @@ -45,6 +45,7 @@ import org.wso2.maven.p2.generate.utils.FileManagementUtil; import org.wso2.maven.p2.generate.utils.MavenUtils; import org.wso2.maven.p2.generate.utils.P2Utils; +import org.wso2.maven.p2.generate.utils.RepoSystemHolder; /** * Write environment information for the current build to file. @@ -274,6 +275,7 @@ private List getProcessedFeatureArtifacts() throws MojoExecutio return processedFeatureArtifacts; if (featureArtifacts == null || featureArtifacts.size() == 0) return null; processedFeatureArtifacts = new ArrayList(); + RepoSystemHolder repoRefs = new RepoSystemHolder(repoSystem, repoSession, Stream.concat(remotePluginRepos.stream(), remoteProjectRepos.stream()).collect(Collectors.toList())); Iterator iter = featureArtifacts.iterator(); while (iter.hasNext()) { FeatureArtifact f = null; @@ -287,7 +289,7 @@ private List getProcessedFeatureArtifacts() throws MojoExecutio f = (FeatureArtifact) obj; f.resolveVersion(getProject()); //getLog().info( "Resolving artifact " + f + " from " + remotePluginRepos ); - f.setArtifact(MavenUtils.getResolvedArtifact(getLog(), repoSystem, repoSession, Stream.concat(remotePluginRepos.stream(), remoteProjectRepos.stream()).collect(Collectors.toList()), f)); + f.setArtifact(MavenUtils.getResolvedArtifact(getLog(), repoRefs , f)); processedFeatureArtifacts.add(f); } catch (Exception e) { throw new MojoExecutionException("Error occured when processing the Feature Artifact: " + obj.toString(), e); @@ -310,6 +312,7 @@ private List getProcessedBundleArtifacts() throws MojoExecutionE return processedBundleArtifacts; if (bundleArtifacts == null || bundleArtifacts.size() == 0) return null; processedBundleArtifacts = new ArrayList(); + RepoSystemHolder repoRefs = new RepoSystemHolder(repoSystem, repoSession, Stream.concat(remotePluginRepos.stream(), remoteProjectRepos.stream()).collect(Collectors.toList())); Iterator iter = bundleArtifacts.iterator(); while (iter.hasNext()) { Object obj = iter.next(); @@ -322,7 +325,7 @@ private List getProcessedBundleArtifacts() throws MojoExecutionE f = (BundleArtifact) obj; f.resolveVersion(getProject()); //getLog().info( "Resolving artifact " + f + " from " + remotePluginRepos ); - f.setArtifact(MavenUtils.getResolvedArtifact(repoSystem, repoSession, Stream.concat(remotePluginRepos.stream(), remoteProjectRepos.stream()).collect(Collectors.toList()), f)); + f.setArtifact(MavenUtils.getResolvedArtifact(repoRefs, f)); processedBundleArtifacts.add(f); } return processedBundleArtifacts; diff --git a/carbon-p2-plugin/src/main/java/org/wso2/maven/p2/generate/feature/FeatureGenMojo.java b/carbon-p2-plugin/src/main/java/org/wso2/maven/p2/generate/feature/FeatureGenMojo.java index 0b8c2705..e0ce45ae 100755 --- a/carbon-p2-plugin/src/main/java/org/wso2/maven/p2/generate/feature/FeatureGenMojo.java +++ b/carbon-p2-plugin/src/main/java/org/wso2/maven/p2/generate/feature/FeatureGenMojo.java @@ -68,6 +68,7 @@ import org.wso2.maven.p2.generate.utils.MavenUtils; import org.wso2.maven.p2.generate.utils.P2Utils; import org.wso2.maven.p2.generate.utils.PropertyReplacer; +import org.wso2.maven.p2.generate.utils.RepoSystemHolder; /** * Write environment information for the current build to file. @@ -276,6 +277,7 @@ private ArrayList getProcessedBundlesList() throws MojoExecutionExceptio if (bundles == null || bundles.size() == 0) return null; processedBundles = new ArrayList(); + RepoSystemHolder repoRefs = new RepoSystemHolder(repoSystem, repoSession, Stream.concat(remotePluginRepos.stream(), remoteProjectRepos.stream()).collect(Collectors.toList())); Iterator iter = bundles.iterator(); while (iter.hasNext()) { Object obj = iter.next(); @@ -289,7 +291,7 @@ private ArrayList getProcessedBundlesList() throws MojoExecutionExceptio } else b = (Bundle) obj; b.resolveVersion(project); - b.setArtifact(MavenUtils.getResolvedArtifact(repoSystem, repoSession, Stream.concat(remotePluginRepos.stream(), remoteProjectRepos.stream()).collect(Collectors.toList()), b)); + b.setArtifact(MavenUtils.getResolvedArtifact(repoRefs, b)); processedBundles.add(b); } return processedBundles; @@ -301,6 +303,7 @@ private ArrayList getProcessedImportBundlesList() throws MojoExecu if (importBundles == null || importBundles.size() == 0) return null; processedImportBundles = new ArrayList(); + RepoSystemHolder repoRefs = new RepoSystemHolder(repoSystem, repoSession, Stream.concat(remotePluginRepos.stream(), remoteProjectRepos.stream()).collect(Collectors.toList())); Iterator iter = importBundles.iterator(); while (iter.hasNext()) { Object obj = iter.next(); @@ -315,7 +318,7 @@ private ArrayList getProcessedImportBundlesList() throws MojoExecu b = (ImportBundle) obj; b.resolveVersion(project); if (!b.isExclude()) { - b.setArtifact(MavenUtils.getResolvedArtifact(repoSystem, repoSession, Stream.concat(remotePluginRepos.stream(), remoteProjectRepos.stream()).collect(Collectors.toList()), b)); + b.setArtifact(MavenUtils.getResolvedArtifact(repoRefs, b)); }else b.resolveOSGIInfo(); processedImportBundles.add(b); @@ -353,7 +356,8 @@ private ArrayList getIncludedFeatures() throws MojoExecutionExc if (includedFeatures == null || includedFeatures.size() == 0) return null; - + + RepoSystemHolder repoRefs = new RepoSystemHolder(repoSystem, repoSession, Stream.concat(remotePluginRepos.stream(), remoteProjectRepos.stream()).collect(Collectors.toList())); processedIncludedFeatures = new ArrayList(includedFeatures.size()); for (Object obj : includedFeatures) { if (obj instanceof String) { @@ -362,7 +366,7 @@ private ArrayList getIncludedFeatures() throws MojoExecutionExc includedFeature.setFeatureVersion(project.getVersion()); DefaultArtifact artifact = new DefaultArtifact(includedFeature.getGroupId(), includedFeature.getArtifactId(), org.apache.maven.artifact.Artifact.SCOPE_RUNTIME, "zip", includedFeature.getArtifactVersion()); includedFeature.setArtifact( - MavenUtils.getResolvedArtifact(this.getLog(), repoSystem, repoSession, Stream.concat(remotePluginRepos.stream(), remoteProjectRepos.stream()).collect(Collectors.toList()), artifact)); + MavenUtils.getResolvedArtifact(this.getLog(), repoRefs, artifact)); processedIncludedFeatures.add(includedFeature); } } @@ -585,32 +589,31 @@ private void createManifestMFFile() throws MojoExecutionException { } private void createP2Inf() throws MojoExecutionException { - BufferedWriter out = null; List p2infStringList = null; - try { - ArrayList list = getProcessedAdviceProperties(); - - if (FILE_P2_INF.exists()) { - p2infStringList = readAdviceFile(FILE_P2_INF.getAbsolutePath()); // In memory storage of current p2.inf - // content - getLog().info("Updating Advice file (p2.inf)"); - } else { - getLog().info("Generating Advice file (p2.inf)"); - } + ArrayList list = getProcessedAdviceProperties(); - out = new BufferedWriter(new FileWriter(FILE_P2_INF.getAbsolutePath())); - // re-writing the already availabled p2.inf lines + if (FILE_P2_INF.exists()) { + p2infStringList = readAdviceFile(FILE_P2_INF.getAbsolutePath()); // In memory storage of current p2.inf content + getLog().info("Updating Advice file (p2.inf)"); + } else { + getLog().info("Generating Advice file (p2.inf)"); + } + + try ( //Use try-with-resources to manage autoclosing of writers + FileWriter fw = new FileWriter(FILE_P2_INF.getAbsolutePath()); + BufferedWriter out = new BufferedWriter(fw) + ){ + // re-writing the already available p2.inf lines Properties properties = new Properties(); properties.setProperty("feature.version", Bundle.getOSGIVersion(getVersion())); if (p2infStringList != null && p2infStringList.size() > 0) { for (String str : p2infStringList) { - out.write(PropertyReplacer.replaceProperties(str, properties) + "\n"); // writing the strings after - // replacing - // ${feature.version} + // writing the strings after replacing ${feature.version} + out.write(PropertyReplacer.replaceProperties(str, properties) + "\n"); } } if (list.size() == 0) - return; // finally block will take care of output stream closing. + return; int nextIndex = P2Utils.getLastIndexOfProperties(FILE_P2_INF) + 1; for (Object category : list) { Property cat = (Property) category; @@ -618,45 +621,23 @@ private void createP2Inf() throws MojoExecutionException { out.write("\nproperties." + nextIndex + ".value=" + cat.getValue()); nextIndex++; } - } catch (Exception e) { + } catch (IOException e) { throw new MojoExecutionException("Unable to create/open p2.inf file", e); - } finally { - if (out != null) - try { - out.close(); - } catch (IOException e) { - throw new MojoExecutionException("Unable to finalize p2.inf file", e); - } } - } private List readAdviceFile(String absolutePath) throws MojoExecutionException { - List stringList = new ArrayList(); - String inputLine = null; - BufferedReader br = null; - try { - br = new BufferedReader(new FileReader(absolutePath)); - while ((inputLine = br.readLine()) != null) { - stringList.add(inputLine); - } - br.close(); - + List advices = new ArrayList<>(); + + try (FileReader fr = new FileReader(absolutePath); BufferedReader br = new BufferedReader(fr)){ + br.lines().forEach(advices::add); } catch (FileNotFoundException e) { throw new MojoExecutionException("Unable to create/open p2.inf file", e); } catch (IOException e) { throw new MojoExecutionException("Error while reading from p2.inf file", e); - } finally { - if (br != null) { - try { - br.close(); - } catch (IOException e) { - throw new MojoExecutionException("Unable to finalize p2.inf file", e); - } - } - } + } - return stringList; + return advices; } private ArrayList getMissingImportPlugins(Document document) throws MojoExecutionException { diff --git a/carbon-p2-plugin/src/main/java/org/wso2/maven/p2/generate/utils/FileManagementUtil.java b/carbon-p2-plugin/src/main/java/org/wso2/maven/p2/generate/utils/FileManagementUtil.java index 9bfcfe08..c66b3528 100755 --- a/carbon-p2-plugin/src/main/java/org/wso2/maven/p2/generate/utils/FileManagementUtil.java +++ b/carbon-p2-plugin/src/main/java/org/wso2/maven/p2/generate/utils/FileManagementUtil.java @@ -60,7 +60,7 @@ public static void changeConfigIniProperty(File configIniFile, String propKey, S } } - public static void copyDirectory(File srcPath, File dstPath, List filesToBeCopied) throws IOException{ + public static void copyDirectory(File srcPath, File dstPath, List filesToBeCopied) throws IOException{ if (srcPath.isDirectory()){ if (!dstPath.exists()){ dstPath.mkdir(); @@ -81,8 +81,8 @@ public static void copyDirectory(File srcPath, File dstPath, List filesToBeCopie } } - public static List getAllFilesPresentInFolder(File srcPath){ - List fileList=new ArrayList(); + public static List getAllFilesPresentInFolder(File srcPath){ + List fileList=new ArrayList<>(); if (srcPath.isDirectory()){ String files[] = srcPath.list(); for(int i = 0; i < files.length; i++){ diff --git a/carbon-p2-plugin/src/main/java/org/wso2/maven/p2/generate/utils/MavenUtils.java b/carbon-p2-plugin/src/main/java/org/wso2/maven/p2/generate/utils/MavenUtils.java index 09ec18d2..208364a0 100755 --- a/carbon-p2-plugin/src/main/java/org/wso2/maven/p2/generate/utils/MavenUtils.java +++ b/carbon-p2-plugin/src/main/java/org/wso2/maven/p2/generate/utils/MavenUtils.java @@ -17,22 +17,14 @@ */ package org.wso2.maven.p2.generate.utils; -import java.util.List; - import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.logging.Log; -import org.eclipse.aether.RepositorySystem; -import org.eclipse.aether.RepositorySystemSession; import org.eclipse.aether.artifact.Artifact; import org.eclipse.aether.artifact.DefaultArtifact; -import org.eclipse.aether.repository.LocalArtifactRequest; -import org.eclipse.aether.repository.LocalArtifactResult; -import org.eclipse.aether.repository.LocalRepositoryManager; -import org.eclipse.aether.repository.RemoteRepository; import org.eclipse.aether.resolution.ArtifactRequest; import org.eclipse.aether.resolution.ArtifactResolutionException; import org.eclipse.aether.resolution.ArtifactResult; @@ -43,21 +35,21 @@ public class MavenUtils { - private static Artifact performResolution(Log log, RepositorySystem repoSystem, RepositorySystemSession repoSession, List remoteRepositories, Artifact artifact) throws MojoExecutionException { + private static Artifact performResolution(Log log, RepoSystemHolder repoRefs, Artifact artifact) throws MojoExecutionException { - LocalRepositoryManager lrm = repoSession.getLocalRepositoryManager(); - LocalArtifactRequest localReq = new LocalArtifactRequest(artifact, remoteRepositories, null); - LocalArtifactResult lat = lrm.find(repoSession,localReq); +// LocalRepositoryManager lrm = repoSession.getLocalRepositoryManager(); +// LocalArtifactRequest localReq = new LocalArtifactRequest(artifact, remoteRepositories, null); +// LocalArtifactResult lat = lrm.find(repoSession,localReq); //if (log!=null) log.info("Locally available? "+lat.isAvailable()); ArtifactRequest request = new ArtifactRequest(); - request.setArtifact(artifact).setRepositories(remoteRepositories); + request.setArtifact(artifact).setRepositories(repoRefs.getRemoteRepositories()); //if (log!=null) log.info("Current Artifact Request: "+request); ArtifactResult result = null; try { - result = repoSystem.resolveArtifact( repoSession, request ); + result = repoRefs.getRepoSystem().resolveArtifact( repoRefs.getRepoSession(), request ); } catch (ArtifactResolutionException e) { - log.error("Resolution error: "+e.getMessage()); + if (log!=null) log.error("Resolution error: "+e.getMessage()); throw new MojoExecutionException("ERROR: "+e.getMessage(),e); } //if (log!=null) log.info("result.isResolved() = "+result.isResolved()); @@ -65,23 +57,23 @@ private static Artifact performResolution(Log log, RepositorySystem repoSystem, return result.getArtifact(); } - public static Artifact getResolvedArtifact(RepositorySystem repoSystem, RepositorySystemSession repoSession, List remoteRepositories, Bundle bundle) throws MojoExecutionException{ + public static Artifact getResolvedArtifact(RepoSystemHolder repoRefs, Bundle bundle) throws MojoExecutionException{ Artifact artifact = new DefaultArtifact(bundle.getGroupId(), bundle.getArtifactId(), null /*org.apache.maven.artifact.Artifact.SCOPE_RUNTIME*/, "jar", bundle.getVersion()); - return MavenUtils.performResolution(null, repoSystem, repoSession, remoteRepositories, artifact); + return MavenUtils.performResolution(null, repoRefs, artifact); } - public static Artifact getResolvedArtifact(Log log, RepositorySystem repoSystem, RepositorySystemSession repoSession, List remoteRepositories, FeatureArtifact featureArtifact) throws MojoExecutionException{ + public static Artifact getResolvedArtifact(Log log, RepoSystemHolder repoRefs, FeatureArtifact featureArtifact) throws MojoExecutionException{ Artifact artifact = new DefaultArtifact(featureArtifact.getGroupId(), featureArtifact.getArtifactId(), null /*org.apache.maven.artifact.Artifact.SCOPE_RUNTIME*/, "zip", featureArtifact.getVersion()); - return MavenUtils.performResolution(log, repoSystem, repoSession, remoteRepositories, artifact); + return MavenUtils.performResolution(log, repoRefs, artifact); } - public static Artifact getResolvedArtifact(Log log, RepositorySystem repoSystem, RepositorySystemSession repoSession, List remoteRepositories, P2Profile p2Profile) throws MojoExecutionException{ + public static Artifact getResolvedArtifact(Log log, RepoSystemHolder repoRefs, P2Profile p2Profile) throws MojoExecutionException{ Artifact artifact = new DefaultArtifact(p2Profile.getGroupId(), p2Profile.getArtifactId(), null /*org.apache.maven.artifact.Artifact.SCOPE_RUNTIME*/, "zip", p2Profile.getVersion()); - return MavenUtils.performResolution(log, repoSystem, repoSession, remoteRepositories, artifact); + return MavenUtils.performResolution(log, repoRefs, artifact); } - public static Artifact getResolvedArtifact(Log log, RepositorySystem repoSystem, RepositorySystemSession repoSession, List remoteRepositories, Artifact artifact) throws MojoExecutionException{ - return MavenUtils.performResolution(log, repoSystem, repoSession, remoteRepositories, artifact); + public static Artifact getResolvedArtifact(Log log, RepoSystemHolder repoRefs, Artifact artifact) throws MojoExecutionException{ + return MavenUtils.performResolution(log, repoRefs, artifact); } public static Document getManifestDocument() throws MojoExecutionException { diff --git a/carbon-p2-plugin/src/main/java/org/wso2/maven/p2/generate/utils/P2Utils.java b/carbon-p2-plugin/src/main/java/org/wso2/maven/p2/generate/utils/P2Utils.java index a7f937d1..07067f44 100755 --- a/carbon-p2-plugin/src/main/java/org/wso2/maven/p2/generate/utils/P2Utils.java +++ b/carbon-p2-plugin/src/main/java/org/wso2/maven/p2/generate/utils/P2Utils.java @@ -30,6 +30,8 @@ import java.util.Map; import java.util.jar.JarFile; import java.util.regex.Pattern; +import java.util.stream.Collectors; +import java.util.stream.Stream; import javax.xml.transform.OutputKeys; import javax.xml.transform.Transformer; @@ -82,11 +84,13 @@ public static void setupLauncherLocation(P2Profile p2Profile, File p2LauncherDir throw new MojoExecutionException("Unable to setup p2 launcher location", e); } } - + + //TODO: Where is this static method called from? public static ArrayList getProcessedP2LanucherFiles(ArrayList processedP2LauncherFiles, EquinoxLauncher equinoxLauncher, MavenProject project,RepositorySystem repoSystem, RepositorySystemSession repoSession, List remoteRepositories) throws MojoExecutionException { if (processedP2LauncherFiles != null) return processedP2LauncherFiles; processedP2LauncherFiles = new ArrayList(); + RepoSystemHolder repoRefs = new RepoSystemHolder(repoSystem, repoSession, remoteRepositories); Iterator iter = equinoxLauncher.getLauncherFiles().iterator(); while (iter.hasNext()) { Object obj = iter.next(); @@ -104,7 +108,7 @@ public static ArrayList getProcessedP2LanucherFiles(ArrayList processedP2Launche if (b.getVersion() == null) throw e; } - b.setArtifact(MavenUtils.getResolvedArtifact(repoSystem, repoSession, remoteRepositories, b)); + b.setArtifact(MavenUtils.getResolvedArtifact(repoRefs, b)); processedP2LauncherFiles.add(b); } return processedP2LauncherFiles; diff --git a/carbon-p2-plugin/src/main/java/org/wso2/maven/p2/generate/utils/RepoSystemHolder.java b/carbon-p2-plugin/src/main/java/org/wso2/maven/p2/generate/utils/RepoSystemHolder.java new file mode 100644 index 00000000..cce04103 --- /dev/null +++ b/carbon-p2-plugin/src/main/java/org/wso2/maven/p2/generate/utils/RepoSystemHolder.java @@ -0,0 +1,50 @@ +/* +* Copyright (c) 2005-2011, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. +* +* WSO2 Inc. licenses this file to you under the Apache License, +* Version 2.0 (the "License"); you may not use this file except +* in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, +* software distributed under the License is distributed on an +* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +* KIND, either express or implied. See the License for the +* specific language governing permissions and limitations +* under the License. +*/ +package org.wso2.maven.p2.generate.utils; + +import java.util.List; + +import org.eclipse.aether.RepositorySystem; +import org.eclipse.aether.RepositorySystemSession; +import org.eclipse.aether.repository.RemoteRepository; + +public class RepoSystemHolder { + + private final RepositorySystem repoSystem; + private final RepositorySystemSession repoSession; + private final List remoteRepositories; + + public RepoSystemHolder(RepositorySystem repoSystem, RepositorySystemSession repoSession, List remoteRepositories) { + this.repoSystem = repoSystem; + this.repoSession = repoSession; + this.remoteRepositories = remoteRepositories; + } + + public RepositorySystem getRepoSystem() { + return repoSystem; + } + + public RepositorySystemSession getRepoSession() { + return repoSession; + } + + public List getRemoteRepositories() { + return remoteRepositories; + } + +}