diff --git a/tycho-plugins/discovery-utils/.classpath b/tycho-plugins/discovery-utils/.classpath deleted file mode 100644 index 1247f9f..0000000 --- a/tycho-plugins/discovery-utils/.classpath +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/tycho-plugins/discovery-utils/.project b/tycho-plugins/discovery-utils/.project deleted file mode 100644 index 122f41c..0000000 --- a/tycho-plugins/discovery-utils/.project +++ /dev/null @@ -1,23 +0,0 @@ - - - discovery-utils - - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.m2e.core.maven2Builder - - - - - - org.eclipse.jdt.core.javanature - org.eclipse.m2e.core.maven2Nature - - diff --git a/tycho-plugins/discovery-utils/pom.xml b/tycho-plugins/discovery-utils/pom.xml deleted file mode 100644 index 2658e66..0000000 --- a/tycho-plugins/discovery-utils/pom.xml +++ /dev/null @@ -1,60 +0,0 @@ - - - 4.0.0 - org.jboss.tools.tycho-plugins - discovery-utils - maven-plugin - Discovery Utils - Utilities to manage Discovery plugins and repositories - - - org.jboss.tools - tycho-plugins - 2.5.0 - - - - - org.eclipse.tycho - tycho-p2-facade - ${tychoVersion} - - - org.eclipse.tycho - tycho-packaging-plugin - ${tychoVersion} - - - org.eclipse.tycho - tycho-core - ${tychoVersion} - - - net.sf.saxon - saxon - 8.7 - - - net.sf.saxon - saxon-dom - 8.7 - - - com.googlecode.maven-download-plugin - download-maven-plugin - 1.6.7 - - - - diff --git a/tycho-plugins/discovery-utils/src/main/java/org/jboss/tools/tycho/discovery/ExtendListingMojo.java b/tycho-plugins/discovery-utils/src/main/java/org/jboss/tools/tycho/discovery/ExtendListingMojo.java deleted file mode 100644 index 5143fd7..0000000 --- a/tycho-plugins/discovery-utils/src/main/java/org/jboss/tools/tycho/discovery/ExtendListingMojo.java +++ /dev/null @@ -1,114 +0,0 @@ -package org.jboss.tools.tycho.discovery; - -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.net.URL; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Properties; -import java.util.Set; - -import org.apache.commons.io.IOUtils; -import org.apache.maven.plugin.AbstractMojo; -import org.apache.maven.plugin.MojoExecutionException; -import org.apache.maven.plugin.MojoFailureException; -import org.apache.maven.plugins.annotations.LifecyclePhase; -import org.apache.maven.plugins.annotations.Mojo; -import org.apache.maven.plugins.annotations.Parameter; -import org.apache.maven.project.MavenProject; -import org.eclipse.tycho.core.ee.TargetDefinitionFile; -import org.eclipse.tycho.core.ee.TargetDefinitionFile.IULocation; -import org.eclipse.tycho.p2.target.facade.TargetDefinition.Location; -import org.eclipse.tycho.p2.target.facade.TargetDefinition.Unit; - -import de.pdark.decentxml.Document; -import de.pdark.decentxml.Element; -import de.pdark.decentxml.XMLParser; - -@Mojo(name="update-listing", defaultPhase=LifecyclePhase.GENERATE_RESOURCES, requiresProject=false) -public class ExtendListingMojo extends AbstractMojo { - - @Parameter(property = "project") - private MavenProject project; - - @Parameter(property = "targetListingFile", defaultValue = "earlyaccess.properties") - private File targetListingFile; - - @Parameter(property = "targetDefinitionFile", required = true) - private File targetDefinitionFile; - - @Parameter(property = "initialListing", required = false) - private URL initialListingFile; - - public void execute() throws MojoExecutionException, MojoFailureException { - File pluginFile = new File(this.project.getBasedir(), "plugin.xml"); - Set earlyAccessIuIds = new HashSet(); - Document pluginDOM = null; - try { - pluginDOM = XMLParser.parse(pluginFile); - } catch (IOException ex) { - throw new MojoFailureException(ex.getMessage(), ex); - } - - for (Element extensionElement : pluginDOM.getChild("plugin").getChildren("extension")) { - if ("org.eclipse.mylyn.discovery.core.connectorDiscovery".equals(extensionElement.getAttributeValue("point"))) { - for (Element connectorElement : extensionElement.getChildren("connectorDescriptor")) { - if (connectorElement.getAttributeValue("certificationId").toLowerCase().contains("earlyaccess")) { - for (Element iuElement : connectorElement.getChildren("iu")) { - earlyAccessIuIds.add(iuElement.getAttributeValue("id") + ".feature.group"); - } - } - } - } - } - - Map earlyAccessIUsToVersion = new HashMap(); - TargetDefinitionFile file = TargetDefinitionFile.read(this.targetDefinitionFile); - for (Location location : file.getLocations()) { - if (! (location instanceof IULocation)) { - throw new MojoExecutionException("Only p2 IUs location are supported"); - } - IULocation iuLocation = (IULocation)location; - for (Unit unit : iuLocation.getUnits()) { - if (earlyAccessIuIds.contains(unit.getId())) { - earlyAccessIUsToVersion.put(unit.getId(), unit.getVersion()); - } - } - } - Properties listing = new Properties(); - if (this.initialListingFile != null) { - InputStream stream = null; - try { - stream = this.initialListingFile.openStream(); - listing.load(stream); - } catch (Exception ex) { - throw new MojoFailureException(ex.getMessage(), ex); - } finally { - IOUtils.closeQuietly(stream); - } - } - for (Entry entry : earlyAccessIUsToVersion.entrySet()) { - String version = entry.getValue(); - String toVersionRange = "[" + version + "," + version + "]"; - String currentEntry = (String) listing.get(entry.getKey()); - if (currentEntry == null) { - currentEntry = toVersionRange; - } else if (!currentEntry.contains(toVersionRange)) { - currentEntry += ";"; - currentEntry += toVersionRange; - } - listing.put(entry.getKey(), currentEntry); - } - try { - FileOutputStream out = new FileOutputStream(this.targetListingFile); - listing.store(out, null); - } catch (Exception ex) { - throw new MojoFailureException(ex.getMessage(), ex); - } - } - -} diff --git a/tycho-plugins/enforcer-rules/pom.xml b/tycho-plugins/enforcer-rules/pom.xml index 5e576f2..ea90fea 100644 --- a/tycho-plugins/enforcer-rules/pom.xml +++ b/tycho-plugins/enforcer-rules/pom.xml @@ -29,7 +29,7 @@ org.jboss.tools tycho-plugins - 2.5.0 + 2.7.5 @@ -65,7 +65,7 @@ org.codehaus.plexus plexus-container-default - 2.1.0 + 2.1.1 junit diff --git a/tycho-plugins/enforcer-rules/src/main/java/org/jboss/tools/releng/CoreUIDependency.java b/tycho-plugins/enforcer-rules/src/main/java/org/jboss/tools/releng/CoreUIDependency.java index 74c2686..92ae7ea 100644 --- a/tycho-plugins/enforcer-rules/src/main/java/org/jboss/tools/releng/CoreUIDependency.java +++ b/tycho-plugins/enforcer-rules/src/main/java/org/jboss/tools/releng/CoreUIDependency.java @@ -28,6 +28,7 @@ public class CoreUIDependency implements EnforcerRule { private String joinString = "\n > "; + @Override public void execute( EnforcerRuleHelper helper ) throws EnforcerRuleException { Log log = helper.getLog(); try { @@ -46,7 +47,7 @@ public void execute( EnforcerRuleHelper helper ) throws EnforcerRuleException { } Set ui = model.getAllUIDeps(); - String[] uiDeps = (String[]) ui.toArray(new String[ui.size()]); + String[] uiDeps = ui.toArray(new String[ui.size()]); if( uiDeps.length > 0 ) { String msg = "[CoreUIDependency] " + (String)helper.evaluate("${project.artifactId}") + " is a Core plugin, but depends on these UI plugins directly or transitively:" + @@ -264,7 +265,7 @@ private void cacheFolders(File pluginFile, HashMap> map, private void findUIDependencies(ManifestModel mm, Log log, boolean verbose) { String symbolicName = mm.bundleId; List deps = new ArrayList(mm.deps); - String[] asArr = (String[]) deps.toArray(new String[deps.size()]); + String[] asArr = deps.toArray(new String[deps.size()]); if( verbose ) { log.debug("[CoreUIDependency] " + symbolicName + " requires the following units: " + joinString + String.join(joinString, asArr)); } @@ -288,6 +289,7 @@ private void findUIDependencies(ManifestModel mm, Log log, boolean verbose) { * * If your rule is not cacheable, then the result here is not important, you may return anything. */ + @Override public String getCacheId() { //no hash on boolean...only parameter so no hash is needed. @@ -300,6 +302,7 @@ public String getCacheId() * project. This means that even things that change from project to project may still * be cacheable in certain instances. */ + @Override public boolean isCacheable() { return false; @@ -312,6 +315,7 @@ public boolean isCacheable() * by the helper need to be queried. You may for example, store certain objects in your rule * and then query them later. */ + @Override public boolean isResultValid( EnforcerRule arg0 ) { return false; diff --git a/tycho-plugins/enforcer-rules/src/main/java/org/jboss/tools/releng/FoundationCoreVersionMatchesParentPom.java b/tycho-plugins/enforcer-rules/src/main/java/org/jboss/tools/releng/FoundationCoreVersionMatchesParentPom.java index 393950c..2342a2a 100644 --- a/tycho-plugins/enforcer-rules/src/main/java/org/jboss/tools/releng/FoundationCoreVersionMatchesParentPom.java +++ b/tycho-plugins/enforcer-rules/src/main/java/org/jboss/tools/releng/FoundationCoreVersionMatchesParentPom.java @@ -30,6 +30,7 @@ public class FoundationCoreVersionMatchesParentPom private String currentVersionProperties = null; private String requiredQualifier = ".Final"; // or .GA + @Override public void execute( EnforcerRuleHelper helper ) throws EnforcerRuleException { @@ -38,7 +39,7 @@ public void execute( EnforcerRuleHelper helper ) try { MavenProject project = (MavenProject) helper.evaluate( "${project}" ); - String basedir = (String) helper.evaluate( "${project.basedir}" ).toString(); + String basedir = helper.evaluate( "${project.basedir}" ).toString(); Properties projProps = project.getProperties(); Enumeration e = projProps.propertyNames(); @@ -111,6 +112,7 @@ public void execute( EnforcerRuleHelper helper ) * * If your rule is not cacheable, then the result here is not important, you may return anything. */ + @Override public String getCacheId() { //no hash on boolean...only parameter so no hash is needed. @@ -123,6 +125,7 @@ public String getCacheId() * project. This means that even things that change from project to project may still * be cacheable in certain instances. */ + @Override public boolean isCacheable() { return false; @@ -135,6 +138,7 @@ public boolean isCacheable() * by the helper need to be queried. You may for example, store certain objects in your rule * and then query them later. */ + @Override public boolean isResultValid( EnforcerRule arg0 ) { return false; diff --git a/tycho-plugins/enforcer-rules/src/main/java/org/jboss/tools/releng/NoSnapshotsAllowed.java b/tycho-plugins/enforcer-rules/src/main/java/org/jboss/tools/releng/NoSnapshotsAllowed.java index 8344f4e..2c87d69 100644 --- a/tycho-plugins/enforcer-rules/src/main/java/org/jboss/tools/releng/NoSnapshotsAllowed.java +++ b/tycho-plugins/enforcer-rules/src/main/java/org/jboss/tools/releng/NoSnapshotsAllowed.java @@ -28,6 +28,7 @@ public class NoSnapshotsAllowed private String includePattern = ""; private String excludePattern = ""; + @Override public void execute( EnforcerRuleHelper helper ) throws EnforcerRuleException { @@ -104,6 +105,7 @@ public void execute( EnforcerRuleHelper helper ) * * If your rule is not cacheable, then the result here is not important, you may return anything. */ + @Override public String getCacheId() { //no hash on boolean...only parameter so no hash is needed. @@ -116,6 +118,7 @@ public String getCacheId() * project. This means that even things that change from project to project may still * be cacheable in certain instances. */ + @Override public boolean isCacheable() { return false; @@ -128,6 +131,7 @@ public boolean isCacheable() * by the helper need to be queried. You may for example, store certain objects in your rule * and then query them later. */ + @Override public boolean isResultValid( EnforcerRule arg0 ) { return false; diff --git a/tycho-plugins/pom.xml b/tycho-plugins/pom.xml index ca040cd..2f3320d 100644 --- a/tycho-plugins/pom.xml +++ b/tycho-plugins/pom.xml @@ -16,9 +16,9 @@ tycho-plugins pom jbosstools-tycho-plugins-parent - 2.5.0 + 2.7.5 - 2.5.0 + 2.7.5 repository.jboss.org UTF-8 @@ -50,9 +50,7 @@ repository-utils - discovery-utils target-platform-utils - tycho-dependency-plugin enforcer-rules @@ -133,23 +131,23 @@ org.apache.maven maven-plugin-api - 3.8.3 + 3.8.5 org.apache.maven maven-core - 3.8.3 + 3.8.5 org.apache.maven.plugin-tools maven-plugin-annotations - 3.6.1 + 3.6.4 provided org.codehaus.plexus plexus-component-annotations - 2.1.0 + 2.1.1 junit diff --git a/tycho-plugins/repository-utils/.classpath b/tycho-plugins/repository-utils/.classpath index 0725c59..e57399c 100644 --- a/tycho-plugins/repository-utils/.classpath +++ b/tycho-plugins/repository-utils/.classpath @@ -8,9 +8,9 @@ + - @@ -23,15 +23,16 @@ - + + - + diff --git a/tycho-plugins/repository-utils/.settings/org.eclipse.jdt.core.prefs b/tycho-plugins/repository-utils/.settings/org.eclipse.jdt.core.prefs index a3b98fd..ba66320 100644 --- a/tycho-plugins/repository-utils/.settings/org.eclipse.jdt.core.prefs +++ b/tycho-plugins/repository-utils/.settings/org.eclipse.jdt.core.prefs @@ -1,8 +1,16 @@ eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 -org.eclipse.jdt.core.compiler.compliance=1.7 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.methodParameters=generate +org.eclipse.jdt.core.compiler.codegen.targetPlatform=11 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=11 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning -org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore -org.eclipse.jdt.core.compiler.release=disabled -org.eclipse.jdt.core.compiler.source=1.7 +org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning +org.eclipse.jdt.core.compiler.release=enabled +org.eclipse.jdt.core.compiler.source=11 diff --git a/tycho-plugins/repository-utils/pom.xml b/tycho-plugins/repository-utils/pom.xml index c644fc3..664a401 100644 --- a/tycho-plugins/repository-utils/pom.xml +++ b/tycho-plugins/repository-utils/pom.xml @@ -21,7 +21,7 @@ org.jboss.tools tycho-plugins - 2.5.0 + 2.7.5 @@ -58,12 +58,12 @@ com.googlecode.maven-download-plugin download-maven-plugin - 1.6.7 + 1.6.8 org.eclipse.jgit org.eclipse.jgit - 5.13.0.202109080827-r + 6.1.0.202203080745-r diff --git a/tycho-plugins/repository-utils/src/main/java/org/jboss/tools/tycho/sitegenerator/CompareWithBaselineMojo.java b/tycho-plugins/repository-utils/src/main/java/org/jboss/tools/tycho/sitegenerator/CompareWithBaselineMojo.java index e33c5c2..87dc872 100644 --- a/tycho-plugins/repository-utils/src/main/java/org/jboss/tools/tycho/sitegenerator/CompareWithBaselineMojo.java +++ b/tycho-plugins/repository-utils/src/main/java/org/jboss/tools/tycho/sitegenerator/CompareWithBaselineMojo.java @@ -91,7 +91,7 @@ public void execute() throws MojoExecutionException, MojoFailureException { for (String baselineRepo : this.baselines) { baselineTPStub.addP2Repository(toRepoURI(baselineRepo)); } - TargetPlatform baselineTP = resolverFactory.getTargetPlatformFactory().createTargetPlatform(baselineTPStub, TychoProjectUtils.getExecutionEnvironmentConfiguration(reactorProject), null, null); + TargetPlatform baselineTP = resolverFactory.getTargetPlatformFactory().createTargetPlatform(baselineTPStub, TychoProjectUtils.getExecutionEnvironmentConfiguration(reactorProject), null); for (Object item : dependencyMetadata) { try { diff --git a/tycho-plugins/repository-utils/src/main/java/org/jboss/tools/tycho/sitegenerator/CreateFullSiteMojo.java b/tycho-plugins/repository-utils/src/main/java/org/jboss/tools/tycho/sitegenerator/CreateFullSiteMojo.java index efa1ea9..a43c02d 100644 --- a/tycho-plugins/repository-utils/src/main/java/org/jboss/tools/tycho/sitegenerator/CreateFullSiteMojo.java +++ b/tycho-plugins/repository-utils/src/main/java/org/jboss/tools/tycho/sitegenerator/CreateFullSiteMojo.java @@ -97,14 +97,14 @@ private void createRevisionFile(File logs) throws IOException, FileNotFoundExcep Properties revProperties = new Properties(); Ref head = gitRepo.exactRef(Constants.HEAD); revProperties.put(Constants.HEAD, head.getObjectId().getName()); - for (Entry entry : gitRepo.getAllRefs().entrySet()) { - if (entry.getKey().startsWith(Constants.R_REMOTES) && entry.getValue().getObjectId().getName().equals(head.getObjectId().getName())) { - int lastSlashIndex = entry.getKey().lastIndexOf('/'); - String remoteName = entry.getKey().substring(Constants.R_REMOTES.length(), lastSlashIndex); + for (Ref entry : gitRepo.getRefDatabase().getRefs()) { + if (entry.getName().startsWith(Constants.R_REMOTES) && entry.getObjectId().getName().equals(head.getObjectId().getName())) { + int lastSlashIndex = entry.getName().lastIndexOf('/'); + String remoteName = entry.getName().substring(Constants.R_REMOTES.length(), lastSlashIndex); String remoteUrl = gitRepo.getConfig().getString("remote", remoteName, "url"); - String branchName = entry.getKey().substring(lastSlashIndex + 1); + String branchName = entry.getName().substring(lastSlashIndex + 1); revProperties.put(remoteUrl + ":" + branchName, - entry.getValue().getObjectId().getName()); + entry.getObjectId().getName()); } } File gitRevisionFile = new File(logs, "GIT_REVISION.txt"); diff --git a/tycho-plugins/repository-utils/src/main/java/org/jboss/tools/tycho/sitegenerator/GenerateRepositoryFacadeMojo.java b/tycho-plugins/repository-utils/src/main/java/org/jboss/tools/tycho/sitegenerator/GenerateRepositoryFacadeMojo.java index 97d9fdf..46ce68c 100644 --- a/tycho-plugins/repository-utils/src/main/java/org/jboss/tools/tycho/sitegenerator/GenerateRepositoryFacadeMojo.java +++ b/tycho-plugins/repository-utils/src/main/java/org/jboss/tools/tycho/sitegenerator/GenerateRepositoryFacadeMojo.java @@ -225,6 +225,7 @@ private enum ReferenceStrategy { private File categoryFile; + @Override public void execute() throws MojoExecutionException, MojoFailureException { if (!PackagingType.TYPE_ECLIPSE_REPOSITORY.equals(this.project.getPackaging())) { return; @@ -892,13 +893,13 @@ private ModelNode createRevisionObject() throws IOException, FileNotFoundExcepti res.get("currentBranch").set(head.getTarget().getName()); } ModelNode knownReferences = new ModelNode(); - for (Entry entry : gitRepo.getAllRefs().entrySet()) { - if (entry.getKey().startsWith(Constants.R_REMOTES) && entry.getValue().getObjectId().getName().equals(head.getObjectId().getName())) { + for (Ref entry : gitRepo.getRefDatabase().getRefs()) { + if (entry.getName().startsWith(Constants.R_REMOTES) && entry.getObjectId().getName().equals(head.getObjectId().getName())) { ModelNode reference = new ModelNode(); - String remoteName = entry.getKey().substring(Constants.R_REMOTES.length()); + String remoteName = entry.getName().substring(Constants.R_REMOTES.length()); remoteName = remoteName.substring(0, remoteName.indexOf('/')); String remoteUrl = gitRepo.getConfig().getString("remote", remoteName, "url"); - String branchName = entry.getKey().substring(Constants.R_REMOTES.length() + 1 + remoteName.length()); + String branchName = entry.getName().substring(Constants.R_REMOTES.length() + 1 + remoteName.length()); reference.get("name").set(remoteName); reference.get("url").set(remoteUrl); reference.get("ref").set(branchName); diff --git a/tycho-plugins/target-platform-utils/.classpath b/tycho-plugins/target-platform-utils/.classpath index f8bd8df..429a4c2 100644 --- a/tycho-plugins/target-platform-utils/.classpath +++ b/tycho-plugins/target-platform-utils/.classpath @@ -8,9 +8,9 @@ + - @@ -18,8 +18,9 @@ - + + diff --git a/tycho-plugins/target-platform-utils/pom.xml b/tycho-plugins/target-platform-utils/pom.xml index 38fab68..0ef55f5 100644 --- a/tycho-plugins/target-platform-utils/pom.xml +++ b/tycho-plugins/target-platform-utils/pom.xml @@ -15,7 +15,7 @@ org.jboss.tools tycho-plugins - 2.5.0 + 2.7.5 org.jboss.tools.tycho-plugins target-platform-utils @@ -27,7 +27,7 @@ org.apache.maven.plugin-tools maven-plugin-annotations - 3.6.1 + 3.6.4 org.eclipse.tycho diff --git a/tycho-plugins/target-platform-utils/src/main/java/org/jboss/tools/tycho/targets/FixVersionsMojo.java b/tycho-plugins/target-platform-utils/src/main/java/org/jboss/tools/tycho/targets/FixVersionsMojo.java index b833a6a..38c0220 100644 --- a/tycho-plugins/target-platform-utils/src/main/java/org/jboss/tools/tycho/targets/FixVersionsMojo.java +++ b/tycho-plugins/target-platform-utils/src/main/java/org/jboss/tools/tycho/targets/FixVersionsMojo.java @@ -15,6 +15,11 @@ import java.io.FileOutputStream; import java.io.IOException; import java.lang.reflect.Method; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.stream.Collectors; +import java.util.stream.Stream; import org.apache.maven.plugin.AbstractMojo; import org.apache.maven.plugin.MojoExecutionException; @@ -27,7 +32,6 @@ import org.codehaus.plexus.logging.Logger; import org.eclipse.sisu.equinox.EquinoxServiceFactory; import org.eclipse.tycho.artifacts.TargetPlatform; -import org.eclipse.tycho.core.ee.TargetDefinitionFile; import org.eclipse.tycho.core.resolver.shared.MavenRepositoryLocation; import org.eclipse.tycho.osgi.adapters.MavenLoggerAdapter; import org.eclipse.tycho.p2.resolver.facade.P2ResolutionResult; @@ -37,6 +41,7 @@ import org.eclipse.tycho.p2.target.facade.TargetDefinition.Location; import org.eclipse.tycho.p2.target.facade.TargetDefinition.Repository; import org.eclipse.tycho.p2.target.facade.TargetDefinition.Unit; +import org.eclipse.tycho.p2.target.facade.TargetDefinitionFile; import org.eclipse.tycho.p2.target.facade.TargetPlatformConfigurationStub; import org.osgi.framework.Version; @@ -47,19 +52,18 @@ public class FixVersionsMojo extends AbstractMojo { @Parameter(property = "targetFile") - private File targetFile; + private File targetFile; @Parameter(property = "project") - private MavenProject project; + private MavenProject project; - @Component - protected EquinoxServiceFactory equinox; + @Component + protected EquinoxServiceFactory equinox; - @Component - private Logger plexusLogger; + @Component + private Logger plexusLogger; - - @SuppressWarnings("deprecation") + @Override public void execute() throws MojoExecutionException, MojoFailureException { if (this.targetFile == null) { if (this.project != null && this.project.getPackaging().equals("eclipse-target-definition")) { @@ -74,63 +78,57 @@ public void execute() throws MojoExecutionException, MojoFailureException { } File outputFile = new File(targetFile.getParentFile(), targetFile.getName() + "_update_hints.txt"); - FileOutputStream fos = null; try { outputFile.createNewFile(); - fos = new FileOutputStream(outputFile); + try (FileOutputStream fos = new FileOutputStream(outputFile)) { - P2ResolverFactory resolverFactory = this.equinox.getService(P2ResolverFactory.class); - TargetDefinitionFile targetDef; - try { - targetDef = TargetDefinitionFile.read(this.targetFile); - } catch (Exception ex) { - throw new MojoExecutionException(ex.getMessage(), ex); - } - for (Location location : targetDef.getLocations()) { - if (!(location instanceof InstallableUnitLocation)) { - getLog().warn("Location type " + location.getClass().getSimpleName() + " not supported"); - continue; + P2ResolverFactory resolverFactory = this.equinox.getService(P2ResolverFactory.class); + TargetDefinitionFile targetDef; + try { + targetDef = TargetDefinitionFile.read(this.targetFile); + } catch (Exception ex) { + throw new MojoExecutionException(ex.getMessage(), ex); } - InstallableUnitLocation loc = (InstallableUnitLocation) location; - TargetPlatformConfigurationStub tpConfig = new TargetPlatformConfigurationStub(); - for (Repository repo : loc.getRepositories()) { - String id = repo.getId(); - if (repo.getId() == null || repo.getId().isEmpty()) { - id = repo.getLocation().toString(); + for (Location location : targetDef.getLocations()) { + if (!(location instanceof InstallableUnitLocation)) { + getLog().warn("Location type " + location.getClass().getSimpleName() + " not supported"); + continue; + } + InstallableUnitLocation loc = (InstallableUnitLocation) location; + TargetPlatformConfigurationStub tpConfig = new TargetPlatformConfigurationStub(); + for (Repository repo : loc.getRepositories()) { + String id = repo.getId(); + if (repo.getId() == null || repo.getId().isEmpty()) { + id = repo.getLocation().toString(); + } + tpConfig.addP2Repository(new MavenRepositoryLocation(id, repo.getLocation())); } - tpConfig.addP2Repository(new MavenRepositoryLocation(id, repo.getLocation())); - } TargetPlatform site = resolverFactory.getTargetPlatformFactory().createTargetPlatform( - tpConfig, new MockExecutionEnvironment(), null, null); + tpConfig, new MockExecutionEnvironment(), null); P2Resolver resolver = resolverFactory.createResolver(new MavenLoggerAdapter(this.plexusLogger, true)); - for (Unit unit : loc.getUnits()) { - getLog().info("checking " + unit.getId()); - String version = findBestMatchingVersion(site, resolver, unit); - if (!version.equals(unit.getVersion())) { - String message = unit.getId() + " ->" + version; - getLog().info(message); - fos.write(message.getBytes()); - fos.write('\n'); - } - if (unit instanceof TargetDefinitionFile.Unit) { - // That's deprecated, but so cool (and no other way to do it except doing parsing by hand) - ((TargetDefinitionFile.Unit)unit).setVersion(version); + for (Unit unit : loc.getUnits()) { + getLog().info("checking " + unit.getId()); + String version = findBestMatchingVersion(site, resolver, unit); + if (!version.equals(unit.getVersion())) { + String message = unit.getId() + " -> " + version; + getLog().info(message); + fos.write(message.getBytes()); + fos.write('\n'); + } } } + if (outputFile.length() > 0) { + getLog().warn("fix-versions mojo is deprecated and will be removed in next release.\nIf build fails with validation errors, please take a look below for a list of available updated version of bundles:"); + Path path = Paths.get(outputFile.getAbsolutePath()); + try (Stream lines = Files.lines(path)) { + getLog().info(lines.collect(Collectors.joining("\n"))); + } + } + } catch (FileNotFoundException ex) { + throw new MojoExecutionException("Error while opening output file " + outputFile, ex); } - TargetDefinitionFile.write(targetDef, new File(targetFile.getParent(), targetFile.getName() + "_fixedVersion.target")); - } catch (FileNotFoundException ex) { - throw new MojoExecutionException("Error while opening output file " + outputFile, ex); } catch (IOException ex) { throw new MojoExecutionException("Can't write to file " + outputFile, ex); - } finally { - if (fos != null) { - try { - fos.close(); - } catch (Exception ex) { - throw new MojoExecutionException("IO error", ex); - } - } } } @@ -171,7 +169,6 @@ private String toQueryExactVersion(String version) { return "[" + version + "," + version + "]"; } - private String toQueryIgnoreMinor(String version) { Version osgiVersion = new Version(version); StringBuilder res = new StringBuilder(); @@ -194,7 +191,6 @@ private String toQueryIgnoreMicro(String version) { return res.toString(); } - private String toQueryIgnoreQualifier(String version) { Version osgiVersion = new Version(version); StringBuilder res = new StringBuilder(); @@ -206,5 +202,4 @@ private String toQueryIgnoreQualifier(String version) { return res.toString(); } - } diff --git a/tycho-plugins/target-platform-utils/src/main/java/org/jboss/tools/tycho/targets/TargetToRepoMojo.java b/tycho-plugins/target-platform-utils/src/main/java/org/jboss/tools/tycho/targets/TargetToRepoMojo.java index 1d49b9e..923202a 100644 --- a/tycho-plugins/target-platform-utils/src/main/java/org/jboss/tools/tycho/targets/TargetToRepoMojo.java +++ b/tycho-plugins/target-platform-utils/src/main/java/org/jboss/tools/tycho/targets/TargetToRepoMojo.java @@ -36,7 +36,6 @@ import org.eclipse.tycho.DefaultArtifactKey; import org.eclipse.tycho.artifacts.TargetPlatform; import org.eclipse.tycho.core.ee.ExecutionEnvironmentUtils; -import org.eclipse.tycho.core.ee.TargetDefinitionFile; import org.eclipse.tycho.core.ee.shared.ExecutionEnvironment; import org.eclipse.tycho.core.ee.shared.ExecutionEnvironmentConfiguration; import org.eclipse.tycho.core.ee.shared.SystemCapability; @@ -51,6 +50,7 @@ import org.eclipse.tycho.p2.target.facade.TargetDefinition.Location; import org.eclipse.tycho.p2.target.facade.TargetDefinition.Repository; import org.eclipse.tycho.p2.target.facade.TargetDefinition.Unit; +import org.eclipse.tycho.p2.target.facade.TargetDefinitionFile; import org.eclipse.tycho.p2.target.facade.TargetPlatformConfigurationStub; import org.eclipse.tycho.p2.tools.DestinationRepositoryDescriptor; import org.eclipse.tycho.p2.tools.RepositoryReferences; @@ -270,7 +270,7 @@ public boolean ignoreExecutionEnvironment() { } } TargetPlatform sitesTP = this.p2Factory.getTargetPlatformFactory().createTargetPlatform(sites, - new MockExecutionEnvironment(), null, null); + new MockExecutionEnvironment(), null); for (DefaultArtifactKey artifactWithoutSources : artifactsWithoutSources) { String sourceUnitId; if (artifactWithoutSources.getId().endsWith(".feature.jar")) { diff --git a/tycho-plugins/tycho-dependency-plugin/.classpath b/tycho-plugins/tycho-dependency-plugin/.classpath deleted file mode 100644 index f8bd8df..0000000 --- a/tycho-plugins/tycho-dependency-plugin/.classpath +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/tycho-plugins/tycho-dependency-plugin/.project b/tycho-plugins/tycho-dependency-plugin/.project deleted file mode 100644 index 24eeba4..0000000 --- a/tycho-plugins/tycho-dependency-plugin/.project +++ /dev/null @@ -1,23 +0,0 @@ - - - tycho-dependency-plugin - - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.m2e.core.maven2Builder - - - - - - org.eclipse.jdt.core.javanature - org.eclipse.m2e.core.maven2Nature - - diff --git a/tycho-plugins/tycho-dependency-plugin/pom.xml b/tycho-plugins/tycho-dependency-plugin/pom.xml deleted file mode 100644 index c24f414..0000000 --- a/tycho-plugins/tycho-dependency-plugin/pom.xml +++ /dev/null @@ -1,38 +0,0 @@ - - - - 4.0.0 - - org.jboss.tools - tycho-plugins - 2.5.0 - - org.jboss.tools.tycho-plugins - tycho-dependency-plugin - maven-plugin - jbosstools-tycho-dependency-plugin - Mojos to have fun with dependency management in Tycho - - - - org.eclipse.tycho - tycho-p2-facade - ${tychoVersion} - - - org.eclipse.tycho - tycho-p2-publisher-plugin - ${tychoVersion} - - - diff --git a/tycho-plugins/tycho-dependency-plugin/src/main/java/org/jboss/tools/tycho/dependency/CopyDependenciesMojo.java b/tycho-plugins/tycho-dependency-plugin/src/main/java/org/jboss/tools/tycho/dependency/CopyDependenciesMojo.java deleted file mode 100644 index b343f49..0000000 --- a/tycho-plugins/tycho-dependency-plugin/src/main/java/org/jboss/tools/tycho/dependency/CopyDependenciesMojo.java +++ /dev/null @@ -1,85 +0,0 @@ -/** - * Copyright (c) 2013, 2014, Red Hat, Inc. - * Distributed under license by Red Hat, Inc. All rights reserved. - * This program is made available under the terms of the - * Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - * - * Contributor: - * Mickael Istria (Red Hat, Inc.) - initial API and implementation - ******************************************************************************/ -package org.jboss.tools.tycho.dependency; - -import java.io.File; -import java.util.Map; - -import org.apache.maven.execution.MavenSession; -import org.apache.maven.plugin.AbstractMojo; -import org.apache.maven.plugin.MojoExecutionException; -import org.apache.maven.plugin.MojoFailureException; -import org.apache.maven.plugins.annotations.Component; -import org.apache.maven.plugins.annotations.Mojo; -import org.apache.maven.plugins.annotations.Parameter; -import org.apache.maven.project.MavenProject; -import org.codehaus.plexus.util.FileUtils; -import org.eclipse.tycho.core.ArtifactDependencyVisitor; -import org.eclipse.tycho.core.PluginDescription; -import org.eclipse.tycho.core.TychoProject; -import org.eclipse.tycho.core.osgitools.DefaultReactorProject; - -/** - * - * @author mistria - */ -@Mojo(name = "copy-dependencies", requiresProject = true) -public class CopyDependenciesMojo extends AbstractMojo { - - @Parameter(property = "session", readonly = true) - private MavenSession session; - - @Parameter(property = "project", readonly = true) - private MavenProject project; - - @Parameter(property = "outputDir", defaultValue = "${project.build.directory}/dependencies") - private File outputDir; - - @Component(role = TychoProject.class) - private Map projectTypes; - - public void execute() throws MojoExecutionException, MojoFailureException { - TychoProject tychoProject = projectTypes.get(this.project.getPackaging()); - if (tychoProject == null) { - throw new MojoExecutionException("This only applies to Tycho projects"); - } - - if (!this.outputDir.exists()) { - this.outputDir.mkdirs(); - } - final StringBuilder errorBuilder = new StringBuilder(); - tychoProject.getDependencyWalker(DefaultReactorProject.adapt(this.project)).walk(new ArtifactDependencyVisitor() { - @Override - public void visitPlugin(PluginDescription pluginRef) { - try { - File location = pluginRef.getLocation(true); - if (location.isFile()) { - FileUtils.copyFileToDirectory(pluginRef.getLocation(true), outputDir); - } else if (location.isDirectory()) { - if (pluginRef.getMavenProject() != null) { - getLog().warn("Reactor projects not yet supported: " + pluginRef.getMavenProject()); - } else { - getLog().warn("Directory-shaped bundles not yet supported: " + pluginRef.getLocation(true)); - } - } - } catch (Exception ex) { - errorBuilder.append("Couldn't copy " + pluginRef.getLocation(true) + " to " + outputDir); - errorBuilder.append("\n"); - } - } - }); - if (errorBuilder.length() > 0) { - throw new MojoFailureException(errorBuilder.toString()); - } - - } - -}