diff --git a/Core/de.devboost.buildboost/.classpath b/Core/de.devboost.buildboost/.classpath index ed2bc12..121e527 100644 --- a/Core/de.devboost.buildboost/.classpath +++ b/Core/de.devboost.buildboost/.classpath @@ -1,7 +1,7 @@ - - - - - - - + + + + + + + diff --git a/Core/de.devboost.buildboost/.settings/org.eclipse.jdt.core.prefs b/Core/de.devboost.buildboost/.settings/org.eclipse.jdt.core.prefs index dabc9a9..497d40b 100644 --- a/Core/de.devboost.buildboost/.settings/org.eclipse.jdt.core.prefs +++ b/Core/de.devboost.buildboost/.settings/org.eclipse.jdt.core.prefs @@ -1,12 +1,12 @@ -#Thu Nov 10 23:39:13 CET 2011 -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 -org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.6 -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.enumIdentifier=error -org.eclipse.jdt.core.compiler.source=1.6 +#Thu Nov 10 23:39:13 CET 2011 +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.6 +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.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.6 diff --git a/Core/de.devboost.buildboost/build.properties b/Core/de.devboost.buildboost/build.properties index a12d47e..b107977 100644 --- a/Core/de.devboost.buildboost/build.properties +++ b/Core/de.devboost.buildboost/build.properties @@ -1,3 +1,3 @@ -source.. = src/ -bin.includes = META-INF/,\ - . +source.. = src/ +bin.includes = META-INF/,\ + . diff --git a/Core/de.devboost.buildboost/buildboost_bootstrap.xml b/Core/de.devboost.buildboost/buildboost_bootstrap.xml index 80f68c4..edfe2af 100644 --- a/Core/de.devboost.buildboost/buildboost_bootstrap.xml +++ b/Core/de.devboost.buildboost/buildboost_bootstrap.xml @@ -1,39 +1,39 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Core/de.devboost.buildboost/buildboost_compile_extensions.xml b/Core/de.devboost.buildboost/buildboost_compile_extensions.xml index 4baf2cf..eede7d0 100644 --- a/Core/de.devboost.buildboost/buildboost_compile_extensions.xml +++ b/Core/de.devboost.buildboost/buildboost_compile_extensions.xml @@ -1,20 +1,20 @@ - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + diff --git a/Core/de.devboost.buildboost/buildboost_generate.xml b/Core/de.devboost.buildboost/buildboost_generate.xml index 7feb359..79a6e4e 100644 --- a/Core/de.devboost.buildboost/buildboost_generate.xml +++ b/Core/de.devboost.buildboost/buildboost_generate.xml @@ -1,15 +1,15 @@ - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + diff --git a/Core/de.devboost.buildboost/src/de/devboost/buildboost/ArtifactSorter.java b/Core/de.devboost.buildboost/src/de/devboost/buildboost/ArtifactSorter.java index 527af5a..f0a1139 100644 --- a/Core/de.devboost.buildboost/src/de/devboost/buildboost/ArtifactSorter.java +++ b/Core/de.devboost.buildboost/src/de/devboost/buildboost/ArtifactSorter.java @@ -1,80 +1,80 @@ -/******************************************************************************* - * Copyright (c) 2006-2012 - * Software Technology Group, Dresden University of Technology - * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 - * - * All rights reserved. This program and the accompanying materials - * are 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 - * - * Contributors: - * Software Technology Group - TU Dresden, Germany; - * DevBoost GmbH - Berlin, Germany - * - initial API and implementation - ******************************************************************************/ -package de.devboost.buildboost; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; -import java.util.Set; - -import de.devboost.buildboost.model.AbstractBuildParticipant; -import de.devboost.buildboost.model.BuildEventType; -import de.devboost.buildboost.model.IArtifact; -import de.devboost.buildboost.model.IArtifactDiscoverer; -import de.devboost.buildboost.model.IArtifactFilter; -import de.devboost.buildboost.model.IBuildContext; -import de.devboost.buildboost.model.IBuildListener; -import de.devboost.buildboost.model.IBuildParticipant; -import de.devboost.buildboost.model.IDependable; -import de.devboost.buildboost.util.ArtifactUtil; -import de.devboost.buildboost.util.Sorter; - -public class ArtifactSorter extends AbstractBuildParticipant { - - @Override - public boolean dependsOn(IBuildParticipant otherParticipant) { - if (otherParticipant instanceof DependencyResolver) { - return true; - } - if (otherParticipant instanceof UnresolvedDependencyChecker) { - return true; - } - if (otherParticipant instanceof IArtifactDiscoverer) { - return true; - } - if (otherParticipant instanceof IArtifactFilter) { - return true; - } - return false; - } - - @Override - public void execute(IBuildContext context) throws BuildException { - Collection discoveredArtifacts = context.getDiscoveredArtifacts(); - IBuildListener buildListener = context.getBuildListener(); - Sorter pluginSorter = new Sorter(); - - // exclude dependencies that cannot be included while sorting - Set discoveredDependables = new ArtifactUtil().getSetOfDependables(discoveredArtifacts); - Set transientHull = pluginSorter.getTransientHull(discoveredDependables); - transientHull.removeAll(discoveredArtifacts); - for (IDependable artifact : transientHull) { - buildListener.handleBuildEvent( - BuildEventType.INFO, - "Artifact " + artifact + " is excluded from topological sorting (artifact is a transitive dependency, but was not selected for build)." - ); - } - - // sort artifacts topologically - List sortedArtifacts = pluginSorter.topologicalSort( - new ArrayList(discoveredArtifacts), - transientHull); - - // replace artifacts - context.removeDiscoveredArtifacts(discoveredArtifacts); - context.addDiscoveredArtifacts(new ArtifactUtil().getConcreteList(sortedArtifacts, IArtifact.class)); - } -} +/******************************************************************************* + * Copyright (c) 2006-2012 + * Software Technology Group, Dresden University of Technology + * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 + * + * All rights reserved. This program and the accompanying materials + * are 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 + * + * Contributors: + * Software Technology Group - TU Dresden, Germany; + * DevBoost GmbH - Berlin, Germany + * - initial API and implementation + ******************************************************************************/ +package de.devboost.buildboost; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import java.util.Set; + +import de.devboost.buildboost.model.AbstractBuildParticipant; +import de.devboost.buildboost.model.BuildEventType; +import de.devboost.buildboost.model.IArtifact; +import de.devboost.buildboost.model.IArtifactDiscoverer; +import de.devboost.buildboost.model.IArtifactFilter; +import de.devboost.buildboost.model.IBuildContext; +import de.devboost.buildboost.model.IBuildListener; +import de.devboost.buildboost.model.IBuildParticipant; +import de.devboost.buildboost.model.IDependable; +import de.devboost.buildboost.util.ArtifactUtil; +import de.devboost.buildboost.util.Sorter; + +public class ArtifactSorter extends AbstractBuildParticipant { + + @Override + public boolean dependsOn(IBuildParticipant otherParticipant) { + if (otherParticipant instanceof DependencyResolver) { + return true; + } + if (otherParticipant instanceof UnresolvedDependencyChecker) { + return true; + } + if (otherParticipant instanceof IArtifactDiscoverer) { + return true; + } + if (otherParticipant instanceof IArtifactFilter) { + return true; + } + return false; + } + + @Override + public void execute(IBuildContext context) throws BuildException { + Collection discoveredArtifacts = context.getDiscoveredArtifacts(); + IBuildListener buildListener = context.getBuildListener(); + Sorter pluginSorter = new Sorter(); + + // exclude dependencies that cannot be included while sorting + Set discoveredDependables = new ArtifactUtil().getSetOfDependables(discoveredArtifacts); + Set transientHull = pluginSorter.getTransientHull(discoveredDependables); + transientHull.removeAll(discoveredArtifacts); + for (IDependable artifact : transientHull) { + buildListener.handleBuildEvent( + BuildEventType.INFO, + "Artifact " + artifact + " is excluded from topological sorting (artifact is a transitive dependency, but was not selected for build)." + ); + } + + // sort artifacts topologically + List sortedArtifacts = pluginSorter.topologicalSort( + new ArrayList(discoveredArtifacts), + transientHull); + + // replace artifacts + context.removeDiscoveredArtifacts(discoveredArtifacts); + context.addDiscoveredArtifacts(new ArtifactUtil().getConcreteList(sortedArtifacts, IArtifact.class)); + } +} diff --git a/Core/de.devboost.buildboost/src/de/devboost/buildboost/AutoBuilder.java b/Core/de.devboost.buildboost/src/de/devboost/buildboost/AutoBuilder.java index 6928f8f..a387407 100644 --- a/Core/de.devboost.buildboost/src/de/devboost/buildboost/AutoBuilder.java +++ b/Core/de.devboost.buildboost/src/de/devboost/buildboost/AutoBuilder.java @@ -1,90 +1,90 @@ -/******************************************************************************* - * Copyright (c) 2006-2012 - * Software Technology Group, Dresden University of Technology - * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 - * - * All rights reserved. This program and the accompanying materials - * are 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 - * - * Contributors: - * Software Technology Group - TU Dresden, Germany; - * DevBoost GmbH - Berlin, Germany - * - initial API and implementation - ******************************************************************************/ -package de.devboost.buildboost; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; - -import de.devboost.buildboost.ant.AntTarget; -import de.devboost.buildboost.model.BuildEventType; -import de.devboost.buildboost.model.IArtifact; -import de.devboost.buildboost.model.IBuildContext; -import de.devboost.buildboost.model.IBuildListener; -import de.devboost.buildboost.model.IBuildParticipant; -import de.devboost.buildboost.model.IDependable; -import de.devboost.buildboost.util.ArtifactUtil; -import de.devboost.buildboost.util.Sorter; - -/** - * The {@link AutoBuilder} is a generic builder that can be configured with sets of - * build participants. These participants can search for artifacts that must be - * built and provide respective build scripts. The {@link AutoBuilder} class is the - * main entry point to the BuildBoost system. A typical use of this class is to - * configure an {@link IBuildContext} with appropriate discoverers, filters and - * build step providers, pass this context to the constructor - * {@link #AutoBuilder(IBuildContext)} and call {@link #generateAntTargets()} - * to obtain scripts that implement the build. - * - * Alternatively, one can use build stages, which encapsulate typical - * configurations, for example a discoverer for Eclipse plug-in projects and - * a build step provider that creates a compile script for such projects. The - * use of build stages is recommended, but only applicable if respective stages - * are available. - */ -public class AutoBuilder { - - private IBuildContext context; - - public AutoBuilder(IBuildContext context) { - this.context = context; - } - - public Collection generateAntTargets() throws BuildException { - IBuildListener listener = context.getBuildListener(); - List participants = context.getBuildParticipants(); - participants = sort(participants); - for (IBuildParticipant participant : participants) { - listener.handleBuildEvent(BuildEventType.INFO, "Sorted participant order: " + participant); - } - for (IBuildParticipant participant : participants) { - listener.handleBuildEvent(BuildEventType.INFO, "Executing build participant: " + participant); - participant.execute(context); - } - - Collection targets = new ArrayList(); - Collection discoveredArtifacts = context.getDiscoveredArtifacts(); - for (IArtifact artifact : discoveredArtifacts) { - if (artifact instanceof AntTarget) { - AntTarget antTarget = (AntTarget) artifact; - targets.add(antTarget); - } - } - return targets; - } - - private List sort(List participants) { - List dependables = new ArrayList(); - for (IBuildParticipant participant : participants) { - dependables.add(new DependableBuildParticipant(participant)); - } - for (DependableBuildParticipant dependable : dependables) { - dependable.initializeDependencies(dependables); - } - List sorted = new Sorter().topologicalSort(new ArtifactUtil().getConcreteList(dependables, IDependable.class)); - return new ArtifactUtil().getConcreteList(sorted, IBuildParticipant.class); - } -} +/******************************************************************************* + * Copyright (c) 2006-2012 + * Software Technology Group, Dresden University of Technology + * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 + * + * All rights reserved. This program and the accompanying materials + * are 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 + * + * Contributors: + * Software Technology Group - TU Dresden, Germany; + * DevBoost GmbH - Berlin, Germany + * - initial API and implementation + ******************************************************************************/ +package de.devboost.buildboost; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +import de.devboost.buildboost.ant.AntTarget; +import de.devboost.buildboost.model.BuildEventType; +import de.devboost.buildboost.model.IArtifact; +import de.devboost.buildboost.model.IBuildContext; +import de.devboost.buildboost.model.IBuildListener; +import de.devboost.buildboost.model.IBuildParticipant; +import de.devboost.buildboost.model.IDependable; +import de.devboost.buildboost.util.ArtifactUtil; +import de.devboost.buildboost.util.Sorter; + +/** + * The {@link AutoBuilder} is a generic builder that can be configured with sets of + * build participants. These participants can search for artifacts that must be + * built and provide respective build scripts. The {@link AutoBuilder} class is the + * main entry point to the BuildBoost system. A typical use of this class is to + * configure an {@link IBuildContext} with appropriate discoverers, filters and + * build step providers, pass this context to the constructor + * {@link #AutoBuilder(IBuildContext)} and call {@link #generateAntTargets()} + * to obtain scripts that implement the build. + * + * Alternatively, one can use build stages, which encapsulate typical + * configurations, for example a discoverer for Eclipse plug-in projects and + * a build step provider that creates a compile script for such projects. The + * use of build stages is recommended, but only applicable if respective stages + * are available. + */ +public class AutoBuilder { + + private IBuildContext context; + + public AutoBuilder(IBuildContext context) { + this.context = context; + } + + public Collection generateAntTargets() throws BuildException { + IBuildListener listener = context.getBuildListener(); + List participants = context.getBuildParticipants(); + participants = sort(participants); + for (IBuildParticipant participant : participants) { + listener.handleBuildEvent(BuildEventType.INFO, "Sorted participant order: " + participant); + } + for (IBuildParticipant participant : participants) { + listener.handleBuildEvent(BuildEventType.INFO, "Executing build participant: " + participant); + participant.execute(context); + } + + Collection targets = new ArrayList(); + Collection discoveredArtifacts = context.getDiscoveredArtifacts(); + for (IArtifact artifact : discoveredArtifacts) { + if (artifact instanceof AntTarget) { + AntTarget antTarget = (AntTarget) artifact; + targets.add(antTarget); + } + } + return targets; + } + + private List sort(List participants) { + List dependables = new ArrayList(); + for (IBuildParticipant participant : participants) { + dependables.add(new DependableBuildParticipant(participant)); + } + for (DependableBuildParticipant dependable : dependables) { + dependable.initializeDependencies(dependables); + } + List sorted = new Sorter().topologicalSort(new ArtifactUtil().getConcreteList(dependables, IDependable.class)); + return new ArtifactUtil().getConcreteList(sorted, IBuildParticipant.class); + } +} diff --git a/Core/de.devboost.buildboost/src/de/devboost/buildboost/BuildContext.java b/Core/de.devboost.buildboost/src/de/devboost/buildboost/BuildContext.java index d139eef..392f77d 100644 --- a/Core/de.devboost.buildboost/src/de/devboost/buildboost/BuildContext.java +++ b/Core/de.devboost.buildboost/src/de/devboost/buildboost/BuildContext.java @@ -1,88 +1,97 @@ -/******************************************************************************* - * Copyright (c) 2006-2012 - * Software Technology Group, Dresden University of Technology - * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 - * - * All rights reserved. This program and the accompanying materials - * are 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 - * - * Contributors: - * Software Technology Group - TU Dresden, Germany; - * DevBoost GmbH - Berlin, Germany - * - initial API and implementation - ******************************************************************************/ -package de.devboost.buildboost; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.LinkedHashSet; -import java.util.List; - -import de.devboost.buildboost.ant.AntTargetGeneratorRunner; -import de.devboost.buildboost.model.IArtifact; -import de.devboost.buildboost.model.IBuildContext; -import de.devboost.buildboost.model.IBuildListener; -import de.devboost.buildboost.model.IBuildParticipant; -import de.devboost.buildboost.util.SystemOutListener; - -/** - * A default implementation of the IBuildContext interface. - */ -public class BuildContext implements IBuildContext { - - private Collection discoveredArtifacts = new LinkedHashSet(); - private IBuildListener buildListener; - private boolean ignoreUnresolvedDependencies; - private List buildParticipants = new ArrayList(); - - public BuildContext() { - super(); - // add default participants - addBuildParticipant(new DependencyResolver()); - addBuildParticipant(new UnresolvedDependencyChecker()); - addBuildParticipant(new ArtifactSorter()); - addBuildParticipant(new AntTargetGeneratorRunner()); - } - - public Collection getDiscoveredArtifacts() { - return Collections.unmodifiableCollection(discoveredArtifacts); - } - - public IBuildListener getBuildListener() { - if (buildListener == null) { - buildListener = new SystemOutListener(); - } - return buildListener; - } - - public void setBuildListener(IBuildListener buildListener) { - this.buildListener = buildListener; - } - - public boolean ignoreUnresolvedDependencies() { - return ignoreUnresolvedDependencies; - } - - public void setIgnoreUnresolvedDependencies(boolean ignoreUnresolvedDependencies) { - this.ignoreUnresolvedDependencies = ignoreUnresolvedDependencies; - } - - public void addDiscoveredArtifacts(Collection artifactsToAdd) { - discoveredArtifacts.addAll(artifactsToAdd); - } - - public void removeDiscoveredArtifacts(Collection artifactsToRemove) { - discoveredArtifacts.removeAll(artifactsToRemove); - } - - public void addBuildParticipant(IBuildParticipant participant) { - buildParticipants.add(participant); - } - - public List getBuildParticipants() { - return buildParticipants; - } -} +/******************************************************************************* + * Copyright (c) 2006-2012 + * Software Technology Group, Dresden University of Technology + * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 + * + * All rights reserved. This program and the accompanying materials + * are 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 + * + * Contributors: + * Software Technology Group - TU Dresden, Germany; + * DevBoost GmbH - Berlin, Germany + * - initial API and implementation + ******************************************************************************/ +package de.devboost.buildboost; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.LinkedHashSet; +import java.util.List; + +import de.devboost.buildboost.ant.AntTargetGeneratorRunner; +import de.devboost.buildboost.model.IArtifact; +import de.devboost.buildboost.model.IBuildContext; +import de.devboost.buildboost.model.IBuildListener; +import de.devboost.buildboost.model.IBuildParticipant; +import de.devboost.buildboost.util.SystemOutListener; + +/** + * A default implementation of the IBuildContext interface. + */ +public class BuildContext implements IBuildContext { + + private final Collection discoveredArtifacts = new LinkedHashSet(); + private IBuildListener buildListener; + private boolean ignoreUnresolvedDependencies; + private final List buildParticipants = new ArrayList(); + + public BuildContext() { + super(); + // add default participants + addBuildParticipant(new DependencyResolver()); + addBuildParticipant(new UnresolvedDependencyChecker()); + addBuildParticipant(new ArtifactSorter()); + addBuildParticipant(new AntTargetGeneratorRunner()); + } + + @Override + public Collection getDiscoveredArtifacts() { + return Collections.unmodifiableCollection(discoveredArtifacts); + } + + @Override + public IBuildListener getBuildListener() { + if (buildListener == null) { + buildListener = new SystemOutListener(); + } + return buildListener; + } + + public void setBuildListener(IBuildListener buildListener) { + this.buildListener = buildListener; + } + + @Override + public boolean ignoreUnresolvedDependencies() { + return ignoreUnresolvedDependencies; + } + + public void setIgnoreUnresolvedDependencies( + boolean ignoreUnresolvedDependencies) { + this.ignoreUnresolvedDependencies = ignoreUnresolvedDependencies; + } + + @Override + public void addDiscoveredArtifacts(Collection artifactsToAdd) { + discoveredArtifacts.addAll(artifactsToAdd); + } + + @Override + public void removeDiscoveredArtifacts( + Collection artifactsToRemove) { + discoveredArtifacts.removeAll(artifactsToRemove); + } + + @Override + public void addBuildParticipant(IBuildParticipant participant) { + buildParticipants.add(participant); + } + + @Override + public List getBuildParticipants() { + return buildParticipants; + } +} diff --git a/Core/de.devboost.buildboost/src/de/devboost/buildboost/BuildException.java b/Core/de.devboost.buildboost/src/de/devboost/buildboost/BuildException.java index dd591cb..a978740 100644 --- a/Core/de.devboost.buildboost/src/de/devboost/buildboost/BuildException.java +++ b/Core/de.devboost.buildboost/src/de/devboost/buildboost/BuildException.java @@ -1,30 +1,30 @@ -/******************************************************************************* - * Copyright (c) 2006-2012 - * Software Technology Group, Dresden University of Technology - * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 - * - * All rights reserved. This program and the accompanying materials - * are 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 - * - * Contributors: - * Software Technology Group - TU Dresden, Germany; - * DevBoost GmbH - Berlin, Germany - * - initial API and implementation - ******************************************************************************/ -package de.devboost.buildboost; - -/** - * A {@link BuildException} can be thrown be participants of the BuildBoost - * script generation process if unexpected situations are detected (e.g. - * required artifacts are missing). - */ -public class BuildException extends Exception { - - private static final long serialVersionUID = 6725403464736524958L; - - public BuildException(String message) { - super(message); - } -} +/******************************************************************************* + * Copyright (c) 2006-2012 + * Software Technology Group, Dresden University of Technology + * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 + * + * All rights reserved. This program and the accompanying materials + * are 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 + * + * Contributors: + * Software Technology Group - TU Dresden, Germany; + * DevBoost GmbH - Berlin, Germany + * - initial API and implementation + ******************************************************************************/ +package de.devboost.buildboost; + +/** + * A {@link BuildException} can be thrown be participants of the BuildBoost + * script generation process if unexpected situations are detected (e.g. + * required artifacts are missing). + */ +public class BuildException extends Exception { + + private static final long serialVersionUID = 6725403464736524958L; + + public BuildException(String message) { + super(message); + } +} diff --git a/Core/de.devboost.buildboost/src/de/devboost/buildboost/BuildScriptGenerator.java b/Core/de.devboost.buildboost/src/de/devboost/buildboost/BuildScriptGenerator.java index 9fa6b11..53ee87a 100644 --- a/Core/de.devboost.buildboost/src/de/devboost/buildboost/BuildScriptGenerator.java +++ b/Core/de.devboost.buildboost/src/de/devboost/buildboost/BuildScriptGenerator.java @@ -1,204 +1,204 @@ -/******************************************************************************* - * Copyright (c) 2006-2012 - * Software Technology Group, Dresden University of Technology - * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 - * - * All rights reserved. This program and the accompanying materials - * are 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 - * - * Contributors: - * Software Technology Group - TU Dresden, Germany; - * DevBoost GmbH - Berlin, Germany - * - initial API and implementation - ******************************************************************************/ -package de.devboost.buildboost; - -import static de.devboost.buildboost.IConstants.ARTIFACTS_FOLDER; -import static de.devboost.buildboost.IConstants.BUILD_BOOST_BIN_FOLDER; -import static de.devboost.buildboost.IConstants.BUILD_BOOST_BUILD_PROJECT_ID_PATTERN; -import static de.devboost.buildboost.IConstants.BUILD_BOOST_CORE_PROJECT_ID; -import static de.devboost.buildboost.IConstants.BUILD_BOOST_GENEXT_PROJECT_ID_PATTERN; -import static de.devboost.buildboost.IConstants.BUILD_FOLDER; -import static de.devboost.buildboost.IConstants.REPOS_FOLDER; - -import java.io.File; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.List; -import java.util.Set; - -import de.devboost.buildboost.ant.AbstractAntTargetGenerator; -import de.devboost.buildboost.ant.AbstractAntTargetGeneratorProvider; -import de.devboost.buildboost.ant.AntScript; -import de.devboost.buildboost.ant.AntTarget; -import de.devboost.buildboost.ant.IAntTargetGenerator; -import de.devboost.buildboost.artifacts.Plugin; -import de.devboost.buildboost.discovery.PluginFinder; -import de.devboost.buildboost.filters.IdentifierFilter; -import de.devboost.buildboost.filters.IdentifierRegexFilter; -import de.devboost.buildboost.filters.OrFilter; -import de.devboost.buildboost.model.IArtifact; -import de.devboost.buildboost.model.IBuildConfiguration; -import de.devboost.buildboost.model.IBuildContext; -import de.devboost.buildboost.model.IBuildParticipant; -import de.devboost.buildboost.model.IBuildStage; -import de.devboost.buildboost.stages.AbstractBuildStage; -import de.devboost.buildboost.stages.CloneRepositoriesStage; -import de.devboost.buildboost.stages.CompileStage; -import de.devboost.buildboost.stages.CopyProjectsStage; -import de.devboost.buildboost.util.XMLContent; - -public class BuildScriptGenerator implements IBuildConfiguration { - - private class MergeBootstrapBinariesStage extends AbstractBuildStage { - - private String sourcePath; - private String buildBoostBinDir; - - public MergeBootstrapBinariesStage(String sourcePath, String buildBoostBinDir) { - super(); - this.sourcePath = sourcePath; - this.buildBoostBinDir = buildBoostBinDir; - } - - @Override - public AntScript getScript() throws BuildException { - File buildDir = new File(sourcePath); - - BuildContext context = createContext(true); - context.addBuildParticipant(new PluginFinder(buildDir)); - - context.addBuildParticipant(new MergeBinariesStepProvider(buildBoostBinDir)); - AutoBuilder builder = new AutoBuilder(context); - - AntScript script = new AntScript(); - script.setName("Merge bootstrapped binaries"); - script.addTargets(builder.generateAntTargets()); - - return script; - } - } - - private class MergeBinariesStepProvider extends AbstractAntTargetGeneratorProvider { - - private String buildBoostBinDir; - - public MergeBinariesStepProvider(String buildBoostBinDir) { - this.buildBoostBinDir = buildBoostBinDir; - } - - @Override - public List getAntTargetGenerators(IBuildContext context, - IArtifact artifact) { - if (artifact instanceof Plugin) { - Plugin plugin = (Plugin) artifact; - if (plugin.isProject()) { - List steps = new ArrayList(); - steps.add(new MergeBinariesStep(plugin, buildBoostBinDir)); - return steps; - } - } - return Collections.emptyList(); - } - } - - private class MergeBinariesStep extends AbstractAntTargetGenerator { - - private Plugin plugin; - private String buildBoostBinDir; - - public MergeBinariesStep(Plugin plugin, String buildBoostBinDir) { - this.plugin = plugin; - this.buildBoostBinDir = buildBoostBinDir; - } - - @Override - public Collection generateAntTargets() throws BuildException { - XMLContent content = new XMLContent(); - Set dependencies = plugin.getAllDependencies(); - content.append(""); - copyToSharedBinFolder(content, plugin); - for (Plugin dependency : dependencies) { - copyToSharedBinFolder(content, dependency); - } - - String identifier = plugin.getIdentifier(); - AntTarget target = new AntTarget("merge-bin-" + identifier, content); - return Collections.singleton(target); - } - - private void copyToSharedBinFolder(XMLContent content, Plugin plugin) { - File pluginFile = plugin.getFile(); - File binFolder; - File tempDir = new File(buildBoostBinDir, "temp"); - if (!plugin.isProject()) { - content.append(""); - content.append(""); - binFolder = tempDir; - } else { - binFolder = pluginFile; - } - content.append(""); - content.append(""); - content.append(""); - - Set libs = plugin.getLibs(); - for (String lib : libs) { - if (plugin.isProject()) { - String absoluteLibPath = plugin.getAbsoluteLibPath(lib); - content.append(""); - } else { - content.append(""); - } - } - content.append(""); - } - } - - @Override - public List getBuildStages(String workspace) { - File buildFolder = new File(workspace, BUILD_FOLDER); - File buildBoostBinFolder = new File(buildFolder, BUILD_BOOST_BIN_FOLDER); - File reposFolder = new File(workspace, REPOS_FOLDER); - File artifactsFolder = new File(buildFolder, ARTIFACTS_FOLDER); - - List stages = new ArrayList(); - - CloneRepositoriesStage stage1 = new CloneRepositoriesStage(); - stage1.setReposFolder(reposFolder.getAbsolutePath()); - - //update a second time, since the first update might have revealed new boost files - CloneRepositoriesStage stage2 = new CloneRepositoriesStage(); - stage2.setReposFolder(reposFolder.getAbsolutePath()); - - CopyProjectsStage stage3 = new CopyProjectsStage(); - stage3.setReposFolder(reposFolder.getAbsolutePath()); - stage3.setArtifactsFolder(artifactsFolder.getAbsolutePath()); - stage3.addBuildParticipant(createFilter()); - - CompileStage stage4 = new CompileStage(); - stage4.setArtifactsFolder(artifactsFolder.getAbsolutePath()); - stage4.addBuildParticipant(createFilter()); - - MergeBootstrapBinariesStage stage5 = new MergeBootstrapBinariesStage( - artifactsFolder.getAbsolutePath(), buildBoostBinFolder.getAbsolutePath()); - stage5.addBuildParticipant(createFilter()); - - stages.add(stage1); - stages.add(stage2); - stages.add(stage3); - stages.add(stage4); - stages.add(stage5); - return stages; - } - - private IBuildParticipant createFilter() { - IdentifierFilter filter1 = new IdentifierFilter(BUILD_BOOST_CORE_PROJECT_ID); - IdentifierRegexFilter filter2 = new IdentifierRegexFilter(BUILD_BOOST_GENEXT_PROJECT_ID_PATTERN); - IdentifierRegexFilter filter3 = new IdentifierRegexFilter(BUILD_BOOST_BUILD_PROJECT_ID_PATTERN); - return new OrFilter(filter1, filter2, filter3); - } -} +/******************************************************************************* + * Copyright (c) 2006-2012 + * Software Technology Group, Dresden University of Technology + * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 + * + * All rights reserved. This program and the accompanying materials + * are 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 + * + * Contributors: + * Software Technology Group - TU Dresden, Germany; + * DevBoost GmbH - Berlin, Germany + * - initial API and implementation + ******************************************************************************/ +package de.devboost.buildboost; + +import static de.devboost.buildboost.IConstants.ARTIFACTS_FOLDER; +import static de.devboost.buildboost.IConstants.BUILD_BOOST_BIN_FOLDER; +import static de.devboost.buildboost.IConstants.BUILD_BOOST_BUILD_PROJECT_ID_PATTERN; +import static de.devboost.buildboost.IConstants.BUILD_BOOST_CORE_PROJECT_ID; +import static de.devboost.buildboost.IConstants.BUILD_BOOST_GENEXT_PROJECT_ID_PATTERN; +import static de.devboost.buildboost.IConstants.BUILD_FOLDER; +import static de.devboost.buildboost.IConstants.REPOS_FOLDER; + +import java.io.File; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.List; +import java.util.Set; + +import de.devboost.buildboost.ant.AbstractAntTargetGenerator; +import de.devboost.buildboost.ant.AbstractAntTargetGeneratorProvider; +import de.devboost.buildboost.ant.AntScript; +import de.devboost.buildboost.ant.AntTarget; +import de.devboost.buildboost.ant.IAntTargetGenerator; +import de.devboost.buildboost.artifacts.Plugin; +import de.devboost.buildboost.discovery.PluginFinder; +import de.devboost.buildboost.filters.IdentifierFilter; +import de.devboost.buildboost.filters.IdentifierRegexFilter; +import de.devboost.buildboost.filters.OrFilter; +import de.devboost.buildboost.model.IArtifact; +import de.devboost.buildboost.model.IBuildConfiguration; +import de.devboost.buildboost.model.IBuildContext; +import de.devboost.buildboost.model.IBuildParticipant; +import de.devboost.buildboost.model.IBuildStage; +import de.devboost.buildboost.stages.AbstractBuildStage; +import de.devboost.buildboost.stages.CloneRepositoriesStage; +import de.devboost.buildboost.stages.CompileStage; +import de.devboost.buildboost.stages.CopyProjectsStage; +import de.devboost.buildboost.util.XMLContent; + +public class BuildScriptGenerator implements IBuildConfiguration { + + private class MergeBootstrapBinariesStage extends AbstractBuildStage { + + private String sourcePath; + private String buildBoostBinDir; + + public MergeBootstrapBinariesStage(String sourcePath, String buildBoostBinDir) { + super(); + this.sourcePath = sourcePath; + this.buildBoostBinDir = buildBoostBinDir; + } + + @Override + public AntScript getScript() throws BuildException { + File buildDir = new File(sourcePath); + + BuildContext context = createContext(true); + context.addBuildParticipant(new PluginFinder(buildDir)); + + context.addBuildParticipant(new MergeBinariesStepProvider(buildBoostBinDir)); + AutoBuilder builder = new AutoBuilder(context); + + AntScript script = new AntScript(); + script.setName("Merge bootstrapped binaries"); + script.addTargets(builder.generateAntTargets()); + + return script; + } + } + + private class MergeBinariesStepProvider extends AbstractAntTargetGeneratorProvider { + + private String buildBoostBinDir; + + public MergeBinariesStepProvider(String buildBoostBinDir) { + this.buildBoostBinDir = buildBoostBinDir; + } + + @Override + public List getAntTargetGenerators(IBuildContext context, + IArtifact artifact) { + if (artifact instanceof Plugin) { + Plugin plugin = (Plugin) artifact; + if (plugin.isProject()) { + List steps = new ArrayList(); + steps.add(new MergeBinariesStep(plugin, buildBoostBinDir)); + return steps; + } + } + return Collections.emptyList(); + } + } + + private class MergeBinariesStep extends AbstractAntTargetGenerator { + + private Plugin plugin; + private String buildBoostBinDir; + + public MergeBinariesStep(Plugin plugin, String buildBoostBinDir) { + this.plugin = plugin; + this.buildBoostBinDir = buildBoostBinDir; + } + + @Override + public Collection generateAntTargets() throws BuildException { + XMLContent content = new XMLContent(); + Set dependencies = plugin.getAllDependencies(); + content.append(""); + copyToSharedBinFolder(content, plugin); + for (Plugin dependency : dependencies) { + copyToSharedBinFolder(content, dependency); + } + + String identifier = plugin.getIdentifier(); + AntTarget target = new AntTarget("merge-bin-" + identifier, content); + return Collections.singleton(target); + } + + private void copyToSharedBinFolder(XMLContent content, Plugin plugin) { + File pluginFile = plugin.getFile(); + File binFolder; + File tempDir = new File(buildBoostBinDir, "temp"); + if (!plugin.isProject()) { + content.append(""); + content.append(""); + binFolder = tempDir; + } else { + binFolder = pluginFile; + } + content.append(""); + content.append(""); + content.append(""); + + Set libs = plugin.getLibs(); + for (String lib : libs) { + if (plugin.isProject()) { + String absoluteLibPath = plugin.getAbsoluteLibPath(lib); + content.append(""); + } else { + content.append(""); + } + } + content.append(""); + } + } + + @Override + public List getBuildStages(String workspace) { + File buildFolder = new File(workspace, BUILD_FOLDER); + File buildBoostBinFolder = new File(buildFolder, BUILD_BOOST_BIN_FOLDER); + File reposFolder = new File(workspace, REPOS_FOLDER); + File artifactsFolder = new File(buildFolder, ARTIFACTS_FOLDER); + + List stages = new ArrayList(); + + CloneRepositoriesStage stage1 = new CloneRepositoriesStage(); + stage1.setReposFolder(reposFolder.getAbsolutePath()); + + //update a second time, since the first update might have revealed new boost files + CloneRepositoriesStage stage2 = new CloneRepositoriesStage(); + stage2.setReposFolder(reposFolder.getAbsolutePath()); + + CopyProjectsStage stage3 = new CopyProjectsStage(); + stage3.setReposFolder(reposFolder.getAbsolutePath()); + stage3.setArtifactsFolder(artifactsFolder.getAbsolutePath()); + stage3.addBuildParticipant(createFilter()); + + CompileStage stage4 = new CompileStage(); + stage4.setArtifactsFolder(artifactsFolder.getAbsolutePath()); + stage4.addBuildParticipant(createFilter()); + + MergeBootstrapBinariesStage stage5 = new MergeBootstrapBinariesStage( + artifactsFolder.getAbsolutePath(), buildBoostBinFolder.getAbsolutePath()); + stage5.addBuildParticipant(createFilter()); + + stages.add(stage1); + stages.add(stage2); + stages.add(stage3); + stages.add(stage4); + stages.add(stage5); + return stages; + } + + private IBuildParticipant createFilter() { + IdentifierFilter filter1 = new IdentifierFilter(BUILD_BOOST_CORE_PROJECT_ID); + IdentifierRegexFilter filter2 = new IdentifierRegexFilter(BUILD_BOOST_GENEXT_PROJECT_ID_PATTERN); + IdentifierRegexFilter filter3 = new IdentifierRegexFilter(BUILD_BOOST_BUILD_PROJECT_ID_PATTERN); + return new OrFilter(filter1, filter2, filter3); + } +} diff --git a/Core/de.devboost.buildboost/src/de/devboost/buildboost/BuildScriptGeneratorRunner.java b/Core/de.devboost.buildboost/src/de/devboost/buildboost/BuildScriptGeneratorRunner.java index 4f8735a..0bb9dd5 100644 --- a/Core/de.devboost.buildboost/src/de/devboost/buildboost/BuildScriptGeneratorRunner.java +++ b/Core/de.devboost.buildboost/src/de/devboost/buildboost/BuildScriptGeneratorRunner.java @@ -1,161 +1,161 @@ -/******************************************************************************* - * Copyright (c) 2006-2012 - * Software Technology Group, Dresden University of Technology - * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 - * - * All rights reserved. This program and the accompanying materials - * are 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 - * - * Contributors: - * Software Technology Group - TU Dresden, Germany; - * DevBoost GmbH - Berlin, Germany - * - initial API and implementation - ******************************************************************************/ -package de.devboost.buildboost; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileWriter; -import java.io.IOException; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.util.List; - -import de.devboost.buildboost.model.IBuildConfiguration; -import de.devboost.buildboost.model.IBuildStage; -import de.devboost.buildboost.util.ScriptSaver; -import de.devboost.buildboost.util.StreamUtil; - -public class BuildScriptGeneratorRunner { - - public static void main(String[] args) throws BuildException { - if (args.length < 2) { - System.out.println("Wrong call to BuildScriptGeneratorRunner.main()."); - System.out.println("Usage: BuildScriptGeneratorRunner.main(pathToWorkspace, classToRun)."); - System.exit(1); - return; - } - new BuildScriptGeneratorRunner().run(args); - } - - private void run(String[] args) throws BuildException { - String workspace = args[0]; - String classToRun = args[1]; - File stageFile = getStageFile(workspace); - String stage = readLastStage(stageFile); - int stageNumber = Integer.parseInt(stage); - writeNextStage(stageFile, stageNumber); - - Class clazzToRun = loadClassToRun(classToRun); - - System.out.println("BuildScriptGeneratorRunner.run() stageNumber = " + stageNumber); - System.out.println("BuildScriptGeneratorRunner.run() clazzToRun = " + clazzToRun.getName()); - Class[] interfaces = clazzToRun.getInterfaces(); - for (Class nextInterface : interfaces) { - System.out.println("BuildScriptGeneratorRunner.run() implemented interface: " + nextInterface.getName()); - } - - boolean isBuildConfiguration = IBuildConfiguration.class.isAssignableFrom(clazzToRun); - if (isBuildConfiguration) { - // instantiate and call via interface - callViaInterface(clazzToRun, workspace, stageNumber); - } else { - // call main method (for backward compatibility) - callMainMethod(clazzToRun, args); - } - } - - private File getStageFile(String workspace) { - return new File(new File(workspace, "build"), "current_stage"); - } - - private Class loadClassToRun(String classToRun) throws BuildException { - Class clazzToRun; - try { - clazzToRun = Class.forName(classToRun); - } catch (ClassNotFoundException e) { - e.printStackTrace(); - throw new BuildException("Can't find class " + classToRun); - } - return clazzToRun; - } - - private void callViaInterface(Class clazzToRun, String workspace, int stageNumber) throws BuildException { - try { - Object newInstance = clazzToRun.newInstance(); - IBuildConfiguration configuration = (IBuildConfiguration) newInstance; - List buildStages = configuration.getBuildStages(workspace); - IBuildStage currentStage = buildStages.get(stageNumber - 1); - String buildDir = workspace + File.separator + "build"; - ScriptSaver scriptSaver = new ScriptSaver(); - File targetDir = new File(buildDir); - scriptSaver.saveStage(targetDir, currentStage, scriptSaver.getStageFileName(stageNumber)); - scriptSaver.saveMasterScript(targetDir, buildStages); - // if this is the last stage, we must remove the 'current_stage' stage file, because - // otherwise subsequent builds will not start at the first stage. this particularly - // applies to the bootstrapping build. - if (stageNumber == buildStages.size()) { - File stageFile = getStageFile(workspace); - stageFile.delete(); - } - } catch (InstantiationException e) { - e.printStackTrace(); - throw new BuildException("Can't instantiate class " + clazzToRun.getName()); - } catch (IllegalAccessException e) { - e.printStackTrace(); - throw new BuildException("Can't access class " + clazzToRun.getName()); - } - } - - private void callMainMethod(Class clazzToRun, String[] args) throws BuildException { - Method mainMethod; - try { - mainMethod = clazzToRun.getMethod("main", String[].class); - } catch (SecurityException e) { - e.printStackTrace(); - throw new BuildException("Can't access method main() in class " + clazzToRun.getName()); - } catch (NoSuchMethodException e) { - e.printStackTrace(); - throw new BuildException("Can't find method main() in class " + clazzToRun.getName()); - } - - try { - mainMethod.invoke(null, (Object) args); - } catch (IllegalArgumentException e) { - e.printStackTrace(); - throw new BuildException("Can't invoke main method in class " + clazzToRun.getName()); - } catch (IllegalAccessException e) { - e.printStackTrace(); - throw new BuildException("Can't invoke main method in class " + clazzToRun.getName()); - } catch (InvocationTargetException e) { - e.printStackTrace(); - throw new BuildException("Can't invoke main method in class " + clazzToRun.getName()); - } - } - - private void writeNextStage(File stageFile, int stageNumber) throws BuildException { - try { - FileWriter writer = new FileWriter(stageFile); - writer.write(Integer.toString(stageNumber + 1)); - writer.close(); - } catch (IOException ioe) { - throw new BuildException("Can't write stage file (" + ioe.getMessage() + ")."); - } - } - - private String readLastStage(File stageFile) throws BuildException { - if (stageFile.exists()) { - try { - FileInputStream fis = new FileInputStream(stageFile); - String stage = new StreamUtil().getContentAsString(fis); - fis.close(); - return stage; - } catch (IOException ioe) { - throw new BuildException("Can't read stage file (" + ioe.getMessage() + ")."); - } - } - return "1"; - } -} +/******************************************************************************* + * Copyright (c) 2006-2012 + * Software Technology Group, Dresden University of Technology + * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 + * + * All rights reserved. This program and the accompanying materials + * are 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 + * + * Contributors: + * Software Technology Group - TU Dresden, Germany; + * DevBoost GmbH - Berlin, Germany + * - initial API and implementation + ******************************************************************************/ +package de.devboost.buildboost; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileWriter; +import java.io.IOException; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.util.List; + +import de.devboost.buildboost.model.IBuildConfiguration; +import de.devboost.buildboost.model.IBuildStage; +import de.devboost.buildboost.util.ScriptSaver; +import de.devboost.buildboost.util.StreamUtil; + +public class BuildScriptGeneratorRunner { + + public static void main(String[] args) throws BuildException { + if (args.length < 2) { + System.out.println("Wrong call to BuildScriptGeneratorRunner.main()."); + System.out.println("Usage: BuildScriptGeneratorRunner.main(pathToWorkspace, classToRun)."); + System.exit(1); + return; + } + new BuildScriptGeneratorRunner().run(args); + } + + private void run(String[] args) throws BuildException { + String workspace = args[0]; + String classToRun = args[1]; + File stageFile = getStageFile(workspace); + String stage = readLastStage(stageFile); + int stageNumber = Integer.parseInt(stage); + writeNextStage(stageFile, stageNumber); + + Class clazzToRun = loadClassToRun(classToRun); + + System.out.println("BuildScriptGeneratorRunner.run() stageNumber = " + stageNumber); + System.out.println("BuildScriptGeneratorRunner.run() clazzToRun = " + clazzToRun.getName()); + Class[] interfaces = clazzToRun.getInterfaces(); + for (Class nextInterface : interfaces) { + System.out.println("BuildScriptGeneratorRunner.run() implemented interface: " + nextInterface.getName()); + } + + boolean isBuildConfiguration = IBuildConfiguration.class.isAssignableFrom(clazzToRun); + if (isBuildConfiguration) { + // instantiate and call via interface + callViaInterface(clazzToRun, workspace, stageNumber); + } else { + // call main method (for backward compatibility) + callMainMethod(clazzToRun, args); + } + } + + private File getStageFile(String workspace) { + return new File(new File(workspace, "build"), "current_stage"); + } + + private Class loadClassToRun(String classToRun) throws BuildException { + Class clazzToRun; + try { + clazzToRun = Class.forName(classToRun); + } catch (ClassNotFoundException e) { + e.printStackTrace(); + throw new BuildException("Can't find class " + classToRun); + } + return clazzToRun; + } + + private void callViaInterface(Class clazzToRun, String workspace, int stageNumber) throws BuildException { + try { + Object newInstance = clazzToRun.newInstance(); + IBuildConfiguration configuration = (IBuildConfiguration) newInstance; + List buildStages = configuration.getBuildStages(workspace); + IBuildStage currentStage = buildStages.get(stageNumber - 1); + String buildDir = workspace + File.separator + "build"; + ScriptSaver scriptSaver = new ScriptSaver(); + File targetDir = new File(buildDir); + scriptSaver.saveStage(targetDir, currentStage, scriptSaver.getStageFileName(stageNumber)); + scriptSaver.saveMasterScript(targetDir, buildStages); + // if this is the last stage, we must remove the 'current_stage' stage file, because + // otherwise subsequent builds will not start at the first stage. this particularly + // applies to the bootstrapping build. + if (stageNumber == buildStages.size()) { + File stageFile = getStageFile(workspace); + stageFile.delete(); + } + } catch (InstantiationException e) { + e.printStackTrace(); + throw new BuildException("Can't instantiate class " + clazzToRun.getName()); + } catch (IllegalAccessException e) { + e.printStackTrace(); + throw new BuildException("Can't access class " + clazzToRun.getName()); + } + } + + private void callMainMethod(Class clazzToRun, String[] args) throws BuildException { + Method mainMethod; + try { + mainMethod = clazzToRun.getMethod("main", String[].class); + } catch (SecurityException e) { + e.printStackTrace(); + throw new BuildException("Can't access method main() in class " + clazzToRun.getName()); + } catch (NoSuchMethodException e) { + e.printStackTrace(); + throw new BuildException("Can't find method main() in class " + clazzToRun.getName()); + } + + try { + mainMethod.invoke(null, (Object) args); + } catch (IllegalArgumentException e) { + e.printStackTrace(); + throw new BuildException("Can't invoke main method in class " + clazzToRun.getName()); + } catch (IllegalAccessException e) { + e.printStackTrace(); + throw new BuildException("Can't invoke main method in class " + clazzToRun.getName()); + } catch (InvocationTargetException e) { + e.printStackTrace(); + throw new BuildException("Can't invoke main method in class " + clazzToRun.getName()); + } + } + + private void writeNextStage(File stageFile, int stageNumber) throws BuildException { + try { + FileWriter writer = new FileWriter(stageFile); + writer.write(Integer.toString(stageNumber + 1)); + writer.close(); + } catch (IOException ioe) { + throw new BuildException("Can't write stage file (" + ioe.getMessage() + ")."); + } + } + + private String readLastStage(File stageFile) throws BuildException { + if (stageFile.exists()) { + try { + FileInputStream fis = new FileInputStream(stageFile); + String stage = new StreamUtil().getContentAsString(fis); + fis.close(); + return stage; + } catch (IOException ioe) { + throw new BuildException("Can't read stage file (" + ioe.getMessage() + ")."); + } + } + return "1"; + } +} diff --git a/Core/de.devboost.buildboost/src/de/devboost/buildboost/DependableBuildParticipant.java b/Core/de.devboost.buildboost/src/de/devboost/buildboost/DependableBuildParticipant.java index 64d0b48..571bb53 100644 --- a/Core/de.devboost.buildboost/src/de/devboost/buildboost/DependableBuildParticipant.java +++ b/Core/de.devboost.buildboost/src/de/devboost/buildboost/DependableBuildParticipant.java @@ -1,81 +1,81 @@ -/******************************************************************************* - * Copyright (c) 2006-2012 - * Software Technology Group, Dresden University of Technology - * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 - * - * All rights reserved. This program and the accompanying materials - * are 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 - * - * Contributors: - * Software Technology Group - TU Dresden, Germany; - * DevBoost GmbH - Berlin, Germany - * - initial API and implementation - ******************************************************************************/ -package de.devboost.buildboost; - -import java.util.Collection; -import java.util.LinkedHashSet; -import java.util.List; - -import de.devboost.buildboost.model.IBuildContext; -import de.devboost.buildboost.model.IBuildParticipant; -import de.devboost.buildboost.model.IDependable; - -public class DependableBuildParticipant implements IDependable, - IBuildParticipant { - - private IBuildParticipant delegate; - private Collection dependencies = new LinkedHashSet(); - - public DependableBuildParticipant(IBuildParticipant participant) { - this.delegate = participant; - } - - public void initializeDependencies(List otherParticipants) { - for (DependableBuildParticipant otherParticipant : otherParticipants) { - if (dependsOn(otherParticipant)) { - dependencies.add(otherParticipant); - } - if (isReqiredFor(otherParticipant)) { - otherParticipant.dependencies.add(this); - } - } - } - - @Override - public void execute(IBuildContext context) throws BuildException { - delegate.execute(context); - } - - @Override - public boolean dependsOn(IBuildParticipant otherParticipant) { - if (otherParticipant instanceof DependableBuildParticipant) { - DependableBuildParticipant dependableBuildParticipant = (DependableBuildParticipant) otherParticipant; - return delegate.dependsOn(dependableBuildParticipant.delegate); - } else { - return delegate.dependsOn(otherParticipant); - } - } - - @Override - public boolean isReqiredFor(IBuildParticipant otherParticipant) { - if (otherParticipant instanceof DependableBuildParticipant) { - DependableBuildParticipant dependableBuildParticipant = (DependableBuildParticipant) otherParticipant; - return delegate.isReqiredFor(dependableBuildParticipant.delegate); - } else { - return delegate.isReqiredFor(otherParticipant); - } - } - - @Override - public Collection getDependencies() { - return dependencies; - } - - @Override - public String toString() { - return delegate.toString(); - } -} +/******************************************************************************* + * Copyright (c) 2006-2012 + * Software Technology Group, Dresden University of Technology + * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 + * + * All rights reserved. This program and the accompanying materials + * are 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 + * + * Contributors: + * Software Technology Group - TU Dresden, Germany; + * DevBoost GmbH - Berlin, Germany + * - initial API and implementation + ******************************************************************************/ +package de.devboost.buildboost; + +import java.util.Collection; +import java.util.LinkedHashSet; +import java.util.List; + +import de.devboost.buildboost.model.IBuildContext; +import de.devboost.buildboost.model.IBuildParticipant; +import de.devboost.buildboost.model.IDependable; + +public class DependableBuildParticipant implements IDependable, + IBuildParticipant { + + private IBuildParticipant delegate; + private Collection dependencies = new LinkedHashSet(); + + public DependableBuildParticipant(IBuildParticipant participant) { + this.delegate = participant; + } + + public void initializeDependencies(List otherParticipants) { + for (DependableBuildParticipant otherParticipant : otherParticipants) { + if (dependsOn(otherParticipant)) { + dependencies.add(otherParticipant); + } + if (isReqiredFor(otherParticipant)) { + otherParticipant.dependencies.add(this); + } + } + } + + @Override + public void execute(IBuildContext context) throws BuildException { + delegate.execute(context); + } + + @Override + public boolean dependsOn(IBuildParticipant otherParticipant) { + if (otherParticipant instanceof DependableBuildParticipant) { + DependableBuildParticipant dependableBuildParticipant = (DependableBuildParticipant) otherParticipant; + return delegate.dependsOn(dependableBuildParticipant.delegate); + } else { + return delegate.dependsOn(otherParticipant); + } + } + + @Override + public boolean isReqiredFor(IBuildParticipant otherParticipant) { + if (otherParticipant instanceof DependableBuildParticipant) { + DependableBuildParticipant dependableBuildParticipant = (DependableBuildParticipant) otherParticipant; + return delegate.isReqiredFor(dependableBuildParticipant.delegate); + } else { + return delegate.isReqiredFor(otherParticipant); + } + } + + @Override + public Collection getDependencies() { + return dependencies; + } + + @Override + public String toString() { + return delegate.toString(); + } +} diff --git a/Core/de.devboost.buildboost/src/de/devboost/buildboost/DependencyResolver.java b/Core/de.devboost.buildboost/src/de/devboost/buildboost/DependencyResolver.java index 173a5e6..ab90aa6 100644 --- a/Core/de.devboost.buildboost/src/de/devboost/buildboost/DependencyResolver.java +++ b/Core/de.devboost.buildboost/src/de/devboost/buildboost/DependencyResolver.java @@ -1,44 +1,44 @@ -/******************************************************************************* - * Copyright (c) 2006-2012 - * Software Technology Group, Dresden University of Technology - * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 - * - * All rights reserved. This program and the accompanying materials - * are 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 - * - * Contributors: - * Software Technology Group - TU Dresden, Germany; - * DevBoost GmbH - Berlin, Germany - * - initial API and implementation - ******************************************************************************/ -package de.devboost.buildboost; - -import java.util.Collection; - -import de.devboost.buildboost.model.AbstractBuildParticipant; -import de.devboost.buildboost.model.IArtifact; -import de.devboost.buildboost.model.IArtifactDiscoverer; -import de.devboost.buildboost.model.IBuildContext; -import de.devboost.buildboost.model.IBuildParticipant; - -public class DependencyResolver extends AbstractBuildParticipant { - - @Override - public boolean dependsOn(IBuildParticipant otherParticipant) { - if (otherParticipant instanceof IArtifactDiscoverer) { - return true; - } - return super.dependsOn(otherParticipant); - } - - @Override - public void execute(IBuildContext context) throws BuildException { - Collection discoveredArtifacts = context.getDiscoveredArtifacts(); - // resolve dependencies - for (IArtifact artifact : discoveredArtifacts) { - artifact.resolveDependencies(discoveredArtifacts); - } - } -} +/******************************************************************************* + * Copyright (c) 2006-2012 + * Software Technology Group, Dresden University of Technology + * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 + * + * All rights reserved. This program and the accompanying materials + * are 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 + * + * Contributors: + * Software Technology Group - TU Dresden, Germany; + * DevBoost GmbH - Berlin, Germany + * - initial API and implementation + ******************************************************************************/ +package de.devboost.buildboost; + +import java.util.Collection; + +import de.devboost.buildboost.model.AbstractBuildParticipant; +import de.devboost.buildboost.model.IArtifact; +import de.devboost.buildboost.model.IArtifactDiscoverer; +import de.devboost.buildboost.model.IBuildContext; +import de.devboost.buildboost.model.IBuildParticipant; + +public class DependencyResolver extends AbstractBuildParticipant { + + @Override + public boolean dependsOn(IBuildParticipant otherParticipant) { + if (otherParticipant instanceof IArtifactDiscoverer) { + return true; + } + return super.dependsOn(otherParticipant); + } + + @Override + public void execute(IBuildContext context) throws BuildException { + Collection discoveredArtifacts = context.getDiscoveredArtifacts(); + // resolve dependencies + for (IArtifact artifact : discoveredArtifacts) { + artifact.resolveDependencies(discoveredArtifacts); + } + } +} diff --git a/Core/de.devboost.buildboost/src/de/devboost/buildboost/GlobalBuildConfiguration.java b/Core/de.devboost.buildboost/src/de/devboost/buildboost/GlobalBuildConfiguration.java new file mode 100644 index 0000000..1d02d67 --- /dev/null +++ b/Core/de.devboost.buildboost/src/de/devboost/buildboost/GlobalBuildConfiguration.java @@ -0,0 +1,112 @@ +package de.devboost.buildboost; + +import java.io.File; +import java.io.FileReader; +import java.io.IOException; +import java.util.Properties; + +/** + * This class is a singleton! + * + */ +public class GlobalBuildConfiguration { + + final private static Properties userProperties = new Properties(); + + // none extern instance creation support + private GlobalBuildConfiguration() { + System.out.println("GlobalUserConfig: set defaults"); + setDefaultValues(); + System.out.println("GlobalUserConfig: read config file"); + readGlobalConfiguration(); + } + + // lazy init by static holder class + private static class Holder { + private static final GlobalBuildConfiguration INSTANCE = new GlobalBuildConfiguration(); + } + + public static GlobalBuildConfiguration getInstance() { + return Holder.INSTANCE; + } + + private void setDefaultValues() { + // debugging support + userProperties.setProperty(GlobalBuildConfiguration.DEBUG, + GlobalBuildConfiguration.DEBUG_DEFAULT); + // remote debug option line + userProperties.setProperty(GlobalBuildConfiguration.JVMARG_DEBUG, + GlobalBuildConfiguration.JVMARG_DEBUG_DEFAULT); + // jvm mx para + userProperties.setProperty(GlobalBuildConfiguration.JVMARG_MX, + GlobalBuildConfiguration.JVMARG_MX_DEFAULT); + // jvm maxperm para + userProperties.setProperty(GlobalBuildConfiguration.JVMARG_MAXPERM, + GlobalBuildConfiguration.JVMARG_MAXPERM_DEFAULT); + } + + private static void readGlobalConfiguration() { + final String userHomePath = System.getProperty("user.home"); + final String globalConfigFileName = userHomePath + File.separator + + ".buildboost"; + final File globalConfigFile = new File(globalConfigFileName); + + if (globalConfigFile.exists() && globalConfigFile.length() > 1) { + System.out + .println("Loading user defined global configuration from .buildboost file."); + FileReader reader = null; + try { + reader = new FileReader(globalConfigFile); + userProperties.load(reader); + } catch (IOException e) { + e.printStackTrace(); + } finally { + if (reader != null) { + try { + reader.close(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + } + } else { + System.out + .println("There was no user configuration found in the users .buildboost file"); + } + } + + public String getConfigItem(final String key) { + return userProperties.getProperty(key); + } + + public String getConfigItem(final String key, final String defaultValue) { + return userProperties.getProperty(key, defaultValue); + } + + public boolean isDebugEnabled() { + return !DEBUG_DEFAULT + .equals(getConfigItem(GlobalBuildConfiguration.DEBUG)); + } + + /* static constants for standard global entries and defaults */ + + // remote debugging support + public static final String DEBUG = "debug"; + // 0=disabled, >0=remote debugging support && loglevel + // 1 = log level 1, 2 = log level 2, ... + public static final String DEBUG_DEFAULT = "0"; + + // jvm remote debug option line + final public static String JVMARG_DEBUG = "jvm_debugoption_line"; + final public static String JVMARG_DEBUG_DEFAULT = "-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000"; + + // jvm mx arg + final public static String JVMARG_MX = "jvmarg_mx"; + final public static String JVMARG_MX_DEFAULT = "-Xmx2048m"; + + // jvm maxperm arg + final public static String JVMARG_MAXPERM = "jvm_maxperm"; + final public static String JVMARG_MAXPERM_DEFAULT = "-XX:MaxPermSize=256m"; + +} diff --git a/Core/de.devboost.buildboost/src/de/devboost/buildboost/IConstants.java b/Core/de.devboost.buildboost/src/de/devboost/buildboost/IConstants.java index 495e4eb..0c9aef8 100644 --- a/Core/de.devboost.buildboost/src/de/devboost/buildboost/IConstants.java +++ b/Core/de.devboost.buildboost/src/de/devboost/buildboost/IConstants.java @@ -1,36 +1,36 @@ -/******************************************************************************* - * Copyright (c) 2006-2012 - * Software Technology Group, Dresden University of Technology - * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 - * - * All rights reserved. This program and the accompanying materials - * are 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 - * - * Contributors: - * Software Technology Group - TU Dresden, Germany; - * DevBoost GmbH - Berlin, Germany - * - initial API and implementation - ******************************************************************************/ -package de.devboost.buildboost; - -/** - * A simple interface to holds constants that are required by the BuildBoost - * system. - */ -public interface IConstants { - - String BUILD_BOOST_REPOSITORY_URL = "https://github.com/DevBoost/BuildBoost.git"; - String BUILD_BOOST_CORE_PROJECT_ID = "de.devboost.buildboost"; - String BUILD_BOOST_GENEXT_PROJECT_ID_PATTERN = "de\\.devboost\\.buildboost\\.genext\\..*"; - String BUILD_BOOST_BUILD_PROJECT_ID_PATTERN = ".*\\.build"; - - String REPOS_FOLDER = "repos"; - String BUILD_FOLDER = "build"; - String ARTIFACTS_FOLDER = "artifacts"; - String PROJECTS_FOLDER = "projects"; - String BUILD_BOOST_BIN_FOLDER = "build-boost-bin"; - - String NL = System.getProperty("line.separator"); -} +/******************************************************************************* + * Copyright (c) 2006-2012 + * Software Technology Group, Dresden University of Technology + * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 + * + * All rights reserved. This program and the accompanying materials + * are 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 + * + * Contributors: + * Software Technology Group - TU Dresden, Germany; + * DevBoost GmbH - Berlin, Germany + * - initial API and implementation + ******************************************************************************/ +package de.devboost.buildboost; + +/** + * A simple interface to holds constants that are required by the BuildBoost + * system. + */ +public interface IConstants { + + String BUILD_BOOST_REPOSITORY_URL = "https://github.com/DevBoost/BuildBoost.git"; + String BUILD_BOOST_CORE_PROJECT_ID = "de.devboost.buildboost"; + String BUILD_BOOST_GENEXT_PROJECT_ID_PATTERN = "de\\.devboost\\.buildboost\\.genext\\..*"; + String BUILD_BOOST_BUILD_PROJECT_ID_PATTERN = ".*\\.build"; + + String REPOS_FOLDER = "repos"; + String BUILD_FOLDER = "build"; + String ARTIFACTS_FOLDER = "artifacts"; + String PROJECTS_FOLDER = "projects"; + String BUILD_BOOST_BIN_FOLDER = "build-boost-bin"; + + String NL = System.getProperty("line.separator"); +} diff --git a/Core/de.devboost.buildboost/src/de/devboost/buildboost/UnresolvedDependencyChecker.java b/Core/de.devboost.buildboost/src/de/devboost/buildboost/UnresolvedDependencyChecker.java index 774f520..fbd9773 100644 --- a/Core/de.devboost.buildboost/src/de/devboost/buildboost/UnresolvedDependencyChecker.java +++ b/Core/de.devboost.buildboost/src/de/devboost/buildboost/UnresolvedDependencyChecker.java @@ -1,63 +1,63 @@ -/******************************************************************************* - * Copyright (c) 2006-2012 - * Software Technology Group, Dresden University of Technology - * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 - * - * All rights reserved. This program and the accompanying materials - * are 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 - * - * Contributors: - * Software Technology Group - TU Dresden, Germany; - * DevBoost GmbH - Berlin, Germany - * - initial API and implementation - ******************************************************************************/ -package de.devboost.buildboost; - -import java.util.Collection; - -import de.devboost.buildboost.model.AbstractBuildParticipant; -import de.devboost.buildboost.model.BuildEventType; -import de.devboost.buildboost.model.IArtifact; -import de.devboost.buildboost.model.IBuildContext; -import de.devboost.buildboost.model.IBuildListener; -import de.devboost.buildboost.model.IBuildParticipant; -import de.devboost.buildboost.model.UnresolvedDependency; - -public class UnresolvedDependencyChecker extends AbstractBuildParticipant { - - @Override - public boolean dependsOn(IBuildParticipant otherParticipant) { - if (otherParticipant instanceof DependencyResolver) { - return true; - } - return false; - } - - @Override - public void execute(IBuildContext context) throws BuildException { - Collection discoveredArtifacts = context.getDiscoveredArtifacts(); - IBuildListener buildListener = context.getBuildListener(); - // check for unresolved dependencies - boolean foundUnresolvedDependency = false; - for (IArtifact artifact : discoveredArtifacts) { - Collection unresolvedDependencies = artifact.getUnresolvedDependencies(); - for (UnresolvedDependency unresolvedDependency : unresolvedDependencies) { - if (unresolvedDependency.isOptional()) { - continue; - } - String message = "Found unresolved dependency in artifact " + artifact + ": " + unresolvedDependency; - if (!context.ignoreUnresolvedDependencies()) { - buildListener.handleBuildEvent(BuildEventType.ERROR, message); - foundUnresolvedDependency = true; - } else { - buildListener.handleBuildEvent(BuildEventType.WARNING, message); - } - } - } - if (foundUnresolvedDependency) { - throw new BuildException("Found unresolved dependencies"); - } - } -} +/******************************************************************************* + * Copyright (c) 2006-2012 + * Software Technology Group, Dresden University of Technology + * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 + * + * All rights reserved. This program and the accompanying materials + * are 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 + * + * Contributors: + * Software Technology Group - TU Dresden, Germany; + * DevBoost GmbH - Berlin, Germany + * - initial API and implementation + ******************************************************************************/ +package de.devboost.buildboost; + +import java.util.Collection; + +import de.devboost.buildboost.model.AbstractBuildParticipant; +import de.devboost.buildboost.model.BuildEventType; +import de.devboost.buildboost.model.IArtifact; +import de.devboost.buildboost.model.IBuildContext; +import de.devboost.buildboost.model.IBuildListener; +import de.devboost.buildboost.model.IBuildParticipant; +import de.devboost.buildboost.model.UnresolvedDependency; + +public class UnresolvedDependencyChecker extends AbstractBuildParticipant { + + @Override + public boolean dependsOn(IBuildParticipant otherParticipant) { + if (otherParticipant instanceof DependencyResolver) { + return true; + } + return false; + } + + @Override + public void execute(IBuildContext context) throws BuildException { + Collection discoveredArtifacts = context.getDiscoveredArtifacts(); + IBuildListener buildListener = context.getBuildListener(); + // check for unresolved dependencies + boolean foundUnresolvedDependency = false; + for (IArtifact artifact : discoveredArtifacts) { + Collection unresolvedDependencies = artifact.getUnresolvedDependencies(); + for (UnresolvedDependency unresolvedDependency : unresolvedDependencies) { + if (unresolvedDependency.isOptional()) { + continue; + } + String message = "Found unresolved dependency in artifact " + artifact + ": " + unresolvedDependency; + if (!context.ignoreUnresolvedDependencies()) { + buildListener.handleBuildEvent(BuildEventType.ERROR, message); + foundUnresolvedDependency = true; + } else { + buildListener.handleBuildEvent(BuildEventType.WARNING, message); + } + } + } + if (foundUnresolvedDependency) { + throw new BuildException("Found unresolved dependencies"); + } + } +} diff --git a/Core/de.devboost.buildboost/src/de/devboost/buildboost/ant/AbstractAntTargetGenerator.java b/Core/de.devboost.buildboost/src/de/devboost/buildboost/ant/AbstractAntTargetGenerator.java index 75b4816..8ea9079 100644 --- a/Core/de.devboost.buildboost/src/de/devboost/buildboost/ant/AbstractAntTargetGenerator.java +++ b/Core/de.devboost.buildboost/src/de/devboost/buildboost/ant/AbstractAntTargetGenerator.java @@ -1,51 +1,75 @@ -/******************************************************************************* - * Copyright (c) 2006-2012 - * Software Technology Group, Dresden University of Technology - * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 - * - * All rights reserved. This program and the accompanying materials - * are 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 - * - * Contributors: - * Software Technology Group - TU Dresden, Germany; - * DevBoost GmbH - Berlin, Germany - * - initial API and implementation - ******************************************************************************/ -package de.devboost.buildboost.ant; - -import java.util.Collection; -import java.util.Collections; - -import de.devboost.buildboost.model.IArtifact; -import de.devboost.buildboost.model.IDependable; -import de.devboost.buildboost.model.UnresolvedDependency; - -public abstract class AbstractAntTargetGenerator implements IAntTargetGenerator { - - @Override - public String getIdentifier() { - return toString(); - } - - @Override - public Collection getDependencies() { - return Collections.emptySet(); - } - - @Override - public void resolveDependencies(Collection allArtifacts) { - // do nothing - } - - @Override - public Collection getUnresolvedDependencies() { - return Collections.emptySet(); - } - - @Override - public long getTimestamp() { - return -1; - } -} +/******************************************************************************* + * Copyright (c) 2006-2012 + * Software Technology Group, Dresden University of Technology + * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 + * + * All rights reserved. This program and the accompanying materials + * are 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 + * + * Contributors: + * Software Technology Group - TU Dresden, Germany; + * DevBoost GmbH - Berlin, Germany + * - initial API and implementation + ******************************************************************************/ +package de.devboost.buildboost.ant; + +import java.io.File; +import java.io.FileNotFoundException; +import java.io.PrintWriter; +import java.util.Collection; +import java.util.Collections; +import java.util.List; + +import de.devboost.buildboost.artifacts.Plugin; +import de.devboost.buildboost.model.IArtifact; +import de.devboost.buildboost.model.IDependable; +import de.devboost.buildboost.model.UnresolvedDependency; + +public abstract class AbstractAntTargetGenerator implements IAntTargetGenerator { + + protected void writeParaFile(final String fileName, + final List plugins) { + final File paraPropFile = new File(fileName); + PrintWriter pw = null; + try { + pw = new PrintWriter(paraPropFile); + for (Plugin plugin : plugins) { + pw.println(plugin.getAbsolutePath()); + } + } catch (FileNotFoundException e) { + e.printStackTrace(); + } finally { + if (pw != null) { + pw.close(); + } + } + + } + + @Override + public String getIdentifier() { + return toString(); + } + + @Override + public Collection getDependencies() { + return Collections.emptySet(); + } + + @Override + public void resolveDependencies(Collection allArtifacts) { + // do nothing + } + + @Override + public Collection getUnresolvedDependencies() { + return Collections.emptySet(); + } + + @Override + public long getTimestamp() { + return -1; + } +} diff --git a/Core/de.devboost.buildboost/src/de/devboost/buildboost/ant/AbstractAntTargetGeneratorProvider.java b/Core/de.devboost.buildboost/src/de/devboost/buildboost/ant/AbstractAntTargetGeneratorProvider.java index a5f5f4d..62b0e2b 100644 --- a/Core/de.devboost.buildboost/src/de/devboost/buildboost/ant/AbstractAntTargetGeneratorProvider.java +++ b/Core/de.devboost.buildboost/src/de/devboost/buildboost/ant/AbstractAntTargetGeneratorProvider.java @@ -1,60 +1,60 @@ -/******************************************************************************* - * Copyright (c) 2006-2012 - * Software Technology Group, Dresden University of Technology - * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 - * - * All rights reserved. This program and the accompanying materials - * are 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 - * - * Contributors: - * Software Technology Group - TU Dresden, Germany; - * DevBoost GmbH - Berlin, Germany - * - initial API and implementation - ******************************************************************************/ -package de.devboost.buildboost.ant; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; - -import de.devboost.buildboost.BuildException; -import de.devboost.buildboost.UnresolvedDependencyChecker; -import de.devboost.buildboost.model.AbstractBuildParticipant; -import de.devboost.buildboost.model.IArtifact; -import de.devboost.buildboost.model.IArtifactDiscoverer; -import de.devboost.buildboost.model.IArtifactFilter; -import de.devboost.buildboost.model.IBuildContext; -import de.devboost.buildboost.model.IBuildParticipant; - -public abstract class AbstractAntTargetGeneratorProvider - extends AbstractBuildParticipant - implements IAntTargetGeneratorProvider { - - @Override - public void execute(IBuildContext context) throws BuildException { - List antTargets = new ArrayList(); - Collection artifacts = context.getDiscoveredArtifacts(); - for (IArtifact artifact : artifacts) { - antTargets.addAll(getAntTargetGenerators(context, artifact)); - } - context.addDiscoveredArtifacts(antTargets); - } - - public boolean dependsOn(IBuildParticipant otherParticipant) { - if (otherParticipant instanceof IArtifactDiscoverer) { - return true; - } - if (otherParticipant instanceof IArtifactFilter) { - return true; - } - if (otherParticipant instanceof UnresolvedDependencyChecker) { - return true; - } - return false; - } - - public abstract Collection getAntTargetGenerators( - IBuildContext context, IArtifact artifact); -} +/******************************************************************************* + * Copyright (c) 2006-2012 + * Software Technology Group, Dresden University of Technology + * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 + * + * All rights reserved. This program and the accompanying materials + * are 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 + * + * Contributors: + * Software Technology Group - TU Dresden, Germany; + * DevBoost GmbH - Berlin, Germany + * - initial API and implementation + ******************************************************************************/ +package de.devboost.buildboost.ant; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +import de.devboost.buildboost.BuildException; +import de.devboost.buildboost.UnresolvedDependencyChecker; +import de.devboost.buildboost.model.AbstractBuildParticipant; +import de.devboost.buildboost.model.IArtifact; +import de.devboost.buildboost.model.IArtifactDiscoverer; +import de.devboost.buildboost.model.IArtifactFilter; +import de.devboost.buildboost.model.IBuildContext; +import de.devboost.buildboost.model.IBuildParticipant; + +public abstract class AbstractAntTargetGeneratorProvider + extends AbstractBuildParticipant + implements IAntTargetGeneratorProvider { + + @Override + public void execute(IBuildContext context) throws BuildException { + List antTargets = new ArrayList(); + Collection artifacts = context.getDiscoveredArtifacts(); + for (IArtifact artifact : artifacts) { + antTargets.addAll(getAntTargetGenerators(context, artifact)); + } + context.addDiscoveredArtifacts(antTargets); + } + + public boolean dependsOn(IBuildParticipant otherParticipant) { + if (otherParticipant instanceof IArtifactDiscoverer) { + return true; + } + if (otherParticipant instanceof IArtifactFilter) { + return true; + } + if (otherParticipant instanceof UnresolvedDependencyChecker) { + return true; + } + return false; + } + + public abstract Collection getAntTargetGenerators( + IBuildContext context, IArtifact artifact); +} diff --git a/Core/de.devboost.buildboost/src/de/devboost/buildboost/ant/AntScript.java b/Core/de.devboost.buildboost/src/de/devboost/buildboost/ant/AntScript.java index bee8a63..42179ef 100644 --- a/Core/de.devboost.buildboost/src/de/devboost/buildboost/ant/AntScript.java +++ b/Core/de.devboost.buildboost/src/de/devboost/buildboost/ant/AntScript.java @@ -1,96 +1,96 @@ -/******************************************************************************* - * Copyright (c) 2006-2012 - * Software Technology Group, Dresden University of Technology - * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 - * - * All rights reserved. This program and the accompanying materials - * are 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 - * - * Contributors: - * Software Technology Group - TU Dresden, Germany; - * DevBoost GmbH - Berlin, Germany - * - initial API and implementation - ******************************************************************************/ -package de.devboost.buildboost.ant; - -import static de.devboost.buildboost.IConstants.NL; - -import java.util.ArrayList; -import java.util.Collection; - -import de.devboost.buildboost.util.XMLContent; - -/** - * An {@link AntScript} is a representation of a generated Ant script. - */ -public class AntScript { - - private String name; - private StringBuffer content = new StringBuffer(); - - private Collection targets = new ArrayList(); - - public String getScript() { - XMLContent script = new XMLContent(); - script.append(""); - script.append(""); - script.append(""); - script.append(content.toString()); - - StringBuilder depends = new StringBuilder(); - for (AntTarget target : targets) { - depends.append(target.getName()); - depends.append(", "); - } - String allDependencies = depends.toString(); - if (allDependencies.length() > 0) { - allDependencies = allDependencies.substring(0, allDependencies.length() - 2); - } - script.append(" 0 ? "depends=\"" + allDependencies + "\"" : "") + " />"); - script.append(NL); - - // TODO make sure that names of the targets do not collide - for (AntTarget target : targets) { - StringBuilder deps = new StringBuilder(); - for (String dependency : target.getRequiredTargets()) { - deps.append(dependency); - deps.append(", "); - } - String allDeps = deps.toString(); - if (allDeps.length() > 0) { - allDeps = allDeps.substring(0, allDeps.length() - 2); - } - script.append(" 0 ? "depends=\"" + allDeps + "\"" : "") + ">"); - script.append(target.getContent()); - script.append(""); - script.append(NL); - } - - script.append(""); - - return script.toString(); - } - - public void setName(String name) { - this.name = name; - } - - /** - * Use {@link #addTarget(AntTarget)} or {@link #addTargets(Collection)} - * instead. - */ - @Deprecated // TODO remove this method once all references are removed - public void addContent(StringBuffer content) { - this.content.append(content); - } - - public void addTargets(Collection targets) { - this.targets.addAll(targets); - } - - public void addTarget(AntTarget target) { - this.targets.add(target); - } -} +/******************************************************************************* + * Copyright (c) 2006-2012 + * Software Technology Group, Dresden University of Technology + * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 + * + * All rights reserved. This program and the accompanying materials + * are 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 + * + * Contributors: + * Software Technology Group - TU Dresden, Germany; + * DevBoost GmbH - Berlin, Germany + * - initial API and implementation + ******************************************************************************/ +package de.devboost.buildboost.ant; + +import static de.devboost.buildboost.IConstants.NL; + +import java.util.ArrayList; +import java.util.Collection; + +import de.devboost.buildboost.util.XMLContent; + +/** + * An {@link AntScript} is a representation of a generated Ant script. + */ +public class AntScript { + + private String name; + private StringBuffer content = new StringBuffer(); + + private Collection targets = new ArrayList(); + + public String getScript() { + XMLContent script = new XMLContent(); + script.append(""); + script.append(""); + script.append(""); + script.append(content.toString()); + + StringBuilder depends = new StringBuilder(); + for (AntTarget target : targets) { + depends.append(target.getName()); + depends.append(", "); + } + String allDependencies = depends.toString(); + if (allDependencies.length() > 0) { + allDependencies = allDependencies.substring(0, allDependencies.length() - 2); + } + script.append(" 0 ? "depends=\"" + allDependencies + "\"" : "") + " />"); + script.append(NL); + + // TODO make sure that names of the targets do not collide + for (AntTarget target : targets) { + StringBuilder deps = new StringBuilder(); + for (String dependency : target.getRequiredTargets()) { + deps.append(dependency); + deps.append(", "); + } + String allDeps = deps.toString(); + if (allDeps.length() > 0) { + allDeps = allDeps.substring(0, allDeps.length() - 2); + } + script.append(" 0 ? "depends=\"" + allDeps + "\"" : "") + ">"); + script.append(target.getContent()); + script.append(""); + script.append(NL); + } + + script.append(""); + + return script.toString(); + } + + public void setName(String name) { + this.name = name; + } + + /** + * Use {@link #addTarget(AntTarget)} or {@link #addTargets(Collection)} + * instead. + */ + @Deprecated // TODO remove this method once all references are removed + public void addContent(StringBuffer content) { + this.content.append(content); + } + + public void addTargets(Collection targets) { + this.targets.addAll(targets); + } + + public void addTarget(AntTarget target) { + this.targets.add(target); + } +} diff --git a/Core/de.devboost.buildboost/src/de/devboost/buildboost/ant/AntTarget.java b/Core/de.devboost.buildboost/src/de/devboost/buildboost/ant/AntTarget.java index f49c548..46ce199 100644 --- a/Core/de.devboost.buildboost/src/de/devboost/buildboost/ant/AntTarget.java +++ b/Core/de.devboost.buildboost/src/de/devboost/buildboost/ant/AntTarget.java @@ -1,78 +1,78 @@ -/******************************************************************************* - * Copyright (c) 2006-2012 - * Software Technology Group, Dresden University of Technology - * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 - * - * All rights reserved. This program and the accompanying materials - * are 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 - * - * Contributors: - * Software Technology Group - TU Dresden, Germany; - * DevBoost GmbH - Berlin, Germany - * - initial API and implementation - ******************************************************************************/ -package de.devboost.buildboost.ant; - -import java.util.Collection; -import java.util.LinkedHashSet; - -import de.devboost.buildboost.artifacts.AbstractArtifact; -import de.devboost.buildboost.util.XMLContent; - -/** - * An {@link AntTarget} is a representation of a generated Ant script fragment. - * - * TODO Add parameter Class creator to all constructors to avoid interfering - * name for generated targets. - */ -public class AntTarget extends AbstractArtifact { - - private static final long serialVersionUID = -7935166108004658132L; - - private String name; - private String content; - private Collection dependencies; - - // TODO the content must not change after calling this constructor as - // changes will not be reflected because we call toString() right here. - public AntTarget(String name, XMLContent content) { - this(name, content.toString()); - } - - public AntTarget(String name, XMLContent content, Collection dependencies) { - this(name, content.toString(), dependencies); - } - - private AntTarget(String name, String content) { - this(name, content, new LinkedHashSet()); - } - - private AntTarget(String name, String content, Collection dependencies) { - this.name = name; - this.content = content; - this.dependencies = dependencies; - } - - /** - * Returns the name of this target. - */ - public String getName() { - return name; - } - - /** - * Returns the script content of this target as string. - */ - public String getContent() { - return content; - } - - /** - * Returns the targets this target depends on. - */ - public Collection getRequiredTargets() { - return dependencies; - } -} +/******************************************************************************* + * Copyright (c) 2006-2012 + * Software Technology Group, Dresden University of Technology + * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 + * + * All rights reserved. This program and the accompanying materials + * are 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 + * + * Contributors: + * Software Technology Group - TU Dresden, Germany; + * DevBoost GmbH - Berlin, Germany + * - initial API and implementation + ******************************************************************************/ +package de.devboost.buildboost.ant; + +import java.util.Collection; +import java.util.LinkedHashSet; + +import de.devboost.buildboost.artifacts.AbstractArtifact; +import de.devboost.buildboost.util.XMLContent; + +/** + * An {@link AntTarget} is a representation of a generated Ant script fragment. + * + * TODO Add parameter Class creator to all constructors to avoid interfering + * name for generated targets. + */ +public class AntTarget extends AbstractArtifact { + + private static final long serialVersionUID = -7935166108004658132L; + + private String name; + private String content; + private Collection dependencies; + + // TODO the content must not change after calling this constructor as + // changes will not be reflected because we call toString() right here. + public AntTarget(String name, XMLContent content) { + this(name, content.toString()); + } + + public AntTarget(String name, XMLContent content, Collection dependencies) { + this(name, content.toString(), dependencies); + } + + private AntTarget(String name, String content) { + this(name, content, new LinkedHashSet()); + } + + private AntTarget(String name, String content, Collection dependencies) { + this.name = name; + this.content = content; + this.dependencies = dependencies; + } + + /** + * Returns the name of this target. + */ + public String getName() { + return name; + } + + /** + * Returns the script content of this target as string. + */ + public String getContent() { + return content; + } + + /** + * Returns the targets this target depends on. + */ + public Collection getRequiredTargets() { + return dependencies; + } +} diff --git a/Core/de.devboost.buildboost/src/de/devboost/buildboost/ant/AntTargetGeneratorRunner.java b/Core/de.devboost.buildboost/src/de/devboost/buildboost/ant/AntTargetGeneratorRunner.java index 3e2d3f5..79d2ad7 100644 --- a/Core/de.devboost.buildboost/src/de/devboost/buildboost/ant/AntTargetGeneratorRunner.java +++ b/Core/de.devboost.buildboost/src/de/devboost/buildboost/ant/AntTargetGeneratorRunner.java @@ -1,49 +1,49 @@ -/******************************************************************************* - * Copyright (c) 2006-2012 - * Software Technology Group, Dresden University of Technology - * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 - * - * All rights reserved. This program and the accompanying materials - * are 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 - * - * Contributors: - * Software Technology Group - TU Dresden, Germany; - * DevBoost GmbH - Berlin, Germany - * - initial API and implementation - ******************************************************************************/ -package de.devboost.buildboost.ant; - -import java.util.ArrayList; -import java.util.Collection; - -import de.devboost.buildboost.BuildException; -import de.devboost.buildboost.model.AbstractBuildParticipant; -import de.devboost.buildboost.model.IArtifact; -import de.devboost.buildboost.model.IBuildContext; -import de.devboost.buildboost.model.IBuildParticipant; - -public class AntTargetGeneratorRunner extends AbstractBuildParticipant { - - @Override - public boolean dependsOn(IBuildParticipant otherParticipant) { - return otherParticipant instanceof IAntTargetGeneratorProvider; - } - - @Override - public void execute(IBuildContext context) throws BuildException { - Collection antTargets = new ArrayList(); - Collection discoveredArtifacts = context.getDiscoveredArtifacts(); - for (IArtifact artifact : discoveredArtifacts) { - if (artifact instanceof IAntTargetGenerator) { - IAntTargetGenerator antTargetGenerator = (IAntTargetGenerator) artifact; - Collection generatedAntTargets = antTargetGenerator.generateAntTargets(); - for (AntTarget antTarget : generatedAntTargets) { - antTargets.add(antTarget); - } - } - } - context.addDiscoveredArtifacts(antTargets); - } -} +/******************************************************************************* + * Copyright (c) 2006-2012 + * Software Technology Group, Dresden University of Technology + * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 + * + * All rights reserved. This program and the accompanying materials + * are 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 + * + * Contributors: + * Software Technology Group - TU Dresden, Germany; + * DevBoost GmbH - Berlin, Germany + * - initial API and implementation + ******************************************************************************/ +package de.devboost.buildboost.ant; + +import java.util.ArrayList; +import java.util.Collection; + +import de.devboost.buildboost.BuildException; +import de.devboost.buildboost.model.AbstractBuildParticipant; +import de.devboost.buildboost.model.IArtifact; +import de.devboost.buildboost.model.IBuildContext; +import de.devboost.buildboost.model.IBuildParticipant; + +public class AntTargetGeneratorRunner extends AbstractBuildParticipant { + + @Override + public boolean dependsOn(IBuildParticipant otherParticipant) { + return otherParticipant instanceof IAntTargetGeneratorProvider; + } + + @Override + public void execute(IBuildContext context) throws BuildException { + Collection antTargets = new ArrayList(); + Collection discoveredArtifacts = context.getDiscoveredArtifacts(); + for (IArtifact artifact : discoveredArtifacts) { + if (artifact instanceof IAntTargetGenerator) { + IAntTargetGenerator antTargetGenerator = (IAntTargetGenerator) artifact; + Collection generatedAntTargets = antTargetGenerator.generateAntTargets(); + for (AntTarget antTarget : generatedAntTargets) { + antTargets.add(antTarget); + } + } + } + context.addDiscoveredArtifacts(antTargets); + } +} diff --git a/Core/de.devboost.buildboost/src/de/devboost/buildboost/ant/IAntTargetGenerator.java b/Core/de.devboost.buildboost/src/de/devboost/buildboost/ant/IAntTargetGenerator.java index 14779bd..b5421e5 100644 --- a/Core/de.devboost.buildboost/src/de/devboost/buildboost/ant/IAntTargetGenerator.java +++ b/Core/de.devboost.buildboost/src/de/devboost/buildboost/ant/IAntTargetGenerator.java @@ -1,26 +1,26 @@ -/******************************************************************************* - * Copyright (c) 2006-2012 - * Software Technology Group, Dresden University of Technology - * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 - * - * All rights reserved. This program and the accompanying materials - * are 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 - * - * Contributors: - * Software Technology Group - TU Dresden, Germany; - * DevBoost GmbH - Berlin, Germany - * - initial API and implementation - ******************************************************************************/ -package de.devboost.buildboost.ant; - -import java.util.Collection; - -import de.devboost.buildboost.BuildException; -import de.devboost.buildboost.model.IArtifact; - -public interface IAntTargetGenerator extends IArtifact { - - public Collection generateAntTargets() throws BuildException; -} +/******************************************************************************* + * Copyright (c) 2006-2012 + * Software Technology Group, Dresden University of Technology + * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 + * + * All rights reserved. This program and the accompanying materials + * are 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 + * + * Contributors: + * Software Technology Group - TU Dresden, Germany; + * DevBoost GmbH - Berlin, Germany + * - initial API and implementation + ******************************************************************************/ +package de.devboost.buildboost.ant; + +import java.util.Collection; + +import de.devboost.buildboost.BuildException; +import de.devboost.buildboost.model.IArtifact; + +public interface IAntTargetGenerator extends IArtifact { + + public Collection generateAntTargets() throws BuildException; +} diff --git a/Core/de.devboost.buildboost/src/de/devboost/buildboost/ant/IAntTargetGeneratorProvider.java b/Core/de.devboost.buildboost/src/de/devboost/buildboost/ant/IAntTargetGeneratorProvider.java index 06689c0..9c3249c 100644 --- a/Core/de.devboost.buildboost/src/de/devboost/buildboost/ant/IAntTargetGeneratorProvider.java +++ b/Core/de.devboost.buildboost/src/de/devboost/buildboost/ant/IAntTargetGeneratorProvider.java @@ -1,21 +1,21 @@ -/******************************************************************************* - * Copyright (c) 2006-2012 - * Software Technology Group, Dresden University of Technology - * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 - * - * All rights reserved. This program and the accompanying materials - * are 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 - * - * Contributors: - * Software Technology Group - TU Dresden, Germany; - * DevBoost GmbH - Berlin, Germany - * - initial API and implementation - ******************************************************************************/ -package de.devboost.buildboost.ant; - -import de.devboost.buildboost.model.IBuildParticipant; - -public interface IAntTargetGeneratorProvider extends IBuildParticipant { -} +/******************************************************************************* + * Copyright (c) 2006-2012 + * Software Technology Group, Dresden University of Technology + * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 + * + * All rights reserved. This program and the accompanying materials + * are 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 + * + * Contributors: + * Software Technology Group - TU Dresden, Germany; + * DevBoost GmbH - Berlin, Germany + * - initial API and implementation + ******************************************************************************/ +package de.devboost.buildboost.ant; + +import de.devboost.buildboost.model.IBuildParticipant; + +public interface IAntTargetGeneratorProvider extends IBuildParticipant { +} diff --git a/Core/de.devboost.buildboost/src/de/devboost/buildboost/artifacts/AbstractArtifact.java b/Core/de.devboost.buildboost/src/de/devboost/buildboost/artifacts/AbstractArtifact.java index df1f042..80bbab2 100644 --- a/Core/de.devboost.buildboost/src/de/devboost/buildboost/artifacts/AbstractArtifact.java +++ b/Core/de.devboost.buildboost/src/de/devboost/buildboost/artifacts/AbstractArtifact.java @@ -1,90 +1,90 @@ -/******************************************************************************* - * Copyright (c) 2006-2012 - * Software Technology Group, Dresden University of Technology - * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 - * - * All rights reserved. This program and the accompanying materials - * are 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 - * - * Contributors: - * Software Technology Group - TU Dresden, Germany; - * DevBoost GmbH - Berlin, Germany - * - initial API and implementation - ******************************************************************************/ -package de.devboost.buildboost.artifacts; - -import java.io.Serializable; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.LinkedHashSet; -import java.util.List; - -import de.devboost.buildboost.model.IArtifact; -import de.devboost.buildboost.model.IDependable; -import de.devboost.buildboost.model.UnresolvedDependency; - -/** - * AbstractArtifact is a base class for implementing artifact types. It provides - * common functionality shared across artifact type, for example, the resolution - * of unresolved dependencies. - * - * This class is intended to be subclasses by clients. - */ -@SuppressWarnings("serial") -public abstract class AbstractArtifact implements IArtifact, Serializable { - - private String identifier; - private Collection dependencies = new LinkedHashSet(); - private Collection unresolvedDependencies = new LinkedHashSet(); - private Collection resolvedDependencies = new LinkedHashSet(); - - public String getIdentifier() { - return identifier; - } - - public Collection getDependencies() { - return Collections.unmodifiableCollection(dependencies); - } - - public void addDependency(IArtifact artifact) { - dependencies.add(artifact); - } - - public Collection getUnresolvedDependencies() { - return unresolvedDependencies; - } - - public Collection getResolvedDependencies() { - return resolvedDependencies; - } - - protected void setIdentifier(String identifier) { - this.identifier = identifier; - } - - public void resolveDependencies(Collection allArtifacts) { - List resolvedDependencies = new ArrayList(); - for (IArtifact artifact : allArtifacts) { - for (UnresolvedDependency nextDependency : getUnresolvedDependencies()) { - if (nextDependency.isFulfilledBy(artifact)) { - resolvedDependencies.add(nextDependency); - dependencies.add(artifact); - } - } - getUnresolvedDependencies().removeAll(resolvedDependencies); - } - } - - @Override - public long getTimestamp() { - return -1; - } - - @Override - public String toString() { - return getClass().getSimpleName() + " [" + getIdentifier() + "]"; - } -} +/******************************************************************************* + * Copyright (c) 2006-2012 + * Software Technology Group, Dresden University of Technology + * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 + * + * All rights reserved. This program and the accompanying materials + * are 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 + * + * Contributors: + * Software Technology Group - TU Dresden, Germany; + * DevBoost GmbH - Berlin, Germany + * - initial API and implementation + ******************************************************************************/ +package de.devboost.buildboost.artifacts; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.LinkedHashSet; +import java.util.List; + +import de.devboost.buildboost.model.IArtifact; +import de.devboost.buildboost.model.IDependable; +import de.devboost.buildboost.model.UnresolvedDependency; + +/** + * AbstractArtifact is a base class for implementing artifact types. It provides + * common functionality shared across artifact type, for example, the resolution + * of unresolved dependencies. + * + * This class is intended to be subclasses by clients. + */ +@SuppressWarnings("serial") +public abstract class AbstractArtifact implements IArtifact, Serializable { + + private String identifier; + private Collection dependencies = new LinkedHashSet(); + private Collection unresolvedDependencies = new LinkedHashSet(); + private Collection resolvedDependencies = new LinkedHashSet(); + + public String getIdentifier() { + return identifier; + } + + public Collection getDependencies() { + return Collections.unmodifiableCollection(dependencies); + } + + public void addDependency(IArtifact artifact) { + dependencies.add(artifact); + } + + public Collection getUnresolvedDependencies() { + return unresolvedDependencies; + } + + public Collection getResolvedDependencies() { + return resolvedDependencies; + } + + protected void setIdentifier(String identifier) { + this.identifier = identifier; + } + + public void resolveDependencies(Collection allArtifacts) { + List resolvedDependencies = new ArrayList(); + for (IArtifact artifact : allArtifacts) { + for (UnresolvedDependency nextDependency : getUnresolvedDependencies()) { + if (nextDependency.isFulfilledBy(artifact)) { + resolvedDependencies.add(nextDependency); + dependencies.add(artifact); + } + } + getUnresolvedDependencies().removeAll(resolvedDependencies); + } + } + + @Override + public long getTimestamp() { + return -1; + } + + @Override + public String toString() { + return getClass().getSimpleName() + " [" + getIdentifier() + "]"; + } +} diff --git a/Core/de.devboost.buildboost/src/de/devboost/buildboost/artifacts/EclipseFeature.java b/Core/de.devboost.buildboost/src/de/devboost/buildboost/artifacts/EclipseFeature.java index 60785cc..ee39316 100644 --- a/Core/de.devboost.buildboost/src/de/devboost/buildboost/artifacts/EclipseFeature.java +++ b/Core/de.devboost.buildboost/src/de/devboost/buildboost/artifacts/EclipseFeature.java @@ -1,161 +1,161 @@ -/******************************************************************************* - * Copyright (c) 2006-2012 - * Software Technology Group, Dresden University of Technology - * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 - * - * All rights reserved. This program and the accompanying materials - * are 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 - * - * Contributors: - * Software Technology Group - TU Dresden, Germany; - * DevBoost GmbH - Berlin, Germany - * - initial API and implementation - ******************************************************************************/ -package de.devboost.buildboost.artifacts; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.InputStream; -import java.io.Serializable; -import java.util.Collection; -import java.util.Collections; -import java.util.LinkedHashSet; -import java.util.Set; -import java.util.zip.ZipEntry; -import java.util.zip.ZipFile; - -import javax.xml.xpath.XPath; -import javax.xml.xpath.XPathConstants; -import javax.xml.xpath.XPathExpressionException; - -import org.w3c.dom.Document; -import org.w3c.dom.Element; - -import de.devboost.buildboost.model.IDependable; -import de.devboost.buildboost.model.UnresolvedDependency; -import de.devboost.buildboost.util.AbstractXMLReader; - -public class EclipseFeature extends AbstractArtifact implements Serializable { - - private static final long serialVersionUID = 8136940018246598015L; - - private static final String FEATURE_XML = "feature.xml"; - - private File file; - - private Set containedPluginIDs = new LinkedHashSet(); - - public EclipseFeature(File file) { - super(); - this.file = file; - if (file.getName().equals(FEATURE_XML)) { - try { - readFeatureInputStream(new FileInputStream(file)); - } catch (FileNotFoundException e) { - e.printStackTrace(); - } - } else { - // this is JAR - try { - ZipFile jar = new ZipFile(file); - ZipEntry entry = jar.getEntry(FEATURE_XML); - InputStream is = jar.getInputStream(entry); - readFeatureInputStream(is); - } catch (IOException e) { - e.printStackTrace(); - } - } - } - - private void readFeatureInputStream(InputStream is) { - AbstractXMLReader xmlUtil = new AbstractXMLReader() { - - private boolean searchingContainedPlugins = false; - - @Override - protected void process(Document document, XPath xpath) - throws XPathExpressionException { - findIdentifier(document, xpath); - searchingContainedPlugins = true; - findContainedPluginDependencies(document, xpath); - searchingContainedPlugins = false; - findFeatureDependencies(document, xpath); - findPluginDependencies(document, xpath); - } - - @Override - protected void addUnresolvedDependencies(Element element, - UnresolvedDependency unresolvedDependency) { - // we exclude dependencies that are specific to a particular OS - // or windowing system - boolean isOsIndependent = isAttributeNotSet(element, "os"); - isOsIndependent &= isAttributeNotSet(element, "ws"); - if (isOsIndependent) { - getUnresolvedDependencies().add(unresolvedDependency); - if (searchingContainedPlugins) { - containedPluginIDs.add(unresolvedDependency.getIdentifier()); - } - } - } - - private boolean isAttributeNotSet(Element element, String attributeName) { - String value = element.getAttribute(attributeName); - boolean isNotSet = value == null || "".equals(value.trim()); - return isNotSet; - } - - private void findIdentifier(Document document, XPath xpath) throws XPathExpressionException { - Element element = (Element) xpath.evaluate("//feature", document, XPathConstants.NODE); - setIdentifier(element.getAttribute("id")); - } - - private void findContainedPluginDependencies(Document document, XPath xpath) - throws XPathExpressionException { - findDependencies(document, xpath, "//plugin", "id", "fragment", Plugin.class); - } - - private void findFeatureDependencies(Document document, XPath xpath) - throws XPathExpressionException { - // TODO deactivated, because this information only becomes important at installation time - // and installation is (currently) always performed against external p2-repositories - // and not against the artifacts that are discovered in the build process - //findDependencies(document, xpath, "//import", "feature", null, EclipseFeature.class); - } - - private void findPluginDependencies(Document document, XPath xpath) - throws XPathExpressionException { - // TODO deactivated (see above) - //findDependencies(document, xpath, "//import", "plugin", null, Plugin.class); - } - }; - - xmlUtil.readXMLStrem(is); - } - - public Collection getPlugins() { - Set plugins = new LinkedHashSet(); - Collection dependencies = getDependencies(); - for (IDependable dependency : dependencies) { - if (dependency instanceof Plugin) { - Plugin plugin = (Plugin) dependency; - if (containedPluginIDs.contains(plugin.getIdentifier())) { - plugins.add(plugin); - } - } - } - return Collections.unmodifiableSet(plugins); - } - - public File getFile() { - return file; - } - - @Override - public long getTimestamp() { - return file.lastModified(); - } -} +/******************************************************************************* + * Copyright (c) 2006-2012 + * Software Technology Group, Dresden University of Technology + * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 + * + * All rights reserved. This program and the accompanying materials + * are 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 + * + * Contributors: + * Software Technology Group - TU Dresden, Germany; + * DevBoost GmbH - Berlin, Germany + * - initial API and implementation + ******************************************************************************/ +package de.devboost.buildboost.artifacts; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.InputStream; +import java.io.Serializable; +import java.util.Collection; +import java.util.Collections; +import java.util.LinkedHashSet; +import java.util.Set; +import java.util.zip.ZipEntry; +import java.util.zip.ZipFile; + +import javax.xml.xpath.XPath; +import javax.xml.xpath.XPathConstants; +import javax.xml.xpath.XPathExpressionException; + +import org.w3c.dom.Document; +import org.w3c.dom.Element; + +import de.devboost.buildboost.model.IDependable; +import de.devboost.buildboost.model.UnresolvedDependency; +import de.devboost.buildboost.util.AbstractXMLReader; + +public class EclipseFeature extends AbstractArtifact implements Serializable { + + private static final long serialVersionUID = 8136940018246598015L; + + private static final String FEATURE_XML = "feature.xml"; + + private File file; + + private Set containedPluginIDs = new LinkedHashSet(); + + public EclipseFeature(File file) { + super(); + this.file = file; + if (file.getName().equals(FEATURE_XML)) { + try { + readFeatureInputStream(new FileInputStream(file)); + } catch (FileNotFoundException e) { + e.printStackTrace(); + } + } else { + // this is JAR + try { + ZipFile jar = new ZipFile(file); + ZipEntry entry = jar.getEntry(FEATURE_XML); + InputStream is = jar.getInputStream(entry); + readFeatureInputStream(is); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + + private void readFeatureInputStream(InputStream is) { + AbstractXMLReader xmlUtil = new AbstractXMLReader() { + + private boolean searchingContainedPlugins = false; + + @Override + protected void process(Document document, XPath xpath) + throws XPathExpressionException { + findIdentifier(document, xpath); + searchingContainedPlugins = true; + findContainedPluginDependencies(document, xpath); + searchingContainedPlugins = false; + findFeatureDependencies(document, xpath); + findPluginDependencies(document, xpath); + } + + @Override + protected void addUnresolvedDependencies(Element element, + UnresolvedDependency unresolvedDependency) { + // we exclude dependencies that are specific to a particular OS + // or windowing system + boolean isOsIndependent = isAttributeNotSet(element, "os"); + isOsIndependent &= isAttributeNotSet(element, "ws"); + if (isOsIndependent) { + getUnresolvedDependencies().add(unresolvedDependency); + if (searchingContainedPlugins) { + containedPluginIDs.add(unresolvedDependency.getIdentifier()); + } + } + } + + private boolean isAttributeNotSet(Element element, String attributeName) { + String value = element.getAttribute(attributeName); + boolean isNotSet = value == null || "".equals(value.trim()); + return isNotSet; + } + + private void findIdentifier(Document document, XPath xpath) throws XPathExpressionException { + Element element = (Element) xpath.evaluate("//feature", document, XPathConstants.NODE); + setIdentifier(element.getAttribute("id")); + } + + private void findContainedPluginDependencies(Document document, XPath xpath) + throws XPathExpressionException { + findDependencies(document, xpath, "//plugin", "id", "fragment", Plugin.class); + } + + private void findFeatureDependencies(Document document, XPath xpath) + throws XPathExpressionException { + // TODO deactivated, because this information only becomes important at installation time + // and installation is (currently) always performed against external p2-repositories + // and not against the artifacts that are discovered in the build process + //findDependencies(document, xpath, "//import", "feature", null, EclipseFeature.class); + } + + private void findPluginDependencies(Document document, XPath xpath) + throws XPathExpressionException { + // TODO deactivated (see above) + //findDependencies(document, xpath, "//import", "plugin", null, Plugin.class); + } + }; + + xmlUtil.readXMLStrem(is); + } + + public Collection getPlugins() { + Set plugins = new LinkedHashSet(); + Collection dependencies = getDependencies(); + for (IDependable dependency : dependencies) { + if (dependency instanceof Plugin) { + Plugin plugin = (Plugin) dependency; + if (containedPluginIDs.contains(plugin.getIdentifier())) { + plugins.add(plugin); + } + } + } + return Collections.unmodifiableSet(plugins); + } + + public File getFile() { + return file; + } + + @Override + public long getTimestamp() { + return file.lastModified(); + } +} diff --git a/Core/de.devboost.buildboost/src/de/devboost/buildboost/artifacts/Plugin.java b/Core/de.devboost.buildboost/src/de/devboost/buildboost/artifacts/Plugin.java index 4e96c50..43b7803 100644 --- a/Core/de.devboost.buildboost/src/de/devboost/buildboost/artifacts/Plugin.java +++ b/Core/de.devboost.buildboost/src/de/devboost/buildboost/artifacts/Plugin.java @@ -1,426 +1,426 @@ -/******************************************************************************* - * Copyright (c) 2006-2012 - * Software Technology Group, Dresden University of Technology - * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 - * - * All rights reserved. This program and the accompanying materials - * are 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 - * - * Contributors: - * Software Technology Group - TU Dresden, Germany; - * DevBoost GmbH - Berlin, Germany - * - initial API and implementation - ******************************************************************************/ -package de.devboost.buildboost.artifacts; - -import java.io.File; -import java.io.FileFilter; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.InputStream; -import java.io.Serializable; -import java.util.Collection; -import java.util.Collections; -import java.util.LinkedHashSet; -import java.util.Set; -import java.util.zip.ZipEntry; -import java.util.zip.ZipFile; - -import de.devboost.buildboost.discovery.reader.DotClasspathReader; -import de.devboost.buildboost.discovery.reader.ManifestReader; -import de.devboost.buildboost.model.IArtifact; -import de.devboost.buildboost.model.IDependable; -import de.devboost.buildboost.model.IFileArtifact; -import de.devboost.buildboost.model.UnresolvedDependency; - -/** - * A Plug-in represents an OSGi bundle (i.e., an Eclipse plug-in) that is either - * found in a target platform (e.g., an Eclipse distribution) or that is part - * of the workspace that is subject to the build process. - */ -public class Plugin extends AbstractArtifact implements IFileArtifact, Serializable { - - private static final long serialVersionUID = 7995849293974638695L; - - /** - * The set of plug-in fragments that complement this plug-in. - */ - private Set fragments = new LinkedHashSet(); - private Plugin fragmentHost = null; - - /** - * The plug-in that is complemented by this plug-in (if this plug-in is a - * fragment). - */ - private UnresolvedDependency unresolvedFragmentHost; - - /** - * The libraries that are required by this plug-in. - */ - private Set libs = new LinkedHashSet(); - - /** - * The location of this plug-in. This can be either a directory or a JAR - * file. - */ - protected File location; - - /** - * The absolute path to the location of the plug-in. Stored for performance - * reasons only. - */ - private String absolutePath; - - private Set allLibs; - - private Set allDependencies; - - private Set exportedPackages; - - /** - * Create a descriptor for the plug-in at the given location. Reads the - * manifest and class path information if available. - * - * @param location - * @throws IOException - * @throws Exception - */ - public Plugin(File location) throws IOException { - super(); - this.location = location; - analyzeManifest(); - analyzeClassPath(); - } - - private void analyzeManifest() throws IOException { - InputStream manifestInputStream = getManifestInputStream(); - if (manifestInputStream == null) { - setIdentifier(location.getName()); - exportedPackages = Collections.emptySet(); - } else { - ManifestReader reader = new ManifestReader(manifestInputStream); - manifestInputStream.close(); - - Set unresolvedDependencies = reader.getDependencies(); - getUnresolvedDependencies().addAll(unresolvedDependencies); - unresolvedFragmentHost = reader.getFragmentHost(); - libs.addAll(reader.getBundleClassPath()); - addWebLibraries(); - - setIdentifier(reader.getSymbolicName()); - - Set exportedPackageName = reader.getExportedPackages(); - exportedPackages = new LinkedHashSet(); - for (String packageName : exportedPackageName) { - exportedPackages.add(new Package(packageName, this)); - } - } - } - - private void addWebLibraries() { - // TODO this belongs somewhere else - if (location.isDirectory()) { - File webLibsDir = new File(new File(new File(location, "WebContent"), "WEB-INF"), "lib"); - if (webLibsDir.exists()) { - File[] webLibs = webLibsDir.listFiles(new FileFilter() { - - public boolean accept(File file) { - return file.isFile() && file.getName().endsWith(".jar"); - } - }); - if (webLibs == null) { - return; - } - for (File webLib : webLibs) { - try { - String relativePath = webLib.getCanonicalFile().getAbsolutePath().substring(location.getCanonicalFile().getAbsolutePath().length() + 1); - libs.add(relativePath); - } catch (IOException e) { - // TODO handle exception - System.out.println("IOException: " + e.getMessage()); - } - } - } - } - } - - /** - * Resolves all unresolved dependencies (denoted by symbolic names) by - * replacing them with actual references to plug-in objects in the given set - * of available plug-ins. - * - * @param allArtifacts all artifacts that were discovered - */ - @Override - public void resolveDependencies(Collection allArtifacts) { - for (IArtifact artifact : allArtifacts) { - Collection resolvedDependencies = getResolvedDependencies(); - Collection unresolvedDependencies = getUnresolvedDependencies(); - - for (UnresolvedDependency dependency : unresolvedDependencies) { - if (dependency.isFulfilledBy(artifact)) { - addDependency(artifact); - resolvedDependencies.add(dependency); - } - } - // --- inserted in superclass code ---- - if (artifact instanceof Plugin) { - Plugin plugin = (Plugin) artifact; - if (unresolvedFragmentHost != null && unresolvedFragmentHost.isFulfilledBy(plugin)) { - plugin.addFragment(this); - fragmentHost = plugin; - addDependency(plugin); - } - } - // --- - unresolvedDependencies.removeAll(resolvedDependencies); - } - } - - private void addFragment(Plugin pluginFragment) { - fragments.add(pluginFragment); - } - - private Collection getPluginDependencies() { - Collection result = new LinkedHashSet(); - for (IDependable artifact : getDependencies()) { - if (artifact instanceof Plugin) { - Plugin plugin = (Plugin) artifact; - result.add(plugin); - if (getFragmentHost() != null) { - result.add(getFragmentHost()); - } - } - if (artifact instanceof Package) { - Package p = (Package) artifact; - result.add(p.getExportingPlugin()); - } - } - return Collections.unmodifiableCollection(result); - } - - /** - * Returns all plug-ins that this plug-in depends on, except the ones that - * are part of the target platform. - */ - public Set getDependenciesExcludingTargetPlatform() { - Set result = new LinkedHashSet(); - for (IDependable dependency : getDependencies()) { - if (dependency instanceof Plugin) { - Plugin plugin = (Plugin) dependency; - if (!plugin.isProject()) { - continue; - } - result.add(plugin); - } - } - return Collections.unmodifiableSet(result); - } - - public Set getExportedPackages() { - return exportedPackages; - } - - public Set getLibs() { - return libs; - } - - /** - * Returns all dependencies transitively. - */ - public Set getAllDependencies() { - if (allDependencies == null) { - Collection pluginDependencies = getPluginDependencies(); - - allDependencies = new LinkedHashSet(); - allDependencies.addAll(pluginDependencies); - allDependencies.addAll(fragments); - - for (Plugin dependency : pluginDependencies) { - allDependencies.addAll(dependency.getAllDependencies()); - } - for (Plugin fragment : fragments) { - allDependencies.addAll(fragment.getAllDependencies()); - } - } - return allDependencies; - } - - /** - * Returns the absolute paths of all libraries (transitively). - */ - public Set getAllLibPaths() { - if (allLibs == null) { - allLibs = new LinkedHashSet(); - for (String lib : getLibs()) { - allLibs.add(getAbsoluteLibPath(lib)); - } - for (Plugin dependency : getPluginDependencies()) { - allLibs.addAll(dependency.getAllLibPaths()); - } - } - return allLibs; - } - - /** - * Returns the absolute path of the given library. - */ - public String getAbsoluteLibPath(String lib) { - String prefix = getAbsolutePath() + "/"; - if (lib.startsWith("/")) { - // absolute paths to libraries must be handled differently - return prefix + ".." + lib; - } else { - return prefix + lib; - } - } - - public File getLocation() { - return location; - } - - public String getAbsolutePath() { - if (absolutePath == null) { - absolutePath = location.getAbsolutePath(); - } - return absolutePath; - } - - /** - * Returns the source folders of this plug-in, if there are any. - */ - public File[] getSourceFolders() { - if (location.isFile()) { - return new File[0]; - } - File[] sourceFolders = location.listFiles(new FileFilter() { - - public boolean accept(File pathname) { - return pathname.getName().equals("src") || - pathname.getName().startsWith("src-") || - pathname.getName().equals("xtend-gen"); - } - }); - if (sourceFolders == null) { - return new File[0]; - } - return sourceFolders; - } - - /** - * Checks whether this plug-in depends on the given other plug-in. - */ - public boolean dependsOn(Plugin otherPlugin) { - // check direct dependency - if (getDependencies().contains(otherPlugin)) { - return true; - } - for (Plugin dependency : getPluginDependencies()) { - if (dependency.dependsOn(otherPlugin)) { - return true; - } - } - return false; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result - + ((getIdentifier() == null) ? 0 : getIdentifier().hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - Plugin other = (Plugin) obj; - if (getIdentifier() == null) { - if (other.getIdentifier() != null) - return false; - } else if (!getIdentifier().equals(other.getIdentifier())) - return false; - return true; - } - - public boolean hasManifest() { - return getManifestFile().exists(); - } - - /** - * Returns an input stream to access the manifest of this plug-in. - */ - private InputStream getManifestInputStream() throws IOException { - File pluginLocation = getLocation(); - if (pluginLocation.isFile()) { - ZipFile zipFile = new ZipFile(pluginLocation); - ZipEntry manifestEntry = zipFile.getEntry("META-INF/MANIFEST.MF"); - if (manifestEntry == null) { - return null; - } - InputStream inputStream = zipFile.getInputStream(manifestEntry); - return inputStream; - } else { - File manifest = getManifestFile(); - if (!manifest.exists()) { - System.out.println("INFO: Project without MANIFEST: " + getLocation().getName()); - return null; - } - return new FileInputStream(manifest); - } - } - - private File getManifestFile() { - File manifest = new File(new File(getLocation(), "META-INF"), "MANIFEST.MF"); - return manifest; - } - - private void analyzeClassPath() throws IOException { - InputStream dotClassPathInputStream = getDotClasspathInputStream(); - if (dotClassPathInputStream != null) { - this.libs.addAll(new DotClasspathReader(dotClassPathInputStream).getDependencies()); - dotClassPathInputStream.close(); - } - } - - private InputStream getDotClasspathInputStream() throws FileNotFoundException { - File pluginLocation = getLocation(); - if (pluginLocation.isDirectory()) { - File dotClassPathFile = new File(pluginLocation, ".classpath"); - if (!dotClassPathFile.exists()) { - return null; - } - return new FileInputStream(dotClassPathFile); - } else { - // JARs do usually not contain .classpath files since they contain - // compiled plug-ins. - return null; - } - } - - public boolean isExperimental() { - return new File(getAbsolutePath(), "EXPERIMENTAL").exists(); - } - - public boolean isProject() { - return true; - } - - public Plugin getFragmentHost() { - return fragmentHost; - } - - public File getFile() { - return getLocation(); - } - -} +/******************************************************************************* + * Copyright (c) 2006-2012 + * Software Technology Group, Dresden University of Technology + * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 + * + * All rights reserved. This program and the accompanying materials + * are 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 + * + * Contributors: + * Software Technology Group - TU Dresden, Germany; + * DevBoost GmbH - Berlin, Germany + * - initial API and implementation + ******************************************************************************/ +package de.devboost.buildboost.artifacts; + +import java.io.File; +import java.io.FileFilter; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.InputStream; +import java.io.Serializable; +import java.util.Collection; +import java.util.Collections; +import java.util.LinkedHashSet; +import java.util.Set; +import java.util.zip.ZipEntry; +import java.util.zip.ZipFile; + +import de.devboost.buildboost.discovery.reader.DotClasspathReader; +import de.devboost.buildboost.discovery.reader.ManifestReader; +import de.devboost.buildboost.model.IArtifact; +import de.devboost.buildboost.model.IDependable; +import de.devboost.buildboost.model.IFileArtifact; +import de.devboost.buildboost.model.UnresolvedDependency; + +/** + * A Plug-in represents an OSGi bundle (i.e., an Eclipse plug-in) that is either + * found in a target platform (e.g., an Eclipse distribution) or that is part + * of the workspace that is subject to the build process. + */ +public class Plugin extends AbstractArtifact implements IFileArtifact, Serializable { + + private static final long serialVersionUID = 7995849293974638695L; + + /** + * The set of plug-in fragments that complement this plug-in. + */ + private Set fragments = new LinkedHashSet(); + private Plugin fragmentHost = null; + + /** + * The plug-in that is complemented by this plug-in (if this plug-in is a + * fragment). + */ + private UnresolvedDependency unresolvedFragmentHost; + + /** + * The libraries that are required by this plug-in. + */ + private Set libs = new LinkedHashSet(); + + /** + * The location of this plug-in. This can be either a directory or a JAR + * file. + */ + protected File location; + + /** + * The absolute path to the location of the plug-in. Stored for performance + * reasons only. + */ + private String absolutePath; + + private Set allLibs; + + private Set allDependencies; + + private Set exportedPackages; + + /** + * Create a descriptor for the plug-in at the given location. Reads the + * manifest and class path information if available. + * + * @param location + * @throws IOException + * @throws Exception + */ + public Plugin(File location) throws IOException { + super(); + this.location = location; + analyzeManifest(); + analyzeClassPath(); + } + + private void analyzeManifest() throws IOException { + InputStream manifestInputStream = getManifestInputStream(); + if (manifestInputStream == null) { + setIdentifier(location.getName()); + exportedPackages = Collections.emptySet(); + } else { + ManifestReader reader = new ManifestReader(manifestInputStream); + manifestInputStream.close(); + + Set unresolvedDependencies = reader.getDependencies(); + getUnresolvedDependencies().addAll(unresolvedDependencies); + unresolvedFragmentHost = reader.getFragmentHost(); + libs.addAll(reader.getBundleClassPath()); + addWebLibraries(); + + setIdentifier(reader.getSymbolicName()); + + Set exportedPackageName = reader.getExportedPackages(); + exportedPackages = new LinkedHashSet(); + for (String packageName : exportedPackageName) { + exportedPackages.add(new Package(packageName, this)); + } + } + } + + private void addWebLibraries() { + // TODO this belongs somewhere else + if (location.isDirectory()) { + File webLibsDir = new File(new File(new File(location, "WebContent"), "WEB-INF"), "lib"); + if (webLibsDir.exists()) { + File[] webLibs = webLibsDir.listFiles(new FileFilter() { + + public boolean accept(File file) { + return file.isFile() && file.getName().endsWith(".jar"); + } + }); + if (webLibs == null) { + return; + } + for (File webLib : webLibs) { + try { + String relativePath = webLib.getCanonicalFile().getAbsolutePath().substring(location.getCanonicalFile().getAbsolutePath().length() + 1); + libs.add(relativePath); + } catch (IOException e) { + // TODO handle exception + System.out.println("IOException: " + e.getMessage()); + } + } + } + } + } + + /** + * Resolves all unresolved dependencies (denoted by symbolic names) by + * replacing them with actual references to plug-in objects in the given set + * of available plug-ins. + * + * @param allArtifacts all artifacts that were discovered + */ + @Override + public void resolveDependencies(Collection allArtifacts) { + for (IArtifact artifact : allArtifacts) { + Collection resolvedDependencies = getResolvedDependencies(); + Collection unresolvedDependencies = getUnresolvedDependencies(); + + for (UnresolvedDependency dependency : unresolvedDependencies) { + if (dependency.isFulfilledBy(artifact)) { + addDependency(artifact); + resolvedDependencies.add(dependency); + } + } + // --- inserted in superclass code ---- + if (artifact instanceof Plugin) { + Plugin plugin = (Plugin) artifact; + if (unresolvedFragmentHost != null && unresolvedFragmentHost.isFulfilledBy(plugin)) { + plugin.addFragment(this); + fragmentHost = plugin; + addDependency(plugin); + } + } + // --- + unresolvedDependencies.removeAll(resolvedDependencies); + } + } + + private void addFragment(Plugin pluginFragment) { + fragments.add(pluginFragment); + } + + private Collection getPluginDependencies() { + Collection result = new LinkedHashSet(); + for (IDependable artifact : getDependencies()) { + if (artifact instanceof Plugin) { + Plugin plugin = (Plugin) artifact; + result.add(plugin); + if (getFragmentHost() != null) { + result.add(getFragmentHost()); + } + } + if (artifact instanceof Package) { + Package p = (Package) artifact; + result.add(p.getExportingPlugin()); + } + } + return Collections.unmodifiableCollection(result); + } + + /** + * Returns all plug-ins that this plug-in depends on, except the ones that + * are part of the target platform. + */ + public Set getDependenciesExcludingTargetPlatform() { + Set result = new LinkedHashSet(); + for (IDependable dependency : getDependencies()) { + if (dependency instanceof Plugin) { + Plugin plugin = (Plugin) dependency; + if (!plugin.isProject()) { + continue; + } + result.add(plugin); + } + } + return Collections.unmodifiableSet(result); + } + + public Set getExportedPackages() { + return exportedPackages; + } + + public Set getLibs() { + return libs; + } + + /** + * Returns all dependencies transitively. + */ + public Set getAllDependencies() { + if (allDependencies == null) { + Collection pluginDependencies = getPluginDependencies(); + + allDependencies = new LinkedHashSet(); + allDependencies.addAll(pluginDependencies); + allDependencies.addAll(fragments); + + for (Plugin dependency : pluginDependencies) { + allDependencies.addAll(dependency.getAllDependencies()); + } + for (Plugin fragment : fragments) { + allDependencies.addAll(fragment.getAllDependencies()); + } + } + return allDependencies; + } + + /** + * Returns the absolute paths of all libraries (transitively). + */ + public Set getAllLibPaths() { + if (allLibs == null) { + allLibs = new LinkedHashSet(); + for (String lib : getLibs()) { + allLibs.add(getAbsoluteLibPath(lib)); + } + for (Plugin dependency : getPluginDependencies()) { + allLibs.addAll(dependency.getAllLibPaths()); + } + } + return allLibs; + } + + /** + * Returns the absolute path of the given library. + */ + public String getAbsoluteLibPath(String lib) { + String prefix = getAbsolutePath() + "/"; + if (lib.startsWith("/")) { + // absolute paths to libraries must be handled differently + return prefix + ".." + lib; + } else { + return prefix + lib; + } + } + + public File getLocation() { + return location; + } + + public String getAbsolutePath() { + if (absolutePath == null) { + absolutePath = location.getAbsolutePath(); + } + return absolutePath; + } + + /** + * Returns the source folders of this plug-in, if there are any. + */ + public File[] getSourceFolders() { + if (location.isFile()) { + return new File[0]; + } + File[] sourceFolders = location.listFiles(new FileFilter() { + + public boolean accept(File pathname) { + return pathname.getName().equals("src") || + pathname.getName().startsWith("src-") || + pathname.getName().equals("xtend-gen"); + } + }); + if (sourceFolders == null) { + return new File[0]; + } + return sourceFolders; + } + + /** + * Checks whether this plug-in depends on the given other plug-in. + */ + public boolean dependsOn(Plugin otherPlugin) { + // check direct dependency + if (getDependencies().contains(otherPlugin)) { + return true; + } + for (Plugin dependency : getPluginDependencies()) { + if (dependency.dependsOn(otherPlugin)) { + return true; + } + } + return false; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + + ((getIdentifier() == null) ? 0 : getIdentifier().hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + Plugin other = (Plugin) obj; + if (getIdentifier() == null) { + if (other.getIdentifier() != null) + return false; + } else if (!getIdentifier().equals(other.getIdentifier())) + return false; + return true; + } + + public boolean hasManifest() { + return getManifestFile().exists(); + } + + /** + * Returns an input stream to access the manifest of this plug-in. + */ + private InputStream getManifestInputStream() throws IOException { + File pluginLocation = getLocation(); + if (pluginLocation.isFile()) { + ZipFile zipFile = new ZipFile(pluginLocation); + ZipEntry manifestEntry = zipFile.getEntry("META-INF/MANIFEST.MF"); + if (manifestEntry == null) { + return null; + } + InputStream inputStream = zipFile.getInputStream(manifestEntry); + return inputStream; + } else { + File manifest = getManifestFile(); + if (!manifest.exists()) { + System.out.println("INFO: Project without MANIFEST: " + getLocation().getName()); + return null; + } + return new FileInputStream(manifest); + } + } + + private File getManifestFile() { + File manifest = new File(new File(getLocation(), "META-INF"), "MANIFEST.MF"); + return manifest; + } + + private void analyzeClassPath() throws IOException { + InputStream dotClassPathInputStream = getDotClasspathInputStream(); + if (dotClassPathInputStream != null) { + this.libs.addAll(new DotClasspathReader(dotClassPathInputStream).getDependencies()); + dotClassPathInputStream.close(); + } + } + + private InputStream getDotClasspathInputStream() throws FileNotFoundException { + File pluginLocation = getLocation(); + if (pluginLocation.isDirectory()) { + File dotClassPathFile = new File(pluginLocation, ".classpath"); + if (!dotClassPathFile.exists()) { + return null; + } + return new FileInputStream(dotClassPathFile); + } else { + // JARs do usually not contain .classpath files since they contain + // compiled plug-ins. + return null; + } + } + + public boolean isExperimental() { + return new File(getAbsolutePath(), "EXPERIMENTAL").exists(); + } + + public boolean isProject() { + return true; + } + + public Plugin getFragmentHost() { + return fragmentHost; + } + + public File getFile() { + return getLocation(); + } + +} diff --git a/Core/de.devboost.buildboost/src/de/devboost/buildboost/artifacts/RepositoriesFile.java b/Core/de.devboost.buildboost/src/de/devboost/buildboost/artifacts/RepositoriesFile.java index ddc2442..cd67568 100644 --- a/Core/de.devboost.buildboost/src/de/devboost/buildboost/artifacts/RepositoriesFile.java +++ b/Core/de.devboost.buildboost/src/de/devboost/buildboost/artifacts/RepositoriesFile.java @@ -1,143 +1,143 @@ -/******************************************************************************* - * Copyright (c) 2006-2012 - * Software Technology Group, Dresden University of Technology - * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 - * - * All rights reserved. This program and the accompanying materials - * are 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 - * - * Contributors: - * Software Technology Group - TU Dresden, Germany; - * DevBoost GmbH - Berlin, Germany - * - initial API and implementation - ******************************************************************************/ -package de.devboost.buildboost.artifacts; - -import static de.devboost.buildboost.IConstants.BUILD_BOOST_REPOSITORY_URL; - -import java.io.BufferedReader; -import java.io.File; -import java.io.FileReader; -import java.io.IOException; -import java.util.ArrayList; -import java.util.LinkedHashMap; -import java.util.LinkedHashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import de.devboost.buildboost.BuildException; - -@SuppressWarnings("serial") -public class RepositoriesFile extends AbstractArtifact { - - public static String SUB_DIR_SEPARATOR = "!"; - - public static String[] SUPPORTED_TYPES = { "svn:", "git:", "get:" }; - - public class Location { - private String type; - private String url; - private Set subDirectories; - - public Location(String type, String url) { - super(); - this.type = type; - this.url = url; - this.subDirectories = new LinkedHashSet(); - //TODO we wouldn't need this if we create an extra repository for extensions - if (BUILD_BOOST_REPOSITORY_URL.equals(url)) { - subDirectories.add("Core/"); - subDirectories.add("Universal/"); - } - } - - public String getType() { - return type; - } - - public String getUrl() { - return url; - } - - public Set getSubDirectories() { - return subDirectories; - } - - } - - private File file; - private Map locations; - - public RepositoriesFile(File file) throws BuildException { - this.file = file; - setIdentifier(file.getName()); - readContent(file); - } - - private void readContent(File file) throws BuildException { - locations = new LinkedHashMap(); - try { - BufferedReader reader = new BufferedReader(new FileReader(file)); - String locationString; - readLine: while((locationString = reader.readLine()) != null) { - locationString = locationString.trim(); - if (isComment(locationString)) { - continue readLine; - } - for (String supportedType : SUPPORTED_TYPES) { - if (locationString.startsWith(supportedType)) { - String type = supportedType.substring(0, supportedType.length() - 1); - String url = locationString.substring(supportedType.length()).trim(); - String subDirectory = null; - int idx = url.lastIndexOf(SUB_DIR_SEPARATOR); - if (idx != -1) { - subDirectory = url.substring(idx + 1); - url = url.substring(0, idx); - } - Location location = locations.get(url); - if (location == null) { - location = new Location(type, url); - locations.put(url, location); - } - if (subDirectory != null) { - location.getSubDirectories().add(subDirectory); - } - continue readLine; - } - } - - reader.close(); - throw new BuildException("Cannot handle repository location: " + locationString); - } - reader.close(); - } catch (IOException e) { - e.printStackTrace(); - } - } - - private boolean isComment(String locationString) { - if (locationString.isEmpty()) { - return true; - } - if (locationString.startsWith("//")) { - return true; - } - return false; - } - - public File getFile() { - return file; - } - - @Override - public long getTimestamp() { - return file.lastModified(); - } - - public List getLocations() { - return new ArrayList(locations.values()); - } -} +/******************************************************************************* + * Copyright (c) 2006-2012 + * Software Technology Group, Dresden University of Technology + * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 + * + * All rights reserved. This program and the accompanying materials + * are 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 + * + * Contributors: + * Software Technology Group - TU Dresden, Germany; + * DevBoost GmbH - Berlin, Germany + * - initial API and implementation + ******************************************************************************/ +package de.devboost.buildboost.artifacts; + +import static de.devboost.buildboost.IConstants.BUILD_BOOST_REPOSITORY_URL; + +import java.io.BufferedReader; +import java.io.File; +import java.io.FileReader; +import java.io.IOException; +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import de.devboost.buildboost.BuildException; + +@SuppressWarnings("serial") +public class RepositoriesFile extends AbstractArtifact { + + public static String SUB_DIR_SEPARATOR = "!"; + + public static String[] SUPPORTED_TYPES = { "svn:", "git:", "get:" }; + + public class Location { + private String type; + private String url; + private Set subDirectories; + + public Location(String type, String url) { + super(); + this.type = type; + this.url = url; + this.subDirectories = new LinkedHashSet(); + //TODO we wouldn't need this if we create an extra repository for extensions + if (BUILD_BOOST_REPOSITORY_URL.equals(url)) { + subDirectories.add("Core/"); + subDirectories.add("Universal/"); + } + } + + public String getType() { + return type; + } + + public String getUrl() { + return url; + } + + public Set getSubDirectories() { + return subDirectories; + } + + } + + private File file; + private Map locations; + + public RepositoriesFile(File file) throws BuildException { + this.file = file; + setIdentifier(file.getName()); + readContent(file); + } + + private void readContent(File file) throws BuildException { + locations = new LinkedHashMap(); + try { + BufferedReader reader = new BufferedReader(new FileReader(file)); + String locationString; + readLine: while((locationString = reader.readLine()) != null) { + locationString = locationString.trim(); + if (isComment(locationString)) { + continue readLine; + } + for (String supportedType : SUPPORTED_TYPES) { + if (locationString.startsWith(supportedType)) { + String type = supportedType.substring(0, supportedType.length() - 1); + String url = locationString.substring(supportedType.length()).trim(); + String subDirectory = null; + int idx = url.lastIndexOf(SUB_DIR_SEPARATOR); + if (idx != -1) { + subDirectory = url.substring(idx + 1); + url = url.substring(0, idx); + } + Location location = locations.get(url); + if (location == null) { + location = new Location(type, url); + locations.put(url, location); + } + if (subDirectory != null) { + location.getSubDirectories().add(subDirectory); + } + continue readLine; + } + } + + reader.close(); + throw new BuildException("Cannot handle repository location: " + locationString); + } + reader.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + + private boolean isComment(String locationString) { + if (locationString.isEmpty()) { + return true; + } + if (locationString.startsWith("//")) { + return true; + } + return false; + } + + public File getFile() { + return file; + } + + @Override + public long getTimestamp() { + return file.lastModified(); + } + + public List getLocations() { + return new ArrayList(locations.values()); + } +} diff --git a/Core/de.devboost.buildboost/src/de/devboost/buildboost/artifacts/TargetPlatformZip.java b/Core/de.devboost.buildboost/src/de/devboost/buildboost/artifacts/TargetPlatformZip.java index 9d12919..677c8f5 100644 --- a/Core/de.devboost.buildboost/src/de/devboost/buildboost/artifacts/TargetPlatformZip.java +++ b/Core/de.devboost.buildboost/src/de/devboost/buildboost/artifacts/TargetPlatformZip.java @@ -1,43 +1,43 @@ -/******************************************************************************* - * Copyright (c) 2006-2012 - * Software Technology Group, Dresden University of Technology - * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 - * - * All rights reserved. This program and the accompanying materials - * are 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 - * - * Contributors: - * Software Technology Group - TU Dresden, Germany; - * DevBoost GmbH - Berlin, Germany - * - initial API and implementation - ******************************************************************************/ -package de.devboost.buildboost.artifacts; - -import java.io.File; - -/** - * A ConcreteSyntaxDefinition represents an EMFText syntax specification (a - * file with extension 'cs'). - */ -@SuppressWarnings("serial") -public class TargetPlatformZip extends AbstractArtifact { - - private File zipFile; - - public TargetPlatformZip(File zipFile) { - super(); - this.zipFile = zipFile; - setIdentifier(zipFile.getName()); - } - - public File getZipFile() { - return zipFile; - } - - @Override - public long getTimestamp() { - return zipFile.lastModified(); - } -} +/******************************************************************************* + * Copyright (c) 2006-2012 + * Software Technology Group, Dresden University of Technology + * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 + * + * All rights reserved. This program and the accompanying materials + * are 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 + * + * Contributors: + * Software Technology Group - TU Dresden, Germany; + * DevBoost GmbH - Berlin, Germany + * - initial API and implementation + ******************************************************************************/ +package de.devboost.buildboost.artifacts; + +import java.io.File; + +/** + * A ConcreteSyntaxDefinition represents an EMFText syntax specification (a + * file with extension 'cs'). + */ +@SuppressWarnings("serial") +public class TargetPlatformZip extends AbstractArtifact { + + private File zipFile; + + public TargetPlatformZip(File zipFile) { + super(); + this.zipFile = zipFile; + setIdentifier(zipFile.getName()); + } + + public File getZipFile() { + return zipFile; + } + + @Override + public long getTimestamp() { + return zipFile.lastModified(); + } +} diff --git a/Core/de.devboost.buildboost/src/de/devboost/buildboost/discovery/AbstractArtifactDiscoverer.java b/Core/de.devboost.buildboost/src/de/devboost/buildboost/discovery/AbstractArtifactDiscoverer.java index e8c13a6..fc86eb5 100644 --- a/Core/de.devboost.buildboost/src/de/devboost/buildboost/discovery/AbstractArtifactDiscoverer.java +++ b/Core/de.devboost.buildboost/src/de/devboost/buildboost/discovery/AbstractArtifactDiscoverer.java @@ -1,40 +1,40 @@ -/******************************************************************************* - * Copyright (c) 2006-2012 - * Software Technology Group, Dresden University of Technology - * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 - * - * All rights reserved. This program and the accompanying materials - * are 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 - * - * Contributors: - * Software Technology Group - TU Dresden, Germany; - * DevBoost GmbH - Berlin, Germany - * - initial API and implementation - ******************************************************************************/ -package de.devboost.buildboost.discovery; - -import java.util.Collection; - -import de.devboost.buildboost.BuildException; -import de.devboost.buildboost.model.AbstractBuildParticipant; -import de.devboost.buildboost.model.BuildEventType; -import de.devboost.buildboost.model.IArtifact; -import de.devboost.buildboost.model.IArtifactDiscoverer; -import de.devboost.buildboost.model.IBuildContext; -import de.devboost.buildboost.model.IBuildListener; - -public abstract class AbstractArtifactDiscoverer extends AbstractBuildParticipant - implements IArtifactDiscoverer { - - @Override - public void execute(IBuildContext context) throws BuildException { - IBuildListener buildListener = context.getBuildListener(); - buildListener.handleBuildEvent( - BuildEventType.INFO, - "Running artifact discoverer: " + this); - Collection discoveredArtifacts = discoverArtifacts(context); - context.addDiscoveredArtifacts(discoveredArtifacts); - } -} +/******************************************************************************* + * Copyright (c) 2006-2012 + * Software Technology Group, Dresden University of Technology + * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 + * + * All rights reserved. This program and the accompanying materials + * are 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 + * + * Contributors: + * Software Technology Group - TU Dresden, Germany; + * DevBoost GmbH - Berlin, Germany + * - initial API and implementation + ******************************************************************************/ +package de.devboost.buildboost.discovery; + +import java.util.Collection; + +import de.devboost.buildboost.BuildException; +import de.devboost.buildboost.model.AbstractBuildParticipant; +import de.devboost.buildboost.model.BuildEventType; +import de.devboost.buildboost.model.IArtifact; +import de.devboost.buildboost.model.IArtifactDiscoverer; +import de.devboost.buildboost.model.IBuildContext; +import de.devboost.buildboost.model.IBuildListener; + +public abstract class AbstractArtifactDiscoverer extends AbstractBuildParticipant + implements IArtifactDiscoverer { + + @Override + public void execute(IBuildContext context) throws BuildException { + IBuildListener buildListener = context.getBuildListener(); + buildListener.handleBuildEvent( + BuildEventType.INFO, + "Running artifact discoverer: " + this); + Collection discoveredArtifacts = discoverArtifacts(context); + context.addDiscoveredArtifacts(discoveredArtifacts); + } +} diff --git a/Core/de.devboost.buildboost/src/de/devboost/buildboost/discovery/AbstractFileFinder.java b/Core/de.devboost.buildboost/src/de/devboost/buildboost/discovery/AbstractFileFinder.java index d74e584..c05bfad 100644 --- a/Core/de.devboost.buildboost/src/de/devboost/buildboost/discovery/AbstractFileFinder.java +++ b/Core/de.devboost.buildboost/src/de/devboost/buildboost/discovery/AbstractFileFinder.java @@ -1,107 +1,107 @@ -/******************************************************************************* - * Copyright (c) 2006-2012 - * Software Technology Group, Dresden University of Technology - * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 - * - * All rights reserved. This program and the accompanying materials - * are 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 - * - * Contributors: - * Software Technology Group - TU Dresden, Germany; - * DevBoost GmbH - Berlin, Germany - * - initial API and implementation - ******************************************************************************/ -package de.devboost.buildboost.discovery; - -import java.io.File; -import java.io.FileFilter; -import java.util.Collection; - -import de.devboost.buildboost.BuildException; -import de.devboost.buildboost.model.IArtifact; -import de.devboost.buildboost.model.IBuildContext; -import de.devboost.buildboost.model.IBuildParticipant; - -/** - * An abstract base class for discoverers that search for files in the - * workspace that is subject to the current build. - * - * @param the type of artifact that is searched for - */ -public abstract class AbstractFileFinder - extends AbstractArtifactDiscoverer { - - protected File directory; - - public AbstractFileFinder(File directory) { - super(); - this.directory = directory; - } - - protected void traverse( - IBuildContext context, - Collection artifacts) throws BuildException { - traverse(context, directory, artifacts); - } - - /** - * Traverses the given directory and all its sub folders recursively to - * find artifacts. Using the two template methods {@link #getFileFilter()} - * and {@link #createArtifactFromFile(File)} sub classes can determine which - * files are considered and how these are converted into artifact objects. - * - * @param context the context this build is performed in - * @param directory the root directory where to start the traversal - * @param artifacts a collection that is used to store the found artifacts - * @throws BuildException - */ - protected void traverse( - IBuildContext context, - File directory, - Collection artifacts) throws BuildException { - - findFiles(directory, artifacts); - - File[] subDirectories = directory.listFiles(getDirectoryFilter()); - if (subDirectories == null) { - return; - } - for (File subDirectory : subDirectories) { - traverse(context, subDirectory, artifacts); - } - } - - private void findFiles(File directory, Collection artifacts) throws BuildException { - File[] files = directory.listFiles(getFileFilter()); - if (files == null) { - return; - } - for (File file : files) { - artifacts.add(createArtifactFromFile(file)); - } - } - - @Override - public boolean dependsOn(IBuildParticipant otherParticipant) { - return false; - } - - @Override - public String toString() { - return getClass().getSimpleName() + "[" + directory.getAbsolutePath() + "]"; - } - - protected abstract ArtifactType createArtifactFromFile(File file) throws BuildException; - - protected FileFilter getDirectoryFilter() { - return new FileFilter() { - public boolean accept(File file) { - return file.isDirectory(); - } - }; - } - - protected abstract FileFilter getFileFilter(); -} +/******************************************************************************* + * Copyright (c) 2006-2012 + * Software Technology Group, Dresden University of Technology + * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 + * + * All rights reserved. This program and the accompanying materials + * are 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 + * + * Contributors: + * Software Technology Group - TU Dresden, Germany; + * DevBoost GmbH - Berlin, Germany + * - initial API and implementation + ******************************************************************************/ +package de.devboost.buildboost.discovery; + +import java.io.File; +import java.io.FileFilter; +import java.util.Collection; + +import de.devboost.buildboost.BuildException; +import de.devboost.buildboost.model.IArtifact; +import de.devboost.buildboost.model.IBuildContext; +import de.devboost.buildboost.model.IBuildParticipant; + +/** + * An abstract base class for discoverers that search for files in the + * workspace that is subject to the current build. + * + * @param the type of artifact that is searched for + */ +public abstract class AbstractFileFinder + extends AbstractArtifactDiscoverer { + + protected File directory; + + public AbstractFileFinder(File directory) { + super(); + this.directory = directory; + } + + protected void traverse( + IBuildContext context, + Collection artifacts) throws BuildException { + traverse(context, directory, artifacts); + } + + /** + * Traverses the given directory and all its sub folders recursively to + * find artifacts. Using the two template methods {@link #getFileFilter()} + * and {@link #createArtifactFromFile(File)} sub classes can determine which + * files are considered and how these are converted into artifact objects. + * + * @param context the context this build is performed in + * @param directory the root directory where to start the traversal + * @param artifacts a collection that is used to store the found artifacts + * @throws BuildException + */ + protected void traverse( + IBuildContext context, + File directory, + Collection artifacts) throws BuildException { + + findFiles(directory, artifacts); + + File[] subDirectories = directory.listFiles(getDirectoryFilter()); + if (subDirectories == null) { + return; + } + for (File subDirectory : subDirectories) { + traverse(context, subDirectory, artifacts); + } + } + + private void findFiles(File directory, Collection artifacts) throws BuildException { + File[] files = directory.listFiles(getFileFilter()); + if (files == null) { + return; + } + for (File file : files) { + artifacts.add(createArtifactFromFile(file)); + } + } + + @Override + public boolean dependsOn(IBuildParticipant otherParticipant) { + return false; + } + + @Override + public String toString() { + return getClass().getSimpleName() + "[" + directory.getAbsolutePath() + "]"; + } + + protected abstract ArtifactType createArtifactFromFile(File file) throws BuildException; + + protected FileFilter getDirectoryFilter() { + return new FileFilter() { + public boolean accept(File file) { + return file.isDirectory(); + } + }; + } + + protected abstract FileFilter getFileFilter(); +} diff --git a/Core/de.devboost.buildboost/src/de/devboost/buildboost/discovery/EclipseFeatureFinder.java b/Core/de.devboost.buildboost/src/de/devboost/buildboost/discovery/EclipseFeatureFinder.java index ece3c55..c7b7616 100644 --- a/Core/de.devboost.buildboost/src/de/devboost/buildboost/discovery/EclipseFeatureFinder.java +++ b/Core/de.devboost.buildboost/src/de/devboost/buildboost/discovery/EclipseFeatureFinder.java @@ -1,90 +1,90 @@ -/******************************************************************************* - * Copyright (c) 2006-2012 - * Software Technology Group, Dresden University of Technology - * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 - * - * All rights reserved. This program and the accompanying materials - * are 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 - * - * Contributors: - * Software Technology Group - TU Dresden, Germany; - * DevBoost GmbH - Berlin, Germany - * - initial API and implementation - ******************************************************************************/ -package de.devboost.buildboost.discovery; - -import java.io.File; -import java.io.FileFilter; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; - -import de.devboost.buildboost.artifacts.EclipseFeature; -import de.devboost.buildboost.model.IArtifact; -import de.devboost.buildboost.model.IBuildContext; -import de.devboost.buildboost.util.ArtifactUtil; - -/** - * An {@link EclipseFeatureFinder} can be used to discover Eclipse features - * (i.e., files with name 'feature.xml'). - * - * TODO inherit from {@link AbstractFileFinder}? - */ -public class EclipseFeatureFinder extends AbstractArtifactDiscoverer { - - private File directory; - - public EclipseFeatureFinder(File directory) { - this.directory = directory; - } - - public Collection discoverArtifacts(IBuildContext context) { - Collection features = discoverArtifacts(context, directory); - return new ArtifactUtil().getSetOfArtifacts(features); - } - - private Collection discoverArtifacts( - IBuildContext context, File directory) { - - Collection features = new ArrayList(); - features.addAll(findFeatureFiles(directory)); - traverseSubDirectories(context, directory, features); - return features; - } - - private void traverseSubDirectories(IBuildContext context, File directory, - Collection features) { - File[] subDirectories = directory.listFiles(new FileFilter() { - - public boolean accept(File file) { - return file.isDirectory(); - } - }); - if (subDirectories == null) { - return; - } - for (File subDirectory : subDirectories) { - features.addAll(discoverArtifacts(context, subDirectory)); - } - } - - private Collection findFeatureFiles(File directory) { - File[] featureXmlFiles = directory.listFiles(new FileFilter() { - - public boolean accept(File file) { - return file.getName().equals("feature.xml"); - } - }); - if (featureXmlFiles == null) { - return Collections.emptySet(); - } - - Collection features = new ArrayList(featureXmlFiles.length); - for (File featureXmlFile : featureXmlFiles) { - features.add(new EclipseFeature(featureXmlFile)); - } - return features; - } -} +/******************************************************************************* + * Copyright (c) 2006-2012 + * Software Technology Group, Dresden University of Technology + * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 + * + * All rights reserved. This program and the accompanying materials + * are 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 + * + * Contributors: + * Software Technology Group - TU Dresden, Germany; + * DevBoost GmbH - Berlin, Germany + * - initial API and implementation + ******************************************************************************/ +package de.devboost.buildboost.discovery; + +import java.io.File; +import java.io.FileFilter; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; + +import de.devboost.buildboost.artifacts.EclipseFeature; +import de.devboost.buildboost.model.IArtifact; +import de.devboost.buildboost.model.IBuildContext; +import de.devboost.buildboost.util.ArtifactUtil; + +/** + * An {@link EclipseFeatureFinder} can be used to discover Eclipse features + * (i.e., files with name 'feature.xml'). + * + * TODO inherit from {@link AbstractFileFinder}? + */ +public class EclipseFeatureFinder extends AbstractArtifactDiscoverer { + + private File directory; + + public EclipseFeatureFinder(File directory) { + this.directory = directory; + } + + public Collection discoverArtifacts(IBuildContext context) { + Collection features = discoverArtifacts(context, directory); + return new ArtifactUtil().getSetOfArtifacts(features); + } + + private Collection discoverArtifacts( + IBuildContext context, File directory) { + + Collection features = new ArrayList(); + features.addAll(findFeatureFiles(directory)); + traverseSubDirectories(context, directory, features); + return features; + } + + private void traverseSubDirectories(IBuildContext context, File directory, + Collection features) { + File[] subDirectories = directory.listFiles(new FileFilter() { + + public boolean accept(File file) { + return file.isDirectory(); + } + }); + if (subDirectories == null) { + return; + } + for (File subDirectory : subDirectories) { + features.addAll(discoverArtifacts(context, subDirectory)); + } + } + + private Collection findFeatureFiles(File directory) { + File[] featureXmlFiles = directory.listFiles(new FileFilter() { + + public boolean accept(File file) { + return file.getName().equals("feature.xml"); + } + }); + if (featureXmlFiles == null) { + return Collections.emptySet(); + } + + Collection features = new ArrayList(featureXmlFiles.length); + for (File featureXmlFile : featureXmlFiles) { + features.add(new EclipseFeature(featureXmlFile)); + } + return features; + } +} diff --git a/Core/de.devboost.buildboost/src/de/devboost/buildboost/discovery/EclipseTargetPlatformAnalyzer.java b/Core/de.devboost.buildboost/src/de/devboost/buildboost/discovery/EclipseTargetPlatformAnalyzer.java index 004f6a2..afc05ff 100644 --- a/Core/de.devboost.buildboost/src/de/devboost/buildboost/discovery/EclipseTargetPlatformAnalyzer.java +++ b/Core/de.devboost.buildboost/src/de/devboost/buildboost/discovery/EclipseTargetPlatformAnalyzer.java @@ -1,270 +1,270 @@ -/******************************************************************************* - * Copyright (c) 2006-2012 - * Software Technology Group, Dresden University of Technology - * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 - * - * All rights reserved. This program and the accompanying materials - * are 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 - * - * Contributors: - * Software Technology Group - TU Dresden, Germany; - * DevBoost GmbH - Berlin, Germany - * - initial API and implementation - ******************************************************************************/ -package de.devboost.buildboost.discovery; - -import java.io.File; -import java.io.FileFilter; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; -import java.util.Collection; -import java.util.Collections; -import java.util.LinkedHashSet; -import java.util.Set; - -import de.devboost.buildboost.artifacts.CompiledPlugin; -import de.devboost.buildboost.artifacts.EclipseFeature; -import de.devboost.buildboost.artifacts.Plugin; -import de.devboost.buildboost.model.BuildEventType; -import de.devboost.buildboost.model.IArtifact; -import de.devboost.buildboost.model.IBuildContext; -import de.devboost.buildboost.model.IBuildListener; -import de.devboost.buildboost.util.ArtifactUtil; - -/** - * The EclipseTargetPlatformAnalyzer can be used to scan an Eclipse instance - * to detect all contained plug-ins. This is required to compile Eclipse - * plug-in projects that depend on plug-in of an Eclipse target platform. - */ -//TODO is there a overlap with FeatureFinder? -public class EclipseTargetPlatformAnalyzer extends AbstractArtifactDiscoverer { - - public static final String ARTIFACT_CACHE_FILE_NAME = "artifact_cache.ser"; - - private interface IArtifactCreator { - - public IArtifact create(File file) throws IOException; - } - - private File targetPlatform; - - public EclipseTargetPlatformAnalyzer(File targetPlatform) { - this.targetPlatform = targetPlatform; - } - - //TODO the discover should traverse the folder hierarchy only once. - // Could we optimize discovering in general such that there is only one traversal each time? - public Collection discoverArtifacts(IBuildContext context) { - IBuildListener buildListener = context.getBuildListener(); - buildListener.handleBuildEvent(BuildEventType.INFO, "Analyzing target platform..."); - - //TODO activate cache - /*Set cachedArtifacts = loadDiscoveredArtifacts(); - if (cachedArtifacts != null) { - buildListener.handleBuildEvent(BuildEventType.INFO, "Loaded cached target platform info: " + cachedArtifacts); - return cachedArtifacts; - }*/ - - LinkedHashSet artifacts = new LinkedHashSet(); - - // first, find plug-ins - Set pluginJarsAndDirs = findJarFilesAndPluginDirs(targetPlatform, new FileFilter() { - - @Override - public boolean accept(File file) { - // exclude JUnit 3, because this requires to check the bundle - // version when resolving dependencies - // TODO remove this once the versions are checked - if (file.getName().contains("org.junit_3")) { - return false; - } - if (file.isDirectory() && isPluginDir(file)) { - return true; - } - if (file.isFile() && file.getName().endsWith(".jar")) { - return true; - } - return false; - } - }); - Set foundPlugins = analyzeTargetPlatformJarFiles(pluginJarsAndDirs, "plug-in", buildListener, new IArtifactCreator() { - - @Override - public IArtifact create(File file) throws IOException { - return new CompiledPlugin(file); - } - }); - artifacts.addAll(foundPlugins); - - // second, find features - Set featureJarsAndDirs = findJarFilesAndPluginDirs(targetPlatform, new FileFilter() { - - @Override - public boolean accept(File file) { - if (!file.getParentFile().getName().equals("features")) { - return false; - } - return isFeatureDirOrJar(file); - } - - }); - - Set foundFeatures = analyzeTargetPlatformJarFiles(featureJarsAndDirs, "feature", buildListener, new IArtifactCreator() { - - @Override - public IArtifact create(File fileDirectoryOrJar) throws IOException { - if (fileDirectoryOrJar.isDirectory()) { - return new EclipseFeature(new File(fileDirectoryOrJar, "feature.xml")); - } else { - return new EclipseFeature(fileDirectoryOrJar); - } - } - }); - - artifacts.addAll(foundFeatures); - saveDiscoveredArtifacts(artifacts); - return artifacts; - } - - private void saveDiscoveredArtifacts(LinkedHashSet artifacts) { - try { - FileOutputStream fos = new FileOutputStream(new File(targetPlatform, ARTIFACT_CACHE_FILE_NAME)); - ObjectOutputStream oos = new ObjectOutputStream(fos); - oos.writeObject(artifacts); - fos.close(); - } catch (FileNotFoundException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - - @SuppressWarnings({ "unchecked", "unused" }) - private Set loadDiscoveredArtifacts() { - File cacheFile = new File(targetPlatform, ARTIFACT_CACHE_FILE_NAME); - if (!cacheFile.exists()) { - return null; - } - try { - FileInputStream fis = new FileInputStream(cacheFile); - ObjectInputStream ois = new ObjectInputStream(fis); - Object object = ois.readObject(); - fis.close(); - - if (object instanceof Set) { - return (Set) object; - } - } catch (FileNotFoundException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (ClassNotFoundException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - return null; - } - - private Set findJarFilesAndPluginDirs(File directory, FileFilter fileFilter) { - if (!directory.isDirectory()) { - return Collections.emptySet(); - } - File[] allFiles = directory.listFiles(); - Set result = new LinkedHashSet(); - for (File file : allFiles) { - //ignore projects and things inside projects - if (file.isDirectory()) { - File dotProject = new File(file, ".project"); - if (dotProject.exists()) { - continue; - } - } - - if (fileFilter.accept(file)) { - result.add(file); - } else if (file.isDirectory()) { - result.addAll(findJarFilesAndPluginDirs(file, fileFilter)); - } - } - return result; - } - - private Set analyzeTargetPlatformJarFiles( - Set targetPlatformFiles, - String type, - IBuildListener buildListener, - IArtifactCreator creator) { - Set artifacts = new LinkedHashSet(); - for (File targetPlatformFile : targetPlatformFiles) { - IArtifact artifact; - try { - artifact = creator.create(targetPlatformFile); - } catch (IOException e) { - buildListener.handleBuildEvent(BuildEventType.WARNING, "Exception while analyzing target platform " + type + " " + targetPlatformFile.toString() + ": " + e.getMessage()); - continue; - } - if (artifact.getIdentifier() == null) { - buildListener.handleBuildEvent( - BuildEventType.INFO, - "Ignoring target platform " + type + " without name at " + targetPlatformFile.getAbsolutePath() - ); - continue; - } - artifacts.add(artifact); - if (artifact instanceof CompiledPlugin) { - artifacts.addAll(((Plugin) artifact).getExportedPackages()); - } - buildListener.handleBuildEvent( - BuildEventType.INFO, - "Found target platform " + type + " '" + artifact.getIdentifier() + "' at " + targetPlatformFile.getAbsolutePath() - ); - } - - return new ArtifactUtil().getSetOfArtifacts(artifacts); - } - - /** - * Checks whether the given directory contains a 'META-INF/MANIFEST.MF' file. - */ - private boolean isPluginDir(File directory) { - File metaInfDir = new File(directory, "META-INF"); - if (!metaInfDir.exists()) { - return false; - } - File manifestFile = new File(metaInfDir, "MANIFEST.MF"); - return manifestFile.exists(); - } - - private boolean isFeatureDirOrJar(File file) { - if (!file.getParentFile().getName().equals("features")) { - return false; - } - if (file.isDirectory()) { - File featureDescriptor = new File(file, "feature.xml"); - if (featureDescriptor.exists()) { - return true; - } - } else { - if (file.getName().endsWith(".jar")) { - return true; - } - } - - return false; - } - - @Override - public String toString() { - return this.getClass().getSimpleName() + "[" + targetPlatform.getPath() + "]"; - } -} +/******************************************************************************* + * Copyright (c) 2006-2012 + * Software Technology Group, Dresden University of Technology + * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 + * + * All rights reserved. This program and the accompanying materials + * are 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 + * + * Contributors: + * Software Technology Group - TU Dresden, Germany; + * DevBoost GmbH - Berlin, Germany + * - initial API and implementation + ******************************************************************************/ +package de.devboost.buildboost.discovery; + +import java.io.File; +import java.io.FileFilter; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.util.Collection; +import java.util.Collections; +import java.util.LinkedHashSet; +import java.util.Set; + +import de.devboost.buildboost.artifacts.CompiledPlugin; +import de.devboost.buildboost.artifacts.EclipseFeature; +import de.devboost.buildboost.artifacts.Plugin; +import de.devboost.buildboost.model.BuildEventType; +import de.devboost.buildboost.model.IArtifact; +import de.devboost.buildboost.model.IBuildContext; +import de.devboost.buildboost.model.IBuildListener; +import de.devboost.buildboost.util.ArtifactUtil; + +/** + * The EclipseTargetPlatformAnalyzer can be used to scan an Eclipse instance + * to detect all contained plug-ins. This is required to compile Eclipse + * plug-in projects that depend on plug-in of an Eclipse target platform. + */ +//TODO is there a overlap with FeatureFinder? +public class EclipseTargetPlatformAnalyzer extends AbstractArtifactDiscoverer { + + public static final String ARTIFACT_CACHE_FILE_NAME = "artifact_cache.ser"; + + private interface IArtifactCreator { + + public IArtifact create(File file) throws IOException; + } + + private File targetPlatform; + + public EclipseTargetPlatformAnalyzer(File targetPlatform) { + this.targetPlatform = targetPlatform; + } + + //TODO the discover should traverse the folder hierarchy only once. + // Could we optimize discovering in general such that there is only one traversal each time? + public Collection discoverArtifacts(IBuildContext context) { + IBuildListener buildListener = context.getBuildListener(); + buildListener.handleBuildEvent(BuildEventType.INFO, "Analyzing target platform..."); + + //TODO activate cache + /*Set cachedArtifacts = loadDiscoveredArtifacts(); + if (cachedArtifacts != null) { + buildListener.handleBuildEvent(BuildEventType.INFO, "Loaded cached target platform info: " + cachedArtifacts); + return cachedArtifacts; + }*/ + + LinkedHashSet artifacts = new LinkedHashSet(); + + // first, find plug-ins + Set pluginJarsAndDirs = findJarFilesAndPluginDirs(targetPlatform, new FileFilter() { + + @Override + public boolean accept(File file) { + // exclude JUnit 3, because this requires to check the bundle + // version when resolving dependencies + // TODO remove this once the versions are checked + if (file.getName().contains("org.junit_3")) { + return false; + } + if (file.isDirectory() && isPluginDir(file)) { + return true; + } + if (file.isFile() && file.getName().endsWith(".jar")) { + return true; + } + return false; + } + }); + Set foundPlugins = analyzeTargetPlatformJarFiles(pluginJarsAndDirs, "plug-in", buildListener, new IArtifactCreator() { + + @Override + public IArtifact create(File file) throws IOException { + return new CompiledPlugin(file); + } + }); + artifacts.addAll(foundPlugins); + + // second, find features + Set featureJarsAndDirs = findJarFilesAndPluginDirs(targetPlatform, new FileFilter() { + + @Override + public boolean accept(File file) { + if (!file.getParentFile().getName().equals("features")) { + return false; + } + return isFeatureDirOrJar(file); + } + + }); + + Set foundFeatures = analyzeTargetPlatformJarFiles(featureJarsAndDirs, "feature", buildListener, new IArtifactCreator() { + + @Override + public IArtifact create(File fileDirectoryOrJar) throws IOException { + if (fileDirectoryOrJar.isDirectory()) { + return new EclipseFeature(new File(fileDirectoryOrJar, "feature.xml")); + } else { + return new EclipseFeature(fileDirectoryOrJar); + } + } + }); + + artifacts.addAll(foundFeatures); + saveDiscoveredArtifacts(artifacts); + return artifacts; + } + + private void saveDiscoveredArtifacts(LinkedHashSet artifacts) { + try { + FileOutputStream fos = new FileOutputStream(new File(targetPlatform, ARTIFACT_CACHE_FILE_NAME)); + ObjectOutputStream oos = new ObjectOutputStream(fos); + oos.writeObject(artifacts); + fos.close(); + } catch (FileNotFoundException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + @SuppressWarnings({ "unchecked", "unused" }) + private Set loadDiscoveredArtifacts() { + File cacheFile = new File(targetPlatform, ARTIFACT_CACHE_FILE_NAME); + if (!cacheFile.exists()) { + return null; + } + try { + FileInputStream fis = new FileInputStream(cacheFile); + ObjectInputStream ois = new ObjectInputStream(fis); + Object object = ois.readObject(); + fis.close(); + + if (object instanceof Set) { + return (Set) object; + } + } catch (FileNotFoundException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (ClassNotFoundException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return null; + } + + private Set findJarFilesAndPluginDirs(File directory, FileFilter fileFilter) { + if (!directory.isDirectory()) { + return Collections.emptySet(); + } + File[] allFiles = directory.listFiles(); + Set result = new LinkedHashSet(); + for (File file : allFiles) { + //ignore projects and things inside projects + if (file.isDirectory()) { + File dotProject = new File(file, ".project"); + if (dotProject.exists()) { + continue; + } + } + + if (fileFilter.accept(file)) { + result.add(file); + } else if (file.isDirectory()) { + result.addAll(findJarFilesAndPluginDirs(file, fileFilter)); + } + } + return result; + } + + private Set analyzeTargetPlatformJarFiles( + Set targetPlatformFiles, + String type, + IBuildListener buildListener, + IArtifactCreator creator) { + Set artifacts = new LinkedHashSet(); + for (File targetPlatformFile : targetPlatformFiles) { + IArtifact artifact; + try { + artifact = creator.create(targetPlatformFile); + } catch (IOException e) { + buildListener.handleBuildEvent(BuildEventType.WARNING, "Exception while analyzing target platform " + type + " " + targetPlatformFile.toString() + ": " + e.getMessage()); + continue; + } + if (artifact.getIdentifier() == null) { + buildListener.handleBuildEvent( + BuildEventType.INFO, + "Ignoring target platform " + type + " without name at " + targetPlatformFile.getAbsolutePath() + ); + continue; + } + artifacts.add(artifact); + if (artifact instanceof CompiledPlugin) { + artifacts.addAll(((Plugin) artifact).getExportedPackages()); + } + buildListener.handleBuildEvent( + BuildEventType.INFO, + "Found target platform " + type + " '" + artifact.getIdentifier() + "' at " + targetPlatformFile.getAbsolutePath() + ); + } + + return new ArtifactUtil().getSetOfArtifacts(artifacts); + } + + /** + * Checks whether the given directory contains a 'META-INF/MANIFEST.MF' file. + */ + private boolean isPluginDir(File directory) { + File metaInfDir = new File(directory, "META-INF"); + if (!metaInfDir.exists()) { + return false; + } + File manifestFile = new File(metaInfDir, "MANIFEST.MF"); + return manifestFile.exists(); + } + + private boolean isFeatureDirOrJar(File file) { + if (!file.getParentFile().getName().equals("features")) { + return false; + } + if (file.isDirectory()) { + File featureDescriptor = new File(file, "feature.xml"); + if (featureDescriptor.exists()) { + return true; + } + } else { + if (file.getName().endsWith(".jar")) { + return true; + } + } + + return false; + } + + @Override + public String toString() { + return this.getClass().getSimpleName() + "[" + targetPlatform.getPath() + "]"; + } +} diff --git a/Core/de.devboost.buildboost/src/de/devboost/buildboost/discovery/PluginFinder.java b/Core/de.devboost.buildboost/src/de/devboost/buildboost/discovery/PluginFinder.java index 3439c91..e583d44 100644 --- a/Core/de.devboost.buildboost/src/de/devboost/buildboost/discovery/PluginFinder.java +++ b/Core/de.devboost.buildboost/src/de/devboost/buildboost/discovery/PluginFinder.java @@ -1,156 +1,156 @@ -/******************************************************************************* - * Copyright (c) 2006-2012 - * Software Technology Group, Dresden University of Technology - * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 - * - * All rights reserved. This program and the accompanying materials - * are 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 - * - * Contributors: - * Software Technology Group - TU Dresden, Germany; - * DevBoost GmbH - Berlin, Germany - * - initial API and implementation - ******************************************************************************/ -package de.devboost.buildboost.discovery; - -import java.io.File; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.Comparator; -import java.util.LinkedHashSet; -import java.util.List; -import java.util.Set; - -import de.devboost.buildboost.artifacts.Plugin; -import de.devboost.buildboost.model.BuildEventType; -import de.devboost.buildboost.model.IArtifact; -import de.devboost.buildboost.model.IBuildContext; -import de.devboost.buildboost.model.IBuildListener; -import de.devboost.buildboost.model.UnresolvedDependency; -import de.devboost.buildboost.util.ArtifactUtil; -import de.devboost.buildboost.util.EclipsePluginHelper; - -/** - * A {@link PluginFinder} can be used to discover Eclipse plug-in projects. - * Such projects typically contain a file called '.project'. - * - * TODO inherit from {@link AbstractFileFinder}? - */ -public class PluginFinder extends AbstractArtifactDiscoverer { - - private File directory; - - public PluginFinder(File directory) { - this.directory = directory; - } - - public Collection discoverArtifacts(IBuildContext context) { - IBuildListener buildListener = context.getBuildListener(); - - Collection allProjectDirs = findProjectDirs(directory, buildListener); - allProjectDirs = sortByPathName(allProjectDirs); - checkForDuplicates(allProjectDirs); - Set allPlugins = convertToPlugins(allProjectDirs, context.getBuildListener()); - // make unmodifiable - return Collections.unmodifiableSet(new ArtifactUtil().getSetOfArtifacts(allPlugins)); - } - - private Set findProjectDirs(File directory, IBuildListener buildListener) { - Set projectDirs = new LinkedHashSet(); - if (!directory.exists()) { - buildListener.handleBuildEvent( - BuildEventType.ERROR, - "Directory " + directory.getAbsolutePath() + " does not exist." - ); - return projectDirs; - } - if (!directory.isDirectory()) { - buildListener.handleBuildEvent( - BuildEventType.ERROR, - "File " + directory.getAbsolutePath() + " is not a directory." - ); - return projectDirs; - } - boolean isProject = new EclipsePluginHelper().isProject(directory); - if (isProject) { - projectDirs.add(directory); - // do not examine children of projects - return projectDirs; - } - // dive into child directories - File[] children = directory.listFiles(); - if (children == null) { - return projectDirs; - } - for (File child : children) { - if (!child.isDirectory()) { - continue; - } - projectDirs.addAll(findProjectDirs(child, buildListener)); - } - return projectDirs; - } - - private Collection sortByPathName(Collection allProjectDirs) { - List unsorted = new ArrayList(); - unsorted.addAll(allProjectDirs); - Collections.sort(unsorted, new Comparator() { - - public int compare(File file1, File file2) { - return file1.getAbsolutePath().compareTo(file2.getAbsolutePath()); - } - }); - return unsorted; - } - - private void checkForDuplicates(Collection allProjectDirs) { - // check whether there are multiple projects with the same name - for (File projectDir : allProjectDirs) { - for (File otherDir : allProjectDirs) { - if (projectDir == otherDir) { - continue; - } - if (otherDir.getName().equals(projectDir.getName())) { - System.out.println("WARNING: Found plug-ins with duplicate name at: " + projectDir.getAbsolutePath() + " and " + otherDir.getAbsolutePath()); - } - } - } - } - - private Set convertToPlugins(Collection projectDirs, IBuildListener listener) { - Set pluginsAndExportedPackages = new LinkedHashSet(); - for (File projectDir : projectDirs) { - Plugin newPlugin; - try { - newPlugin = new Plugin(projectDir); - // TODO this belongs somewhere else - if (projectDir.getName().endsWith(".webapp")) { - UnresolvedDependency tomcatDependency = new UnresolvedDependency(Plugin.class, "org.apache.tomcat_6_0_32", null, true, null, true, false, false); - newPlugin.getUnresolvedDependencies().add(tomcatDependency); - } - } catch (IOException e) { - throw new RuntimeException(e.getMessage()); - } - if (newPlugin.isExperimental()) { - listener.handleBuildEvent(BuildEventType.INFO, "Ignoring EXPERIMENTAL project: " + newPlugin.getIdentifier()); - continue; - } - if (newPlugin.getSourceFolders().length == 0) { - listener.handleBuildEvent(BuildEventType.INFO, "Project without source folders: " + newPlugin.getIdentifier()); - } - listener.handleBuildEvent(BuildEventType.INFO, "Discovered project: " + newPlugin.getIdentifier()); - pluginsAndExportedPackages.add(newPlugin); - pluginsAndExportedPackages.addAll(newPlugin.getExportedPackages()); - } - return pluginsAndExportedPackages; - } - - @Override - public String toString() { - return getClass().getSimpleName() + "[" + directory.getAbsolutePath() + "]"; - } -} +/******************************************************************************* + * Copyright (c) 2006-2012 + * Software Technology Group, Dresden University of Technology + * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 + * + * All rights reserved. This program and the accompanying materials + * are 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 + * + * Contributors: + * Software Technology Group - TU Dresden, Germany; + * DevBoost GmbH - Berlin, Germany + * - initial API and implementation + ******************************************************************************/ +package de.devboost.buildboost.discovery; + +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.Comparator; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Set; + +import de.devboost.buildboost.artifacts.Plugin; +import de.devboost.buildboost.model.BuildEventType; +import de.devboost.buildboost.model.IArtifact; +import de.devboost.buildboost.model.IBuildContext; +import de.devboost.buildboost.model.IBuildListener; +import de.devboost.buildboost.model.UnresolvedDependency; +import de.devboost.buildboost.util.ArtifactUtil; +import de.devboost.buildboost.util.EclipsePluginHelper; + +/** + * A {@link PluginFinder} can be used to discover Eclipse plug-in projects. + * Such projects typically contain a file called '.project'. + * + * TODO inherit from {@link AbstractFileFinder}? + */ +public class PluginFinder extends AbstractArtifactDiscoverer { + + private File directory; + + public PluginFinder(File directory) { + this.directory = directory; + } + + public Collection discoverArtifacts(IBuildContext context) { + IBuildListener buildListener = context.getBuildListener(); + + Collection allProjectDirs = findProjectDirs(directory, buildListener); + allProjectDirs = sortByPathName(allProjectDirs); + checkForDuplicates(allProjectDirs); + Set allPlugins = convertToPlugins(allProjectDirs, context.getBuildListener()); + // make unmodifiable + return Collections.unmodifiableSet(new ArtifactUtil().getSetOfArtifacts(allPlugins)); + } + + private Set findProjectDirs(File directory, IBuildListener buildListener) { + Set projectDirs = new LinkedHashSet(); + if (!directory.exists()) { + buildListener.handleBuildEvent( + BuildEventType.ERROR, + "Directory " + directory.getAbsolutePath() + " does not exist." + ); + return projectDirs; + } + if (!directory.isDirectory()) { + buildListener.handleBuildEvent( + BuildEventType.ERROR, + "File " + directory.getAbsolutePath() + " is not a directory." + ); + return projectDirs; + } + boolean isProject = new EclipsePluginHelper().isProject(directory); + if (isProject) { + projectDirs.add(directory); + // do not examine children of projects + return projectDirs; + } + // dive into child directories + File[] children = directory.listFiles(); + if (children == null) { + return projectDirs; + } + for (File child : children) { + if (!child.isDirectory()) { + continue; + } + projectDirs.addAll(findProjectDirs(child, buildListener)); + } + return projectDirs; + } + + private Collection sortByPathName(Collection allProjectDirs) { + List unsorted = new ArrayList(); + unsorted.addAll(allProjectDirs); + Collections.sort(unsorted, new Comparator() { + + public int compare(File file1, File file2) { + return file1.getAbsolutePath().compareTo(file2.getAbsolutePath()); + } + }); + return unsorted; + } + + private void checkForDuplicates(Collection allProjectDirs) { + // check whether there are multiple projects with the same name + for (File projectDir : allProjectDirs) { + for (File otherDir : allProjectDirs) { + if (projectDir == otherDir) { + continue; + } + if (otherDir.getName().equals(projectDir.getName())) { + System.out.println("WARNING: Found plug-ins with duplicate name at: " + projectDir.getAbsolutePath() + " and " + otherDir.getAbsolutePath()); + } + } + } + } + + private Set convertToPlugins(Collection projectDirs, IBuildListener listener) { + Set pluginsAndExportedPackages = new LinkedHashSet(); + for (File projectDir : projectDirs) { + Plugin newPlugin; + try { + newPlugin = new Plugin(projectDir); + // TODO this belongs somewhere else + if (projectDir.getName().endsWith(".webapp")) { + UnresolvedDependency tomcatDependency = new UnresolvedDependency(Plugin.class, "org.apache.tomcat_6_0_32", null, true, null, true, false, false); + newPlugin.getUnresolvedDependencies().add(tomcatDependency); + } + } catch (IOException e) { + throw new RuntimeException(e.getMessage()); + } + if (newPlugin.isExperimental()) { + listener.handleBuildEvent(BuildEventType.INFO, "Ignoring EXPERIMENTAL project: " + newPlugin.getIdentifier()); + continue; + } + if (newPlugin.getSourceFolders().length == 0) { + listener.handleBuildEvent(BuildEventType.INFO, "Project without source folders: " + newPlugin.getIdentifier()); + } + listener.handleBuildEvent(BuildEventType.INFO, "Discovered project: " + newPlugin.getIdentifier()); + pluginsAndExportedPackages.add(newPlugin); + pluginsAndExportedPackages.addAll(newPlugin.getExportedPackages()); + } + return pluginsAndExportedPackages; + } + + @Override + public String toString() { + return getClass().getSimpleName() + "[" + directory.getAbsolutePath() + "]"; + } +} diff --git a/Core/de.devboost.buildboost/src/de/devboost/buildboost/discovery/RepositoriesFileFinder.java b/Core/de.devboost.buildboost/src/de/devboost/buildboost/discovery/RepositoriesFileFinder.java index 3c3b481..d0cb9dd 100644 --- a/Core/de.devboost.buildboost/src/de/devboost/buildboost/discovery/RepositoriesFileFinder.java +++ b/Core/de.devboost.buildboost/src/de/devboost/buildboost/discovery/RepositoriesFileFinder.java @@ -1,55 +1,55 @@ -/******************************************************************************* - * Copyright (c) 2006-2012 - * Software Technology Group, Dresden University of Technology - * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 - * - * All rights reserved. This program and the accompanying materials - * are 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 - * - * Contributors: - * Software Technology Group - TU Dresden, Germany; - * DevBoost GmbH - Berlin, Germany - * - initial API and implementation - ******************************************************************************/ -package de.devboost.buildboost.discovery; - -import java.io.File; -import java.io.FileFilter; -import java.util.ArrayList; -import java.util.Collection; - -import de.devboost.buildboost.BuildException; -import de.devboost.buildboost.artifacts.RepositoriesFile; -import de.devboost.buildboost.model.IArtifact; -import de.devboost.buildboost.model.IBuildContext; -import de.devboost.buildboost.util.ArtifactUtil; - -public class RepositoriesFileFinder extends AbstractFileFinder { - - public static final String REPOSITORIES_EXTENSION = ".repositories"; - - public RepositoriesFileFinder(File directory) { - super(directory); - } - - public Collection discoverArtifacts(IBuildContext context) throws BuildException { - Collection boostFiles = new ArrayList(); - traverse(context, boostFiles); - return new ArtifactUtil().getSetOfArtifacts(boostFiles); - } - - protected RepositoriesFile createArtifactFromFile(File file) throws BuildException { - return new RepositoriesFile(file); - } - - protected FileFilter getFileFilter() { - return new FileFilter() { - - public boolean accept(File file) { - return file.getName().endsWith(REPOSITORIES_EXTENSION) && file.isFile(); - } - }; - } -} +/******************************************************************************* + * Copyright (c) 2006-2012 + * Software Technology Group, Dresden University of Technology + * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 + * + * All rights reserved. This program and the accompanying materials + * are 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 + * + * Contributors: + * Software Technology Group - TU Dresden, Germany; + * DevBoost GmbH - Berlin, Germany + * - initial API and implementation + ******************************************************************************/ +package de.devboost.buildboost.discovery; + +import java.io.File; +import java.io.FileFilter; +import java.util.ArrayList; +import java.util.Collection; + +import de.devboost.buildboost.BuildException; +import de.devboost.buildboost.artifacts.RepositoriesFile; +import de.devboost.buildboost.model.IArtifact; +import de.devboost.buildboost.model.IBuildContext; +import de.devboost.buildboost.util.ArtifactUtil; + +public class RepositoriesFileFinder extends AbstractFileFinder { + + public static final String REPOSITORIES_EXTENSION = ".repositories"; + + public RepositoriesFileFinder(File directory) { + super(directory); + } + + public Collection discoverArtifacts(IBuildContext context) throws BuildException { + Collection boostFiles = new ArrayList(); + traverse(context, boostFiles); + return new ArtifactUtil().getSetOfArtifacts(boostFiles); + } + + protected RepositoriesFile createArtifactFromFile(File file) throws BuildException { + return new RepositoriesFile(file); + } + + protected FileFilter getFileFilter() { + return new FileFilter() { + + public boolean accept(File file) { + return file.getName().endsWith(REPOSITORIES_EXTENSION) && file.isFile(); + } + }; + } +} diff --git a/Core/de.devboost.buildboost/src/de/devboost/buildboost/discovery/TargetPlatformZipFinder.java b/Core/de.devboost.buildboost/src/de/devboost/buildboost/discovery/TargetPlatformZipFinder.java index 1d88f2f..fd0d1f5 100644 --- a/Core/de.devboost.buildboost/src/de/devboost/buildboost/discovery/TargetPlatformZipFinder.java +++ b/Core/de.devboost.buildboost/src/de/devboost/buildboost/discovery/TargetPlatformZipFinder.java @@ -1,72 +1,72 @@ -/******************************************************************************* - * Copyright (c) 2006-2012 - * Software Technology Group, Dresden University of Technology - * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 - * - * All rights reserved. This program and the accompanying materials - * are 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 - * - * Contributors: - * Software Technology Group - TU Dresden, Germany; - * DevBoost GmbH - Berlin, Germany - * - initial API and implementation - ******************************************************************************/ -package de.devboost.buildboost.discovery; - -import java.io.File; -import java.io.FileFilter; -import java.util.ArrayList; -import java.util.Collection; - -import de.devboost.buildboost.BuildException; -import de.devboost.buildboost.artifacts.TargetPlatformZip; -import de.devboost.buildboost.model.BuildEventType; -import de.devboost.buildboost.model.IArtifact; -import de.devboost.buildboost.model.IBuildContext; -import de.devboost.buildboost.model.IBuildListener; -import de.devboost.buildboost.util.ArtifactUtil; - -public class TargetPlatformZipFinder extends AbstractFileFinder { - - public TargetPlatformZipFinder(File directory) { - super(directory); - } - - public Collection discoverArtifacts(IBuildContext context) throws BuildException { - IBuildListener buildListener = context.getBuildListener(); - - Collection zipFiles = new ArrayList(); - traverse(context, zipFiles); - for (TargetPlatformZip targetPlatformZip : zipFiles) { - buildListener.handleBuildEvent(BuildEventType.INFO, "Found target platform zip: " + targetPlatformZip.getIdentifier()); - } - return new ArtifactUtil().getSetOfArtifacts(zipFiles); - } - - @Override - protected void traverse(IBuildContext context, File directory, - Collection artifacts) throws BuildException { - //ignore projects and things inside projects - File dotProject = new File(directory, ".project"); - if (dotProject.exists()) { - return; - } - super.traverse(context, directory, artifacts); - } - - protected TargetPlatformZip createArtifactFromFile(File file) { - return new TargetPlatformZip(file); - } - - protected FileFilter getFileFilter() { - return new FileFilter() { - - public boolean accept(File file) { - return !file.isDirectory() && - (file.getName().endsWith(".zip") || file.getName().endsWith(".tar.gz")); - } - }; - } -} +/******************************************************************************* + * Copyright (c) 2006-2012 + * Software Technology Group, Dresden University of Technology + * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 + * + * All rights reserved. This program and the accompanying materials + * are 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 + * + * Contributors: + * Software Technology Group - TU Dresden, Germany; + * DevBoost GmbH - Berlin, Germany + * - initial API and implementation + ******************************************************************************/ +package de.devboost.buildboost.discovery; + +import java.io.File; +import java.io.FileFilter; +import java.util.ArrayList; +import java.util.Collection; + +import de.devboost.buildboost.BuildException; +import de.devboost.buildboost.artifacts.TargetPlatformZip; +import de.devboost.buildboost.model.BuildEventType; +import de.devboost.buildboost.model.IArtifact; +import de.devboost.buildboost.model.IBuildContext; +import de.devboost.buildboost.model.IBuildListener; +import de.devboost.buildboost.util.ArtifactUtil; + +public class TargetPlatformZipFinder extends AbstractFileFinder { + + public TargetPlatformZipFinder(File directory) { + super(directory); + } + + public Collection discoverArtifacts(IBuildContext context) throws BuildException { + IBuildListener buildListener = context.getBuildListener(); + + Collection zipFiles = new ArrayList(); + traverse(context, zipFiles); + for (TargetPlatformZip targetPlatformZip : zipFiles) { + buildListener.handleBuildEvent(BuildEventType.INFO, "Found target platform zip: " + targetPlatformZip.getIdentifier()); + } + return new ArtifactUtil().getSetOfArtifacts(zipFiles); + } + + @Override + protected void traverse(IBuildContext context, File directory, + Collection artifacts) throws BuildException { + //ignore projects and things inside projects + File dotProject = new File(directory, ".project"); + if (dotProject.exists()) { + return; + } + super.traverse(context, directory, artifacts); + } + + protected TargetPlatformZip createArtifactFromFile(File file) { + return new TargetPlatformZip(file); + } + + protected FileFilter getFileFilter() { + return new FileFilter() { + + public boolean accept(File file) { + return !file.isDirectory() && + (file.getName().endsWith(".zip") || file.getName().endsWith(".tar.gz")); + } + }; + } +} diff --git a/Core/de.devboost.buildboost/src/de/devboost/buildboost/discovery/reader/DotClasspathReader.java b/Core/de.devboost.buildboost/src/de/devboost/buildboost/discovery/reader/DotClasspathReader.java index 0609b53..fd58645 100644 --- a/Core/de.devboost.buildboost/src/de/devboost/buildboost/discovery/reader/DotClasspathReader.java +++ b/Core/de.devboost.buildboost/src/de/devboost/buildboost/discovery/reader/DotClasspathReader.java @@ -1,55 +1,55 @@ -/******************************************************************************* - * Copyright (c) 2006-2012 - * Software Technology Group, Dresden University of Technology - * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 - * - * All rights reserved. This program and the accompanying materials - * are 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 - * - * Contributors: - * Software Technology Group - TU Dresden, Germany; - * DevBoost GmbH - Berlin, Germany - * - initial API and implementation - ******************************************************************************/ -package de.devboost.buildboost.discovery.reader; - -import java.io.IOException; -import java.io.InputStream; -import java.util.LinkedHashSet; -import java.util.Set; - -import de.devboost.buildboost.util.StreamUtil; - -/** - * This class can be used to extract information from '.classpath' files. - */ -public class DotClasspathReader { - - private String content; - - public DotClasspathReader(InputStream dotClasspathInputStream) throws IOException { - content = new StreamUtil().getContentAsString(dotClasspathInputStream); - } - - public Set getDependencies() { - Set libs = new LinkedHashSet(); - - String beginString = "kind=\"lib\" path=\""; - String endString = "\""; - - int idx = content.indexOf(beginString); - while (idx != -1) { - int begin = idx + beginString.length(); - int end = content.indexOf(endString, begin); - - String path = content.substring(begin, end); - libs.add(path); - - idx = content.indexOf(beginString, end); - } - - return libs; - } -} +/******************************************************************************* + * Copyright (c) 2006-2012 + * Software Technology Group, Dresden University of Technology + * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 + * + * All rights reserved. This program and the accompanying materials + * are 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 + * + * Contributors: + * Software Technology Group - TU Dresden, Germany; + * DevBoost GmbH - Berlin, Germany + * - initial API and implementation + ******************************************************************************/ +package de.devboost.buildboost.discovery.reader; + +import java.io.IOException; +import java.io.InputStream; +import java.util.LinkedHashSet; +import java.util.Set; + +import de.devboost.buildboost.util.StreamUtil; + +/** + * This class can be used to extract information from '.classpath' files. + */ +public class DotClasspathReader { + + private String content; + + public DotClasspathReader(InputStream dotClasspathInputStream) throws IOException { + content = new StreamUtil().getContentAsString(dotClasspathInputStream); + } + + public Set getDependencies() { + Set libs = new LinkedHashSet(); + + String beginString = "kind=\"lib\" path=\""; + String endString = "\""; + + int idx = content.indexOf(beginString); + while (idx != -1) { + int begin = idx + beginString.length(); + int end = content.indexOf(endString, begin); + + String path = content.substring(begin, end); + libs.add(path); + + idx = content.indexOf(beginString, end); + } + + return libs; + } +} diff --git a/Core/de.devboost.buildboost/src/de/devboost/buildboost/discovery/reader/ManifestReader.java b/Core/de.devboost.buildboost/src/de/devboost/buildboost/discovery/reader/ManifestReader.java index 5fbbc88..03204a9 100644 --- a/Core/de.devboost.buildboost/src/de/devboost/buildboost/discovery/reader/ManifestReader.java +++ b/Core/de.devboost.buildboost/src/de/devboost/buildboost/discovery/reader/ManifestReader.java @@ -1,393 +1,393 @@ -/******************************************************************************* - * Copyright (c) 2006-2012 - * Software Technology Group, Dresden University of Technology - * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 - * - * All rights reserved. This program and the accompanying materials - * are 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 - * - * Contributors: - * Software Technology Group - TU Dresden, Germany; - * DevBoost GmbH - Berlin, Germany - * - initial API and implementation - ******************************************************************************/ -package de.devboost.buildboost.discovery.reader; - -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.util.LinkedHashSet; -import java.util.Set; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import de.devboost.buildboost.artifacts.Package; -import de.devboost.buildboost.artifacts.Plugin; -import de.devboost.buildboost.model.UnresolvedDependency; - -/** - * This class can be used to extract information from 'MANIFEST.MF' files. - */ -public class ManifestReader { - - public final static String ALPHA = "[a-zA-Z0-9_\\.-]"; - public final static String ALPHA_AND_MINUS = "[a-zA-Z0-9_\\.]|-"; - public final static String QUALIFIED_NAME_REGEX = "(" + ALPHA + "+)"; - public final static String OPTION_NAME_REGEX = "((" + ALPHA_AND_MINUS + ")+)"; - public final static String QUALIFIED_NUMBER_REGEX = "([0-9\\.]+)"; - public final static String INCLUDING_EXCLUDING_REGEX = "(\\[|\\))"; - public final static String BUNDLE_VERSION_REGEX = "bundle-version=\\\"(" + QUALIFIED_NUMBER_REGEX + "|" + INCLUDING_EXCLUDING_REGEX + QUALIFIED_NUMBER_REGEX + "," + QUALIFIED_NUMBER_REGEX + INCLUDING_EXCLUDING_REGEX + ")\\\""; - public final static String RESOLUTION_REFEX = "resolution:=\\\"?optional\\\"?"; - public final static String VISIBILITY_REGEX = "visibility:=\\\"?reexport\\\"?"; - public final static String USES_REGEX = "uses:=\\\"?" + ALPHA + "\\\"?"; - public final static String OPTION_VALUE_REGEX = "((\\\"[^\\\"]+\\\")+|[^\\\"]([^;,])+)"; - public final static String OPTION_REGEX = ";[ ]*(" + OPTION_NAME_REGEX + "[:]?=" + OPTION_VALUE_REGEX + ")"; - public final static String DEPENDENCY_REGEX = - "(" + - QUALIFIED_NAME_REGEX + - "((" + OPTION_REGEX + ")*)" + - ")" + - ",?"; - - private final static Pattern DEPENDENCY_PATTERN = Pattern.compile(DEPENDENCY_REGEX); - - public final static String REQUIRED_BUNDLE_PREFIX = "Require-Bundle: "; - public final static String IMPORT_PACKAGE_PREFIX = "Import-Package: "; - public final static String EXPORT_PACKAGE_PREFIX = "Export-Package: "; - public final static String NAME_PREFIX = "Bundle-SymbolicName: "; - public final static String CLASSPATH_PREFIX = "Bundle-ClassPath: "; - public final static String REQUIRE_VERSION_PREFIX = "bundle-version="; - public final static String VERSION_PREFIX = "Bundle-Version: "; - public final static String FRAGMENT_HOST_PREFIX = "Fragment-Host: "; - public final static String RESOLUTION_OPTIONAL = "resolution:=\"optional\""; - - public final static Pattern REQUIRED_BUNDLE_REGEX = Pattern.compile(REQUIRED_BUNDLE_PREFIX + ".*(\r)?\n"); - public final static Pattern IMPORT_PACKAGE_REGEX = Pattern.compile("(? classpath; - private Set dependencies; - private Set exportedPackages; - private String symbolicName; - private UnresolvedDependency fragmentHost; - private String version; - - public ManifestReader(InputStream manifestInputStream) throws IOException { - content = getContentAsString(manifestInputStream); - manifestInputStream.close(); - content = content.replace("\r\n ", ""); - content = content.replace("\n ", ""); - content = content.replace("\r ", ""); - } - - public Set getDependencies() { - if (dependencies == null) { - dependencies = new LinkedHashSet(); - findDependencies(content, Plugin.class, REQUIRED_BUNDLE_REGEX, REQUIRED_BUNDLE_PREFIX); - findDependencies(content, Package.class, IMPORT_PACKAGE_REGEX, IMPORT_PACKAGE_PREFIX); - } - return dependencies; - } - - public Set getExportedPackages() { - if (exportedPackages == null) { - exportedPackages = findDependencies(content, null, EXPORT_PACKAGE_REGEX, EXPORT_PACKAGE_PREFIX); - if (getSymbolicName().equals("org.eclipse.osgi")) { - addOSGINativeDefaultPackageExports(); - } - } - return exportedPackages; - } - - public String getSymbolicName() { - if (symbolicName == null) { - symbolicName = getValue(NAME_REGEX, NAME_PREFIX, "UNKNOWN_SYMBOLIC_NAME"); - } - return symbolicName; - } - - public Set getBundleClassPath() { - if (classpath == null) { - classpath = new LinkedHashSet(); - Matcher matcher = CLASSPATH_REGEX.matcher(content); - if (matcher.find()) { - String classpathLine = matcher.group(); - classpathLine = classpathLine.substring(CLASSPATH_PREFIX.length()); - String[] classpathEntries = classpathLine.split(","); - for (String classpathEntry : classpathEntries) { - String[] parts = classpathEntry.split("\\;"); - String path = parts[0].trim(); - if (".".equals(path)) { - continue; - } - //TODO this is declared in "org.eclipse.equinox.registry" but the JAR does not exist - if ("runtime_registry_compatibility.jar".equals(path)) { - continue; - } - classpath.add(path); - } - } - } - return classpath; - } - - private Set findDependencies(String content, Class dependencyType, Pattern regex, String prefix) { - Set names = new LinkedHashSet(); - Matcher matcher = regex.matcher(content); - if (matcher.find()) { - String requiredBundlesLine = matcher.group(); - requiredBundlesLine = requiredBundlesLine.substring(prefix.length()); - Matcher matcher2 = DEPENDENCY_PATTERN.matcher(requiredBundlesLine); - while (matcher2.find()) { - String bundleOrPackageName = matcher2.group(2).trim(); - String allOptions = matcher2.group(3).trim(); - String[] options = allOptions.split(";( )*"); - - // TODO use this two properties - boolean inclusiveMin = true; - boolean inclusiveMax = true; - String minVersion = null; - String maxVersion = null; - boolean optional = false; - boolean reexport = false; - //boolean uses = false; - for (String option : options) { - if ("".equals(option)) { - continue; - } - String[] groups = getGroups(option, BUNDLE_VERSION_REGEX); - if (groups != null) { - inclusiveMin = "[".equals(groups[3]); - String group4 = groups[4]; - minVersion = group4 == null ? null : group4.trim(); - String group5 = groups[5]; - maxVersion = group5 == null ? null : group5.trim(); - String group6 = groups[6]; - inclusiveMax = "]".equals(group6); - continue; - } - groups = getGroups(option, RESOLUTION_REFEX); - if (groups != null) { - optional = true; - continue; - } - groups = getGroups(option, VISIBILITY_REGEX); - if (groups != null) { - reexport = true; - continue; - } - /*groups = getGroups(option, USES_REGEX); - if (groups != null) { - uses = true; - continue; - }*/ - } - if ("system.bundle".equals(bundleOrPackageName)) { - bundleOrPackageName = "org.eclipse.osgi"; - } - if (dependencyType != null) { - UnresolvedDependency dependency = new UnresolvedDependency(dependencyType, bundleOrPackageName, minVersion, inclusiveMin, maxVersion, inclusiveMax, optional, reexport); - - if (dependencyType == Package.class && getExportedPackages().contains(bundleOrPackageName)) { - // cyclic! - // TODO improve package import/export support - } else { - dependencies.add(dependency); - } - } - names.add(bundleOrPackageName); - } - } - return names; - } - - private String[] getGroups(String text, String regex) { - Pattern pattern = Pattern.compile(regex); - Matcher matcher = pattern.matcher(text); - if (matcher.find()) { - String[] groups = new String[matcher.groupCount() + 1]; - for (int i = 0; i < groups.length; i++) { - groups[i] = matcher.group(i); - //System.out.println("groups[" + i +"] = " + groups[i]); - } - return groups; - } - return null; - } - - public static String getContentAsString(InputStream inputStream) throws IOException { - StringBuffer content = new StringBuffer(); - InputStreamReader reader = new InputStreamReader(inputStream); - int next = -1; - while ((next = reader.read()) >= 0) { - content.append((char) next); - } - return content.toString(); - } - - public String getVersion() { - if (version == null) { - String rawVersion = getValue(VERSION_REGEX, VERSION_PREFIX, "UNKNOWN_VERSION"); - - Matcher matcher = Pattern.compile("[0-9]+(\\.[0-9]+)*").matcher(rawVersion); - matcher.find(); - version = matcher.group(); - } - return version; - } - - public UnresolvedDependency getFragmentHost() { - if (fragmentHost == null) { - String fragmentHostBundleName = getValue(FRAGMENT_HOST_REGEX, FRAGMENT_HOST_PREFIX, null); - fragmentHost = new UnresolvedDependency(Plugin.class, fragmentHostBundleName, null, true, null, true, false, false); - } - return fragmentHost; - } - - private String getValue(Pattern regex, String prefix, String defaultValue) { - Matcher matcher = regex.matcher(content); - if (matcher.find()) { - String symbolicNameLine = matcher.group(); - String[] parts = symbolicNameLine.split(";"); - symbolicNameLine = parts[0]; - symbolicNameLine = symbolicNameLine.replace("\n", ""); - symbolicNameLine = symbolicNameLine.replace("\r", ""); - symbolicNameLine = symbolicNameLine.substring(prefix.length()); - return symbolicNameLine; - } - return defaultValue; - } - - //TODO read .profile file(s) instead! - private void addOSGINativeDefaultPackageExports() { - exportedPackages.add("javax.accessibility"); - exportedPackages.add("javax.activity"); - exportedPackages.add("javax.crypto"); - exportedPackages.add("javax.crypto.interfaces"); - exportedPackages.add("javax.crypto.spec"); - exportedPackages.add("javax.imageio"); - exportedPackages.add("javax.imageio.event"); - exportedPackages.add("javax.imageio.metadata"); - exportedPackages.add("javax.imageio.plugins.bmp"); - exportedPackages.add("javax.imageio.plugins.jpeg"); - exportedPackages.add("javax.imageio.spi"); - exportedPackages.add("javax.imageio.stream"); - exportedPackages.add("javax.management"); - exportedPackages.add("javax.management.loading"); - exportedPackages.add("javax.management.modelmbean"); - exportedPackages.add("javax.management.monitor"); - exportedPackages.add("javax.management.openmbean"); - exportedPackages.add("javax.management.relation"); - exportedPackages.add("javax.management.remote"); - exportedPackages.add("javax.management.remote.rmi"); - exportedPackages.add("javax.management.timer"); - exportedPackages.add("javax.naming"); - exportedPackages.add("javax.naming.directory"); - exportedPackages.add("javax.naming.event"); - exportedPackages.add("javax.naming.ldap"); - exportedPackages.add("javax.naming.spi"); - exportedPackages.add("javax.net"); - exportedPackages.add("javax.net.ssl"); - exportedPackages.add("javax.print"); - exportedPackages.add("javax.print.attribute"); - exportedPackages.add("javax.print.attribute.standard"); - exportedPackages.add("javax.print.event"); - exportedPackages.add("javax.rmi"); - exportedPackages.add("javax.rmi.CORBA"); - exportedPackages.add("javax.rmi.ssl"); - exportedPackages.add("javax.security.auth"); - exportedPackages.add("javax.security.auth.callback"); - exportedPackages.add("javax.security.auth.kerberos"); - exportedPackages.add("javax.security.auth.login"); - exportedPackages.add("javax.security.auth.spi"); - exportedPackages.add("javax.security.auth.x500"); - exportedPackages.add("javax.security.cert"); - exportedPackages.add("javax.security.sasl"); - exportedPackages.add("javax.sound.midi"); - exportedPackages.add("javax.sound.midi.spi"); - exportedPackages.add("javax.sound.sampled"); - exportedPackages.add("javax.sound.sampled.spi"); - exportedPackages.add("javax.sql"); - exportedPackages.add("javax.sql.rowset"); - exportedPackages.add("javax.sql.rowset.serial"); - exportedPackages.add("javax.sql.rowset.spi"); - exportedPackages.add("javax.swing"); - exportedPackages.add("javax.swing.border"); - exportedPackages.add("javax.swing.colorchooser"); - exportedPackages.add("javax.swing.event"); - exportedPackages.add("javax.swing.filechooser"); - exportedPackages.add("javax.swing.plaf"); - exportedPackages.add("javax.swing.plaf.basic"); - exportedPackages.add("javax.swing.plaf.metal"); - exportedPackages.add("javax.swing.plaf.multi"); - exportedPackages.add("javax.swing.plaf.synth"); - exportedPackages.add("javax.swing.table"); - exportedPackages.add("javax.swing.text"); - exportedPackages.add("javax.swing.text.html"); - exportedPackages.add("javax.swing.text.html.parser"); - exportedPackages.add("javax.swing.text.rtf"); - exportedPackages.add("javax.swing.tree"); - exportedPackages.add("javax.swing.undo"); - exportedPackages.add("javax.transaction"); - exportedPackages.add("javax.transaction.xa"); - exportedPackages.add("javax.xml"); - exportedPackages.add("javax.xml.datatype"); - exportedPackages.add("javax.xml.namespace"); - exportedPackages.add("javax.xml.parsers"); - exportedPackages.add("javax.xml.transform"); - exportedPackages.add("javax.xml.transform.dom"); - exportedPackages.add("javax.xml.transform.sax"); - exportedPackages.add("javax.xml.transform.stream"); - exportedPackages.add("javax.xml.validation"); - exportedPackages.add("javax.xml.xpath"); - exportedPackages.add("org.ietf.jgss"); - exportedPackages.add("org.omg.CORBA"); - exportedPackages.add("org.omg.CORBA_2_3"); - exportedPackages.add("org.omg.CORBA_2_3.portable"); - exportedPackages.add("org.omg.CORBA.DynAnyPackage"); - exportedPackages.add("org.omg.CORBA.ORBPackage"); - exportedPackages.add("org.omg.CORBA.portable"); - exportedPackages.add("org.omg.CORBA.TypeCodePackage"); - exportedPackages.add("org.omg.CosNaming"); - exportedPackages.add("org.omg.CosNaming.NamingContextExtPackage"); - exportedPackages.add("org.omg.CosNaming.NamingContextPackage"); - exportedPackages.add("org.omg.Dynamic"); - exportedPackages.add("org.omg.DynamicAny"); - exportedPackages.add("org.omg.DynamicAny.DynAnyFactoryPackage"); - exportedPackages.add("org.omg.DynamicAny.DynAnyPackage"); - exportedPackages.add("org.omg.IOP"); - exportedPackages.add("org.omg.IOP.CodecFactoryPackage"); - exportedPackages.add("org.omg.IOP.CodecPackage"); - exportedPackages.add("org.omg.Messaging"); - exportedPackages.add("org.omg.PortableInterceptor"); - exportedPackages.add("org.omg.PortableInterceptor.ORBInitInfoPackage"); - exportedPackages.add("org.omg.PortableServer"); - exportedPackages.add("org.omg.PortableServer.CurrentPackage"); - exportedPackages.add("org.omg.PortableServer.POAManagerPackage"); - exportedPackages.add("org.omg.PortableServer.POAPackage"); - exportedPackages.add("org.omg.PortableServer.portable"); - exportedPackages.add("org.omg.PortableServer.ServantLocatorPackage"); - exportedPackages.add("org.omg.SendingContext"); - exportedPackages.add("org.omg.stub.java.rmi"); - exportedPackages.add("org.w3c.dom"); - exportedPackages.add("org.w3c.dom.bootstrap"); - exportedPackages.add("org.w3c.dom.css"); - exportedPackages.add("org.w3c.dom.events"); - exportedPackages.add("org.w3c.dom.html"); - exportedPackages.add("org.w3c.dom.ls"); - exportedPackages.add("org.w3c.dom.ranges"); - exportedPackages.add("org.w3c.dom.stylesheets"); - exportedPackages.add("org.w3c.dom.traversal"); - exportedPackages.add("org.w3c.dom.views "); - exportedPackages.add("org.xml.sax"); - exportedPackages.add("org.xml.sax.ext"); - exportedPackages.add("org.xml.sax.helpers"); - } -} +/******************************************************************************* + * Copyright (c) 2006-2012 + * Software Technology Group, Dresden University of Technology + * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 + * + * All rights reserved. This program and the accompanying materials + * are 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 + * + * Contributors: + * Software Technology Group - TU Dresden, Germany; + * DevBoost GmbH - Berlin, Germany + * - initial API and implementation + ******************************************************************************/ +package de.devboost.buildboost.discovery.reader; + +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.util.LinkedHashSet; +import java.util.Set; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import de.devboost.buildboost.artifacts.Package; +import de.devboost.buildboost.artifacts.Plugin; +import de.devboost.buildboost.model.UnresolvedDependency; + +/** + * This class can be used to extract information from 'MANIFEST.MF' files. + */ +public class ManifestReader { + + public final static String ALPHA = "[a-zA-Z0-9_\\.-]"; + public final static String ALPHA_AND_MINUS = "[a-zA-Z0-9_\\.]|-"; + public final static String QUALIFIED_NAME_REGEX = "(" + ALPHA + "+)"; + public final static String OPTION_NAME_REGEX = "((" + ALPHA_AND_MINUS + ")+)"; + public final static String QUALIFIED_NUMBER_REGEX = "([0-9\\.]+)"; + public final static String INCLUDING_EXCLUDING_REGEX = "(\\[|\\))"; + public final static String BUNDLE_VERSION_REGEX = "bundle-version=\\\"(" + QUALIFIED_NUMBER_REGEX + "|" + INCLUDING_EXCLUDING_REGEX + QUALIFIED_NUMBER_REGEX + "," + QUALIFIED_NUMBER_REGEX + INCLUDING_EXCLUDING_REGEX + ")\\\""; + public final static String RESOLUTION_REFEX = "resolution:=\\\"?optional\\\"?"; + public final static String VISIBILITY_REGEX = "visibility:=\\\"?reexport\\\"?"; + public final static String USES_REGEX = "uses:=\\\"?" + ALPHA + "\\\"?"; + public final static String OPTION_VALUE_REGEX = "((\\\"[^\\\"]+\\\")+|[^\\\"]([^;,])+)"; + public final static String OPTION_REGEX = ";[ ]*(" + OPTION_NAME_REGEX + "[:]?=" + OPTION_VALUE_REGEX + ")"; + public final static String DEPENDENCY_REGEX = + "(" + + QUALIFIED_NAME_REGEX + + "((" + OPTION_REGEX + ")*)" + + ")" + + ",?"; + + private final static Pattern DEPENDENCY_PATTERN = Pattern.compile(DEPENDENCY_REGEX); + + public final static String REQUIRED_BUNDLE_PREFIX = "Require-Bundle: "; + public final static String IMPORT_PACKAGE_PREFIX = "Import-Package: "; + public final static String EXPORT_PACKAGE_PREFIX = "Export-Package: "; + public final static String NAME_PREFIX = "Bundle-SymbolicName: "; + public final static String CLASSPATH_PREFIX = "Bundle-ClassPath: "; + public final static String REQUIRE_VERSION_PREFIX = "bundle-version="; + public final static String VERSION_PREFIX = "Bundle-Version: "; + public final static String FRAGMENT_HOST_PREFIX = "Fragment-Host: "; + public final static String RESOLUTION_OPTIONAL = "resolution:=\"optional\""; + + public final static Pattern REQUIRED_BUNDLE_REGEX = Pattern.compile(REQUIRED_BUNDLE_PREFIX + ".*(\r)?\n"); + public final static Pattern IMPORT_PACKAGE_REGEX = Pattern.compile("(? classpath; + private Set dependencies; + private Set exportedPackages; + private String symbolicName; + private UnresolvedDependency fragmentHost; + private String version; + + public ManifestReader(InputStream manifestInputStream) throws IOException { + content = getContentAsString(manifestInputStream); + manifestInputStream.close(); + content = content.replace("\r\n ", ""); + content = content.replace("\n ", ""); + content = content.replace("\r ", ""); + } + + public Set getDependencies() { + if (dependencies == null) { + dependencies = new LinkedHashSet(); + findDependencies(content, Plugin.class, REQUIRED_BUNDLE_REGEX, REQUIRED_BUNDLE_PREFIX); + findDependencies(content, Package.class, IMPORT_PACKAGE_REGEX, IMPORT_PACKAGE_PREFIX); + } + return dependencies; + } + + public Set getExportedPackages() { + if (exportedPackages == null) { + exportedPackages = findDependencies(content, null, EXPORT_PACKAGE_REGEX, EXPORT_PACKAGE_PREFIX); + if (getSymbolicName().equals("org.eclipse.osgi")) { + addOSGINativeDefaultPackageExports(); + } + } + return exportedPackages; + } + + public String getSymbolicName() { + if (symbolicName == null) { + symbolicName = getValue(NAME_REGEX, NAME_PREFIX, "UNKNOWN_SYMBOLIC_NAME"); + } + return symbolicName; + } + + public Set getBundleClassPath() { + if (classpath == null) { + classpath = new LinkedHashSet(); + Matcher matcher = CLASSPATH_REGEX.matcher(content); + if (matcher.find()) { + String classpathLine = matcher.group(); + classpathLine = classpathLine.substring(CLASSPATH_PREFIX.length()); + String[] classpathEntries = classpathLine.split(","); + for (String classpathEntry : classpathEntries) { + String[] parts = classpathEntry.split("\\;"); + String path = parts[0].trim(); + if (".".equals(path)) { + continue; + } + //TODO this is declared in "org.eclipse.equinox.registry" but the JAR does not exist + if ("runtime_registry_compatibility.jar".equals(path)) { + continue; + } + classpath.add(path); + } + } + } + return classpath; + } + + private Set findDependencies(String content, Class dependencyType, Pattern regex, String prefix) { + Set names = new LinkedHashSet(); + Matcher matcher = regex.matcher(content); + if (matcher.find()) { + String requiredBundlesLine = matcher.group(); + requiredBundlesLine = requiredBundlesLine.substring(prefix.length()); + Matcher matcher2 = DEPENDENCY_PATTERN.matcher(requiredBundlesLine); + while (matcher2.find()) { + String bundleOrPackageName = matcher2.group(2).trim(); + String allOptions = matcher2.group(3).trim(); + String[] options = allOptions.split(";( )*"); + + // TODO use this two properties + boolean inclusiveMin = true; + boolean inclusiveMax = true; + String minVersion = null; + String maxVersion = null; + boolean optional = false; + boolean reexport = false; + //boolean uses = false; + for (String option : options) { + if ("".equals(option)) { + continue; + } + String[] groups = getGroups(option, BUNDLE_VERSION_REGEX); + if (groups != null) { + inclusiveMin = "[".equals(groups[3]); + String group4 = groups[4]; + minVersion = group4 == null ? null : group4.trim(); + String group5 = groups[5]; + maxVersion = group5 == null ? null : group5.trim(); + String group6 = groups[6]; + inclusiveMax = "]".equals(group6); + continue; + } + groups = getGroups(option, RESOLUTION_REFEX); + if (groups != null) { + optional = true; + continue; + } + groups = getGroups(option, VISIBILITY_REGEX); + if (groups != null) { + reexport = true; + continue; + } + /*groups = getGroups(option, USES_REGEX); + if (groups != null) { + uses = true; + continue; + }*/ + } + if ("system.bundle".equals(bundleOrPackageName)) { + bundleOrPackageName = "org.eclipse.osgi"; + } + if (dependencyType != null) { + UnresolvedDependency dependency = new UnresolvedDependency(dependencyType, bundleOrPackageName, minVersion, inclusiveMin, maxVersion, inclusiveMax, optional, reexport); + + if (dependencyType == Package.class && getExportedPackages().contains(bundleOrPackageName)) { + // cyclic! + // TODO improve package import/export support + } else { + dependencies.add(dependency); + } + } + names.add(bundleOrPackageName); + } + } + return names; + } + + private String[] getGroups(String text, String regex) { + Pattern pattern = Pattern.compile(regex); + Matcher matcher = pattern.matcher(text); + if (matcher.find()) { + String[] groups = new String[matcher.groupCount() + 1]; + for (int i = 0; i < groups.length; i++) { + groups[i] = matcher.group(i); + //System.out.println("groups[" + i +"] = " + groups[i]); + } + return groups; + } + return null; + } + + public static String getContentAsString(InputStream inputStream) throws IOException { + StringBuffer content = new StringBuffer(); + InputStreamReader reader = new InputStreamReader(inputStream); + int next = -1; + while ((next = reader.read()) >= 0) { + content.append((char) next); + } + return content.toString(); + } + + public String getVersion() { + if (version == null) { + String rawVersion = getValue(VERSION_REGEX, VERSION_PREFIX, "UNKNOWN_VERSION"); + + Matcher matcher = Pattern.compile("[0-9]+(\\.[0-9]+)*").matcher(rawVersion); + matcher.find(); + version = matcher.group(); + } + return version; + } + + public UnresolvedDependency getFragmentHost() { + if (fragmentHost == null) { + String fragmentHostBundleName = getValue(FRAGMENT_HOST_REGEX, FRAGMENT_HOST_PREFIX, null); + fragmentHost = new UnresolvedDependency(Plugin.class, fragmentHostBundleName, null, true, null, true, false, false); + } + return fragmentHost; + } + + private String getValue(Pattern regex, String prefix, String defaultValue) { + Matcher matcher = regex.matcher(content); + if (matcher.find()) { + String symbolicNameLine = matcher.group(); + String[] parts = symbolicNameLine.split(";"); + symbolicNameLine = parts[0]; + symbolicNameLine = symbolicNameLine.replace("\n", ""); + symbolicNameLine = symbolicNameLine.replace("\r", ""); + symbolicNameLine = symbolicNameLine.substring(prefix.length()); + return symbolicNameLine; + } + return defaultValue; + } + + //TODO read .profile file(s) instead! + private void addOSGINativeDefaultPackageExports() { + exportedPackages.add("javax.accessibility"); + exportedPackages.add("javax.activity"); + exportedPackages.add("javax.crypto"); + exportedPackages.add("javax.crypto.interfaces"); + exportedPackages.add("javax.crypto.spec"); + exportedPackages.add("javax.imageio"); + exportedPackages.add("javax.imageio.event"); + exportedPackages.add("javax.imageio.metadata"); + exportedPackages.add("javax.imageio.plugins.bmp"); + exportedPackages.add("javax.imageio.plugins.jpeg"); + exportedPackages.add("javax.imageio.spi"); + exportedPackages.add("javax.imageio.stream"); + exportedPackages.add("javax.management"); + exportedPackages.add("javax.management.loading"); + exportedPackages.add("javax.management.modelmbean"); + exportedPackages.add("javax.management.monitor"); + exportedPackages.add("javax.management.openmbean"); + exportedPackages.add("javax.management.relation"); + exportedPackages.add("javax.management.remote"); + exportedPackages.add("javax.management.remote.rmi"); + exportedPackages.add("javax.management.timer"); + exportedPackages.add("javax.naming"); + exportedPackages.add("javax.naming.directory"); + exportedPackages.add("javax.naming.event"); + exportedPackages.add("javax.naming.ldap"); + exportedPackages.add("javax.naming.spi"); + exportedPackages.add("javax.net"); + exportedPackages.add("javax.net.ssl"); + exportedPackages.add("javax.print"); + exportedPackages.add("javax.print.attribute"); + exportedPackages.add("javax.print.attribute.standard"); + exportedPackages.add("javax.print.event"); + exportedPackages.add("javax.rmi"); + exportedPackages.add("javax.rmi.CORBA"); + exportedPackages.add("javax.rmi.ssl"); + exportedPackages.add("javax.security.auth"); + exportedPackages.add("javax.security.auth.callback"); + exportedPackages.add("javax.security.auth.kerberos"); + exportedPackages.add("javax.security.auth.login"); + exportedPackages.add("javax.security.auth.spi"); + exportedPackages.add("javax.security.auth.x500"); + exportedPackages.add("javax.security.cert"); + exportedPackages.add("javax.security.sasl"); + exportedPackages.add("javax.sound.midi"); + exportedPackages.add("javax.sound.midi.spi"); + exportedPackages.add("javax.sound.sampled"); + exportedPackages.add("javax.sound.sampled.spi"); + exportedPackages.add("javax.sql"); + exportedPackages.add("javax.sql.rowset"); + exportedPackages.add("javax.sql.rowset.serial"); + exportedPackages.add("javax.sql.rowset.spi"); + exportedPackages.add("javax.swing"); + exportedPackages.add("javax.swing.border"); + exportedPackages.add("javax.swing.colorchooser"); + exportedPackages.add("javax.swing.event"); + exportedPackages.add("javax.swing.filechooser"); + exportedPackages.add("javax.swing.plaf"); + exportedPackages.add("javax.swing.plaf.basic"); + exportedPackages.add("javax.swing.plaf.metal"); + exportedPackages.add("javax.swing.plaf.multi"); + exportedPackages.add("javax.swing.plaf.synth"); + exportedPackages.add("javax.swing.table"); + exportedPackages.add("javax.swing.text"); + exportedPackages.add("javax.swing.text.html"); + exportedPackages.add("javax.swing.text.html.parser"); + exportedPackages.add("javax.swing.text.rtf"); + exportedPackages.add("javax.swing.tree"); + exportedPackages.add("javax.swing.undo"); + exportedPackages.add("javax.transaction"); + exportedPackages.add("javax.transaction.xa"); + exportedPackages.add("javax.xml"); + exportedPackages.add("javax.xml.datatype"); + exportedPackages.add("javax.xml.namespace"); + exportedPackages.add("javax.xml.parsers"); + exportedPackages.add("javax.xml.transform"); + exportedPackages.add("javax.xml.transform.dom"); + exportedPackages.add("javax.xml.transform.sax"); + exportedPackages.add("javax.xml.transform.stream"); + exportedPackages.add("javax.xml.validation"); + exportedPackages.add("javax.xml.xpath"); + exportedPackages.add("org.ietf.jgss"); + exportedPackages.add("org.omg.CORBA"); + exportedPackages.add("org.omg.CORBA_2_3"); + exportedPackages.add("org.omg.CORBA_2_3.portable"); + exportedPackages.add("org.omg.CORBA.DynAnyPackage"); + exportedPackages.add("org.omg.CORBA.ORBPackage"); + exportedPackages.add("org.omg.CORBA.portable"); + exportedPackages.add("org.omg.CORBA.TypeCodePackage"); + exportedPackages.add("org.omg.CosNaming"); + exportedPackages.add("org.omg.CosNaming.NamingContextExtPackage"); + exportedPackages.add("org.omg.CosNaming.NamingContextPackage"); + exportedPackages.add("org.omg.Dynamic"); + exportedPackages.add("org.omg.DynamicAny"); + exportedPackages.add("org.omg.DynamicAny.DynAnyFactoryPackage"); + exportedPackages.add("org.omg.DynamicAny.DynAnyPackage"); + exportedPackages.add("org.omg.IOP"); + exportedPackages.add("org.omg.IOP.CodecFactoryPackage"); + exportedPackages.add("org.omg.IOP.CodecPackage"); + exportedPackages.add("org.omg.Messaging"); + exportedPackages.add("org.omg.PortableInterceptor"); + exportedPackages.add("org.omg.PortableInterceptor.ORBInitInfoPackage"); + exportedPackages.add("org.omg.PortableServer"); + exportedPackages.add("org.omg.PortableServer.CurrentPackage"); + exportedPackages.add("org.omg.PortableServer.POAManagerPackage"); + exportedPackages.add("org.omg.PortableServer.POAPackage"); + exportedPackages.add("org.omg.PortableServer.portable"); + exportedPackages.add("org.omg.PortableServer.ServantLocatorPackage"); + exportedPackages.add("org.omg.SendingContext"); + exportedPackages.add("org.omg.stub.java.rmi"); + exportedPackages.add("org.w3c.dom"); + exportedPackages.add("org.w3c.dom.bootstrap"); + exportedPackages.add("org.w3c.dom.css"); + exportedPackages.add("org.w3c.dom.events"); + exportedPackages.add("org.w3c.dom.html"); + exportedPackages.add("org.w3c.dom.ls"); + exportedPackages.add("org.w3c.dom.ranges"); + exportedPackages.add("org.w3c.dom.stylesheets"); + exportedPackages.add("org.w3c.dom.traversal"); + exportedPackages.add("org.w3c.dom.views "); + exportedPackages.add("org.xml.sax"); + exportedPackages.add("org.xml.sax.ext"); + exportedPackages.add("org.xml.sax.helpers"); + } +} diff --git a/Core/de.devboost.buildboost/src/de/devboost/buildboost/filters/AbstractFilter.java b/Core/de.devboost.buildboost/src/de/devboost/buildboost/filters/AbstractFilter.java index 0d37767..1a7d159 100644 --- a/Core/de.devboost.buildboost/src/de/devboost/buildboost/filters/AbstractFilter.java +++ b/Core/de.devboost.buildboost/src/de/devboost/buildboost/filters/AbstractFilter.java @@ -1,62 +1,62 @@ -/******************************************************************************* - * Copyright (c) 2006-2012 - * Software Technology Group, Dresden University of Technology - * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 - * - * All rights reserved. This program and the accompanying materials - * are 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 - * - * Contributors: - * Software Technology Group - TU Dresden, Germany; - * DevBoost GmbH - Berlin, Germany - * - initial API and implementation - ******************************************************************************/ -package de.devboost.buildboost.filters; - -import java.util.ArrayList; -import java.util.Collection; - -import de.devboost.buildboost.BuildException; -import de.devboost.buildboost.DependencyResolver; -import de.devboost.buildboost.model.AbstractBuildParticipant; -import de.devboost.buildboost.model.BuildEventType; -import de.devboost.buildboost.model.IArtifact; -import de.devboost.buildboost.model.IArtifactDiscoverer; -import de.devboost.buildboost.model.IArtifactFilter; -import de.devboost.buildboost.model.IBuildContext; -import de.devboost.buildboost.model.IBuildListener; -import de.devboost.buildboost.model.IBuildParticipant; - -public abstract class AbstractFilter extends AbstractBuildParticipant implements IArtifactFilter { - - @Override - public void execute(IBuildContext context) throws BuildException { - IBuildListener buildListener = context.getBuildListener(); - Collection artifacts = context.getDiscoveredArtifacts(); - Collection artifactsToRemove = new ArrayList(); - for (IArtifact artifact : artifacts) { - if (!accept(artifact)) { - buildListener.handleBuildEvent(BuildEventType.INFO, "Artifact " + artifact + " is removed because of filter " + this); - artifactsToRemove.add(artifact); - } - } - context.removeDiscoveredArtifacts(artifactsToRemove); - } - - public OrFilter or(IArtifactFilter other) { - return new OrFilter(this, other); - } - - @Override - public boolean dependsOn(IBuildParticipant otherParticipant) { - if (otherParticipant instanceof IArtifactDiscoverer) { - return true; - } - if (otherParticipant instanceof DependencyResolver) { - return true; - } - return false; - } -} +/******************************************************************************* + * Copyright (c) 2006-2012 + * Software Technology Group, Dresden University of Technology + * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 + * + * All rights reserved. This program and the accompanying materials + * are 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 + * + * Contributors: + * Software Technology Group - TU Dresden, Germany; + * DevBoost GmbH - Berlin, Germany + * - initial API and implementation + ******************************************************************************/ +package de.devboost.buildboost.filters; + +import java.util.ArrayList; +import java.util.Collection; + +import de.devboost.buildboost.BuildException; +import de.devboost.buildboost.DependencyResolver; +import de.devboost.buildboost.model.AbstractBuildParticipant; +import de.devboost.buildboost.model.BuildEventType; +import de.devboost.buildboost.model.IArtifact; +import de.devboost.buildboost.model.IArtifactDiscoverer; +import de.devboost.buildboost.model.IArtifactFilter; +import de.devboost.buildboost.model.IBuildContext; +import de.devboost.buildboost.model.IBuildListener; +import de.devboost.buildboost.model.IBuildParticipant; + +public abstract class AbstractFilter extends AbstractBuildParticipant implements IArtifactFilter { + + @Override + public void execute(IBuildContext context) throws BuildException { + IBuildListener buildListener = context.getBuildListener(); + Collection artifacts = context.getDiscoveredArtifacts(); + Collection artifactsToRemove = new ArrayList(); + for (IArtifact artifact : artifacts) { + if (!accept(artifact)) { + buildListener.handleBuildEvent(BuildEventType.INFO, "Artifact " + artifact + " is removed because of filter " + this); + artifactsToRemove.add(artifact); + } + } + context.removeDiscoveredArtifacts(artifactsToRemove); + } + + public OrFilter or(IArtifactFilter other) { + return new OrFilter(this, other); + } + + @Override + public boolean dependsOn(IBuildParticipant otherParticipant) { + if (otherParticipant instanceof IArtifactDiscoverer) { + return true; + } + if (otherParticipant instanceof DependencyResolver) { + return true; + } + return false; + } +} diff --git a/Core/de.devboost.buildboost/src/de/devboost/buildboost/filters/ArtifactTypeFilter.java b/Core/de.devboost.buildboost/src/de/devboost/buildboost/filters/ArtifactTypeFilter.java index 6e3bfec..c8b8ad1 100644 --- a/Core/de.devboost.buildboost/src/de/devboost/buildboost/filters/ArtifactTypeFilter.java +++ b/Core/de.devboost.buildboost/src/de/devboost/buildboost/filters/ArtifactTypeFilter.java @@ -1,37 +1,37 @@ -/******************************************************************************* - * Copyright (c) 2006-2012 - * Software Technology Group, Dresden University of Technology - * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 - * - * All rights reserved. This program and the accompanying materials - * are 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 - * - * Contributors: - * Software Technology Group - TU Dresden, Germany; - * DevBoost GmbH - Berlin, Germany - * - initial API and implementation - ******************************************************************************/ -package de.devboost.buildboost.filters; - -import de.devboost.buildboost.model.IArtifact; - -public class ArtifactTypeFilter extends AbstractFilter { - - private Class artifactType = null; - - public ArtifactTypeFilter(Class artifactType) { - this.artifactType = artifactType; - } - - - public boolean accept(IArtifact artifact) { - return artifactType.isInstance(artifact); - } - - @Override - public String toString() { - return getClass().getSimpleName() + " [type = " + artifactType.getSimpleName() + "]"; - } -} +/******************************************************************************* + * Copyright (c) 2006-2012 + * Software Technology Group, Dresden University of Technology + * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 + * + * All rights reserved. This program and the accompanying materials + * are 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 + * + * Contributors: + * Software Technology Group - TU Dresden, Germany; + * DevBoost GmbH - Berlin, Germany + * - initial API and implementation + ******************************************************************************/ +package de.devboost.buildboost.filters; + +import de.devboost.buildboost.model.IArtifact; + +public class ArtifactTypeFilter extends AbstractFilter { + + private Class artifactType = null; + + public ArtifactTypeFilter(Class artifactType) { + this.artifactType = artifactType; + } + + + public boolean accept(IArtifact artifact) { + return artifactType.isInstance(artifact); + } + + @Override + public String toString() { + return getClass().getSimpleName() + " [type = " + artifactType.getSimpleName() + "]"; + } +} diff --git a/Core/de.devboost.buildboost/src/de/devboost/buildboost/filters/DirectoryFilter.java b/Core/de.devboost.buildboost/src/de/devboost/buildboost/filters/DirectoryFilter.java index 256c6e2..3476995 100644 --- a/Core/de.devboost.buildboost/src/de/devboost/buildboost/filters/DirectoryFilter.java +++ b/Core/de.devboost.buildboost/src/de/devboost/buildboost/filters/DirectoryFilter.java @@ -1,62 +1,62 @@ -/******************************************************************************* - * Copyright (c) 2006-2012 - * Software Technology Group, Dresden University of Technology - * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 - * - * All rights reserved. This program and the accompanying materials - * are 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 - * - * Contributors: - * Software Technology Group - TU Dresden, Germany; - * DevBoost GmbH - Berlin, Germany - * - initial API and implementation - ******************************************************************************/ -package de.devboost.buildboost.filters; - -import java.io.File; -import java.util.LinkedHashSet; -import java.util.Set; - -import de.devboost.buildboost.model.IArtifact; -import de.devboost.buildboost.model.IFileArtifact; - -/** - * A DirectoryFilter can be used to exclude artifacts that are contained in a - * certain directory. The DirectoryFilter walks up the parent hierarchy of the - * file that contains the artifact and compares the names of the parent - * directories with the given exclusion list. - */ -public class DirectoryFilter extends AbstractFilter { - - private Set excludedNames; - - public DirectoryFilter(Set excludedNames) { - this.excludedNames = excludedNames; - } - - public DirectoryFilter(String... excludedNames) { - this.excludedNames = new LinkedHashSet(); - for (String name : excludedNames) { - this.excludedNames.add(name); - } - } - - public boolean accept(IArtifact artifact) { - if (artifact instanceof IFileArtifact) { - IFileArtifact fileArtifact = (IFileArtifact) artifact; - File file = fileArtifact.getFile(); - while (file != null) { - String name = file.getName(); - if (excludedNames.contains(name)) { - return false; - } - file = file.getParentFile(); - } - - } - return true; - } - -} +/******************************************************************************* + * Copyright (c) 2006-2012 + * Software Technology Group, Dresden University of Technology + * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 + * + * All rights reserved. This program and the accompanying materials + * are 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 + * + * Contributors: + * Software Technology Group - TU Dresden, Germany; + * DevBoost GmbH - Berlin, Germany + * - initial API and implementation + ******************************************************************************/ +package de.devboost.buildboost.filters; + +import java.io.File; +import java.util.LinkedHashSet; +import java.util.Set; + +import de.devboost.buildboost.model.IArtifact; +import de.devboost.buildboost.model.IFileArtifact; + +/** + * A DirectoryFilter can be used to exclude artifacts that are contained in a + * certain directory. The DirectoryFilter walks up the parent hierarchy of the + * file that contains the artifact and compares the names of the parent + * directories with the given exclusion list. + */ +public class DirectoryFilter extends AbstractFilter { + + private Set excludedNames; + + public DirectoryFilter(Set excludedNames) { + this.excludedNames = excludedNames; + } + + public DirectoryFilter(String... excludedNames) { + this.excludedNames = new LinkedHashSet(); + for (String name : excludedNames) { + this.excludedNames.add(name); + } + } + + public boolean accept(IArtifact artifact) { + if (artifact instanceof IFileArtifact) { + IFileArtifact fileArtifact = (IFileArtifact) artifact; + File file = fileArtifact.getFile(); + while (file != null) { + String name = file.getName(); + if (excludedNames.contains(name)) { + return false; + } + file = file.getParentFile(); + } + + } + return true; + } + +} diff --git a/Core/de.devboost.buildboost/src/de/devboost/buildboost/filters/IdentifierFilter.java b/Core/de.devboost.buildboost/src/de/devboost/buildboost/filters/IdentifierFilter.java index b611ad1..bfb1c2c 100644 --- a/Core/de.devboost.buildboost/src/de/devboost/buildboost/filters/IdentifierFilter.java +++ b/Core/de.devboost.buildboost/src/de/devboost/buildboost/filters/IdentifierFilter.java @@ -1,53 +1,53 @@ -/******************************************************************************* - * Copyright (c) 2006-2012 - * Software Technology Group, Dresden University of Technology - * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 - * - * All rights reserved. This program and the accompanying materials - * are 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 - * - * Contributors: - * Software Technology Group - TU Dresden, Germany; - * DevBoost GmbH - Berlin, Germany - * - initial API and implementation - ******************************************************************************/ -package de.devboost.buildboost.filters; - -import java.util.Collections; -import java.util.LinkedHashSet; -import java.util.Set; - -import de.devboost.buildboost.model.IArtifact; - -/** - * A filter that accepts artifacts where the identifier is within a given set - * of valid identifiers. - */ -public class IdentifierFilter extends AbstractFilter { - - private Set validArtifactIdentifiers = new LinkedHashSet(1); - - public IdentifierFilter(String validArtifactIdentifier) { - this(Collections.singleton(validArtifactIdentifier)); - } - - public IdentifierFilter(Set validArtifactIdentifiers) { - this.validArtifactIdentifiers = validArtifactIdentifiers; - } - - public boolean accept(IArtifact artifact) { - String identifier = artifact.getIdentifier(); - if (validArtifactIdentifiers.contains(identifier)) { - return true; - } else { - return false; - } - } - - @Override - public String toString() { - return getClass().getSimpleName() + " [valid identifiers = " + validArtifactIdentifiers + "]"; - } -} +/******************************************************************************* + * Copyright (c) 2006-2012 + * Software Technology Group, Dresden University of Technology + * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 + * + * All rights reserved. This program and the accompanying materials + * are 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 + * + * Contributors: + * Software Technology Group - TU Dresden, Germany; + * DevBoost GmbH - Berlin, Germany + * - initial API and implementation + ******************************************************************************/ +package de.devboost.buildboost.filters; + +import java.util.Collections; +import java.util.LinkedHashSet; +import java.util.Set; + +import de.devboost.buildboost.model.IArtifact; + +/** + * A filter that accepts artifacts where the identifier is within a given set + * of valid identifiers. + */ +public class IdentifierFilter extends AbstractFilter { + + private Set validArtifactIdentifiers = new LinkedHashSet(1); + + public IdentifierFilter(String validArtifactIdentifier) { + this(Collections.singleton(validArtifactIdentifier)); + } + + public IdentifierFilter(Set validArtifactIdentifiers) { + this.validArtifactIdentifiers = validArtifactIdentifiers; + } + + public boolean accept(IArtifact artifact) { + String identifier = artifact.getIdentifier(); + if (validArtifactIdentifiers.contains(identifier)) { + return true; + } else { + return false; + } + } + + @Override + public String toString() { + return getClass().getSimpleName() + " [valid identifiers = " + validArtifactIdentifiers + "]"; + } +} diff --git a/Core/de.devboost.buildboost/src/de/devboost/buildboost/filters/IdentifierRegexFilter.java b/Core/de.devboost.buildboost/src/de/devboost/buildboost/filters/IdentifierRegexFilter.java index 219fb43..bceba2a 100644 --- a/Core/de.devboost.buildboost/src/de/devboost/buildboost/filters/IdentifierRegexFilter.java +++ b/Core/de.devboost.buildboost/src/de/devboost/buildboost/filters/IdentifierRegexFilter.java @@ -1,45 +1,45 @@ -/******************************************************************************* - * Copyright (c) 2006-2012 - * Software Technology Group, Dresden University of Technology - * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 - * - * All rights reserved. This program and the accompanying materials - * are 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 - * - * Contributors: - * Software Technology Group - TU Dresden, Germany; - * DevBoost GmbH - Berlin, Germany - * - initial API and implementation - ******************************************************************************/ -package de.devboost.buildboost.filters; - -import de.devboost.buildboost.model.IArtifact; - -/** - * A filter that accepts all artifacts with an identifier that matches a given - * regular expression. - */ -public class IdentifierRegexFilter extends AbstractFilter { - - private String regularExpression; - - public IdentifierRegexFilter(String regularExpression) { - this.regularExpression = regularExpression; - } - - public boolean accept(IArtifact artifact) { - String identifier = artifact.getIdentifier(); - if (identifier != null && identifier.matches(regularExpression)) { - return true; - } else { - return false; - } - } - - @Override - public String toString() { - return getClass().getSimpleName() + " [regularExpression = " + regularExpression + "]"; - } -} +/******************************************************************************* + * Copyright (c) 2006-2012 + * Software Technology Group, Dresden University of Technology + * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 + * + * All rights reserved. This program and the accompanying materials + * are 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 + * + * Contributors: + * Software Technology Group - TU Dresden, Germany; + * DevBoost GmbH - Berlin, Germany + * - initial API and implementation + ******************************************************************************/ +package de.devboost.buildboost.filters; + +import de.devboost.buildboost.model.IArtifact; + +/** + * A filter that accepts all artifacts with an identifier that matches a given + * regular expression. + */ +public class IdentifierRegexFilter extends AbstractFilter { + + private String regularExpression; + + public IdentifierRegexFilter(String regularExpression) { + this.regularExpression = regularExpression; + } + + public boolean accept(IArtifact artifact) { + String identifier = artifact.getIdentifier(); + if (identifier != null && identifier.matches(regularExpression)) { + return true; + } else { + return false; + } + } + + @Override + public String toString() { + return getClass().getSimpleName() + " [regularExpression = " + regularExpression + "]"; + } +} diff --git a/Core/de.devboost.buildboost/src/de/devboost/buildboost/filters/NegatingFilter.java b/Core/de.devboost.buildboost/src/de/devboost/buildboost/filters/NegatingFilter.java index 36fb8fc..27b5649 100644 --- a/Core/de.devboost.buildboost/src/de/devboost/buildboost/filters/NegatingFilter.java +++ b/Core/de.devboost.buildboost/src/de/devboost/buildboost/filters/NegatingFilter.java @@ -1,42 +1,42 @@ -/******************************************************************************* - * Copyright (c) 2006-2012 - * Software Technology Group, Dresden University of Technology - * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 - * - * All rights reserved. This program and the accompanying materials - * are 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 - * - * Contributors: - * Software Technology Group - TU Dresden, Germany; - * DevBoost GmbH - Berlin, Germany - * - initial API and implementation - ******************************************************************************/ -package de.devboost.buildboost.filters; - -import de.devboost.buildboost.model.IArtifact; -import de.devboost.buildboost.model.IArtifactFilter; - -/** - * A {@link NegatingFilter} accepts all artifacts that are discarded by a given - * other filter. - */ -public class NegatingFilter extends AbstractFilter { - - private IArtifactFilter filterToNegate; - - public NegatingFilter(IArtifactFilter filterToNegate) { - super(); - this.filterToNegate = filterToNegate; - } - - public boolean accept(IArtifact artifact) { - return !filterToNegate.accept(artifact); - } - - @Override - public String toString() { - return this.getClass().getSimpleName() + " [" + filterToNegate + "]"; - } -} +/******************************************************************************* + * Copyright (c) 2006-2012 + * Software Technology Group, Dresden University of Technology + * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 + * + * All rights reserved. This program and the accompanying materials + * are 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 + * + * Contributors: + * Software Technology Group - TU Dresden, Germany; + * DevBoost GmbH - Berlin, Germany + * - initial API and implementation + ******************************************************************************/ +package de.devboost.buildboost.filters; + +import de.devboost.buildboost.model.IArtifact; +import de.devboost.buildboost.model.IArtifactFilter; + +/** + * A {@link NegatingFilter} accepts all artifacts that are discarded by a given + * other filter. + */ +public class NegatingFilter extends AbstractFilter { + + private IArtifactFilter filterToNegate; + + public NegatingFilter(IArtifactFilter filterToNegate) { + super(); + this.filterToNegate = filterToNegate; + } + + public boolean accept(IArtifact artifact) { + return !filterToNegate.accept(artifact); + } + + @Override + public String toString() { + return this.getClass().getSimpleName() + " [" + filterToNegate + "]"; + } +} diff --git a/Core/de.devboost.buildboost/src/de/devboost/buildboost/filters/OrFilter.java b/Core/de.devboost.buildboost/src/de/devboost/buildboost/filters/OrFilter.java index 8372fb7..9073db5 100644 --- a/Core/de.devboost.buildboost/src/de/devboost/buildboost/filters/OrFilter.java +++ b/Core/de.devboost.buildboost/src/de/devboost/buildboost/filters/OrFilter.java @@ -1,54 +1,54 @@ -/******************************************************************************* - * Copyright (c) 2006-2012 - * Software Technology Group, Dresden University of Technology - * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 - * - * All rights reserved. This program and the accompanying materials - * are 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 - * - * Contributors: - * Software Technology Group - TU Dresden, Germany; - * DevBoost GmbH - Berlin, Germany - * - initial API and implementation - ******************************************************************************/ -package de.devboost.buildboost.filters; - -import de.devboost.buildboost.model.IArtifact; -import de.devboost.buildboost.model.IArtifactFilter; -import de.devboost.buildboost.util.StringUtil; - -/** - * A {@link OrFilter} accepts all artifacts that are accepted by at least one - * filter from a given set of filters. - */ -public class OrFilter extends AbstractFilter { - - private IArtifactFilter[] filters; - - /** - * Creates a disjunctive filter over the given list of filters. - */ - public OrFilter(IArtifactFilter... filters) { - super(); - this.filters = filters; - } - - /** - * Returns true if the artifact is accepted by one of the filters. - */ - public boolean accept(IArtifact artifact) { - for (IArtifactFilter filter : filters) { - if (filter.accept(artifact)) { - return true; - } - } - return false; - } - - @Override - public String toString() { - return getClass().getSimpleName() + "[" + new StringUtil().explode(filters, ", ") + "]"; - } -} +/******************************************************************************* + * Copyright (c) 2006-2012 + * Software Technology Group, Dresden University of Technology + * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 + * + * All rights reserved. This program and the accompanying materials + * are 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 + * + * Contributors: + * Software Technology Group - TU Dresden, Germany; + * DevBoost GmbH - Berlin, Germany + * - initial API and implementation + ******************************************************************************/ +package de.devboost.buildboost.filters; + +import de.devboost.buildboost.model.IArtifact; +import de.devboost.buildboost.model.IArtifactFilter; +import de.devboost.buildboost.util.StringUtil; + +/** + * A {@link OrFilter} accepts all artifacts that are accepted by at least one + * filter from a given set of filters. + */ +public class OrFilter extends AbstractFilter { + + private IArtifactFilter[] filters; + + /** + * Creates a disjunctive filter over the given list of filters. + */ + public OrFilter(IArtifactFilter... filters) { + super(); + this.filters = filters; + } + + /** + * Returns true if the artifact is accepted by one of the filters. + */ + public boolean accept(IArtifact artifact) { + for (IArtifactFilter filter : filters) { + if (filter.accept(artifact)) { + return true; + } + } + return false; + } + + @Override + public String toString() { + return getClass().getSimpleName() + "[" + new StringUtil().explode(filters, ", ") + "]"; + } +} diff --git a/Core/de.devboost.buildboost/src/de/devboost/buildboost/model/AbstractBuildParticipant.java b/Core/de.devboost.buildboost/src/de/devboost/buildboost/model/AbstractBuildParticipant.java index 67ae786..8672990 100644 --- a/Core/de.devboost.buildboost/src/de/devboost/buildboost/model/AbstractBuildParticipant.java +++ b/Core/de.devboost.buildboost/src/de/devboost/buildboost/model/AbstractBuildParticipant.java @@ -1,34 +1,34 @@ -/******************************************************************************* - * Copyright (c) 2006-2012 - * Software Technology Group, Dresden University of Technology - * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 - * - * All rights reserved. This program and the accompanying materials - * are 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 - * - * Contributors: - * Software Technology Group - TU Dresden, Germany; - * DevBoost GmbH - Berlin, Germany - * - initial API and implementation - ******************************************************************************/ -package de.devboost.buildboost.model; - -public abstract class AbstractBuildParticipant implements IBuildParticipant { - - @Override - public boolean dependsOn(IBuildParticipant otherParticipant) { - return false; - } - - @Override - public boolean isReqiredFor(IBuildParticipant otherParticipant) { - return false; - } - - @Override - public String toString() { - return this.getClass().getName(); - } -} +/******************************************************************************* + * Copyright (c) 2006-2012 + * Software Technology Group, Dresden University of Technology + * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 + * + * All rights reserved. This program and the accompanying materials + * are 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 + * + * Contributors: + * Software Technology Group - TU Dresden, Germany; + * DevBoost GmbH - Berlin, Germany + * - initial API and implementation + ******************************************************************************/ +package de.devboost.buildboost.model; + +public abstract class AbstractBuildParticipant implements IBuildParticipant { + + @Override + public boolean dependsOn(IBuildParticipant otherParticipant) { + return false; + } + + @Override + public boolean isReqiredFor(IBuildParticipant otherParticipant) { + return false; + } + + @Override + public String toString() { + return this.getClass().getName(); + } +} diff --git a/Core/de.devboost.buildboost/src/de/devboost/buildboost/model/BuildEventType.java b/Core/de.devboost.buildboost/src/de/devboost/buildboost/model/BuildEventType.java index a3a923c..339d254 100644 --- a/Core/de.devboost.buildboost/src/de/devboost/buildboost/model/BuildEventType.java +++ b/Core/de.devboost.buildboost/src/de/devboost/buildboost/model/BuildEventType.java @@ -1,21 +1,21 @@ -/******************************************************************************* - * Copyright (c) 2006-2012 - * Software Technology Group, Dresden University of Technology - * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 - * - * All rights reserved. This program and the accompanying materials - * are 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 - * - * Contributors: - * Software Technology Group - TU Dresden, Germany; - * DevBoost GmbH - Berlin, Germany - * - initial API and implementation - ******************************************************************************/ -package de.devboost.buildboost.model; - -public enum BuildEventType { - - INFO, WARNING, ERROR -} +/******************************************************************************* + * Copyright (c) 2006-2012 + * Software Technology Group, Dresden University of Technology + * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 + * + * All rights reserved. This program and the accompanying materials + * are 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 + * + * Contributors: + * Software Technology Group - TU Dresden, Germany; + * DevBoost GmbH - Berlin, Germany + * - initial API and implementation + ******************************************************************************/ +package de.devboost.buildboost.model; + +public enum BuildEventType { + + INFO, WARNING, ERROR +} diff --git a/Core/de.devboost.buildboost/src/de/devboost/buildboost/model/IArtifact.java b/Core/de.devboost.buildboost/src/de/devboost/buildboost/model/IArtifact.java index 0787760..540791d 100644 --- a/Core/de.devboost.buildboost/src/de/devboost/buildboost/model/IArtifact.java +++ b/Core/de.devboost.buildboost/src/de/devboost/buildboost/model/IArtifact.java @@ -1,44 +1,44 @@ -/******************************************************************************* - * Copyright (c) 2006-2012 - * Software Technology Group, Dresden University of Technology - * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 - * - * All rights reserved. This program and the accompanying materials - * are 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 - * - * Contributors: - * Software Technology Group - TU Dresden, Germany; - * DevBoost GmbH - Berlin, Germany - * - initial API and implementation - ******************************************************************************/ -package de.devboost.buildboost.model; - -import java.util.Collection; - -/** - * An {@link IArtifact} is something that is subject to the build process. Each - * artifact requires a unique identifier and may expose dependencies to other - * artifacts. - */ -public interface IArtifact extends IDependable { - - /** - * Returns the unique identifier for this artifact. - */ - public String getIdentifier(); - - //TODO currently unused / for incremental build / needed? - public long getTimestamp(); - - /** - * Returns all dependencies that must be build before this artifact can be - * built. - */ - //public Collection getDependencies(); - - public void resolveDependencies(Collection allArtifacts); - - public Collection getUnresolvedDependencies(); -} +/******************************************************************************* + * Copyright (c) 2006-2012 + * Software Technology Group, Dresden University of Technology + * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 + * + * All rights reserved. This program and the accompanying materials + * are 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 + * + * Contributors: + * Software Technology Group - TU Dresden, Germany; + * DevBoost GmbH - Berlin, Germany + * - initial API and implementation + ******************************************************************************/ +package de.devboost.buildboost.model; + +import java.util.Collection; + +/** + * An {@link IArtifact} is something that is subject to the build process. Each + * artifact requires a unique identifier and may expose dependencies to other + * artifacts. + */ +public interface IArtifact extends IDependable { + + /** + * Returns the unique identifier for this artifact. + */ + public String getIdentifier(); + + //TODO currently unused / for incremental build / needed? + public long getTimestamp(); + + /** + * Returns all dependencies that must be build before this artifact can be + * built. + */ + //public Collection getDependencies(); + + public void resolveDependencies(Collection allArtifacts); + + public Collection getUnresolvedDependencies(); +} diff --git a/Core/de.devboost.buildboost/src/de/devboost/buildboost/model/IArtifactDiscoverer.java b/Core/de.devboost.buildboost/src/de/devboost/buildboost/model/IArtifactDiscoverer.java index 192349a..862b8f7 100644 --- a/Core/de.devboost.buildboost/src/de/devboost/buildboost/model/IArtifactDiscoverer.java +++ b/Core/de.devboost.buildboost/src/de/devboost/buildboost/model/IArtifactDiscoverer.java @@ -1,36 +1,36 @@ -/******************************************************************************* - * Copyright (c) 2006-2012 - * Software Technology Group, Dresden University of Technology - * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 - * - * All rights reserved. This program and the accompanying materials - * are 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 - * - * Contributors: - * Software Technology Group - TU Dresden, Germany; - * DevBoost GmbH - Berlin, Germany - * - initial API and implementation - ******************************************************************************/ -package de.devboost.buildboost.model; - -import java.util.Collection; - -import de.devboost.buildboost.BuildException; - -/** - * An IArtifactDiscoverer can be used to discover artifacts that are required - * while performing a build. Prominent examples of such discoverers are project - * finders and target platform analyzers. - * - * IArtifactDiscoverers are use in the very beginning of a build to collect all - * artifacts that will be incorporated in the build. After the artifacts have - * been found, the can be filtered using {@link IArtifactFilter}s. The resulting - * set of artifacts is then sorted according to their dependencies and - * appropriate build steps are performed. - */ -public interface IArtifactDiscoverer extends IBuildParticipant { - - public Collection discoverArtifacts(IBuildContext context) throws BuildException; -} +/******************************************************************************* + * Copyright (c) 2006-2012 + * Software Technology Group, Dresden University of Technology + * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 + * + * All rights reserved. This program and the accompanying materials + * are 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 + * + * Contributors: + * Software Technology Group - TU Dresden, Germany; + * DevBoost GmbH - Berlin, Germany + * - initial API and implementation + ******************************************************************************/ +package de.devboost.buildboost.model; + +import java.util.Collection; + +import de.devboost.buildboost.BuildException; + +/** + * An IArtifactDiscoverer can be used to discover artifacts that are required + * while performing a build. Prominent examples of such discoverers are project + * finders and target platform analyzers. + * + * IArtifactDiscoverers are use in the very beginning of a build to collect all + * artifacts that will be incorporated in the build. After the artifacts have + * been found, the can be filtered using {@link IArtifactFilter}s. The resulting + * set of artifacts is then sorted according to their dependencies and + * appropriate build steps are performed. + */ +public interface IArtifactDiscoverer extends IBuildParticipant { + + public Collection discoverArtifacts(IBuildContext context) throws BuildException; +} diff --git a/Core/de.devboost.buildboost/src/de/devboost/buildboost/model/IArtifactFilter.java b/Core/de.devboost.buildboost/src/de/devboost/buildboost/model/IArtifactFilter.java index 921c149..d835396 100644 --- a/Core/de.devboost.buildboost/src/de/devboost/buildboost/model/IArtifactFilter.java +++ b/Core/de.devboost.buildboost/src/de/devboost/buildboost/model/IArtifactFilter.java @@ -1,31 +1,31 @@ -/******************************************************************************* - * Copyright (c) 2006-2012 - * Software Technology Group, Dresden University of Technology - * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 - * - * All rights reserved. This program and the accompanying materials - * are 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 - * - * Contributors: - * Software Technology Group - TU Dresden, Germany; - * DevBoost GmbH - Berlin, Germany - * - initial API and implementation - ******************************************************************************/ -package de.devboost.buildboost.model; - -/** - * An IArtifactFilter can be used to filter the set of discovered artifacts. - * This allows, for example, to exclude experimental projects from the build - * process. It also provides a very fine-grained control over which artifacts - * will be subject to the build an which will not be processed. - */ -public interface IArtifactFilter extends IBuildParticipant { - - /** - * Returns true if the given artifact shall be processed during the current - * build. - */ - public boolean accept(IArtifact artifact); -} +/******************************************************************************* + * Copyright (c) 2006-2012 + * Software Technology Group, Dresden University of Technology + * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 + * + * All rights reserved. This program and the accompanying materials + * are 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 + * + * Contributors: + * Software Technology Group - TU Dresden, Germany; + * DevBoost GmbH - Berlin, Germany + * - initial API and implementation + ******************************************************************************/ +package de.devboost.buildboost.model; + +/** + * An IArtifactFilter can be used to filter the set of discovered artifacts. + * This allows, for example, to exclude experimental projects from the build + * process. It also provides a very fine-grained control over which artifacts + * will be subject to the build an which will not be processed. + */ +public interface IArtifactFilter extends IBuildParticipant { + + /** + * Returns true if the given artifact shall be processed during the current + * build. + */ + public boolean accept(IArtifact artifact); +} diff --git a/Core/de.devboost.buildboost/src/de/devboost/buildboost/model/IBuildConfiguration.java b/Core/de.devboost.buildboost/src/de/devboost/buildboost/model/IBuildConfiguration.java index 1ca081a..b2549a3 100644 --- a/Core/de.devboost.buildboost/src/de/devboost/buildboost/model/IBuildConfiguration.java +++ b/Core/de.devboost.buildboost/src/de/devboost/buildboost/model/IBuildConfiguration.java @@ -1,28 +1,28 @@ -/******************************************************************************* - * Copyright (c) 2006-2012 - * Software Technology Group, Dresden University of Technology - * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 - * - * All rights reserved. This program and the accompanying materials - * are 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 - * - * Contributors: - * Software Technology Group - TU Dresden, Germany; - * DevBoost GmbH - Berlin, Germany - * - initial API and implementation - ******************************************************************************/ -package de.devboost.buildboost.model; - -import java.util.List; - -/** - * An IBuildConfiguration is used by BuildBoost to obtain the list of build - * stages. This interfaces should be implemented by the main class of all build - * plug-ins. - */ -public interface IBuildConfiguration { - - public List getBuildStages(String workspace); -} +/******************************************************************************* + * Copyright (c) 2006-2012 + * Software Technology Group, Dresden University of Technology + * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 + * + * All rights reserved. This program and the accompanying materials + * are 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 + * + * Contributors: + * Software Technology Group - TU Dresden, Germany; + * DevBoost GmbH - Berlin, Germany + * - initial API and implementation + ******************************************************************************/ +package de.devboost.buildboost.model; + +import java.util.List; + +/** + * An IBuildConfiguration is used by BuildBoost to obtain the list of build + * stages. This interfaces should be implemented by the main class of all build + * plug-ins. + */ +public interface IBuildConfiguration { + + public List getBuildStages(String workspace); +} diff --git a/Core/de.devboost.buildboost/src/de/devboost/buildboost/model/IBuildContext.java b/Core/de.devboost.buildboost/src/de/devboost/buildboost/model/IBuildContext.java index 1bdba53..a86a502 100644 --- a/Core/de.devboost.buildboost/src/de/devboost/buildboost/model/IBuildContext.java +++ b/Core/de.devboost.buildboost/src/de/devboost/buildboost/model/IBuildContext.java @@ -1,57 +1,57 @@ -/******************************************************************************* - * Copyright (c) 2006-2012 - * Software Technology Group, Dresden University of Technology - * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 - * - * All rights reserved. This program and the accompanying materials - * are 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 - * - * Contributors: - * Software Technology Group - TU Dresden, Germany; - * DevBoost GmbH - Berlin, Germany - * - initial API and implementation - ******************************************************************************/ -package de.devboost.buildboost.model; - -import java.util.Collection; -import java.util.List; - -/** - * The IBuildContext collects information during the build and provides - * access to this information to all components that are involved in - * this process. - */ -public interface IBuildContext { - - /** - * Returns an unmodifiable collection containing the artifacts discovered - * so far. - */ - public Collection getDiscoveredArtifacts(); - - /** - * Removes the given collection of artifacts from the set of discovered - * artifacts. - */ - public void removeDiscoveredArtifacts(Collection artifactsToRemove); - - /** - * Adds the given collection of artifacts to the set of discovered - * artifacts. - */ - public void addDiscoveredArtifacts(Collection artifactsToAdd); - - /** - * Returns the listener for the current build. The listener can be used to - * send status messages about the build process. - */ - public IBuildListener getBuildListener(); - - public boolean ignoreUnresolvedDependencies(); - - public List getBuildParticipants(); - - public void addBuildParticipant(IBuildParticipant participant); -} +/******************************************************************************* + * Copyright (c) 2006-2012 + * Software Technology Group, Dresden University of Technology + * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 + * + * All rights reserved. This program and the accompanying materials + * are 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 + * + * Contributors: + * Software Technology Group - TU Dresden, Germany; + * DevBoost GmbH - Berlin, Germany + * - initial API and implementation + ******************************************************************************/ +package de.devboost.buildboost.model; + +import java.util.Collection; +import java.util.List; + +/** + * The IBuildContext collects information during the build and provides + * access to this information to all components that are involved in + * this process. + */ +public interface IBuildContext { + + /** + * Returns an unmodifiable collection containing the artifacts discovered + * so far. + */ + public Collection getDiscoveredArtifacts(); + + /** + * Removes the given collection of artifacts from the set of discovered + * artifacts. + */ + public void removeDiscoveredArtifacts(Collection artifactsToRemove); + + /** + * Adds the given collection of artifacts to the set of discovered + * artifacts. + */ + public void addDiscoveredArtifacts(Collection artifactsToAdd); + + /** + * Returns the listener for the current build. The listener can be used to + * send status messages about the build process. + */ + public IBuildListener getBuildListener(); + + public boolean ignoreUnresolvedDependencies(); + + public List getBuildParticipants(); + + public void addBuildParticipant(IBuildParticipant participant); +} diff --git a/Core/de.devboost.buildboost/src/de/devboost/buildboost/model/IBuildListener.java b/Core/de.devboost.buildboost/src/de/devboost/buildboost/model/IBuildListener.java index 622568c..f468691 100644 --- a/Core/de.devboost.buildboost/src/de/devboost/buildboost/model/IBuildListener.java +++ b/Core/de.devboost.buildboost/src/de/devboost/buildboost/model/IBuildListener.java @@ -1,21 +1,21 @@ -/******************************************************************************* - * Copyright (c) 2006-2012 - * Software Technology Group, Dresden University of Technology - * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 - * - * All rights reserved. This program and the accompanying materials - * are 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 - * - * Contributors: - * Software Technology Group - TU Dresden, Germany; - * DevBoost GmbH - Berlin, Germany - * - initial API and implementation - ******************************************************************************/ -package de.devboost.buildboost.model; - -public interface IBuildListener { - - public void handleBuildEvent(BuildEventType type, String message); -} +/******************************************************************************* + * Copyright (c) 2006-2012 + * Software Technology Group, Dresden University of Technology + * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 + * + * All rights reserved. This program and the accompanying materials + * are 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 + * + * Contributors: + * Software Technology Group - TU Dresden, Germany; + * DevBoost GmbH - Berlin, Germany + * - initial API and implementation + ******************************************************************************/ +package de.devboost.buildboost.model; + +public interface IBuildListener { + + public void handleBuildEvent(BuildEventType type, String message); +} diff --git a/Core/de.devboost.buildboost/src/de/devboost/buildboost/model/IBuildParticipant.java b/Core/de.devboost.buildboost/src/de/devboost/buildboost/model/IBuildParticipant.java index e6dc976..c400875 100644 --- a/Core/de.devboost.buildboost/src/de/devboost/buildboost/model/IBuildParticipant.java +++ b/Core/de.devboost.buildboost/src/de/devboost/buildboost/model/IBuildParticipant.java @@ -1,41 +1,41 @@ -/******************************************************************************* - * Copyright (c) 2006-2012 - * Software Technology Group, Dresden University of Technology - * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 - * - * All rights reserved. This program and the accompanying materials - * are 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 - * - * Contributors: - * Software Technology Group - TU Dresden, Germany; - * DevBoost GmbH - Berlin, Germany - * - initial API and implementation - ******************************************************************************/ -package de.devboost.buildboost.model; - -import de.devboost.buildboost.AutoBuilder; -import de.devboost.buildboost.BuildException; -import de.devboost.buildboost.ant.IAntTargetGeneratorProvider; - -/** - * The IBuildParticipant is an empty interface that is extended by concrete - * interfaces that provide access to specific services required while executing - * a build. The most imports extensions of this interface are: - * {@link IArtifactDiscoverer}, - * {@link IArtifactFilter}, and - * {@link IAntTargetGeneratorProvider}. - * - * The sole purpose of this interface is to allow to pass all services that - * participate in a build in a single list to the {@link AutoBuilder} class. - */ -public interface IBuildParticipant { - - // TODO update documentation - public boolean dependsOn(IBuildParticipant otherParticipant); - - public boolean isReqiredFor(IBuildParticipant otherParticipant); - - public void execute(IBuildContext context) throws BuildException; -} +/******************************************************************************* + * Copyright (c) 2006-2012 + * Software Technology Group, Dresden University of Technology + * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 + * + * All rights reserved. This program and the accompanying materials + * are 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 + * + * Contributors: + * Software Technology Group - TU Dresden, Germany; + * DevBoost GmbH - Berlin, Germany + * - initial API and implementation + ******************************************************************************/ +package de.devboost.buildboost.model; + +import de.devboost.buildboost.AutoBuilder; +import de.devboost.buildboost.BuildException; +import de.devboost.buildboost.ant.IAntTargetGeneratorProvider; + +/** + * The IBuildParticipant is an empty interface that is extended by concrete + * interfaces that provide access to specific services required while executing + * a build. The most imports extensions of this interface are: + * {@link IArtifactDiscoverer}, + * {@link IArtifactFilter}, and + * {@link IAntTargetGeneratorProvider}. + * + * The sole purpose of this interface is to allow to pass all services that + * participate in a build in a single list to the {@link AutoBuilder} class. + */ +public interface IBuildParticipant { + + // TODO update documentation + public boolean dependsOn(IBuildParticipant otherParticipant); + + public boolean isReqiredFor(IBuildParticipant otherParticipant); + + public void execute(IBuildContext context) throws BuildException; +} diff --git a/Core/de.devboost.buildboost/src/de/devboost/buildboost/model/IBuildStage.java b/Core/de.devboost.buildboost/src/de/devboost/buildboost/model/IBuildStage.java index f31bc86..718d833 100644 --- a/Core/de.devboost.buildboost/src/de/devboost/buildboost/model/IBuildStage.java +++ b/Core/de.devboost.buildboost/src/de/devboost/buildboost/model/IBuildStage.java @@ -1,30 +1,30 @@ -/******************************************************************************* - * Copyright (c) 2006-2012 - * Software Technology Group, Dresden University of Technology - * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 - * - * All rights reserved. This program and the accompanying materials - * are 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 - * - * Contributors: - * Software Technology Group - TU Dresden, Germany; - * DevBoost GmbH - Berlin, Germany - * - initial API and implementation - ******************************************************************************/ -package de.devboost.buildboost.model; - -import de.devboost.buildboost.BuildException; -import de.devboost.buildboost.ant.AntScript; - -public interface IBuildStage { - - public AntScript getScript() throws BuildException; - - /** - * Build stages can be disabled which means that the code for the respective - * build is generated but not executed. - */ - public boolean isEnabled(); -} +/******************************************************************************* + * Copyright (c) 2006-2012 + * Software Technology Group, Dresden University of Technology + * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 + * + * All rights reserved. This program and the accompanying materials + * are 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 + * + * Contributors: + * Software Technology Group - TU Dresden, Germany; + * DevBoost GmbH - Berlin, Germany + * - initial API and implementation + ******************************************************************************/ +package de.devboost.buildboost.model; + +import de.devboost.buildboost.BuildException; +import de.devboost.buildboost.ant.AntScript; + +public interface IBuildStage { + + public AntScript getScript() throws BuildException; + + /** + * Build stages can be disabled which means that the code for the respective + * build is generated but not executed. + */ + public boolean isEnabled(); +} diff --git a/Core/de.devboost.buildboost/src/de/devboost/buildboost/model/IDependable.java b/Core/de.devboost.buildboost/src/de/devboost/buildboost/model/IDependable.java index 43da6b8..ee69d12 100644 --- a/Core/de.devboost.buildboost/src/de/devboost/buildboost/model/IDependable.java +++ b/Core/de.devboost.buildboost/src/de/devboost/buildboost/model/IDependable.java @@ -1,23 +1,23 @@ -/******************************************************************************* - * Copyright (c) 2006-2012 - * Software Technology Group, Dresden University of Technology - * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 - * - * All rights reserved. This program and the accompanying materials - * are 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 - * - * Contributors: - * Software Technology Group - TU Dresden, Germany; - * DevBoost GmbH - Berlin, Germany - * - initial API and implementation - ******************************************************************************/ -package de.devboost.buildboost.model; - -import java.util.Collection; - -public interface IDependable { - - public Collection getDependencies(); -} +/******************************************************************************* + * Copyright (c) 2006-2012 + * Software Technology Group, Dresden University of Technology + * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 + * + * All rights reserved. This program and the accompanying materials + * are 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 + * + * Contributors: + * Software Technology Group - TU Dresden, Germany; + * DevBoost GmbH - Berlin, Germany + * - initial API and implementation + ******************************************************************************/ +package de.devboost.buildboost.model; + +import java.util.Collection; + +public interface IDependable { + + public Collection getDependencies(); +} diff --git a/Core/de.devboost.buildboost/src/de/devboost/buildboost/model/IFileArtifact.java b/Core/de.devboost.buildboost/src/de/devboost/buildboost/model/IFileArtifact.java index dc95970..a155f22 100644 --- a/Core/de.devboost.buildboost/src/de/devboost/buildboost/model/IFileArtifact.java +++ b/Core/de.devboost.buildboost/src/de/devboost/buildboost/model/IFileArtifact.java @@ -1,26 +1,26 @@ -/******************************************************************************* - * Copyright (c) 2006-2012 - * Software Technology Group, Dresden University of Technology - * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 - * - * All rights reserved. This program and the accompanying materials - * are 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 - * - * Contributors: - * Software Technology Group - TU Dresden, Germany; - * DevBoost GmbH - Berlin, Germany - * - initial API and implementation - ******************************************************************************/ -package de.devboost.buildboost.model; - -import java.io.File; - -/** - * A IFileArtifact is an artifact that is contained in a file. - */ -public interface IFileArtifact extends IArtifact { - - public File getFile(); -} +/******************************************************************************* + * Copyright (c) 2006-2012 + * Software Technology Group, Dresden University of Technology + * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 + * + * All rights reserved. This program and the accompanying materials + * are 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 + * + * Contributors: + * Software Technology Group - TU Dresden, Germany; + * DevBoost GmbH - Berlin, Germany + * - initial API and implementation + ******************************************************************************/ +package de.devboost.buildboost.model; + +import java.io.File; + +/** + * A IFileArtifact is an artifact that is contained in a file. + */ +public interface IFileArtifact extends IArtifact { + + public File getFile(); +} diff --git a/Core/de.devboost.buildboost/src/de/devboost/buildboost/model/UnresolvedDependency.java b/Core/de.devboost.buildboost/src/de/devboost/buildboost/model/UnresolvedDependency.java index e1cd9b9..08b7e14 100644 --- a/Core/de.devboost.buildboost/src/de/devboost/buildboost/model/UnresolvedDependency.java +++ b/Core/de.devboost.buildboost/src/de/devboost/buildboost/model/UnresolvedDependency.java @@ -1,158 +1,158 @@ -/******************************************************************************* - * Copyright (c) 2006-2012 - * Software Technology Group, Dresden University of Technology - * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 - * - * All rights reserved. This program and the accompanying materials - * are 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 - * - * Contributors: - * Software Technology Group - TU Dresden, Germany; - * DevBoost GmbH - Berlin, Germany - * - initial API and implementation - ******************************************************************************/ -package de.devboost.buildboost.model; - -import java.io.Serializable; - -/** - * An UnresolvedDependency is a pair consisting of a symbolic artifact - * identifier and a version. UnresolvedDependency objects are used to represent - * dependencies between artifacts when the actual artifacts are not known yet. - * During the analysis process performed by BuildBoost, UnresolvedDependency - * objects are replaced by links to actual artifact objects. - */ -public class UnresolvedDependency implements Serializable { - - private static final long serialVersionUID = 7284232444651755786L; - - private Class type; - private String identifier; - private String minVersion; - private String maxVersion; - private boolean optional; - private boolean reexport; - private boolean inclusiveMin; - private boolean inclusiveMax; - - /** - * Creates a new unresolved dependency object of the given type having the - * given identifier. - * - * @param type the type of artifact the dependency refers to - * @param identifier the symbolic identifier of the referenced artifact - * @param minVersion the minimal version that is required - * @param inclusiveMin a flag indicating whether the minimal version is inclusive or not - * @param maxVersion the maximum version that is required - * @param inclusiveMax a flag indicating whether the maximum version is inclusive or not - * @param optional a flag indicating whether the dependency is optional - * @param reexport a flag indicating whether this dependency is re-exported - */ - public UnresolvedDependency(Class type, String identifier, String minVersion, boolean inclusiveMin, String maxVersion, boolean inclusiveMax, boolean optional, boolean reexport) { - super(); - this.type = type; - this.identifier = identifier; - this.minVersion = minVersion; - this.maxVersion = maxVersion; - this.optional = optional; - this.reexport = reexport; - this.inclusiveMin = inclusiveMin; - this.inclusiveMax = inclusiveMax; - } - - public String getIdentifier() { - return identifier; - } - - public String getMinVersion() { - return minVersion; - } - - public String getMaxVersion() { - return maxVersion; - } - - public boolean isOptional() { - return optional; - } - - public boolean isReexported() { - return reexport; - } - - public boolean isInclusiveMin() { - return inclusiveMin; - } - - public boolean isInclusiveMax() { - return inclusiveMax; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result - + ((identifier == null) ? 0 : identifier.hashCode()); - result = prime * result + ((minVersion == null) ? 0 : minVersion.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - UnresolvedDependency other = (UnresolvedDependency) obj; - if (type == null) { - if (other.type != null) - return false; - } - if (identifier == null) { - if (other.identifier != null) - return false; - } - if (!type.equals(other.type)) { - return false; - } - if (!identifier.equals(other.identifier)) { - return false; - } - if (minVersion == null) { - if (other.minVersion != null) - return false; - } else if (!minVersion.equals(other.minVersion)) - return false; - return true; - } - - /** - * Returns true if this dependency is fulfilled by the given artifact. - */ - public boolean isFulfilledBy(IArtifact artifact) { - // check type - if (!type.isInstance(artifact)) { - return false; - } - // check symbolic identifier - if (artifact.getIdentifier().equals(getIdentifier())) { - return true; - } - // TODO check versions for compatibility - return false; - } - - public void setOptional(boolean optional) { - this.optional = optional; - } - - @Override - public String toString() { - return type.getSimpleName() + " id=" + identifier + (minVersion == null ? "" : ", version=" + minVersion) + (optional ? ", optional" : "") + (reexport ? ", reexport" : ""); - } -} +/******************************************************************************* + * Copyright (c) 2006-2012 + * Software Technology Group, Dresden University of Technology + * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 + * + * All rights reserved. This program and the accompanying materials + * are 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 + * + * Contributors: + * Software Technology Group - TU Dresden, Germany; + * DevBoost GmbH - Berlin, Germany + * - initial API and implementation + ******************************************************************************/ +package de.devboost.buildboost.model; + +import java.io.Serializable; + +/** + * An UnresolvedDependency is a pair consisting of a symbolic artifact + * identifier and a version. UnresolvedDependency objects are used to represent + * dependencies between artifacts when the actual artifacts are not known yet. + * During the analysis process performed by BuildBoost, UnresolvedDependency + * objects are replaced by links to actual artifact objects. + */ +public class UnresolvedDependency implements Serializable { + + private static final long serialVersionUID = 7284232444651755786L; + + private Class type; + private String identifier; + private String minVersion; + private String maxVersion; + private boolean optional; + private boolean reexport; + private boolean inclusiveMin; + private boolean inclusiveMax; + + /** + * Creates a new unresolved dependency object of the given type having the + * given identifier. + * + * @param type the type of artifact the dependency refers to + * @param identifier the symbolic identifier of the referenced artifact + * @param minVersion the minimal version that is required + * @param inclusiveMin a flag indicating whether the minimal version is inclusive or not + * @param maxVersion the maximum version that is required + * @param inclusiveMax a flag indicating whether the maximum version is inclusive or not + * @param optional a flag indicating whether the dependency is optional + * @param reexport a flag indicating whether this dependency is re-exported + */ + public UnresolvedDependency(Class type, String identifier, String minVersion, boolean inclusiveMin, String maxVersion, boolean inclusiveMax, boolean optional, boolean reexport) { + super(); + this.type = type; + this.identifier = identifier; + this.minVersion = minVersion; + this.maxVersion = maxVersion; + this.optional = optional; + this.reexport = reexport; + this.inclusiveMin = inclusiveMin; + this.inclusiveMax = inclusiveMax; + } + + public String getIdentifier() { + return identifier; + } + + public String getMinVersion() { + return minVersion; + } + + public String getMaxVersion() { + return maxVersion; + } + + public boolean isOptional() { + return optional; + } + + public boolean isReexported() { + return reexport; + } + + public boolean isInclusiveMin() { + return inclusiveMin; + } + + public boolean isInclusiveMax() { + return inclusiveMax; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + + ((identifier == null) ? 0 : identifier.hashCode()); + result = prime * result + ((minVersion == null) ? 0 : minVersion.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + UnresolvedDependency other = (UnresolvedDependency) obj; + if (type == null) { + if (other.type != null) + return false; + } + if (identifier == null) { + if (other.identifier != null) + return false; + } + if (!type.equals(other.type)) { + return false; + } + if (!identifier.equals(other.identifier)) { + return false; + } + if (minVersion == null) { + if (other.minVersion != null) + return false; + } else if (!minVersion.equals(other.minVersion)) + return false; + return true; + } + + /** + * Returns true if this dependency is fulfilled by the given artifact. + */ + public boolean isFulfilledBy(IArtifact artifact) { + // check type + if (!type.isInstance(artifact)) { + return false; + } + // check symbolic identifier + if (artifact.getIdentifier().equals(getIdentifier())) { + return true; + } + // TODO check versions for compatibility + return false; + } + + public void setOptional(boolean optional) { + this.optional = optional; + } + + @Override + public String toString() { + return type.getSimpleName() + " id=" + identifier + (minVersion == null ? "" : ", version=" + minVersion) + (optional ? ", optional" : "") + (reexport ? ", reexport" : ""); + } +} diff --git a/Core/de.devboost.buildboost/src/de/devboost/buildboost/stages/AbstractBuildStage.java b/Core/de.devboost.buildboost/src/de/devboost/buildboost/stages/AbstractBuildStage.java index 42224f9..a8e30cf 100644 --- a/Core/de.devboost.buildboost/src/de/devboost/buildboost/stages/AbstractBuildStage.java +++ b/Core/de.devboost.buildboost/src/de/devboost/buildboost/stages/AbstractBuildStage.java @@ -1,61 +1,61 @@ -/******************************************************************************* - * Copyright (c) 2006-2012 - * Software Technology Group, Dresden University of Technology - * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 - * - * All rights reserved. This program and the accompanying materials - * are 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 - * - * Contributors: - * Software Technology Group - TU Dresden, Germany; - * DevBoost GmbH - Berlin, Germany - * - initial API and implementation - ******************************************************************************/ -package de.devboost.buildboost.stages; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; - -import de.devboost.buildboost.BuildContext; -import de.devboost.buildboost.model.IBuildParticipant; -import de.devboost.buildboost.model.IBuildStage; - -public abstract class AbstractBuildStage implements IBuildStage { - - private List participants = new ArrayList(); - private boolean enabled = true; - - public void addBuildParticipant(IBuildParticipant participant) { - participants.add(participant); - } - - public void addBuildParticipants(Collection participants) { - this.participants.addAll(participants); - } - - protected BuildContext createContext(boolean ignoreUnresolvedDependencies) { - BuildContext context = new BuildContext(); - context.setIgnoreUnresolvedDependencies(ignoreUnresolvedDependencies); - for (IBuildParticipant participant : participants) { - context.addBuildParticipant(participant); - } - return context; - } - - public void setEnabled(boolean enabled) { - this.enabled = enabled; - } - - @Override - public boolean isEnabled() { - return enabled; - } - - @Override - public String toString() { - return getClass().getSimpleName(); - } -} +/******************************************************************************* + * Copyright (c) 2006-2012 + * Software Technology Group, Dresden University of Technology + * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 + * + * All rights reserved. This program and the accompanying materials + * are 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 + * + * Contributors: + * Software Technology Group - TU Dresden, Germany; + * DevBoost GmbH - Berlin, Germany + * - initial API and implementation + ******************************************************************************/ +package de.devboost.buildboost.stages; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +import de.devboost.buildboost.BuildContext; +import de.devboost.buildboost.model.IBuildParticipant; +import de.devboost.buildboost.model.IBuildStage; + +public abstract class AbstractBuildStage implements IBuildStage { + + private List participants = new ArrayList(); + private boolean enabled = true; + + public void addBuildParticipant(IBuildParticipant participant) { + participants.add(participant); + } + + public void addBuildParticipants(Collection participants) { + this.participants.addAll(participants); + } + + protected BuildContext createContext(boolean ignoreUnresolvedDependencies) { + BuildContext context = new BuildContext(); + context.setIgnoreUnresolvedDependencies(ignoreUnresolvedDependencies); + for (IBuildParticipant participant : participants) { + context.addBuildParticipant(participant); + } + return context; + } + + public void setEnabled(boolean enabled) { + this.enabled = enabled; + } + + @Override + public boolean isEnabled() { + return enabled; + } + + @Override + public String toString() { + return getClass().getSimpleName(); + } +} diff --git a/Core/de.devboost.buildboost/src/de/devboost/buildboost/stages/CloneRepositoriesStage.java b/Core/de.devboost.buildboost/src/de/devboost/buildboost/stages/CloneRepositoriesStage.java index ff53447..01e651b 100644 --- a/Core/de.devboost.buildboost/src/de/devboost/buildboost/stages/CloneRepositoriesStage.java +++ b/Core/de.devboost.buildboost/src/de/devboost/buildboost/stages/CloneRepositoriesStage.java @@ -1,55 +1,55 @@ -/******************************************************************************* - * Copyright (c) 2006-2012 - * Software Technology Group, Dresden University of Technology - * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 - * - * All rights reserved. This program and the accompanying materials - * are 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 - * - * Contributors: - * Software Technology Group - TU Dresden, Germany; - * DevBoost GmbH - Berlin, Germany - * - initial API and implementation - ******************************************************************************/ -package de.devboost.buildboost.stages; - -import java.io.File; -import java.util.Collection; - -import de.devboost.buildboost.AutoBuilder; -import de.devboost.buildboost.BuildContext; -import de.devboost.buildboost.BuildException; -import de.devboost.buildboost.ant.AntScript; -import de.devboost.buildboost.ant.AntTarget; -import de.devboost.buildboost.discovery.RepositoriesFileFinder; -import de.devboost.buildboost.steps.clone.CloneRepositoriesBuildStepProvider; - -public class CloneRepositoriesStage extends AbstractBuildStage { - - private String reposFolder; - - public void setReposFolder(String reposFolder) { - this.reposFolder = reposFolder; - } - - public AntScript getScript() throws BuildException { - BuildContext context = createContext(true); - - context.addBuildParticipant( - new RepositoriesFileFinder(new File(reposFolder))); - context.addBuildParticipant( - new CloneRepositoriesBuildStepProvider(new File(reposFolder))); - - AutoBuilder builder = new AutoBuilder(context); - Collection targets = builder.generateAntTargets(); - - AntScript copyScript = new AntScript(); - copyScript.setName("Clone repositories stage"); - copyScript.addTargets(targets); - - return copyScript; - } - -} +/******************************************************************************* + * Copyright (c) 2006-2012 + * Software Technology Group, Dresden University of Technology + * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 + * + * All rights reserved. This program and the accompanying materials + * are 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 + * + * Contributors: + * Software Technology Group - TU Dresden, Germany; + * DevBoost GmbH - Berlin, Germany + * - initial API and implementation + ******************************************************************************/ +package de.devboost.buildboost.stages; + +import java.io.File; +import java.util.Collection; + +import de.devboost.buildboost.AutoBuilder; +import de.devboost.buildboost.BuildContext; +import de.devboost.buildboost.BuildException; +import de.devboost.buildboost.ant.AntScript; +import de.devboost.buildboost.ant.AntTarget; +import de.devboost.buildboost.discovery.RepositoriesFileFinder; +import de.devboost.buildboost.steps.clone.CloneRepositoriesBuildStepProvider; + +public class CloneRepositoriesStage extends AbstractBuildStage { + + private String reposFolder; + + public void setReposFolder(String reposFolder) { + this.reposFolder = reposFolder; + } + + public AntScript getScript() throws BuildException { + BuildContext context = createContext(true); + + context.addBuildParticipant( + new RepositoriesFileFinder(new File(reposFolder))); + context.addBuildParticipant( + new CloneRepositoriesBuildStepProvider(new File(reposFolder))); + + AutoBuilder builder = new AutoBuilder(context); + Collection targets = builder.generateAntTargets(); + + AntScript copyScript = new AntScript(); + copyScript.setName("Clone repositories stage"); + copyScript.addTargets(targets); + + return copyScript; + } + +} diff --git a/Core/de.devboost.buildboost/src/de/devboost/buildboost/stages/CompileStage.java b/Core/de.devboost.buildboost/src/de/devboost/buildboost/stages/CompileStage.java index 5c17359..f6774de 100644 --- a/Core/de.devboost.buildboost/src/de/devboost/buildboost/stages/CompileStage.java +++ b/Core/de.devboost.buildboost/src/de/devboost/buildboost/stages/CompileStage.java @@ -1,74 +1,74 @@ -/******************************************************************************* - * Copyright (c) 2006-2012 - * Software Technology Group, Dresden University of Technology - * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 - * - * All rights reserved. This program and the accompanying materials - * are 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 - * - * Contributors: - * Software Technology Group - TU Dresden, Germany; - * DevBoost GmbH - Berlin, Germany - * - initial API and implementation - ******************************************************************************/ -package de.devboost.buildboost.stages; - -import java.io.File; - -import de.devboost.buildboost.AutoBuilder; -import de.devboost.buildboost.BuildContext; -import de.devboost.buildboost.BuildException; -import de.devboost.buildboost.ant.AntScript; -import de.devboost.buildboost.discovery.EclipseTargetPlatformAnalyzer; -import de.devboost.buildboost.discovery.PluginFinder; -import de.devboost.buildboost.model.IUniversalBuildStage; -import de.devboost.buildboost.steps.compile.CompileProjectStepProvider; -import de.devboost.buildboost.steps.compile.JDKVersion; - -public class CompileStage extends AbstractBuildStage implements IUniversalBuildStage { - - private String artifactsFolder; - - private String sourceFileEncoding; - private JDKVersion jdkVersion; - - public void setArtifactsFolder(String artifactsFolder) { - this.artifactsFolder = artifactsFolder; - } - - public void setSourceFileEncoding(String sourceFileEncoding) { - this.sourceFileEncoding = sourceFileEncoding; - } - - public void setJdkVersion(JDKVersion jdkVersion) { - this.jdkVersion = jdkVersion; - } - - public AntScript getScript() throws BuildException { - // TODO check configuration - File buildDir = new File(artifactsFolder); - - BuildContext context = createContext(false); - File targetPlatform = new File(artifactsFolder); - context.addBuildParticipant(new EclipseTargetPlatformAnalyzer(targetPlatform)); - - context.addBuildParticipant(new PluginFinder(buildDir)); - - context.addBuildParticipant(new CompileProjectStepProvider(jdkVersion, sourceFileEncoding)); - - AutoBuilder builder = new AutoBuilder(context); - - AntScript script = new AntScript(); - script.setName("Compile all projects"); - script.addTargets(builder.generateAntTargets()); - - return script; - } - - @Override - public int getPriority() { - return 8000; - } -} +/******************************************************************************* + * Copyright (c) 2006-2012 + * Software Technology Group, Dresden University of Technology + * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 + * + * All rights reserved. This program and the accompanying materials + * are 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 + * + * Contributors: + * Software Technology Group - TU Dresden, Germany; + * DevBoost GmbH - Berlin, Germany + * - initial API and implementation + ******************************************************************************/ +package de.devboost.buildboost.stages; + +import java.io.File; + +import de.devboost.buildboost.AutoBuilder; +import de.devboost.buildboost.BuildContext; +import de.devboost.buildboost.BuildException; +import de.devboost.buildboost.ant.AntScript; +import de.devboost.buildboost.discovery.EclipseTargetPlatformAnalyzer; +import de.devboost.buildboost.discovery.PluginFinder; +import de.devboost.buildboost.model.IUniversalBuildStage; +import de.devboost.buildboost.steps.compile.CompileProjectStepProvider; +import de.devboost.buildboost.steps.compile.JDKVersion; + +public class CompileStage extends AbstractBuildStage implements IUniversalBuildStage { + + private String artifactsFolder; + + private String sourceFileEncoding; + private JDKVersion jdkVersion; + + public void setArtifactsFolder(String artifactsFolder) { + this.artifactsFolder = artifactsFolder; + } + + public void setSourceFileEncoding(String sourceFileEncoding) { + this.sourceFileEncoding = sourceFileEncoding; + } + + public void setJdkVersion(JDKVersion jdkVersion) { + this.jdkVersion = jdkVersion; + } + + public AntScript getScript() throws BuildException { + // TODO check configuration + File buildDir = new File(artifactsFolder); + + BuildContext context = createContext(false); + File targetPlatform = new File(artifactsFolder); + context.addBuildParticipant(new EclipseTargetPlatformAnalyzer(targetPlatform)); + + context.addBuildParticipant(new PluginFinder(buildDir)); + + context.addBuildParticipant(new CompileProjectStepProvider(jdkVersion, sourceFileEncoding)); + + AutoBuilder builder = new AutoBuilder(context); + + AntScript script = new AntScript(); + script.setName("Compile all projects"); + script.addTargets(builder.generateAntTargets()); + + return script; + } + + @Override + public int getPriority() { + return 8000; + } +} diff --git a/Core/de.devboost.buildboost/src/de/devboost/buildboost/stages/CopyProjectsStage.java b/Core/de.devboost.buildboost/src/de/devboost/buildboost/stages/CopyProjectsStage.java index e70a5b5..b77e70b 100644 --- a/Core/de.devboost.buildboost/src/de/devboost/buildboost/stages/CopyProjectsStage.java +++ b/Core/de.devboost.buildboost/src/de/devboost/buildboost/stages/CopyProjectsStage.java @@ -1,72 +1,72 @@ -/******************************************************************************* - * Copyright (c) 2006-2012 - * Software Technology Group, Dresden University of Technology - * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 - * - * All rights reserved. This program and the accompanying materials - * are 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 - * - * Contributors: - * Software Technology Group - TU Dresden, Germany; - * DevBoost GmbH - Berlin, Germany - * - initial API and implementation - ******************************************************************************/ -package de.devboost.buildboost.stages; - -import java.io.File; -import java.util.Collection; - -import de.devboost.buildboost.AutoBuilder; -import de.devboost.buildboost.BuildContext; -import de.devboost.buildboost.BuildException; -import de.devboost.buildboost.ant.AntScript; -import de.devboost.buildboost.ant.AntTarget; -import de.devboost.buildboost.discovery.EclipseTargetPlatformAnalyzer; -import de.devboost.buildboost.discovery.PluginFinder; -import de.devboost.buildboost.discovery.TargetPlatformZipFinder; -import de.devboost.buildboost.model.IUniversalBuildStage; -import de.devboost.buildboost.steps.copy.CopyPluginsAndFeaturesBuildStepProvider; -import de.devboost.buildboost.steps.copy.CopyProjectsBuildStepProvider; -import de.devboost.buildboost.steps.copy.ExtractZipFileBuildStepProvider; - -public class CopyProjectsStage extends AbstractBuildStage implements IUniversalBuildStage { - - private String reposFolder; - private String artifactsFolder; - - public void setReposFolder(String reposFolder) { - this.reposFolder = reposFolder; - } - - public void setArtifactsFolder(String artifactsFolder) { - this.artifactsFolder = artifactsFolder; - } - - public AntScript getScript() throws BuildException { - BuildContext context = createContext(true); - context.addBuildParticipant(new PluginFinder(new File(reposFolder))); - context.addBuildParticipant(new CopyProjectsBuildStepProvider(new File(artifactsFolder))); - - context.addBuildParticipant(new EclipseTargetPlatformAnalyzer(new File(reposFolder))); - context.addBuildParticipant(new CopyPluginsAndFeaturesBuildStepProvider(new File(artifactsFolder))); - context.addBuildParticipant(new TargetPlatformZipFinder(new File(reposFolder))); - context.addBuildParticipant(new ExtractZipFileBuildStepProvider(new File(artifactsFolder))); - - context.setIgnoreUnresolvedDependencies(true); - AutoBuilder builder = new AutoBuilder(context); - Collection targets = builder.generateAntTargets(); - - AntScript copyScript = new AntScript(); - copyScript.setName("Copy plug-in stage"); - copyScript.addTargets(targets); - - return copyScript; - } - - @Override - public int getPriority() { - return 0; - } -} +/******************************************************************************* + * Copyright (c) 2006-2012 + * Software Technology Group, Dresden University of Technology + * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 + * + * All rights reserved. This program and the accompanying materials + * are 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 + * + * Contributors: + * Software Technology Group - TU Dresden, Germany; + * DevBoost GmbH - Berlin, Germany + * - initial API and implementation + ******************************************************************************/ +package de.devboost.buildboost.stages; + +import java.io.File; +import java.util.Collection; + +import de.devboost.buildboost.AutoBuilder; +import de.devboost.buildboost.BuildContext; +import de.devboost.buildboost.BuildException; +import de.devboost.buildboost.ant.AntScript; +import de.devboost.buildboost.ant.AntTarget; +import de.devboost.buildboost.discovery.EclipseTargetPlatformAnalyzer; +import de.devboost.buildboost.discovery.PluginFinder; +import de.devboost.buildboost.discovery.TargetPlatformZipFinder; +import de.devboost.buildboost.model.IUniversalBuildStage; +import de.devboost.buildboost.steps.copy.CopyPluginsAndFeaturesBuildStepProvider; +import de.devboost.buildboost.steps.copy.CopyProjectsBuildStepProvider; +import de.devboost.buildboost.steps.copy.ExtractZipFileBuildStepProvider; + +public class CopyProjectsStage extends AbstractBuildStage implements IUniversalBuildStage { + + private String reposFolder; + private String artifactsFolder; + + public void setReposFolder(String reposFolder) { + this.reposFolder = reposFolder; + } + + public void setArtifactsFolder(String artifactsFolder) { + this.artifactsFolder = artifactsFolder; + } + + public AntScript getScript() throws BuildException { + BuildContext context = createContext(true); + context.addBuildParticipant(new PluginFinder(new File(reposFolder))); + context.addBuildParticipant(new CopyProjectsBuildStepProvider(new File(artifactsFolder))); + + context.addBuildParticipant(new EclipseTargetPlatformAnalyzer(new File(reposFolder))); + context.addBuildParticipant(new CopyPluginsAndFeaturesBuildStepProvider(new File(artifactsFolder))); + context.addBuildParticipant(new TargetPlatformZipFinder(new File(reposFolder))); + context.addBuildParticipant(new ExtractZipFileBuildStepProvider(new File(artifactsFolder))); + + context.setIgnoreUnresolvedDependencies(true); + AutoBuilder builder = new AutoBuilder(context); + Collection targets = builder.generateAntTargets(); + + AntScript copyScript = new AntScript(); + copyScript.setName("Copy plug-in stage"); + copyScript.addTargets(targets); + + return copyScript; + } + + @Override + public int getPriority() { + return 0; + } +} diff --git a/Core/de.devboost.buildboost/src/de/devboost/buildboost/stages/ExtractPluginsStage.java b/Core/de.devboost.buildboost/src/de/devboost/buildboost/stages/ExtractPluginsStage.java index 6243d90..4ddb3d0 100644 --- a/Core/de.devboost.buildboost/src/de/devboost/buildboost/stages/ExtractPluginsStage.java +++ b/Core/de.devboost.buildboost/src/de/devboost/buildboost/stages/ExtractPluginsStage.java @@ -1,59 +1,59 @@ -/******************************************************************************* - * Copyright (c) 2006-2012 - * Software Technology Group, Dresden University of Technology - * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 - * - * All rights reserved. This program and the accompanying materials - * are 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 - * - * Contributors: - * Software Technology Group - TU Dresden, Germany; - * DevBoost GmbH - Berlin, Germany - * - initial API and implementation - ******************************************************************************/ -package de.devboost.buildboost.stages; - -import java.io.File; - -import de.devboost.buildboost.AutoBuilder; -import de.devboost.buildboost.BuildContext; -import de.devboost.buildboost.BuildException; -import de.devboost.buildboost.ant.AntScript; -import de.devboost.buildboost.discovery.EclipseTargetPlatformAnalyzer; -import de.devboost.buildboost.model.IUniversalBuildStage; -import de.devboost.buildboost.steps.compile.ExtractPluginZipStepProvider; - -public class ExtractPluginsStage extends AbstractBuildStage implements IUniversalBuildStage { - - private String artifactsFolder; - - public void setArtifactsFolder(String artifactsFolder) { - this.artifactsFolder = artifactsFolder; - } - - public AntScript getScript() throws BuildException { - File buildDir = new File(artifactsFolder); - BuildContext context = createContext(false); - File targetPlatform = new File(artifactsFolder); - context.addBuildParticipant(new EclipseTargetPlatformAnalyzer(targetPlatform)); - context.addBuildParticipant(new ExtractPluginZipStepProvider(new File( - buildDir, EclipseTargetPlatformAnalyzer.ARTIFACT_CACHE_FILE_NAME))); - - context.setIgnoreUnresolvedDependencies(true); - - AutoBuilder builder = new AutoBuilder(context); - - AntScript script = new AntScript(); - script.setName("Extract plugins with libs"); - script.addTargets(builder.generateAntTargets()); - - return script; - } - - @Override - public int getPriority() { - return 20; - } -} +/******************************************************************************* + * Copyright (c) 2006-2012 + * Software Technology Group, Dresden University of Technology + * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 + * + * All rights reserved. This program and the accompanying materials + * are 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 + * + * Contributors: + * Software Technology Group - TU Dresden, Germany; + * DevBoost GmbH - Berlin, Germany + * - initial API and implementation + ******************************************************************************/ +package de.devboost.buildboost.stages; + +import java.io.File; + +import de.devboost.buildboost.AutoBuilder; +import de.devboost.buildboost.BuildContext; +import de.devboost.buildboost.BuildException; +import de.devboost.buildboost.ant.AntScript; +import de.devboost.buildboost.discovery.EclipseTargetPlatformAnalyzer; +import de.devboost.buildboost.model.IUniversalBuildStage; +import de.devboost.buildboost.steps.compile.ExtractPluginZipStepProvider; + +public class ExtractPluginsStage extends AbstractBuildStage implements IUniversalBuildStage { + + private String artifactsFolder; + + public void setArtifactsFolder(String artifactsFolder) { + this.artifactsFolder = artifactsFolder; + } + + public AntScript getScript() throws BuildException { + File buildDir = new File(artifactsFolder); + BuildContext context = createContext(false); + File targetPlatform = new File(artifactsFolder); + context.addBuildParticipant(new EclipseTargetPlatformAnalyzer(targetPlatform)); + context.addBuildParticipant(new ExtractPluginZipStepProvider(new File( + buildDir, EclipseTargetPlatformAnalyzer.ARTIFACT_CACHE_FILE_NAME))); + + context.setIgnoreUnresolvedDependencies(true); + + AutoBuilder builder = new AutoBuilder(context); + + AntScript script = new AntScript(); + script.setName("Extract plugins with libs"); + script.addTargets(builder.generateAntTargets()); + + return script; + } + + @Override + public int getPriority() { + return 20; + } +} diff --git a/Core/de.devboost.buildboost/src/de/devboost/buildboost/stages/WrapAntScriptStage.java b/Core/de.devboost.buildboost/src/de/devboost/buildboost/stages/WrapAntScriptStage.java index e6d6e5b..33a315b 100644 --- a/Core/de.devboost.buildboost/src/de/devboost/buildboost/stages/WrapAntScriptStage.java +++ b/Core/de.devboost.buildboost/src/de/devboost/buildboost/stages/WrapAntScriptStage.java @@ -1,70 +1,70 @@ -/******************************************************************************* - * Copyright (c) 2006-2012 - * Software Technology Group, Dresden University of Technology - * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 - * - * All rights reserved. This program and the accompanying materials - * are 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 - * - * Contributors: - * Software Technology Group - TU Dresden, Germany; - * DevBoost GmbH - Berlin, Germany - * - initial API and implementation - ******************************************************************************/ -package de.devboost.buildboost.stages; - -import java.io.File; - -import de.devboost.buildboost.BuildException; -import de.devboost.buildboost.ant.AntScript; -import de.devboost.buildboost.ant.AntTarget; -import de.devboost.buildboost.util.XMLContent; - -/** - * The {@link WrapAntScriptStage} can be used to integrate existing Ant scripts - * into a build process. The stage produces a Ant target that calls the given - * Ant script. - */ -public class WrapAntScriptStage extends AbstractBuildStage { - - private File directory; - private File antFile; - private String target; - - /** - * Create a new {@link WrapAntScriptStage}. - * - * @param directory the working directory for the Ant script - * @param antFile the script to call (using absolute files is recommended - * here, because this parameter is independent of the 'directory' - * parameter) - */ - public WrapAntScriptStage(File directory, File antFile) { - this(directory, antFile, null); - } - - public WrapAntScriptStage(File directory, File antFile, String target) { - super(); - this.directory = directory; - this.antFile = antFile; - this.target = target; - } - - @Override - public AntScript getScript() throws BuildException { - XMLContent content = new XMLContent(); - String targetAttribute = ""; - if (this.target != null) { - targetAttribute = " target=\"" + this.target + "\""; - } - content.append(""); - - AntScript script = new AntScript(); - AntTarget target = new AntTarget("execute-ant-script", content); - script.addTarget(target); - return script; - } - -} +/******************************************************************************* + * Copyright (c) 2006-2012 + * Software Technology Group, Dresden University of Technology + * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 + * + * All rights reserved. This program and the accompanying materials + * are 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 + * + * Contributors: + * Software Technology Group - TU Dresden, Germany; + * DevBoost GmbH - Berlin, Germany + * - initial API and implementation + ******************************************************************************/ +package de.devboost.buildboost.stages; + +import java.io.File; + +import de.devboost.buildboost.BuildException; +import de.devboost.buildboost.ant.AntScript; +import de.devboost.buildboost.ant.AntTarget; +import de.devboost.buildboost.util.XMLContent; + +/** + * The {@link WrapAntScriptStage} can be used to integrate existing Ant scripts + * into a build process. The stage produces a Ant target that calls the given + * Ant script. + */ +public class WrapAntScriptStage extends AbstractBuildStage { + + private File directory; + private File antFile; + private String target; + + /** + * Create a new {@link WrapAntScriptStage}. + * + * @param directory the working directory for the Ant script + * @param antFile the script to call (using absolute files is recommended + * here, because this parameter is independent of the 'directory' + * parameter) + */ + public WrapAntScriptStage(File directory, File antFile) { + this(directory, antFile, null); + } + + public WrapAntScriptStage(File directory, File antFile, String target) { + super(); + this.directory = directory; + this.antFile = antFile; + this.target = target; + } + + @Override + public AntScript getScript() throws BuildException { + XMLContent content = new XMLContent(); + String targetAttribute = ""; + if (this.target != null) { + targetAttribute = " target=\"" + this.target + "\""; + } + content.append(""); + + AntScript script = new AntScript(); + AntTarget target = new AntTarget("execute-ant-script", content); + script.addTarget(target); + return script; + } + +} diff --git a/Core/de.devboost.buildboost/src/de/devboost/buildboost/stages/WrapCommandlineScriptStage.java b/Core/de.devboost.buildboost/src/de/devboost/buildboost/stages/WrapCommandlineScriptStage.java index a58711b..5601707 100644 --- a/Core/de.devboost.buildboost/src/de/devboost/buildboost/stages/WrapCommandlineScriptStage.java +++ b/Core/de.devboost.buildboost/src/de/devboost/buildboost/stages/WrapCommandlineScriptStage.java @@ -1,59 +1,59 @@ -/******************************************************************************* - * Copyright (c) 2006-2012 - * Software Technology Group, Dresden University of Technology - * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 - * - * All rights reserved. This program and the accompanying materials - * are 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 - * - * Contributors: - * Software Technology Group - TU Dresden, Germany; - * DevBoost GmbH - Berlin, Germany - * - initial API and implementation - ******************************************************************************/ -package de.devboost.buildboost.stages; - -import java.io.File; - -import de.devboost.buildboost.BuildException; -import de.devboost.buildboost.ant.AntScript; -import de.devboost.buildboost.ant.AntTarget; -import de.devboost.buildboost.util.XMLContent; - -/** - * The {@link WrapCommandlineScriptStage} can be used to integrate existing - * command line script into a build process. The stage produces a Ant target - * that calls the given script. - */ -public class WrapCommandlineScriptStage extends AbstractBuildStage { - - private File workingDir; - private String executable; - - /** - * Creates a new {@link WrapCommandlineScriptStage}. - * - * @param workingDir the working directory for the command line script - * @param executable the path to the executable (using absolute paths is - * recommended here, because this parameter is independent of the - * 'workingDir' parameter) - */ - public WrapCommandlineScriptStage(File workingDir, String executable) { - super(); - this.workingDir = workingDir; - this.executable = executable; - } - - @Override - public AntScript getScript() throws BuildException { - XMLContent content = new XMLContent(); - content.append(""); - - AntScript script = new AntScript(); - AntTarget target = new AntTarget("execute-cmd-line-script", content); - script.addTarget(target); - return script; - } -} +/******************************************************************************* + * Copyright (c) 2006-2012 + * Software Technology Group, Dresden University of Technology + * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 + * + * All rights reserved. This program and the accompanying materials + * are 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 + * + * Contributors: + * Software Technology Group - TU Dresden, Germany; + * DevBoost GmbH - Berlin, Germany + * - initial API and implementation + ******************************************************************************/ +package de.devboost.buildboost.stages; + +import java.io.File; + +import de.devboost.buildboost.BuildException; +import de.devboost.buildboost.ant.AntScript; +import de.devboost.buildboost.ant.AntTarget; +import de.devboost.buildboost.util.XMLContent; + +/** + * The {@link WrapCommandlineScriptStage} can be used to integrate existing + * command line script into a build process. The stage produces a Ant target + * that calls the given script. + */ +public class WrapCommandlineScriptStage extends AbstractBuildStage { + + private File workingDir; + private String executable; + + /** + * Creates a new {@link WrapCommandlineScriptStage}. + * + * @param workingDir the working directory for the command line script + * @param executable the path to the executable (using absolute paths is + * recommended here, because this parameter is independent of the + * 'workingDir' parameter) + */ + public WrapCommandlineScriptStage(File workingDir, String executable) { + super(); + this.workingDir = workingDir; + this.executable = executable; + } + + @Override + public AntScript getScript() throws BuildException { + XMLContent content = new XMLContent(); + content.append(""); + + AntScript script = new AntScript(); + AntTarget target = new AntTarget("execute-cmd-line-script", content); + script.addTarget(target); + return script; + } +} diff --git a/Core/de.devboost.buildboost/src/de/devboost/buildboost/steps/ClasspathHelper.java b/Core/de.devboost.buildboost/src/de/devboost/buildboost/steps/ClasspathHelper.java index 72e559f..9811a87 100644 --- a/Core/de.devboost.buildboost/src/de/devboost/buildboost/steps/ClasspathHelper.java +++ b/Core/de.devboost.buildboost/src/de/devboost/buildboost/steps/ClasspathHelper.java @@ -1,102 +1,102 @@ -/******************************************************************************* - * Copyright (c) 2006-2012 - * Software Technology Group, Dresden University of Technology - * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 - * - * All rights reserved. This program and the accompanying materials - * are 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 - * - * Contributors: - * Software Technology Group - TU Dresden, Germany; - * DevBoost GmbH - Berlin, Germany - * - initial API and implementation - ******************************************************************************/ -package de.devboost.buildboost.steps; - -import java.util.Collection; -import java.util.LinkedHashSet; -import java.util.Set; - -import de.devboost.buildboost.IConstants; -import de.devboost.buildboost.artifacts.Plugin; -import de.devboost.buildboost.model.IDependable; -import de.devboost.buildboost.util.XMLContent; - -public class ClasspathHelper { - - private String prefix; - private String suffix; - - public ClasspathHelper() { - this(""); - } - - public ClasspathHelper(String prefix, String suffix) { - this.prefix = prefix; - this.suffix = suffix; - } - - public XMLContent getClasspath(IDependable artifact, boolean includeSelf) { - XMLContent result; - if (artifact instanceof Plugin) { - Plugin plugin = (Plugin) artifact; - result = getClasspath(plugin, includeSelf); - } else { - result = new XMLContent(); - Collection dependencies = artifact.getDependencies(); - for (IDependable dependency : dependencies) { - result.append(getClasspath(dependency, includeSelf)); - } - } - XMLContent normalizedClassPath = removeDuplicateEntries(result); - return normalizedClassPath; - } - - // TODO move this to the XMLContent class - private XMLContent removeDuplicateEntries(XMLContent result) { - // remove duplicate entries - String content = result.toString(); - String[] lines = content.split(IConstants.NL); - Set uniqueLines = new LinkedHashSet(); - for (String line : lines) { - uniqueLines.add(line); - } - XMLContent normalizedClassPath = new XMLContent(); - for (String uniqueLine : uniqueLines) { - normalizedClassPath.append(uniqueLine); - } - return normalizedClassPath; - } - - public XMLContent getClasspath(Plugin plugin, boolean includePlugin) { - XMLContent classpath = new XMLContent(); - if (includePlugin) { - classpath.append(getPluginClassPath(plugin)); - } - // add libraries - for (String lib : plugin.getAllLibPaths()) { - classpath.append(prefix + lib + suffix); - } - - for (Plugin dependency : plugin.getAllDependencies()) { - classpath.append(getPluginClassPath(dependency)); - } - return classpath; - } - - private XMLContent getPluginClassPath(Plugin plugin) { - XMLContent classpath = new XMLContent(); - classpath.append(prefix + plugin.getAbsolutePath() + suffix); - return classpath; - } - - public String getBinPath(Plugin project) { - return project.getFile().getAbsolutePath(); - } -} +/******************************************************************************* + * Copyright (c) 2006-2012 + * Software Technology Group, Dresden University of Technology + * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 + * + * All rights reserved. This program and the accompanying materials + * are 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 + * + * Contributors: + * Software Technology Group - TU Dresden, Germany; + * DevBoost GmbH - Berlin, Germany + * - initial API and implementation + ******************************************************************************/ +package de.devboost.buildboost.steps; + +import java.util.Collection; +import java.util.LinkedHashSet; +import java.util.Set; + +import de.devboost.buildboost.IConstants; +import de.devboost.buildboost.artifacts.Plugin; +import de.devboost.buildboost.model.IDependable; +import de.devboost.buildboost.util.XMLContent; + +public class ClasspathHelper { + + private String prefix; + private String suffix; + + public ClasspathHelper() { + this(""); + } + + public ClasspathHelper(String prefix, String suffix) { + this.prefix = prefix; + this.suffix = suffix; + } + + public XMLContent getClasspath(IDependable artifact, boolean includeSelf) { + XMLContent result; + if (artifact instanceof Plugin) { + Plugin plugin = (Plugin) artifact; + result = getClasspath(plugin, includeSelf); + } else { + result = new XMLContent(); + Collection dependencies = artifact.getDependencies(); + for (IDependable dependency : dependencies) { + result.append(getClasspath(dependency, includeSelf)); + } + } + XMLContent normalizedClassPath = removeDuplicateEntries(result); + return normalizedClassPath; + } + + // TODO move this to the XMLContent class + private XMLContent removeDuplicateEntries(XMLContent result) { + // remove duplicate entries + String content = result.toString(); + String[] lines = content.split(IConstants.NL); + Set uniqueLines = new LinkedHashSet(); + for (String line : lines) { + uniqueLines.add(line); + } + XMLContent normalizedClassPath = new XMLContent(); + for (String uniqueLine : uniqueLines) { + normalizedClassPath.append(uniqueLine); + } + return normalizedClassPath; + } + + public XMLContent getClasspath(Plugin plugin, boolean includePlugin) { + XMLContent classpath = new XMLContent(); + if (includePlugin) { + classpath.append(getPluginClassPath(plugin)); + } + // add libraries + for (String lib : plugin.getAllLibPaths()) { + classpath.append(prefix + lib + suffix); + } + + for (Plugin dependency : plugin.getAllDependencies()) { + classpath.append(getPluginClassPath(dependency)); + } + return classpath; + } + + private XMLContent getPluginClassPath(Plugin plugin) { + XMLContent classpath = new XMLContent(); + classpath.append(prefix + plugin.getAbsolutePath() + suffix); + return classpath; + } + + public String getBinPath(Plugin project) { + return project.getFile().getAbsolutePath(); + } +} diff --git a/Core/de.devboost.buildboost/src/de/devboost/buildboost/steps/SystemOutStepProvider.java b/Core/de.devboost.buildboost/src/de/devboost/buildboost/steps/SystemOutStepProvider.java index 5694593..8d07bb6 100644 --- a/Core/de.devboost.buildboost/src/de/devboost/buildboost/steps/SystemOutStepProvider.java +++ b/Core/de.devboost.buildboost/src/de/devboost/buildboost/steps/SystemOutStepProvider.java @@ -1,47 +1,47 @@ -/******************************************************************************* - * Copyright (c) 2006-2012 - * Software Technology Group, Dresden University of Technology - * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 - * - * All rights reserved. This program and the accompanying materials - * are 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 - * - * Contributors: - * Software Technology Group - TU Dresden, Germany; - * DevBoost GmbH - Berlin, Germany - * - initial API and implementation - ******************************************************************************/ -package de.devboost.buildboost.steps; - -import java.util.Collection; -import java.util.Collections; -import java.util.List; - -import de.devboost.buildboost.ant.AbstractAntTargetGenerator; -import de.devboost.buildboost.ant.AbstractAntTargetGeneratorProvider; -import de.devboost.buildboost.ant.AntTarget; -import de.devboost.buildboost.ant.IAntTargetGenerator; -import de.devboost.buildboost.model.IArtifact; -import de.devboost.buildboost.model.IBuildContext; -import de.devboost.buildboost.util.XMLContent; - -/** - * The {@link SystemOutStepProvider} generates a script the prints all artifacts - * to the console. - */ -public class SystemOutStepProvider extends AbstractAntTargetGeneratorProvider { - - public List getAntTargetGenerators(IBuildContext context, final IArtifact artifact) { - IAntTargetGenerator step = new AbstractAntTargetGenerator() { - - public Collection generateAntTargets() { - XMLContent content = new XMLContent(); - content.append(""); - return Collections.singleton(new AntTarget("output", content)); - } - }; - return Collections.singletonList(step); - } -} +/******************************************************************************* + * Copyright (c) 2006-2012 + * Software Technology Group, Dresden University of Technology + * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 + * + * All rights reserved. This program and the accompanying materials + * are 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 + * + * Contributors: + * Software Technology Group - TU Dresden, Germany; + * DevBoost GmbH - Berlin, Germany + * - initial API and implementation + ******************************************************************************/ +package de.devboost.buildboost.steps; + +import java.util.Collection; +import java.util.Collections; +import java.util.List; + +import de.devboost.buildboost.ant.AbstractAntTargetGenerator; +import de.devboost.buildboost.ant.AbstractAntTargetGeneratorProvider; +import de.devboost.buildboost.ant.AntTarget; +import de.devboost.buildboost.ant.IAntTargetGenerator; +import de.devboost.buildboost.model.IArtifact; +import de.devboost.buildboost.model.IBuildContext; +import de.devboost.buildboost.util.XMLContent; + +/** + * The {@link SystemOutStepProvider} generates a script the prints all artifacts + * to the console. + */ +public class SystemOutStepProvider extends AbstractAntTargetGeneratorProvider { + + public List getAntTargetGenerators(IBuildContext context, final IArtifact artifact) { + IAntTargetGenerator step = new AbstractAntTargetGenerator() { + + public Collection generateAntTargets() { + XMLContent content = new XMLContent(); + content.append(""); + return Collections.singleton(new AntTarget("output", content)); + } + }; + return Collections.singletonList(step); + } +} diff --git a/Core/de.devboost.buildboost/src/de/devboost/buildboost/steps/clone/CloneRepositoriesBuildStep.java b/Core/de.devboost.buildboost/src/de/devboost/buildboost/steps/clone/CloneRepositoriesBuildStep.java index 571c823..5fe002d 100644 --- a/Core/de.devboost.buildboost/src/de/devboost/buildboost/steps/clone/CloneRepositoriesBuildStep.java +++ b/Core/de.devboost.buildboost/src/de/devboost/buildboost/steps/clone/CloneRepositoriesBuildStep.java @@ -1,198 +1,249 @@ -/******************************************************************************* - * Copyright (c) 2006-2012 - * Software Technology Group, Dresden University of Technology - * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 - * - * All rights reserved. This program and the accompanying materials - * are 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 - * - * Contributors: - * Software Technology Group - TU Dresden, Germany; - * DevBoost GmbH - Berlin, Germany - * - initial API and implementation - ******************************************************************************/ -package de.devboost.buildboost.steps.clone; - -import java.io.File; -import java.util.ArrayList; -import java.util.Collection; - -import de.devboost.buildboost.ant.AbstractAntTargetGenerator; -import de.devboost.buildboost.ant.AntTarget; -import de.devboost.buildboost.artifacts.RepositoriesFile.Location; -import de.devboost.buildboost.util.AntScriptUtil; -import de.devboost.buildboost.util.XMLContent; - - -public class CloneRepositoriesBuildStep extends AbstractAntTargetGenerator { - - private File reposFolder; - private Collection locations; - - public CloneRepositoriesBuildStep(File reposFolder, Collection locations) { - super(); - this.reposFolder = reposFolder; - this.locations = locations; - } - - public Collection generateAntTargets() { - Collection result = new ArrayList(); - result.add(writeRepositoryList()); - - for (Location location : locations) { - String locationURL = location.getUrl(); - String localRepositoryFolderName = url2FolderName(locationURL); - - String rootName = url2FolderName(locationURL.substring(locationURL.lastIndexOf("/") + 1)); - - File localRepo = new File(new File(reposFolder, localRepositoryFolderName), rootName); - - XMLContent content = new XMLContent(); - - content.append(""); - content.append(""); - content.append(""); - content.append(""); - content.append(""); - content.append(""); - content.append(""); - content.append(""); - - boolean isGit = location.getType().equals("git"); - boolean isSVN = location.getType().equals("svn"); - - String localRepositoryPath = getLocalRepositoryPath(location); - - if (isGit) { - if (localRepo.exists()) { - content.append(""); - content.append(""); - content.append(""); - } else { - content.append(""); - content.append(""); - content.append(""); - content.append(""); - content.append(""); - content.append(""); - content.append(""); - } - if (!location.getSubDirectories().isEmpty()) { - //enable sparse checkout - content.append(""); - content.append(""); - content.append(""); - content.append(""); - content.append(""); - String dirList = ".gitignore${line.separator}"; - for (String subDir : location.getSubDirectories()) { - dirList += subDir; - dirList += "${line.separator}"; - } - content.append(""); - content.append(""); - content.append(""); - content.append(""); - content.append(""); - content.append(""); - } - } else if (isSVN) { - if (localRepo.exists()) { - // execute update - content.append(""); - content.append(""); - content.append(""); - } else { - // execute checkout - content.append(""); - content.append(""); - content.append(""); - content.append(""); - content.append(""); - } - } else /* isGet */ { - if (!localRepo.exists()) { - content.append(""); - if (!location.getSubDirectories().isEmpty()) { - if (localRepo.getName().endsWith(".zip")) { - String zipFilePath = new File(localRepo, rootName).getAbsolutePath() ; - content.append(""); - content.append(""); - content.append(""); - for (String zipEntry : location.getSubDirectories()) { - content.append(""); - } - content.append(""); - content.append(""); - content.append(""); - } else /* folder */ { - for (String subPath : location.getSubDirectories()) { - content.append(""); - } - } - } else { - AntScriptUtil.addDownloadFileScript(content, locationURL, localRepositoryPath); - } - } - } - result.add(new AntTarget("update-" + localRepositoryFolderName, content)); - } - return result; - } - - private AntTarget writeRepositoryList() { - XMLContent content = new XMLContent(); - String revisionFile = new File(reposFolder, "buildboost_repository_list.txt").getAbsolutePath(); - content.append(""); - content.append(""); - for (Location location : locations) { - boolean isGit = location.getType().equals("git"); - boolean isSVN = location.getType().equals("svn"); - - String locationURL = location.getUrl(); - - String localRepositoryPath = getLocalRepositoryPath(location); - - if (isSVN || isGit) { - content.append(""); - content.append(""); - content.append(""); - content.append(""); - content.append(""); - content.append(""); - } - } - - return new AntTarget("write-repository-list", content); - } - - protected String getLocalRepositoryPath(Location location) { - String locationURL = location.getUrl(); - String localRepositoryFolderName = url2FolderName(locationURL); - String rootName = url2FolderName(locationURL.substring(locationURL.lastIndexOf("/") + 1)); - return new File(new File(reposFolder, localRepositoryFolderName), rootName).getAbsolutePath(); - } - - protected String url2FolderName(String url) { - int idx; - String folderName = url; - //cut leading protocol - idx = folderName.indexOf("//"); - if (idx != -1) { - folderName = folderName.substring(idx + 2); - } - //cut arguments - idx = folderName.indexOf("?"); - if (idx != -1) { - folderName = folderName.substring(0, idx); - } - folderName = folderName.replace(":", ""); - folderName = folderName.replace("~", "_"); - folderName = folderName.replace("/", "_"); - folderName = folderName.replace("\\", "_"); - folderName = folderName.replace(" ", "-"); - return folderName; - } -} +/******************************************************************************* + * Copyright (c) 2006-2012 + * Software Technology Group, Dresden University of Technology + * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 + * + * All rights reserved. This program and the accompanying materials + * are 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 + * + * Contributors: + * Software Technology Group - TU Dresden, Germany; + * DevBoost GmbH - Berlin, Germany + * - initial API and implementation + ******************************************************************************/ +package de.devboost.buildboost.steps.clone; + +import java.io.File; +import java.util.ArrayList; +import java.util.Collection; + +import de.devboost.buildboost.ant.AbstractAntTargetGenerator; +import de.devboost.buildboost.ant.AntTarget; +import de.devboost.buildboost.artifacts.RepositoriesFile.Location; +import de.devboost.buildboost.util.AntScriptUtil; +import de.devboost.buildboost.util.XMLContent; + +public class CloneRepositoriesBuildStep extends AbstractAntTargetGenerator { + + private final File reposFolder; + private final Collection locations; + + public CloneRepositoriesBuildStep(File reposFolder, + Collection locations) { + super(); + this.reposFolder = reposFolder; + this.locations = locations; + } + + @Override + public Collection generateAntTargets() { + Collection result = new ArrayList(); + result.add(writeRepositoryList()); + + for (Location location : locations) { + String locationURL = location.getUrl(); + String localRepositoryFolderName = url2FolderName(locationURL); + + String rootName = url2FolderName(locationURL.substring(locationURL + .lastIndexOf("/") + 1)); + + File localRepo = new File(new File(reposFolder, + localRepositoryFolderName), rootName); + + XMLContent content = new XMLContent(); + + content.append(""); + content.append(""); + content.append(""); + content.append(""); + content.append(""); + content.append(""); + content.append(""); + content.append(""); + + boolean isGit = location.getType().equals("git"); + boolean isSVN = location.getType().equals("svn"); + + String localRepositoryPath = getLocalRepositoryPath(location); + + if (isGit) { + if (localRepo.exists()) { + content.append(""); + content.append(""); + content.append(""); + } else { + content.append(""); + content.append(""); + content.append(""); + content.append(""); + content.append(""); + content.append(""); + content.append(""); + } + if (!location.getSubDirectories().isEmpty()) { + // enable sparse checkout + content.append(""); + content.append(""); + content.append(""); + content.append(""); + content.append(""); + String dirList = ".gitignore${line.separator}"; + for (String subDir : location.getSubDirectories()) { + dirList += subDir; + dirList += "${line.separator}"; + } + content.append(""); + content.append(""); + content.append(""); + content.append(""); + content.append(""); + content.append(""); + } + } else if (isSVN) { + if (localRepo.exists()) { + // execute update + content.append(""); + content.append(""); + content.append(""); + } else { + // execute checkout + content.append(""); + content.append(""); + content.append(""); + content.append(""); + content.append(""); + } + } else /* isGet */{ + if (!localRepo.exists()) { + content.append(""); + if (!location.getSubDirectories().isEmpty()) { + if (localRepo.getName().endsWith(".zip")) { + String zipFilePath = new File(localRepo, rootName) + .getAbsolutePath(); + content.append(""); + content.append(""); + content.append(""); + for (String zipEntry : location.getSubDirectories()) { + content.append(""); + } + content.append(""); + content.append(""); + content.append(""); + } else /* folder */{ + for (String subPath : location.getSubDirectories()) { + content.append(""); + } + } + } else { + AntScriptUtil.addDownloadFileScript(content, + locationURL, localRepositoryPath); + } + } + } + result.add(new AntTarget("update-" + localRepositoryFolderName, + content)); + } + return result; + } + + private AntTarget writeRepositoryList() { + XMLContent content = new XMLContent(); + String revisionFile = new File(reposFolder, + "buildboost_repository_list.txt").getAbsolutePath(); + content.append(""); + content.append(""); + for (Location location : locations) { + boolean isGit = location.getType().equals("git"); + boolean isSVN = location.getType().equals("svn"); + + String locationURL = location.getUrl(); + + String localRepositoryPath = getLocalRepositoryPath(location); + + if (isSVN || isGit) { + content.append(""); + content.append(""); + content.append(""); + content.append(""); + content.append(""); + content.append(""); + } + } + + return new AntTarget("write-repository-list", content); + } + + protected String getLocalRepositoryPath(Location location) { + String locationURL = location.getUrl(); + String localRepositoryFolderName = url2FolderName(locationURL); + String rootName = url2FolderName(locationURL.substring(locationURL + .lastIndexOf("/") + 1)); + return new File(new File(reposFolder, localRepositoryFolderName), + rootName).getAbsolutePath(); + } + + protected String url2FolderName(String url) { + int idx; + String folderName = url; + // cut leading protocol + idx = folderName.indexOf("//"); + if (idx != -1) { + folderName = folderName.substring(idx + 2); + } + // cut arguments + idx = folderName.indexOf("?"); + if (idx != -1) { + folderName = folderName.substring(0, idx); + } + folderName = encodeFileOrFolderName(folderName); + return folderName; + } + + /** + * @param folderName + * Name of file or folder (os dependend) + * @return encoded Folder name as new object (copy) + */ + public static String encodeFileOrFolderName(String orgFolderName) { + // explicit copy to avoid the same object in a special case without + // special chars. + String folderName = new String(orgFolderName); + folderName = folderName.replace(":", ""); + folderName = folderName.replace("~", "_"); + folderName = folderName.replace("/", "_"); + folderName = folderName.replace("\\", "_"); + folderName = folderName.replace(" ", "-"); + return folderName; + } +} diff --git a/Core/de.devboost.buildboost/src/de/devboost/buildboost/steps/clone/CloneRepositoriesBuildStepProvider.java b/Core/de.devboost.buildboost/src/de/devboost/buildboost/steps/clone/CloneRepositoriesBuildStepProvider.java index 42844c3..a564052 100644 --- a/Core/de.devboost.buildboost/src/de/devboost/buildboost/steps/clone/CloneRepositoriesBuildStepProvider.java +++ b/Core/de.devboost.buildboost/src/de/devboost/buildboost/steps/clone/CloneRepositoriesBuildStepProvider.java @@ -1,119 +1,119 @@ -/******************************************************************************* - * Copyright (c) 2006-2012 - * Software Technology Group, Dresden University of Technology - * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 - * - * All rights reserved. This program and the accompanying materials - * are 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 - * - * Contributors: - * Software Technology Group - TU Dresden, Germany; - * DevBoost GmbH - Berlin, Germany - * - initial API and implementation - ******************************************************************************/ -package de.devboost.buildboost.steps.clone; - -import java.io.File; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Iterator; -import java.util.List; - -import de.devboost.buildboost.BuildException; -import de.devboost.buildboost.UnresolvedDependencyChecker; -import de.devboost.buildboost.ant.IAntTargetGenerator; -import de.devboost.buildboost.ant.IAntTargetGeneratorProvider; -import de.devboost.buildboost.artifacts.RepositoriesFile; -import de.devboost.buildboost.artifacts.RepositoriesFile.Location; -import de.devboost.buildboost.model.AbstractBuildParticipant; -import de.devboost.buildboost.model.IArtifact; -import de.devboost.buildboost.model.IArtifactDiscoverer; -import de.devboost.buildboost.model.IArtifactFilter; -import de.devboost.buildboost.model.IBuildContext; -import de.devboost.buildboost.model.IBuildParticipant; - -/** - * The {@link CloneRepositoriesBuildStepProvider} add a {@link CloneRepositoriesBuildStep} - * for each {@link RepositoriesFile}. - */ -public class CloneRepositoriesBuildStepProvider extends AbstractBuildParticipant - implements IAntTargetGeneratorProvider { - - private File reposFolder; - - public CloneRepositoriesBuildStepProvider(File reposFolder) { - super(); - this.reposFolder = reposFolder; - } - - public void execute(IBuildContext context) throws BuildException { - List antTargets = new ArrayList(); - Collection artifacts = context.getDiscoveredArtifacts(); - antTargets.add(getAntTargetGenerators(context, artifacts)); - context.addDiscoveredArtifacts(antTargets); - } - - public IAntTargetGenerator getAntTargetGenerators(IBuildContext context, Collection artifacts) { - Collection locations = new ArrayList(); - for (IArtifact artifact : artifacts) { - if (artifact instanceof RepositoriesFile) { - RepositoriesFile repositoriesFile = (RepositoriesFile) artifact; - for (Location location : repositoriesFile.getLocations()) { - boolean locationDuplicate = false; - for (Location locationInList : locations) { - if (locationInList.getUrl().equals(location.getUrl())) { - locationDuplicate = true; - locationInList.getSubDirectories().addAll(location.getSubDirectories()); - break; - } - } - if (!locationDuplicate) { - locations.add(location); - } - } - } - } - - removeOverlapsInSVNLocations(locations); - - CloneRepositoriesBuildStep step = new CloneRepositoriesBuildStep(reposFolder, locations); - return step; - } - - private void removeOverlapsInSVNLocations(Collection locations) { - for (Location location1 : new ArrayList(locations)) { - if (!"svn".equals(location1.getType())) { - continue; - } - for (Iterator i = locations.iterator(); i.hasNext();) { - Location location2 = i.next(); - if (!"svn".equals(location2.getType())) { - continue; - } - String location1URL = location1.getUrl(); - if (!location1URL.endsWith("/")) { - location1URL = location1URL + "/"; - } - if (!location1.equals(location2) && location2.getUrl().startsWith(location1URL)) { - i.remove(); - } - } - } - } - - public boolean dependsOn(IBuildParticipant otherParticipant) { - if (otherParticipant instanceof IArtifactDiscoverer) { - return true; - } - if (otherParticipant instanceof IArtifactFilter) { - return true; - } - if (otherParticipant instanceof UnresolvedDependencyChecker) { - return true; - } - return false; - } - -} +/******************************************************************************* + * Copyright (c) 2006-2012 + * Software Technology Group, Dresden University of Technology + * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 + * + * All rights reserved. This program and the accompanying materials + * are 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 + * + * Contributors: + * Software Technology Group - TU Dresden, Germany; + * DevBoost GmbH - Berlin, Germany + * - initial API and implementation + ******************************************************************************/ +package de.devboost.buildboost.steps.clone; + +import java.io.File; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Iterator; +import java.util.List; + +import de.devboost.buildboost.BuildException; +import de.devboost.buildboost.UnresolvedDependencyChecker; +import de.devboost.buildboost.ant.IAntTargetGenerator; +import de.devboost.buildboost.ant.IAntTargetGeneratorProvider; +import de.devboost.buildboost.artifacts.RepositoriesFile; +import de.devboost.buildboost.artifacts.RepositoriesFile.Location; +import de.devboost.buildboost.model.AbstractBuildParticipant; +import de.devboost.buildboost.model.IArtifact; +import de.devboost.buildboost.model.IArtifactDiscoverer; +import de.devboost.buildboost.model.IArtifactFilter; +import de.devboost.buildboost.model.IBuildContext; +import de.devboost.buildboost.model.IBuildParticipant; + +/** + * The {@link CloneRepositoriesBuildStepProvider} add a {@link CloneRepositoriesBuildStep} + * for each {@link RepositoriesFile}. + */ +public class CloneRepositoriesBuildStepProvider extends AbstractBuildParticipant + implements IAntTargetGeneratorProvider { + + private File reposFolder; + + public CloneRepositoriesBuildStepProvider(File reposFolder) { + super(); + this.reposFolder = reposFolder; + } + + public void execute(IBuildContext context) throws BuildException { + List antTargets = new ArrayList(); + Collection artifacts = context.getDiscoveredArtifacts(); + antTargets.add(getAntTargetGenerators(context, artifacts)); + context.addDiscoveredArtifacts(antTargets); + } + + public IAntTargetGenerator getAntTargetGenerators(IBuildContext context, Collection artifacts) { + Collection locations = new ArrayList(); + for (IArtifact artifact : artifacts) { + if (artifact instanceof RepositoriesFile) { + RepositoriesFile repositoriesFile = (RepositoriesFile) artifact; + for (Location location : repositoriesFile.getLocations()) { + boolean locationDuplicate = false; + for (Location locationInList : locations) { + if (locationInList.getUrl().equals(location.getUrl())) { + locationDuplicate = true; + locationInList.getSubDirectories().addAll(location.getSubDirectories()); + break; + } + } + if (!locationDuplicate) { + locations.add(location); + } + } + } + } + + removeOverlapsInSVNLocations(locations); + + CloneRepositoriesBuildStep step = new CloneRepositoriesBuildStep(reposFolder, locations); + return step; + } + + private void removeOverlapsInSVNLocations(Collection locations) { + for (Location location1 : new ArrayList(locations)) { + if (!"svn".equals(location1.getType())) { + continue; + } + for (Iterator i = locations.iterator(); i.hasNext();) { + Location location2 = i.next(); + if (!"svn".equals(location2.getType())) { + continue; + } + String location1URL = location1.getUrl(); + if (!location1URL.endsWith("/")) { + location1URL = location1URL + "/"; + } + if (!location1.equals(location2) && location2.getUrl().startsWith(location1URL)) { + i.remove(); + } + } + } + } + + public boolean dependsOn(IBuildParticipant otherParticipant) { + if (otherParticipant instanceof IArtifactDiscoverer) { + return true; + } + if (otherParticipant instanceof IArtifactFilter) { + return true; + } + if (otherParticipant instanceof UnresolvedDependencyChecker) { + return true; + } + return false; + } + +} diff --git a/Core/de.devboost.buildboost/src/de/devboost/buildboost/steps/compile/CompileProjectStep.java b/Core/de.devboost.buildboost/src/de/devboost/buildboost/steps/compile/CompileProjectStep.java index 20b94a7..1aee1dd 100644 --- a/Core/de.devboost.buildboost/src/de/devboost/buildboost/steps/compile/CompileProjectStep.java +++ b/Core/de.devboost.buildboost/src/de/devboost/buildboost/steps/compile/CompileProjectStep.java @@ -1,100 +1,100 @@ -/******************************************************************************* - * Copyright (c) 2006-2012 - * Software Technology Group, Dresden University of Technology - * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 - * - * All rights reserved. This program and the accompanying materials - * are 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 - * - * Contributors: - * Software Technology Group - TU Dresden, Germany; - * DevBoost GmbH - Berlin, Germany - * - initial API and implementation - ******************************************************************************/ -package de.devboost.buildboost.steps.compile; - -import static de.devboost.buildboost.IConstants.NL; - -import java.io.File; -import java.util.Collection; -import java.util.Collections; - -import de.devboost.buildboost.ant.AbstractAntTargetGenerator; -import de.devboost.buildboost.ant.AntTarget; -import de.devboost.buildboost.artifacts.Plugin; -import de.devboost.buildboost.steps.ClasspathHelper; -import de.devboost.buildboost.util.XMLContent; - -/** - * The {@link CompileProjectStep} generates a script that compiles a plug-in - * project. - */ -public class CompileProjectStep extends AbstractAntTargetGenerator { - - private Plugin project; - private String sourceFileEncoding; - private JDKVersion targetVersion; - - public CompileProjectStep(Plugin plugin, JDKVersion targetVersion, String sourceFileEncoding) { - this.project = plugin; - this.sourceFileEncoding = sourceFileEncoding; - this.targetVersion = targetVersion; - } - - /** - * Returns the ANT build instructions for a single plug-in projects. The - * returned script compiles the content of all source folders and copies - * all resource files to the bin folder. - */ - public Collection generateAntTargets() { - File[] sourceFolders = project.getSourceFolders(); - if (sourceFolders.length == 0 || !project.hasManifest()) { - // nothing to do for projects without source folders or manifest - return Collections.emptySet(); - } - XMLContent content = new XMLContent(); - String projectName = project.getIdentifier(); - - content.append(""); - String binPath = new ClasspathHelper().getBinPath(project); - content.append(NL); - String target = ""; - if (targetVersion != null) { - target = " target=\"" + targetVersion.getNumber() + "\""; - } - String javacTag = ""); - } - content.append(NL); - content.append(""); - content.append(new ClasspathHelper().getClasspath(project, false)); - - content.append(""); - content.append(""); - content.append(NL); - // copy resource files from source folder to binary folder - for (File sourceFolder : sourceFolders) { - content.append(""); - content.append(""); - content.append(""); - content.append(""); - content.append(""); - } - content.append(NL); - return Collections.singleton(new AntTarget("compile-" + projectName, content)); - } - - private String getSourceFolderPath(File sourceFolder) { - // TODO this does not work for source folders that are not directly contained in the project root directory - return new File(project.getFile(), sourceFolder.getName()).getAbsolutePath(); - } -} +/******************************************************************************* + * Copyright (c) 2006-2012 + * Software Technology Group, Dresden University of Technology + * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 + * + * All rights reserved. This program and the accompanying materials + * are 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 + * + * Contributors: + * Software Technology Group - TU Dresden, Germany; + * DevBoost GmbH - Berlin, Germany + * - initial API and implementation + ******************************************************************************/ +package de.devboost.buildboost.steps.compile; + +import static de.devboost.buildboost.IConstants.NL; + +import java.io.File; +import java.util.Collection; +import java.util.Collections; + +import de.devboost.buildboost.ant.AbstractAntTargetGenerator; +import de.devboost.buildboost.ant.AntTarget; +import de.devboost.buildboost.artifacts.Plugin; +import de.devboost.buildboost.steps.ClasspathHelper; +import de.devboost.buildboost.util.XMLContent; + +/** + * The {@link CompileProjectStep} generates a script that compiles a plug-in + * project. + */ +public class CompileProjectStep extends AbstractAntTargetGenerator { + + private Plugin project; + private String sourceFileEncoding; + private JDKVersion targetVersion; + + public CompileProjectStep(Plugin plugin, JDKVersion targetVersion, String sourceFileEncoding) { + this.project = plugin; + this.sourceFileEncoding = sourceFileEncoding; + this.targetVersion = targetVersion; + } + + /** + * Returns the ANT build instructions for a single plug-in projects. The + * returned script compiles the content of all source folders and copies + * all resource files to the bin folder. + */ + public Collection generateAntTargets() { + File[] sourceFolders = project.getSourceFolders(); + if (sourceFolders.length == 0 || !project.hasManifest()) { + // nothing to do for projects without source folders or manifest + return Collections.emptySet(); + } + XMLContent content = new XMLContent(); + String projectName = project.getIdentifier(); + + content.append(""); + String binPath = new ClasspathHelper().getBinPath(project); + content.append(NL); + String target = ""; + if (targetVersion != null) { + target = " target=\"" + targetVersion.getNumber() + "\""; + } + String javacTag = ""); + } + content.append(NL); + content.append(""); + content.append(new ClasspathHelper().getClasspath(project, false)); + + content.append(""); + content.append(""); + content.append(NL); + // copy resource files from source folder to binary folder + for (File sourceFolder : sourceFolders) { + content.append(""); + content.append(""); + content.append(""); + content.append(""); + content.append(""); + } + content.append(NL); + return Collections.singleton(new AntTarget("compile-" + projectName, content)); + } + + private String getSourceFolderPath(File sourceFolder) { + // TODO this does not work for source folders that are not directly contained in the project root directory + return new File(project.getFile(), sourceFolder.getName()).getAbsolutePath(); + } +} diff --git a/Core/de.devboost.buildboost/src/de/devboost/buildboost/steps/compile/CompileProjectStepProvider.java b/Core/de.devboost.buildboost/src/de/devboost/buildboost/steps/compile/CompileProjectStepProvider.java index cd90bc1..372d3d2 100644 --- a/Core/de.devboost.buildboost/src/de/devboost/buildboost/steps/compile/CompileProjectStepProvider.java +++ b/Core/de.devboost.buildboost/src/de/devboost/buildboost/steps/compile/CompileProjectStepProvider.java @@ -1,51 +1,51 @@ -/******************************************************************************* - * Copyright (c) 2006-2012 - * Software Technology Group, Dresden University of Technology - * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 - * - * All rights reserved. This program and the accompanying materials - * are 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 - * - * Contributors: - * Software Technology Group - TU Dresden, Germany; - * DevBoost GmbH - Berlin, Germany - * - initial API and implementation - ******************************************************************************/ -package de.devboost.buildboost.steps.compile; - -import java.util.Collections; -import java.util.List; - -import de.devboost.buildboost.ant.AbstractAntTargetGeneratorProvider; -import de.devboost.buildboost.ant.IAntTargetGenerator; -import de.devboost.buildboost.artifacts.Plugin; -import de.devboost.buildboost.model.IArtifact; -import de.devboost.buildboost.model.IBuildContext; - -public class CompileProjectStepProvider extends AbstractAntTargetGeneratorProvider { - - private String sourceFileEncoding; - private JDKVersion jdkVersion; - - public CompileProjectStepProvider() { - this(null, null); - } - - public CompileProjectStepProvider(JDKVersion jdkVersion, String sourceFileEncoding) { - super(); - this.jdkVersion = jdkVersion; - this.sourceFileEncoding = sourceFileEncoding; - } - - public List getAntTargetGenerators(IBuildContext context, IArtifact artifact) { - if (artifact instanceof Plugin) { - Plugin plugin = (Plugin) artifact; - IAntTargetGenerator step = new CompileProjectStep(plugin, jdkVersion, sourceFileEncoding); - return Collections.singletonList(step); - } else { - return Collections.emptyList(); - } - } -} +/******************************************************************************* + * Copyright (c) 2006-2012 + * Software Technology Group, Dresden University of Technology + * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 + * + * All rights reserved. This program and the accompanying materials + * are 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 + * + * Contributors: + * Software Technology Group - TU Dresden, Germany; + * DevBoost GmbH - Berlin, Germany + * - initial API and implementation + ******************************************************************************/ +package de.devboost.buildboost.steps.compile; + +import java.util.Collections; +import java.util.List; + +import de.devboost.buildboost.ant.AbstractAntTargetGeneratorProvider; +import de.devboost.buildboost.ant.IAntTargetGenerator; +import de.devboost.buildboost.artifacts.Plugin; +import de.devboost.buildboost.model.IArtifact; +import de.devboost.buildboost.model.IBuildContext; + +public class CompileProjectStepProvider extends AbstractAntTargetGeneratorProvider { + + private String sourceFileEncoding; + private JDKVersion jdkVersion; + + public CompileProjectStepProvider() { + this(null, null); + } + + public CompileProjectStepProvider(JDKVersion jdkVersion, String sourceFileEncoding) { + super(); + this.jdkVersion = jdkVersion; + this.sourceFileEncoding = sourceFileEncoding; + } + + public List getAntTargetGenerators(IBuildContext context, IArtifact artifact) { + if (artifact instanceof Plugin) { + Plugin plugin = (Plugin) artifact; + IAntTargetGenerator step = new CompileProjectStep(plugin, jdkVersion, sourceFileEncoding); + return Collections.singletonList(step); + } else { + return Collections.emptyList(); + } + } +} diff --git a/Core/de.devboost.buildboost/src/de/devboost/buildboost/steps/compile/CompileScriptGenerator.java b/Core/de.devboost.buildboost/src/de/devboost/buildboost/steps/compile/CompileScriptGenerator.java index 692d84b..e1f9ff1 100644 --- a/Core/de.devboost.buildboost/src/de/devboost/buildboost/steps/compile/CompileScriptGenerator.java +++ b/Core/de.devboost.buildboost/src/de/devboost/buildboost/steps/compile/CompileScriptGenerator.java @@ -1,81 +1,81 @@ -/******************************************************************************* - * Copyright (c) 2006-2012 - * Software Technology Group, Dresden University of Technology - * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 - * - * All rights reserved. This program and the accompanying materials - * are 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 - * - * Contributors: - * Software Technology Group - TU Dresden, Germany; - * DevBoost GmbH - Berlin, Germany - * - initial API and implementation - ******************************************************************************/ -package de.devboost.buildboost.steps.compile; - -import static de.devboost.buildboost.IConstants.NL; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; -import java.util.Set; - -import de.devboost.buildboost.ant.AntTarget; -import de.devboost.buildboost.artifacts.Plugin; -import de.devboost.buildboost.model.IDependable; -import de.devboost.buildboost.util.ArtifactUtil; -import de.devboost.buildboost.util.Sorter; -import de.devboost.buildboost.util.XMLContent; - -/** - * A utility class that can create Ant scripts to compile Eclipse plug-in - * projects. - */ -public class CompileScriptGenerator { - - /** - * Returns an ANT script that compiles all the given projects in the correct - * order. - * - * @param pluginsToCompile - * @param targetPlatformPlugins - * @return - */ - public String getCompileAntScript(Collection pluginsToCompile, Set targetPlatformPlugins) { - if (pluginsToCompile.contains(null)) { - throw new RuntimeException("null not allowed"); - } - Set targetPlatformArtifacts = new ArtifactUtil().getSetOfDependables(targetPlatformPlugins); - // create ANT script that compiles the given collection of projects - XMLContent content = new XMLContent(); - content.append(""); - content.append(""); - content.append(""); - content.append(""); - List sortedPlugins = new ArrayList(); - Sorter sorter = new Sorter(); - sortedPlugins.addAll(pluginsToCompile); - for (IDependable plugin : sortedPlugins) { - List cycle = sorter.findCycle(plugin, targetPlatformArtifacts); - if (cycle == null) { - continue; - } - System.out.println("Cycle: " + cycle); - } - sortedPlugins = sorter.topologicalSort(sortedPlugins, targetPlatformArtifacts); - for (IDependable artifact : sortedPlugins) { - if (artifact instanceof Plugin) { - Plugin plugin = (Plugin) artifact; - Collection targets = new CompileProjectStep(plugin, null, null).generateAntTargets(); - for (AntTarget antTarget : targets) { - content.append(antTarget.getContent()); - } - } - } - content.append("" + NL); - content.append("" + NL); - return content.toString(); - } -} +/******************************************************************************* + * Copyright (c) 2006-2012 + * Software Technology Group, Dresden University of Technology + * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 + * + * All rights reserved. This program and the accompanying materials + * are 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 + * + * Contributors: + * Software Technology Group - TU Dresden, Germany; + * DevBoost GmbH - Berlin, Germany + * - initial API and implementation + ******************************************************************************/ +package de.devboost.buildboost.steps.compile; + +import static de.devboost.buildboost.IConstants.NL; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import java.util.Set; + +import de.devboost.buildboost.ant.AntTarget; +import de.devboost.buildboost.artifacts.Plugin; +import de.devboost.buildboost.model.IDependable; +import de.devboost.buildboost.util.ArtifactUtil; +import de.devboost.buildboost.util.Sorter; +import de.devboost.buildboost.util.XMLContent; + +/** + * A utility class that can create Ant scripts to compile Eclipse plug-in + * projects. + */ +public class CompileScriptGenerator { + + /** + * Returns an ANT script that compiles all the given projects in the correct + * order. + * + * @param pluginsToCompile + * @param targetPlatformPlugins + * @return + */ + public String getCompileAntScript(Collection pluginsToCompile, Set targetPlatformPlugins) { + if (pluginsToCompile.contains(null)) { + throw new RuntimeException("null not allowed"); + } + Set targetPlatformArtifacts = new ArtifactUtil().getSetOfDependables(targetPlatformPlugins); + // create ANT script that compiles the given collection of projects + XMLContent content = new XMLContent(); + content.append(""); + content.append(""); + content.append(""); + content.append(""); + List sortedPlugins = new ArrayList(); + Sorter sorter = new Sorter(); + sortedPlugins.addAll(pluginsToCompile); + for (IDependable plugin : sortedPlugins) { + List cycle = sorter.findCycle(plugin, targetPlatformArtifacts); + if (cycle == null) { + continue; + } + System.out.println("Cycle: " + cycle); + } + sortedPlugins = sorter.topologicalSort(sortedPlugins, targetPlatformArtifacts); + for (IDependable artifact : sortedPlugins) { + if (artifact instanceof Plugin) { + Plugin plugin = (Plugin) artifact; + Collection targets = new CompileProjectStep(plugin, null, null).generateAntTargets(); + for (AntTarget antTarget : targets) { + content.append(antTarget.getContent()); + } + } + } + content.append("" + NL); + content.append("" + NL); + return content.toString(); + } +} diff --git a/Core/de.devboost.buildboost/src/de/devboost/buildboost/steps/compile/ExtractPluginZipStep.java b/Core/de.devboost.buildboost/src/de/devboost/buildboost/steps/compile/ExtractPluginZipStep.java index 0851a26..5b2d2ca 100644 --- a/Core/de.devboost.buildboost/src/de/devboost/buildboost/steps/compile/ExtractPluginZipStep.java +++ b/Core/de.devboost.buildboost/src/de/devboost/buildboost/steps/compile/ExtractPluginZipStep.java @@ -1,49 +1,49 @@ -/******************************************************************************* - * Copyright (c) 2006-2012 - * Software Technology Group, Dresden University of Technology - * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 - * - * All rights reserved. This program and the accompanying materials - * are 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 - * - * Contributors: - * Software Technology Group - TU Dresden, Germany; - * DevBoost GmbH - Berlin, Germany - * - initial API and implementation - ******************************************************************************/ -package de.devboost.buildboost.steps.compile; - -import java.io.File; -import java.util.Collection; -import java.util.Collections; - -import de.devboost.buildboost.ant.AbstractAntTargetGenerator; -import de.devboost.buildboost.ant.AntTarget; -import de.devboost.buildboost.artifacts.CompiledPlugin; -import de.devboost.buildboost.util.XMLContent; - -public class ExtractPluginZipStep extends AbstractAntTargetGenerator { - - private CompiledPlugin plugin; - private File targetPlatformCache; - - public ExtractPluginZipStep(CompiledPlugin plugin, File targetPlatformCache) { - this.plugin = plugin; - this.targetPlatformCache = targetPlatformCache; - } - - public Collection generateAntTargets() { - XMLContent content = new XMLContent(); - File zippedLocation = plugin.getLocation(); - plugin.unzip(); - File unzippedLocation = plugin.getLocation(); - content.append(""); - content.append(""); - //delete cache file because target platform has changed - content.append(""); - return Collections.singleton(new AntTarget("unzip-plugin-with-libs-" + plugin.getIdentifier(), content)); - } - -} +/******************************************************************************* + * Copyright (c) 2006-2012 + * Software Technology Group, Dresden University of Technology + * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 + * + * All rights reserved. This program and the accompanying materials + * are 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 + * + * Contributors: + * Software Technology Group - TU Dresden, Germany; + * DevBoost GmbH - Berlin, Germany + * - initial API and implementation + ******************************************************************************/ +package de.devboost.buildboost.steps.compile; + +import java.io.File; +import java.util.Collection; +import java.util.Collections; + +import de.devboost.buildboost.ant.AbstractAntTargetGenerator; +import de.devboost.buildboost.ant.AntTarget; +import de.devboost.buildboost.artifacts.CompiledPlugin; +import de.devboost.buildboost.util.XMLContent; + +public class ExtractPluginZipStep extends AbstractAntTargetGenerator { + + private CompiledPlugin plugin; + private File targetPlatformCache; + + public ExtractPluginZipStep(CompiledPlugin plugin, File targetPlatformCache) { + this.plugin = plugin; + this.targetPlatformCache = targetPlatformCache; + } + + public Collection generateAntTargets() { + XMLContent content = new XMLContent(); + File zippedLocation = plugin.getLocation(); + plugin.unzip(); + File unzippedLocation = plugin.getLocation(); + content.append(""); + content.append(""); + //delete cache file because target platform has changed + content.append(""); + return Collections.singleton(new AntTarget("unzip-plugin-with-libs-" + plugin.getIdentifier(), content)); + } + +} diff --git a/Core/de.devboost.buildboost/src/de/devboost/buildboost/steps/compile/ExtractPluginZipStepProvider.java b/Core/de.devboost.buildboost/src/de/devboost/buildboost/steps/compile/ExtractPluginZipStepProvider.java index b58fd39..9947668 100644 --- a/Core/de.devboost.buildboost/src/de/devboost/buildboost/steps/compile/ExtractPluginZipStepProvider.java +++ b/Core/de.devboost.buildboost/src/de/devboost/buildboost/steps/compile/ExtractPluginZipStepProvider.java @@ -1,47 +1,47 @@ -/******************************************************************************* - * Copyright (c) 2006-2012 - * Software Technology Group, Dresden University of Technology - * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 - * - * All rights reserved. This program and the accompanying materials - * are 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 - * - * Contributors: - * Software Technology Group - TU Dresden, Germany; - * DevBoost GmbH - Berlin, Germany - * - initial API and implementation - ******************************************************************************/ -package de.devboost.buildboost.steps.compile; - -import java.io.File; -import java.util.Collections; -import java.util.List; - -import de.devboost.buildboost.ant.AbstractAntTargetGeneratorProvider; -import de.devboost.buildboost.ant.IAntTargetGenerator; -import de.devboost.buildboost.artifacts.CompiledPlugin; -import de.devboost.buildboost.model.IArtifact; -import de.devboost.buildboost.model.IBuildContext; - -public class ExtractPluginZipStepProvider extends AbstractAntTargetGeneratorProvider { - - private File targetPlatformCache; - - public ExtractPluginZipStepProvider(File targetPlatformCache) { - super(); - this.targetPlatformCache = targetPlatformCache; - } - - public List getAntTargetGenerators(IBuildContext context, IArtifact artifact) { - if (artifact instanceof CompiledPlugin) { - CompiledPlugin plugin = (CompiledPlugin) artifact; - if (plugin.isZipped() && !plugin.getLibs().isEmpty()) { - IAntTargetGenerator step = new ExtractPluginZipStep(plugin, targetPlatformCache); - return Collections.singletonList(step); - } - } - return Collections.emptyList(); - } -} +/******************************************************************************* + * Copyright (c) 2006-2012 + * Software Technology Group, Dresden University of Technology + * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 + * + * All rights reserved. This program and the accompanying materials + * are 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 + * + * Contributors: + * Software Technology Group - TU Dresden, Germany; + * DevBoost GmbH - Berlin, Germany + * - initial API and implementation + ******************************************************************************/ +package de.devboost.buildboost.steps.compile; + +import java.io.File; +import java.util.Collections; +import java.util.List; + +import de.devboost.buildboost.ant.AbstractAntTargetGeneratorProvider; +import de.devboost.buildboost.ant.IAntTargetGenerator; +import de.devboost.buildboost.artifacts.CompiledPlugin; +import de.devboost.buildboost.model.IArtifact; +import de.devboost.buildboost.model.IBuildContext; + +public class ExtractPluginZipStepProvider extends AbstractAntTargetGeneratorProvider { + + private File targetPlatformCache; + + public ExtractPluginZipStepProvider(File targetPlatformCache) { + super(); + this.targetPlatformCache = targetPlatformCache; + } + + public List getAntTargetGenerators(IBuildContext context, IArtifact artifact) { + if (artifact instanceof CompiledPlugin) { + CompiledPlugin plugin = (CompiledPlugin) artifact; + if (plugin.isZipped() && !plugin.getLibs().isEmpty()) { + IAntTargetGenerator step = new ExtractPluginZipStep(plugin, targetPlatformCache); + return Collections.singletonList(step); + } + } + return Collections.emptyList(); + } +} diff --git a/Core/de.devboost.buildboost/src/de/devboost/buildboost/steps/compile/JDKVersion.java b/Core/de.devboost.buildboost/src/de/devboost/buildboost/steps/compile/JDKVersion.java index 11e2708..5220116 100644 --- a/Core/de.devboost.buildboost/src/de/devboost/buildboost/steps/compile/JDKVersion.java +++ b/Core/de.devboost.buildboost/src/de/devboost/buildboost/steps/compile/JDKVersion.java @@ -1,32 +1,32 @@ -/******************************************************************************* - * Copyright (c) 2006-2012 - * Software Technology Group, Dresden University of Technology - * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 - * - * All rights reserved. This program and the accompanying materials - * are 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 - * - * Contributors: - * Software Technology Group - TU Dresden, Germany; - * DevBoost GmbH - Berlin, Germany - * - initial API and implementation - ******************************************************************************/ -package de.devboost.buildboost.steps.compile; - -public enum JDKVersion { - JAVA_SE_5("1.5"), - JAVA_SE_6("1.6"), - JAVA_SE_7("1.7"); - - private String number; - - private JDKVersion(String number) { - this.number = number; - } - - public String getNumber() { - return number; - } -} +/******************************************************************************* + * Copyright (c) 2006-2012 + * Software Technology Group, Dresden University of Technology + * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 + * + * All rights reserved. This program and the accompanying materials + * are 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 + * + * Contributors: + * Software Technology Group - TU Dresden, Germany; + * DevBoost GmbH - Berlin, Germany + * - initial API and implementation + ******************************************************************************/ +package de.devboost.buildboost.steps.compile; + +public enum JDKVersion { + JAVA_SE_5("1.5"), + JAVA_SE_6("1.6"), + JAVA_SE_7("1.7"); + + private String number; + + private JDKVersion(String number) { + this.number = number; + } + + public String getNumber() { + return number; + } +} diff --git a/Core/de.devboost.buildboost/src/de/devboost/buildboost/steps/copy/CopyPluginsAndFeaturesBuildStep.java b/Core/de.devboost.buildboost/src/de/devboost/buildboost/steps/copy/CopyPluginsAndFeaturesBuildStep.java index 2397176..aea2b86 100644 --- a/Core/de.devboost.buildboost/src/de/devboost/buildboost/steps/copy/CopyPluginsAndFeaturesBuildStep.java +++ b/Core/de.devboost.buildboost/src/de/devboost/buildboost/steps/copy/CopyPluginsAndFeaturesBuildStep.java @@ -1,76 +1,76 @@ -/******************************************************************************* - * Copyright (c) 2006-2012 - * Software Technology Group, Dresden University of Technology - * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 - * - * All rights reserved. This program and the accompanying materials - * are 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 - * - * Contributors: - * Software Technology Group - TU Dresden, Germany; - * DevBoost GmbH - Berlin, Germany - * - initial API and implementation - ******************************************************************************/ -package de.devboost.buildboost.steps.copy; - -import java.io.File; -import java.util.Collection; -import java.util.Collections; - -import de.devboost.buildboost.BuildException; -import de.devboost.buildboost.ant.AbstractAntTargetGenerator; -import de.devboost.buildboost.ant.AntTarget; -import de.devboost.buildboost.artifacts.CompiledPlugin; -import de.devboost.buildboost.artifacts.EclipseFeature; -import de.devboost.buildboost.model.IArtifact; -import de.devboost.buildboost.util.XMLContent; - -/** - * The {@link CopyPluginsAndFeaturesBuildStep} generates a script the copies the given - * bundled plug-in (JAR file) to a target directory. - */ -public class CopyPluginsAndFeaturesBuildStep extends AbstractAntTargetGenerator { - - private IArtifact pluginOrFeature; - private File targetDir; - - public CopyPluginsAndFeaturesBuildStep(IArtifact pluginOrFeature, File targetDir) { - super(); - this.pluginOrFeature = pluginOrFeature; - this.targetDir = new File(new File(targetDir, "target-platform"), "eclipse"); - } - - public Collection generateAntTargets() throws BuildException { - String pluginOrFeatureName = pluginOrFeature.getIdentifier(); - - String targetSubDir; - File location; - if (pluginOrFeature instanceof CompiledPlugin) { - location = ((CompiledPlugin) pluginOrFeature).getFile(); - File pluginsFolder = new File(targetDir, "plugins"); - if (location.isDirectory()) { - targetSubDir = new File(pluginsFolder, pluginOrFeatureName).getAbsolutePath(); - } else { - targetSubDir = pluginsFolder.getAbsolutePath(); - } - } else { - location = ((EclipseFeature) pluginOrFeature).getFile(); - targetSubDir = new File(new File(targetDir, "features"), pluginOrFeatureName).getAbsolutePath(); - } - - XMLContent content = new XMLContent(); - if (location.isFile()) { - content.append(""); - } else { - content.append(""); - content.append(""); - content.append(""); - content.append(""); - content.append(""); - } - return Collections.singleton(new AntTarget("copy-" - + pluginOrFeature.getClass().getSimpleName().toLowerCase() + "-" + pluginOrFeatureName, content)); - } -} +/******************************************************************************* + * Copyright (c) 2006-2012 + * Software Technology Group, Dresden University of Technology + * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 + * + * All rights reserved. This program and the accompanying materials + * are 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 + * + * Contributors: + * Software Technology Group - TU Dresden, Germany; + * DevBoost GmbH - Berlin, Germany + * - initial API and implementation + ******************************************************************************/ +package de.devboost.buildboost.steps.copy; + +import java.io.File; +import java.util.Collection; +import java.util.Collections; + +import de.devboost.buildboost.BuildException; +import de.devboost.buildboost.ant.AbstractAntTargetGenerator; +import de.devboost.buildboost.ant.AntTarget; +import de.devboost.buildboost.artifacts.CompiledPlugin; +import de.devboost.buildboost.artifacts.EclipseFeature; +import de.devboost.buildboost.model.IArtifact; +import de.devboost.buildboost.util.XMLContent; + +/** + * The {@link CopyPluginsAndFeaturesBuildStep} generates a script the copies the given + * bundled plug-in (JAR file) to a target directory. + */ +public class CopyPluginsAndFeaturesBuildStep extends AbstractAntTargetGenerator { + + private IArtifact pluginOrFeature; + private File targetDir; + + public CopyPluginsAndFeaturesBuildStep(IArtifact pluginOrFeature, File targetDir) { + super(); + this.pluginOrFeature = pluginOrFeature; + this.targetDir = new File(new File(targetDir, "target-platform"), "eclipse"); + } + + public Collection generateAntTargets() throws BuildException { + String pluginOrFeatureName = pluginOrFeature.getIdentifier(); + + String targetSubDir; + File location; + if (pluginOrFeature instanceof CompiledPlugin) { + location = ((CompiledPlugin) pluginOrFeature).getFile(); + File pluginsFolder = new File(targetDir, "plugins"); + if (location.isDirectory()) { + targetSubDir = new File(pluginsFolder, pluginOrFeatureName).getAbsolutePath(); + } else { + targetSubDir = pluginsFolder.getAbsolutePath(); + } + } else { + location = ((EclipseFeature) pluginOrFeature).getFile(); + targetSubDir = new File(new File(targetDir, "features"), pluginOrFeatureName).getAbsolutePath(); + } + + XMLContent content = new XMLContent(); + if (location.isFile()) { + content.append(""); + } else { + content.append(""); + content.append(""); + content.append(""); + content.append(""); + content.append(""); + } + return Collections.singleton(new AntTarget("copy-" + + pluginOrFeature.getClass().getSimpleName().toLowerCase() + "-" + pluginOrFeatureName, content)); + } +} diff --git a/Core/de.devboost.buildboost/src/de/devboost/buildboost/steps/copy/CopyPluginsAndFeaturesBuildStepProvider.java b/Core/de.devboost.buildboost/src/de/devboost/buildboost/steps/copy/CopyPluginsAndFeaturesBuildStepProvider.java index a9b4335..7795e67 100644 --- a/Core/de.devboost.buildboost/src/de/devboost/buildboost/steps/copy/CopyPluginsAndFeaturesBuildStepProvider.java +++ b/Core/de.devboost.buildboost/src/de/devboost/buildboost/steps/copy/CopyPluginsAndFeaturesBuildStepProvider.java @@ -1,51 +1,51 @@ -/******************************************************************************* - * Copyright (c) 2006-2012 - * Software Technology Group, Dresden University of Technology - * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 - * - * All rights reserved. This program and the accompanying materials - * are 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 - * - * Contributors: - * Software Technology Group - TU Dresden, Germany; - * DevBoost GmbH - Berlin, Germany - * - initial API and implementation - ******************************************************************************/ -package de.devboost.buildboost.steps.copy; - -import java.io.File; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -import de.devboost.buildboost.ant.AbstractAntTargetGeneratorProvider; -import de.devboost.buildboost.ant.IAntTargetGenerator; -import de.devboost.buildboost.artifacts.CompiledPlugin; -import de.devboost.buildboost.artifacts.EclipseFeature; -import de.devboost.buildboost.model.IArtifact; -import de.devboost.buildboost.model.IBuildContext; - -/** - * The {@link CopyPluginsAndFeaturesBuildStepProvider} add a {@link CopyPluginsAndFeaturesBuildStep} - * for each bundled plug-in. This provider does not apply to plug-in projects. - */ -public class CopyPluginsAndFeaturesBuildStepProvider extends AbstractAntTargetGeneratorProvider { - - private File targetDir; - - public CopyPluginsAndFeaturesBuildStepProvider(File targetDir) { - super(); - this.targetDir = targetDir; - } - - public List getAntTargetGenerators(IBuildContext context, IArtifact artifact) { - if (artifact instanceof CompiledPlugin || artifact instanceof EclipseFeature) { - List steps = new ArrayList(1); - steps.add(new CopyPluginsAndFeaturesBuildStep(artifact, targetDir)); - return steps; - } - return Collections.emptyList(); - } -} +/******************************************************************************* + * Copyright (c) 2006-2012 + * Software Technology Group, Dresden University of Technology + * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 + * + * All rights reserved. This program and the accompanying materials + * are 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 + * + * Contributors: + * Software Technology Group - TU Dresden, Germany; + * DevBoost GmbH - Berlin, Germany + * - initial API and implementation + ******************************************************************************/ +package de.devboost.buildboost.steps.copy; + +import java.io.File; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import de.devboost.buildboost.ant.AbstractAntTargetGeneratorProvider; +import de.devboost.buildboost.ant.IAntTargetGenerator; +import de.devboost.buildboost.artifacts.CompiledPlugin; +import de.devboost.buildboost.artifacts.EclipseFeature; +import de.devboost.buildboost.model.IArtifact; +import de.devboost.buildboost.model.IBuildContext; + +/** + * The {@link CopyPluginsAndFeaturesBuildStepProvider} add a {@link CopyPluginsAndFeaturesBuildStep} + * for each bundled plug-in. This provider does not apply to plug-in projects. + */ +public class CopyPluginsAndFeaturesBuildStepProvider extends AbstractAntTargetGeneratorProvider { + + private File targetDir; + + public CopyPluginsAndFeaturesBuildStepProvider(File targetDir) { + super(); + this.targetDir = targetDir; + } + + public List getAntTargetGenerators(IBuildContext context, IArtifact artifact) { + if (artifact instanceof CompiledPlugin || artifact instanceof EclipseFeature) { + List steps = new ArrayList(1); + steps.add(new CopyPluginsAndFeaturesBuildStep(artifact, targetDir)); + return steps; + } + return Collections.emptyList(); + } +} diff --git a/Core/de.devboost.buildboost/src/de/devboost/buildboost/steps/copy/CopyProjectsBuildStep.java b/Core/de.devboost.buildboost/src/de/devboost/buildboost/steps/copy/CopyProjectsBuildStep.java index 92fc161..c18119b 100644 --- a/Core/de.devboost.buildboost/src/de/devboost/buildboost/steps/copy/CopyProjectsBuildStep.java +++ b/Core/de.devboost.buildboost/src/de/devboost/buildboost/steps/copy/CopyProjectsBuildStep.java @@ -1,62 +1,62 @@ -/******************************************************************************* - * Copyright (c) 2006-2012 - * Software Technology Group, Dresden University of Technology - * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 - * - * All rights reserved. This program and the accompanying materials - * are 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 - * - * Contributors: - * Software Technology Group - TU Dresden, Germany; - * DevBoost GmbH - Berlin, Germany - * - initial API and implementation - ******************************************************************************/ -package de.devboost.buildboost.steps.copy; - -import static de.devboost.buildboost.IConstants.PROJECTS_FOLDER; - -import java.io.File; -import java.util.Collection; -import java.util.Collections; - -import de.devboost.buildboost.ant.AbstractAntTargetGenerator; -import de.devboost.buildboost.ant.AntTarget; -import de.devboost.buildboost.artifacts.Plugin; -import de.devboost.buildboost.util.XMLContent; - -/** - * The {@link CopyProjectsBuildStep} generates a script that copies plug-in - * projects from one directory (typically a SVN working copy) to another - * directory (typically a directory where the actual build is performed). The - * {@link CopyProjectsBuildStep} uses synchronization instead of pure copying - * to avoid unnecessary copy operations. - */ -public class CopyProjectsBuildStep extends AbstractAntTargetGenerator { - - private File targetDir; - private Plugin plugin; - - public CopyProjectsBuildStep(File targetDir, Plugin plugin) { - super(); - this.targetDir = new File(targetDir, PROJECTS_FOLDER); - this.plugin = plugin; - } - - public Collection generateAntTargets() { - String pluginName = plugin.getIdentifier(); - - XMLContent content = new XMLContent(); - content.append(""); - content.append(""); - content.append(""); //! in local build, Eclipse may compile classes here in addition - content.append(""); - content.append(""); - // TODO make this configurable / how does this interact with clean and with incremental build? - content.append(""); - content.append(""); - content.append(""); - return Collections.singleton(new AntTarget("copy-" + pluginName, content)); - } -} +/******************************************************************************* + * Copyright (c) 2006-2012 + * Software Technology Group, Dresden University of Technology + * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 + * + * All rights reserved. This program and the accompanying materials + * are 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 + * + * Contributors: + * Software Technology Group - TU Dresden, Germany; + * DevBoost GmbH - Berlin, Germany + * - initial API and implementation + ******************************************************************************/ +package de.devboost.buildboost.steps.copy; + +import static de.devboost.buildboost.IConstants.PROJECTS_FOLDER; + +import java.io.File; +import java.util.Collection; +import java.util.Collections; + +import de.devboost.buildboost.ant.AbstractAntTargetGenerator; +import de.devboost.buildboost.ant.AntTarget; +import de.devboost.buildboost.artifacts.Plugin; +import de.devboost.buildboost.util.XMLContent; + +/** + * The {@link CopyProjectsBuildStep} generates a script that copies plug-in + * projects from one directory (typically a SVN working copy) to another + * directory (typically a directory where the actual build is performed). The + * {@link CopyProjectsBuildStep} uses synchronization instead of pure copying + * to avoid unnecessary copy operations. + */ +public class CopyProjectsBuildStep extends AbstractAntTargetGenerator { + + private File targetDir; + private Plugin plugin; + + public CopyProjectsBuildStep(File targetDir, Plugin plugin) { + super(); + this.targetDir = new File(targetDir, PROJECTS_FOLDER); + this.plugin = plugin; + } + + public Collection generateAntTargets() { + String pluginName = plugin.getIdentifier(); + + XMLContent content = new XMLContent(); + content.append(""); + content.append(""); + content.append(""); //! in local build, Eclipse may compile classes here in addition + content.append(""); + content.append(""); + // TODO make this configurable / how does this interact with clean and with incremental build? + content.append(""); + content.append(""); + content.append(""); + return Collections.singleton(new AntTarget("copy-" + pluginName, content)); + } +} diff --git a/Core/de.devboost.buildboost/src/de/devboost/buildboost/steps/copy/CopyProjectsBuildStepProvider.java b/Core/de.devboost.buildboost/src/de/devboost/buildboost/steps/copy/CopyProjectsBuildStepProvider.java index 9b9f8c9..0b809ab 100644 --- a/Core/de.devboost.buildboost/src/de/devboost/buildboost/steps/copy/CopyProjectsBuildStepProvider.java +++ b/Core/de.devboost.buildboost/src/de/devboost/buildboost/steps/copy/CopyProjectsBuildStepProvider.java @@ -1,54 +1,54 @@ -/******************************************************************************* - * Copyright (c) 2006-2012 - * Software Technology Group, Dresden University of Technology - * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 - * - * All rights reserved. This program and the accompanying materials - * are 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 - * - * Contributors: - * Software Technology Group - TU Dresden, Germany; - * DevBoost GmbH - Berlin, Germany - * - initial API and implementation - ******************************************************************************/ -package de.devboost.buildboost.steps.copy; - -import java.io.File; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -import de.devboost.buildboost.ant.AbstractAntTargetGeneratorProvider; -import de.devboost.buildboost.ant.IAntTargetGenerator; -import de.devboost.buildboost.artifacts.Plugin; -import de.devboost.buildboost.model.IArtifact; -import de.devboost.buildboost.model.IBuildContext; - -/** - * The {@link CopyProjectsBuildStepProvider} add a {@link CopyProjectsBuildStep} - * for each plug-in project. - */ -public class CopyProjectsBuildStepProvider extends AbstractAntTargetGeneratorProvider { - - private File targetDir; - - public CopyProjectsBuildStepProvider(File targetDir) { - super(); - this.targetDir = targetDir; - } - - public List getAntTargetGenerators(IBuildContext context, IArtifact artifact) { - if (artifact instanceof Plugin) { - Plugin plugin = (Plugin) artifact; - if (plugin.isProject()) { - List steps = new ArrayList(1); - CopyProjectsBuildStep step = new CopyProjectsBuildStep(targetDir, plugin); - steps.add(step); - return steps; - } - } - return Collections.emptyList(); - } -} +/******************************************************************************* + * Copyright (c) 2006-2012 + * Software Technology Group, Dresden University of Technology + * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 + * + * All rights reserved. This program and the accompanying materials + * are 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 + * + * Contributors: + * Software Technology Group - TU Dresden, Germany; + * DevBoost GmbH - Berlin, Germany + * - initial API and implementation + ******************************************************************************/ +package de.devboost.buildboost.steps.copy; + +import java.io.File; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import de.devboost.buildboost.ant.AbstractAntTargetGeneratorProvider; +import de.devboost.buildboost.ant.IAntTargetGenerator; +import de.devboost.buildboost.artifacts.Plugin; +import de.devboost.buildboost.model.IArtifact; +import de.devboost.buildboost.model.IBuildContext; + +/** + * The {@link CopyProjectsBuildStepProvider} add a {@link CopyProjectsBuildStep} + * for each plug-in project. + */ +public class CopyProjectsBuildStepProvider extends AbstractAntTargetGeneratorProvider { + + private File targetDir; + + public CopyProjectsBuildStepProvider(File targetDir) { + super(); + this.targetDir = targetDir; + } + + public List getAntTargetGenerators(IBuildContext context, IArtifact artifact) { + if (artifact instanceof Plugin) { + Plugin plugin = (Plugin) artifact; + if (plugin.isProject()) { + List steps = new ArrayList(1); + CopyProjectsBuildStep step = new CopyProjectsBuildStep(targetDir, plugin); + steps.add(step); + return steps; + } + } + return Collections.emptyList(); + } +} diff --git a/Core/de.devboost.buildboost/src/de/devboost/buildboost/steps/copy/ExtractZipFileBuildStep.java b/Core/de.devboost.buildboost/src/de/devboost/buildboost/steps/copy/ExtractZipFileBuildStep.java index d105f15..1264306 100644 --- a/Core/de.devboost.buildboost/src/de/devboost/buildboost/steps/copy/ExtractZipFileBuildStep.java +++ b/Core/de.devboost.buildboost/src/de/devboost/buildboost/steps/copy/ExtractZipFileBuildStep.java @@ -1,74 +1,74 @@ -/******************************************************************************* - * Copyright (c) 2006-2012 - * Software Technology Group, Dresden University of Technology - * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 - * - * All rights reserved. This program and the accompanying materials - * are 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 - * - * Contributors: - * Software Technology Group - TU Dresden, Germany; - * DevBoost GmbH - Berlin, Germany - * - initial API and implementation - ******************************************************************************/ -package de.devboost.buildboost.steps.copy; - -import java.io.File; -import java.io.IOException; -import java.util.Collection; -import java.util.Collections; -import java.util.Enumeration; -import java.util.zip.ZipEntry; -import java.util.zip.ZipFile; - -import de.devboost.buildboost.BuildException; -import de.devboost.buildboost.ant.AbstractAntTargetGenerator; -import de.devboost.buildboost.ant.AntTarget; -import de.devboost.buildboost.artifacts.TargetPlatformZip; -import de.devboost.buildboost.util.XMLContent; -import de.devboost.buildboost.util.AntScriptUtil; - -public class ExtractZipFileBuildStep extends AbstractAntTargetGenerator { - - private TargetPlatformZip zip; - private File targetDir; - - public ExtractZipFileBuildStep(TargetPlatformZip zip, File targetDir) { - super(); - this.zip = zip; - this.targetDir = new File(targetDir, "target-platform"); - } - - public Collection generateAntTargets() throws BuildException { - XMLContent content = new XMLContent(); - File file = zip.getZipFile(); - AntScriptUtil.addZipFileExtractionScript(content, file, new File(targetDir, determineEclipseTargetStructurePrefix(file))); - return Collections.singleton(new AntTarget("unzip-target-platform-" + zip.getIdentifier(), content)); - } - - - - public String determineEclipseTargetStructurePrefix(File file) { - if (!file.getName().endsWith(".zip")) { - return ""; - } - try { - Enumeration entries = new ZipFile(file).entries(); - while (entries.hasMoreElements()) { - String entryName = entries.nextElement().getName(); - if (entryName.startsWith("eclipse/plugins/")) { - return ""; - } - if (entryName.startsWith("plugins/")) { - return "eclipse"; - } - } - } catch (IOException e) { - //ignore - e.printStackTrace(); - } - return "eclipse/plugins"; - } -} +/******************************************************************************* + * Copyright (c) 2006-2012 + * Software Technology Group, Dresden University of Technology + * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 + * + * All rights reserved. This program and the accompanying materials + * are 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 + * + * Contributors: + * Software Technology Group - TU Dresden, Germany; + * DevBoost GmbH - Berlin, Germany + * - initial API and implementation + ******************************************************************************/ +package de.devboost.buildboost.steps.copy; + +import java.io.File; +import java.io.IOException; +import java.util.Collection; +import java.util.Collections; +import java.util.Enumeration; +import java.util.zip.ZipEntry; +import java.util.zip.ZipFile; + +import de.devboost.buildboost.BuildException; +import de.devboost.buildboost.ant.AbstractAntTargetGenerator; +import de.devboost.buildboost.ant.AntTarget; +import de.devboost.buildboost.artifacts.TargetPlatformZip; +import de.devboost.buildboost.util.XMLContent; +import de.devboost.buildboost.util.AntScriptUtil; + +public class ExtractZipFileBuildStep extends AbstractAntTargetGenerator { + + private TargetPlatformZip zip; + private File targetDir; + + public ExtractZipFileBuildStep(TargetPlatformZip zip, File targetDir) { + super(); + this.zip = zip; + this.targetDir = new File(targetDir, "target-platform"); + } + + public Collection generateAntTargets() throws BuildException { + XMLContent content = new XMLContent(); + File file = zip.getZipFile(); + AntScriptUtil.addZipFileExtractionScript(content, file, new File(targetDir, determineEclipseTargetStructurePrefix(file))); + return Collections.singleton(new AntTarget("unzip-target-platform-" + zip.getIdentifier(), content)); + } + + + + public String determineEclipseTargetStructurePrefix(File file) { + if (!file.getName().endsWith(".zip")) { + return ""; + } + try { + Enumeration entries = new ZipFile(file).entries(); + while (entries.hasMoreElements()) { + String entryName = entries.nextElement().getName(); + if (entryName.startsWith("eclipse/plugins/")) { + return ""; + } + if (entryName.startsWith("plugins/")) { + return "eclipse"; + } + } + } catch (IOException e) { + //ignore + e.printStackTrace(); + } + return "eclipse/plugins"; + } +} diff --git a/Core/de.devboost.buildboost/src/de/devboost/buildboost/steps/copy/ExtractZipFileBuildStepProvider.java b/Core/de.devboost.buildboost/src/de/devboost/buildboost/steps/copy/ExtractZipFileBuildStepProvider.java index 8617526..84d101c 100644 --- a/Core/de.devboost.buildboost/src/de/devboost/buildboost/steps/copy/ExtractZipFileBuildStepProvider.java +++ b/Core/de.devboost.buildboost/src/de/devboost/buildboost/steps/copy/ExtractZipFileBuildStepProvider.java @@ -1,51 +1,51 @@ -/******************************************************************************* - * Copyright (c) 2006-2012 - * Software Technology Group, Dresden University of Technology - * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 - * - * All rights reserved. This program and the accompanying materials - * are 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 - * - * Contributors: - * Software Technology Group - TU Dresden, Germany; - * DevBoost GmbH - Berlin, Germany - * - initial API and implementation - ******************************************************************************/ -package de.devboost.buildboost.steps.copy; - -import java.io.File; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -import de.devboost.buildboost.ant.AbstractAntTargetGeneratorProvider; -import de.devboost.buildboost.ant.IAntTargetGenerator; -import de.devboost.buildboost.artifacts.TargetPlatformZip; -import de.devboost.buildboost.model.IArtifact; -import de.devboost.buildboost.model.IBuildContext; - -/** - * The {@link ExtractZipFileBuildStepProvider} add a {@link CopyPluginsAndFeaturesBuildStep} - * for each bundled plug-in. This provider does not apply to plug-in projects. - */ -public class ExtractZipFileBuildStepProvider extends AbstractAntTargetGeneratorProvider { - - private File targetDir; - - public ExtractZipFileBuildStepProvider(File targetDir) { - super(); - this.targetDir = targetDir; - } - - public List getAntTargetGenerators(IBuildContext context, IArtifact artifact) { - if (artifact instanceof TargetPlatformZip) { - TargetPlatformZip zip = (TargetPlatformZip) artifact; - List steps = new ArrayList(1); - steps.add(new ExtractZipFileBuildStep(zip, targetDir)); - return steps; - } - return Collections.emptyList(); - } -} +/******************************************************************************* + * Copyright (c) 2006-2012 + * Software Technology Group, Dresden University of Technology + * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 + * + * All rights reserved. This program and the accompanying materials + * are 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 + * + * Contributors: + * Software Technology Group - TU Dresden, Germany; + * DevBoost GmbH - Berlin, Germany + * - initial API and implementation + ******************************************************************************/ +package de.devboost.buildboost.steps.copy; + +import java.io.File; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import de.devboost.buildboost.ant.AbstractAntTargetGeneratorProvider; +import de.devboost.buildboost.ant.IAntTargetGenerator; +import de.devboost.buildboost.artifacts.TargetPlatformZip; +import de.devboost.buildboost.model.IArtifact; +import de.devboost.buildboost.model.IBuildContext; + +/** + * The {@link ExtractZipFileBuildStepProvider} add a {@link CopyPluginsAndFeaturesBuildStep} + * for each bundled plug-in. This provider does not apply to plug-in projects. + */ +public class ExtractZipFileBuildStepProvider extends AbstractAntTargetGeneratorProvider { + + private File targetDir; + + public ExtractZipFileBuildStepProvider(File targetDir) { + super(); + this.targetDir = targetDir; + } + + public List getAntTargetGenerators(IBuildContext context, IArtifact artifact) { + if (artifact instanceof TargetPlatformZip) { + TargetPlatformZip zip = (TargetPlatformZip) artifact; + List steps = new ArrayList(1); + steps.add(new ExtractZipFileBuildStep(zip, targetDir)); + return steps; + } + return Collections.emptyList(); + } +} diff --git a/Core/de.devboost.buildboost/src/de/devboost/buildboost/util/AbstractXMLReader.java b/Core/de.devboost.buildboost/src/de/devboost/buildboost/util/AbstractXMLReader.java index 593a53b..131048f 100644 --- a/Core/de.devboost.buildboost/src/de/devboost/buildboost/util/AbstractXMLReader.java +++ b/Core/de.devboost.buildboost/src/de/devboost/buildboost/util/AbstractXMLReader.java @@ -1,104 +1,104 @@ -/******************************************************************************* - * Copyright (c) 2006-2012 - * Software Technology Group, Dresden University of Technology - * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 - * - * All rights reserved. This program and the accompanying materials - * are 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 - * - * Contributors: - * Software Technology Group - TU Dresden, Germany; - * DevBoost GmbH - Berlin, Germany - * - initial API and implementation - ******************************************************************************/ -package de.devboost.buildboost.util; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.InputStream; -import java.net.MalformedURLException; - -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; -import javax.xml.parsers.ParserConfigurationException; -import javax.xml.xpath.XPath; -import javax.xml.xpath.XPathConstants; -import javax.xml.xpath.XPathExpressionException; -import javax.xml.xpath.XPathFactory; - -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; -import org.xml.sax.SAXException; - -import de.devboost.buildboost.model.IArtifact; -import de.devboost.buildboost.model.UnresolvedDependency; - -public abstract class AbstractXMLReader { - - public void readXMLFile(File file) { - InputStream inputStream; - try { - inputStream = new FileInputStream(file); - readXMLStrem(inputStream); - } catch (FileNotFoundException e) { - e.printStackTrace(); - } - } - - public void readXMLStrem(InputStream inputStream) { - DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance(); - - try { - DocumentBuilder builder = builderFactory.newDocumentBuilder(); - Document document = builder.parse(inputStream); - XPath xpath = XPathFactory.newInstance().newXPath(); - process(document, xpath); - inputStream.close(); - } catch (ParserConfigurationException e) { - } catch (MalformedURLException e) { - } catch (IOException e) { - } catch (SAXException e) { - } catch (XPathExpressionException e) { - } - // TODO handle exceptions? - } - - protected void findDependencies(Document document, XPath xpath, - String pathExpression, String idAttribute, String optionalAttribute, - Class dependencyType) - throws XPathExpressionException { - NodeList nodelist = (NodeList) xpath.evaluate(pathExpression, document, XPathConstants.NODESET); - for (int i = 0; i < nodelist.getLength(); i++) { - Node node = nodelist.item(i); - if (node instanceof Element) { - Element element = (Element) node; - String idAttributeValue = element.getAttribute(idAttribute); - // ignore elements where the ID attribute is not set - if (idAttributeValue == null || "".equals(idAttributeValue.trim())) { - continue; - } - - boolean optional = false; - if (optionalAttribute != null) { - String optionalValue = element.getAttribute(optionalAttribute); - if ("true".equals(optionalValue)) { - optional = true; - } - } - - // TODO add version? - addUnresolvedDependencies(element, new UnresolvedDependency(dependencyType, idAttributeValue, null, true, null, true, optional, false)); - } - } - } - - protected abstract void process(Document document, XPath xpath) throws XPathExpressionException; - - protected abstract void addUnresolvedDependencies(Element element, UnresolvedDependency unresolvedDependency); -} +/******************************************************************************* + * Copyright (c) 2006-2012 + * Software Technology Group, Dresden University of Technology + * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 + * + * All rights reserved. This program and the accompanying materials + * are 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 + * + * Contributors: + * Software Technology Group - TU Dresden, Germany; + * DevBoost GmbH - Berlin, Germany + * - initial API and implementation + ******************************************************************************/ +package de.devboost.buildboost.util; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.InputStream; +import java.net.MalformedURLException; + +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.ParserConfigurationException; +import javax.xml.xpath.XPath; +import javax.xml.xpath.XPathConstants; +import javax.xml.xpath.XPathExpressionException; +import javax.xml.xpath.XPathFactory; + +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; +import org.xml.sax.SAXException; + +import de.devboost.buildboost.model.IArtifact; +import de.devboost.buildboost.model.UnresolvedDependency; + +public abstract class AbstractXMLReader { + + public void readXMLFile(File file) { + InputStream inputStream; + try { + inputStream = new FileInputStream(file); + readXMLStrem(inputStream); + } catch (FileNotFoundException e) { + e.printStackTrace(); + } + } + + public void readXMLStrem(InputStream inputStream) { + DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance(); + + try { + DocumentBuilder builder = builderFactory.newDocumentBuilder(); + Document document = builder.parse(inputStream); + XPath xpath = XPathFactory.newInstance().newXPath(); + process(document, xpath); + inputStream.close(); + } catch (ParserConfigurationException e) { + } catch (MalformedURLException e) { + } catch (IOException e) { + } catch (SAXException e) { + } catch (XPathExpressionException e) { + } + // TODO handle exceptions? + } + + protected void findDependencies(Document document, XPath xpath, + String pathExpression, String idAttribute, String optionalAttribute, + Class dependencyType) + throws XPathExpressionException { + NodeList nodelist = (NodeList) xpath.evaluate(pathExpression, document, XPathConstants.NODESET); + for (int i = 0; i < nodelist.getLength(); i++) { + Node node = nodelist.item(i); + if (node instanceof Element) { + Element element = (Element) node; + String idAttributeValue = element.getAttribute(idAttribute); + // ignore elements where the ID attribute is not set + if (idAttributeValue == null || "".equals(idAttributeValue.trim())) { + continue; + } + + boolean optional = false; + if (optionalAttribute != null) { + String optionalValue = element.getAttribute(optionalAttribute); + if ("true".equals(optionalValue)) { + optional = true; + } + } + + // TODO add version? + addUnresolvedDependencies(element, new UnresolvedDependency(dependencyType, idAttributeValue, null, true, null, true, optional, false)); + } + } + } + + protected abstract void process(Document document, XPath xpath) throws XPathExpressionException; + + protected abstract void addUnresolvedDependencies(Element element, UnresolvedDependency unresolvedDependency); +} diff --git a/Core/de.devboost.buildboost/src/de/devboost/buildboost/util/ArtifactUtil.java b/Core/de.devboost.buildboost/src/de/devboost/buildboost/util/ArtifactUtil.java index 9ce84fc..0d2719a 100644 --- a/Core/de.devboost.buildboost/src/de/devboost/buildboost/util/ArtifactUtil.java +++ b/Core/de.devboost.buildboost/src/de/devboost/buildboost/util/ArtifactUtil.java @@ -1,83 +1,83 @@ -/******************************************************************************* - * Copyright (c) 2006-2012 - * Software Technology Group, Dresden University of Technology - * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 - * - * All rights reserved. This program and the accompanying materials - * are 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 - * - * Contributors: - * Software Technology Group - TU Dresden, Germany; - * DevBoost GmbH - Berlin, Germany - * - initial API and implementation - ******************************************************************************/ -package de.devboost.buildboost.util; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.LinkedHashSet; -import java.util.List; -import java.util.Set; - -import de.devboost.buildboost.model.IArtifact; -import de.devboost.buildboost.model.IDependable; - -/** - * A utility class to convert between sets of artifacts with different type - * parameters, where the actuals contents of the sets are compatible, but the - * Java type inferences cannot recognize this. - */ -public class ArtifactUtil { - - public Set getSetOfDependables(Collection concreteArtifacts) { - Set result = new LinkedHashSet(); - for (T concreteArtifact : concreteArtifacts) { - result.add(concreteArtifact); - } - return result; - } - - public Set getSetOfArtifacts(Collection concreteArtifacts) { - Set result = new LinkedHashSet(); - for (T concreteArtifact : concreteArtifacts) { - result.add(concreteArtifact); - } - return result; - } - - public Set getConcreteSet(Collection abstractArtifacts, Class clazz) { - Set result = new LinkedHashSet(); - for (Object abstractArtifact : abstractArtifacts) { - if (clazz.isInstance(abstractArtifact)) { - result.add(clazz.cast(abstractArtifact)); - } else { - throw new RuntimeException("Can't cast " + abstractArtifact + " to " + clazz.getName()); - } - } - return result; - } - - public List getConcreteList(Collection abstractArtifacts, Class clazz) { - List result = new ArrayList(); - for (Object abstractArtifact : abstractArtifacts) { - if (clazz.isInstance(abstractArtifact)) { - result.add(clazz.cast(abstractArtifact)); - } else { - throw new RuntimeException("Can't cast " + abstractArtifact + " to " + clazz.getName()); - } - } - return result; - } - - public Collection filter(Collection collection, Class clazz) { - List result = new ArrayList(); - for (Object next : collection) { - if (clazz.isInstance(next)) { - result.add(clazz.cast(next)); - } - } - return result; - } -} +/******************************************************************************* + * Copyright (c) 2006-2012 + * Software Technology Group, Dresden University of Technology + * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 + * + * All rights reserved. This program and the accompanying materials + * are 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 + * + * Contributors: + * Software Technology Group - TU Dresden, Germany; + * DevBoost GmbH - Berlin, Germany + * - initial API and implementation + ******************************************************************************/ +package de.devboost.buildboost.util; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Set; + +import de.devboost.buildboost.model.IArtifact; +import de.devboost.buildboost.model.IDependable; + +/** + * A utility class to convert between sets of artifacts with different type + * parameters, where the actuals contents of the sets are compatible, but the + * Java type inferences cannot recognize this. + */ +public class ArtifactUtil { + + public Set getSetOfDependables(Collection concreteArtifacts) { + Set result = new LinkedHashSet(); + for (T concreteArtifact : concreteArtifacts) { + result.add(concreteArtifact); + } + return result; + } + + public Set getSetOfArtifacts(Collection concreteArtifacts) { + Set result = new LinkedHashSet(); + for (T concreteArtifact : concreteArtifacts) { + result.add(concreteArtifact); + } + return result; + } + + public Set getConcreteSet(Collection abstractArtifacts, Class clazz) { + Set result = new LinkedHashSet(); + for (Object abstractArtifact : abstractArtifacts) { + if (clazz.isInstance(abstractArtifact)) { + result.add(clazz.cast(abstractArtifact)); + } else { + throw new RuntimeException("Can't cast " + abstractArtifact + " to " + clazz.getName()); + } + } + return result; + } + + public List getConcreteList(Collection abstractArtifacts, Class clazz) { + List result = new ArrayList(); + for (Object abstractArtifact : abstractArtifacts) { + if (clazz.isInstance(abstractArtifact)) { + result.add(clazz.cast(abstractArtifact)); + } else { + throw new RuntimeException("Can't cast " + abstractArtifact + " to " + clazz.getName()); + } + } + return result; + } + + public Collection filter(Collection collection, Class clazz) { + List result = new ArrayList(); + for (Object next : collection) { + if (clazz.isInstance(next)) { + result.add(clazz.cast(next)); + } + } + return result; + } +} diff --git a/Core/de.devboost.buildboost/src/de/devboost/buildboost/util/EclipsePluginHelper.java b/Core/de.devboost.buildboost/src/de/devboost/buildboost/util/EclipsePluginHelper.java index e8d1e64..191af14 100644 --- a/Core/de.devboost.buildboost/src/de/devboost/buildboost/util/EclipsePluginHelper.java +++ b/Core/de.devboost.buildboost/src/de/devboost/buildboost/util/EclipsePluginHelper.java @@ -1,63 +1,63 @@ -/******************************************************************************* - * Copyright (c) 2006-2012 - * Software Technology Group, Dresden University of Technology - * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 - * - * All rights reserved. This program and the accompanying materials - * are 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 - * - * Contributors: - * Software Technology Group - TU Dresden, Germany; - * DevBoost GmbH - Berlin, Germany - * - initial API and implementation - ******************************************************************************/ -package de.devboost.buildboost.util; - -import java.io.File; -import java.io.FileFilter; - -/** - * A utility class to process Eclipse plug-ins projects. - */ -public class EclipsePluginHelper { - - /** - * Checks whether the given directory contains a '.project' file. - */ - public boolean isProject(File directory) { - if (!directory.isDirectory()) { - return false; - } - File[] files = directory.listFiles(new FileFilter() { - - public boolean accept(File file) { - return ".project".equals(file.getName()); - } - }); - if (files == null) { - return false; - } - return files.length > 0; - } - - /** - * Searches for a parent of the given file that is an Eclipse plug-in - * project. If no such parent is found, null is returned. - * - * @param file a file contained in an Eclipse plug-in project - * @return the directory root of the plug-in project - */ - public File findProjectDir(File file) { - File parent = file.getParentFile(); - while (parent != null) { - boolean isProject = isProject(parent); - if (isProject) { - return parent; - } - parent = parent.getParentFile(); - } - return null; - } -} +/******************************************************************************* + * Copyright (c) 2006-2012 + * Software Technology Group, Dresden University of Technology + * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 + * + * All rights reserved. This program and the accompanying materials + * are 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 + * + * Contributors: + * Software Technology Group - TU Dresden, Germany; + * DevBoost GmbH - Berlin, Germany + * - initial API and implementation + ******************************************************************************/ +package de.devboost.buildboost.util; + +import java.io.File; +import java.io.FileFilter; + +/** + * A utility class to process Eclipse plug-ins projects. + */ +public class EclipsePluginHelper { + + /** + * Checks whether the given directory contains a '.project' file. + */ + public boolean isProject(File directory) { + if (!directory.isDirectory()) { + return false; + } + File[] files = directory.listFiles(new FileFilter() { + + public boolean accept(File file) { + return ".project".equals(file.getName()); + } + }); + if (files == null) { + return false; + } + return files.length > 0; + } + + /** + * Searches for a parent of the given file that is an Eclipse plug-in + * project. If no such parent is found, null is returned. + * + * @param file a file contained in an Eclipse plug-in project + * @return the directory root of the plug-in project + */ + public File findProjectDir(File file) { + File parent = file.getParentFile(); + while (parent != null) { + boolean isProject = isProject(parent); + if (isProject) { + return parent; + } + parent = parent.getParentFile(); + } + return null; + } +} diff --git a/Core/de.devboost.buildboost/src/de/devboost/buildboost/util/ScriptSaver.java b/Core/de.devboost.buildboost/src/de/devboost/buildboost/util/ScriptSaver.java index 18ec253..341388e 100644 --- a/Core/de.devboost.buildboost/src/de/devboost/buildboost/util/ScriptSaver.java +++ b/Core/de.devboost.buildboost/src/de/devboost/buildboost/util/ScriptSaver.java @@ -1,140 +1,140 @@ -/******************************************************************************* - * Copyright (c) 2006-2012 - * Software Technology Group, Dresden University of Technology - * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 - * - * All rights reserved. This program and the accompanying materials - * are 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 - * - * Contributors: - * Software Technology Group - TU Dresden, Germany; - * DevBoost GmbH - Berlin, Germany - * - initial API and implementation - ******************************************************************************/ -package de.devboost.buildboost.util; - -import static de.devboost.buildboost.IConstants.ARTIFACTS_FOLDER; -import static de.devboost.buildboost.IConstants.BUILD_BOOST_BIN_FOLDER; -import static de.devboost.buildboost.IConstants.BUILD_BOOST_CORE_PROJECT_ID; -import static de.devboost.buildboost.IConstants.PROJECTS_FOLDER; - -import java.io.File; -import java.io.FileWriter; -import java.io.IOException; -import java.util.List; - -import de.devboost.buildboost.BuildException; -import de.devboost.buildboost.BuildScriptGeneratorRunner; -import de.devboost.buildboost.ant.AntScript; -import de.devboost.buildboost.ant.AntTarget; -import de.devboost.buildboost.model.IBuildStage; - -/** - * The {@link ScriptSaver} class can be used to save the script generated by - * build stages to disc. - */ -public class ScriptSaver { - - /** - * Creates one build script for each build stage and a master script that - * calls the stages subsequently. All script are saved in the given target - * directory and using names. - * - * @param targetDir the directory where to save the scripts - * @param stages the stages used to obtain the scripts - * @throws BuildException thrown if something goes wrong while generating - * build scripts - */ - public void saveStages(File targetDir, List stages) throws BuildException { - // first save scripts for stages - int stageNumber = 1; - for (IBuildStage stage : stages) { - String fileName = getStageFileName(stageNumber); - saveStage(targetDir, stage, fileName); - stageNumber++; - } - saveMasterScript(targetDir, stages); - } - - public void saveMasterScript(File targetDir, List stages) throws BuildException { - // then create master script that calls the scripts for the stages - AntScript masterScript = new AntScript(); - XMLContent content = new XMLContent(); - int lastStageNumber = stages.size() + 1; - for (int i = 1; i < lastStageNumber; i++) { - IBuildStage stage = stages.get(i - 1); - if (stage.isEnabled()) { - content.append(""); - } else { - content.append(""); - } - if (i < lastStageNumber - 1) { - // we must regenerate the build scripts after each stage, - // because stages can rely on the output of the previous one. - content.append(""); - // TODO put this into a macro - content.append(""); - content.append(""); - content.append(""); - content.append(""); - - content.append(""); - content.append(""); - content.append(""); - content.append(""); - content.append(""); - content.append(""); - } - } - AntTarget masterTarget = new AntTarget("buildboost-master", content); - masterScript.addTarget(masterTarget); - // save master script that calls all the stage scripts - save(targetDir, masterScript.getScript(), "buildboost_master.xml"); - } - - public void saveStage(File targetDir, IBuildStage stage, String fileName) - throws BuildException { - AntScript script = stage.getScript(); - save(targetDir, script.getScript(), fileName); - } - - /** - * Returns an auto-generated name for the build stage with the given index. - * - * @param stageNumber the index of the build stage - * @return a file name that is unique for each index - */ - public String getStageFileName(int stageNumber) { - return "buildboost_stage_" + stageNumber + ".xml"; - } - - /** - * Saves the content of the given {@link StringBuffer} to a file. - * - * This method is deprecated. Use {@link IBuildStage}s instead of creating - * the content of build scripts directly. - * - * @param targetDir - * @param content - * @param fileName - * @throws BuildException - */ - @Deprecated // TODO make this method private once all references are removed - public void save(File targetDir, StringBuffer content, String fileName) throws BuildException { - save(targetDir, content.toString(), fileName); - } - - @Deprecated // TODO make this method private once all references are removed - public void save(File targetDir, String content, String fileName) throws BuildException { - try { - targetDir.mkdirs(); - FileWriter writer = new FileWriter(new File(targetDir.getAbsolutePath() + File.separator + fileName)); - writer.append(content); - writer.close(); - } catch (IOException e) { - throw new BuildException("IOException while saving script '" + fileName + "' (" + e.getMessage() + ")."); - } - } -} +/******************************************************************************* + * Copyright (c) 2006-2012 + * Software Technology Group, Dresden University of Technology + * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 + * + * All rights reserved. This program and the accompanying materials + * are 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 + * + * Contributors: + * Software Technology Group - TU Dresden, Germany; + * DevBoost GmbH - Berlin, Germany + * - initial API and implementation + ******************************************************************************/ +package de.devboost.buildboost.util; + +import static de.devboost.buildboost.IConstants.ARTIFACTS_FOLDER; +import static de.devboost.buildboost.IConstants.BUILD_BOOST_BIN_FOLDER; +import static de.devboost.buildboost.IConstants.BUILD_BOOST_CORE_PROJECT_ID; +import static de.devboost.buildboost.IConstants.PROJECTS_FOLDER; + +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; +import java.util.List; + +import de.devboost.buildboost.BuildException; +import de.devboost.buildboost.BuildScriptGeneratorRunner; +import de.devboost.buildboost.ant.AntScript; +import de.devboost.buildboost.ant.AntTarget; +import de.devboost.buildboost.model.IBuildStage; + +/** + * The {@link ScriptSaver} class can be used to save the script generated by + * build stages to disc. + */ +public class ScriptSaver { + + /** + * Creates one build script for each build stage and a master script that + * calls the stages subsequently. All script are saved in the given target + * directory and using names. + * + * @param targetDir the directory where to save the scripts + * @param stages the stages used to obtain the scripts + * @throws BuildException thrown if something goes wrong while generating + * build scripts + */ + public void saveStages(File targetDir, List stages) throws BuildException { + // first save scripts for stages + int stageNumber = 1; + for (IBuildStage stage : stages) { + String fileName = getStageFileName(stageNumber); + saveStage(targetDir, stage, fileName); + stageNumber++; + } + saveMasterScript(targetDir, stages); + } + + public void saveMasterScript(File targetDir, List stages) throws BuildException { + // then create master script that calls the scripts for the stages + AntScript masterScript = new AntScript(); + XMLContent content = new XMLContent(); + int lastStageNumber = stages.size() + 1; + for (int i = 1; i < lastStageNumber; i++) { + IBuildStage stage = stages.get(i - 1); + if (stage.isEnabled()) { + content.append(""); + } else { + content.append(""); + } + if (i < lastStageNumber - 1) { + // we must regenerate the build scripts after each stage, + // because stages can rely on the output of the previous one. + content.append(""); + // TODO put this into a macro + content.append(""); + content.append(""); + content.append(""); + content.append(""); + + content.append(""); + content.append(""); + content.append(""); + content.append(""); + content.append(""); + content.append(""); + } + } + AntTarget masterTarget = new AntTarget("buildboost-master", content); + masterScript.addTarget(masterTarget); + // save master script that calls all the stage scripts + save(targetDir, masterScript.getScript(), "buildboost_master.xml"); + } + + public void saveStage(File targetDir, IBuildStage stage, String fileName) + throws BuildException { + AntScript script = stage.getScript(); + save(targetDir, script.getScript(), fileName); + } + + /** + * Returns an auto-generated name for the build stage with the given index. + * + * @param stageNumber the index of the build stage + * @return a file name that is unique for each index + */ + public String getStageFileName(int stageNumber) { + return "buildboost_stage_" + stageNumber + ".xml"; + } + + /** + * Saves the content of the given {@link StringBuffer} to a file. + * + * This method is deprecated. Use {@link IBuildStage}s instead of creating + * the content of build scripts directly. + * + * @param targetDir + * @param content + * @param fileName + * @throws BuildException + */ + @Deprecated // TODO make this method private once all references are removed + public void save(File targetDir, StringBuffer content, String fileName) throws BuildException { + save(targetDir, content.toString(), fileName); + } + + @Deprecated // TODO make this method private once all references are removed + public void save(File targetDir, String content, String fileName) throws BuildException { + try { + targetDir.mkdirs(); + FileWriter writer = new FileWriter(new File(targetDir.getAbsolutePath() + File.separator + fileName)); + writer.append(content); + writer.close(); + } catch (IOException e) { + throw new BuildException("IOException while saving script '" + fileName + "' (" + e.getMessage() + ")."); + } + } +} diff --git a/Core/de.devboost.buildboost/src/de/devboost/buildboost/util/Sorter.java b/Core/de.devboost.buildboost/src/de/devboost/buildboost/util/Sorter.java index 4842209..d958996 100644 --- a/Core/de.devboost.buildboost/src/de/devboost/buildboost/util/Sorter.java +++ b/Core/de.devboost.buildboost/src/de/devboost/buildboost/util/Sorter.java @@ -1,224 +1,224 @@ -/******************************************************************************* - * Copyright (c) 2006-2012 - * Software Technology Group, Dresden University of Technology - * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 - * - * All rights reserved. This program and the accompanying materials - * are 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 - * - * Contributors: - * Software Technology Group - TU Dresden, Germany; - * DevBoost GmbH - Berlin, Germany - * - initial API and implementation - ******************************************************************************/ -package de.devboost.buildboost.util; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.Iterator; -import java.util.LinkedHashMap; -import java.util.LinkedHashSet; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.Queue; -import java.util.Set; - -import de.devboost.buildboost.artifacts.Package; -import de.devboost.buildboost.model.IDependable; - -/** - * A class to sort artifacts topologically in order to determine a reasonable - * order in which they must be built. - */ -public class Sorter { - - public List findCycle(IDependable start) { - return findCycle(start, Collections.emptySet()); - } - - public List findCycle(IDependable start, Set ignore) { - Set visitedPlugins = new LinkedHashSet(); - visitedPlugins.add(start); - - return findCycle(start, ignore, visitedPlugins); - } - - private List findCycle(IDependable artifact, Set ignore, Set visitedPlugins) { - Collection dependencies = new LinkedHashSet(artifact.getDependencies()); - dependencies.removeAll(ignore); - - for (IDependable dependency : dependencies) { - if (visitedPlugins.contains(dependency)) { - // found cycle - List cycle = new ArrayList(1); - cycle.add(dependency); - return cycle; - } else { - Set subVisited = new LinkedHashSet(); - subVisited.addAll(visitedPlugins); - subVisited.add(dependency); - List cycle = findCycle(dependency, ignore, subVisited); - if (cycle != null) { - cycle.add(dependency); - return cycle; - } - } - } - return null; - } - - /** - * Returns the transient hull of dependencies for the given collection of - * artifacts. - * - * @param artifacts - * @return - */ - public Set getTransientHull(Collection artifacts) { - Set toAnalyze = new LinkedHashSet(); - toAnalyze.addAll(artifacts); - - Set result = new LinkedHashSet(); - while (!toAnalyze.isEmpty()) { - IDependable next = toAnalyze.iterator().next(); - result.add(next); - toAnalyze.remove(next); - Collection dependencies = next.getDependencies(); - for (IDependable dependency : dependencies) { - if (!result.contains(dependency)) { - toAnalyze.add(dependency); - } - } - } - return result; - } - - public List topologicalSort(List list) { - return topologicalSort(list, Collections.emptySet()); - } - - /** - * Sorts the given list of artifacts topologically according to their - * declared dependencies. - */ - public List topologicalSort(List artifacts, Set artifactsToIgnore) { - // check that set of artifacts is complete - Set transientHull = getTransientHull(artifacts); - transientHull.removeAll(artifactsToIgnore); - transientHull.removeAll(artifacts); - if (!transientHull.isEmpty()) { - throw new RuntimeException("Can't sort artifacts topologically, some dependencies are missing (" + transientHull + ")."); - } - - int totalListSize = artifacts.size(); - Map> graph = new LinkedHashMap>(); - Queue queue = new LinkedList(); - IDependable[] sorted = new IDependable[totalListSize]; - // create dependency graph - for (int i = 0; i < artifacts.size(); i++) { - graph.put(artifacts.get(i), new LinkedHashSet()); - - Collection requiredJobs = new LinkedHashSet(); - requiredJobs.addAll(artifacts.get(i).getDependencies()); - requiredJobs.removeAll(artifactsToIgnore); - - Set dependencySet = (Set) graph.get(artifacts.get(i)); - for (IDependable requiredJob : requiredJobs) { - dependencySet.add(requiredJob); - } - // artifacts that do not depend on other artifacts are the starting - // point for the creation of the topological order - if (dependencySet.isEmpty()) { - queue.add(artifacts.get(i)); - } - } - - // Getting the nodes in sorted order - int index = 0; - while (!queue.isEmpty()) { - IDependable next = queue.remove(); - sorted[index++] = next; - Iterator iter = graph.keySet().iterator(); - while (iter.hasNext()) { - // for each key in graph - // check if node is not already removed - IDependable key = iter.next(); - Set dependencySet = (Set) graph.get(key); - if (!dependencySet.isEmpty()) { - dependencySet.remove(next); - if (next instanceof Package) { - //TODO this is needed because the fairly complex package - // import/export mechanism of OSGi which allows multiple - // (re-)exports of the same package - removeAllSimilarPackages(dependencySet, (Package) next); - } - // if this node now has zero incoming edges - if (dependencySet.isEmpty()) { - queue.add(key); - } - } - } - } - - if (index < totalListSize) { - throw new RuntimeException("Cycle detected in plug-in dependencies or plug-in is missing from set of all plug-ins."); - } - - List result = new ArrayList(sorted.length); - for (IDependable next : sorted) { - result.add(next); - } - return result; - } - - private void removeAllSimilarPackages(Set dependencySet, Package p) { - for (Iterator i = dependencySet.iterator(); i.hasNext();) { - IDependable next = i.next(); - if (next instanceof Package && - ((Package) next).getIdentifier().endsWith(p.getIdentifier())) { - i.remove(); - } - } - } - - /** - * Sorts the given list of artifacts topologically and creates a bucket for - * each set of artifacts where artifacts are on the same topological level. - * - * @param artifacts - * @return - */ - public List> sortTopologicallyToBuckets( - List artifacts) { - List sorted = topologicalSort(artifacts); - List> buckets = new ArrayList>(); - List bucket = new ArrayList(); - for (IDependable next : sorted) { - // check whether the current bucket is a fresh one - if (bucket.isEmpty()) { - bucket.add(next); - continue; - } - // check whether the current bucket contains an artifact the - // current element depends on - for (IDependable nextInBucket : bucket) { - boolean hasDependencyToBucket = next.getDependencies().contains(nextInBucket); - if (hasDependencyToBucket) { - // create new bucket - buckets.add(bucket); - bucket = new ArrayList(); - break; - } - } - bucket.add(next); - } - if (!bucket.isEmpty()) { - buckets.add(bucket); - } - return buckets; - } -} +/******************************************************************************* + * Copyright (c) 2006-2012 + * Software Technology Group, Dresden University of Technology + * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 + * + * All rights reserved. This program and the accompanying materials + * are 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 + * + * Contributors: + * Software Technology Group - TU Dresden, Germany; + * DevBoost GmbH - Berlin, Germany + * - initial API and implementation + ******************************************************************************/ +package de.devboost.buildboost.util; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.Iterator; +import java.util.LinkedHashMap; +import java.util.LinkedHashSet; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.Queue; +import java.util.Set; + +import de.devboost.buildboost.artifacts.Package; +import de.devboost.buildboost.model.IDependable; + +/** + * A class to sort artifacts topologically in order to determine a reasonable + * order in which they must be built. + */ +public class Sorter { + + public List findCycle(IDependable start) { + return findCycle(start, Collections.emptySet()); + } + + public List findCycle(IDependable start, Set ignore) { + Set visitedPlugins = new LinkedHashSet(); + visitedPlugins.add(start); + + return findCycle(start, ignore, visitedPlugins); + } + + private List findCycle(IDependable artifact, Set ignore, Set visitedPlugins) { + Collection dependencies = new LinkedHashSet(artifact.getDependencies()); + dependencies.removeAll(ignore); + + for (IDependable dependency : dependencies) { + if (visitedPlugins.contains(dependency)) { + // found cycle + List cycle = new ArrayList(1); + cycle.add(dependency); + return cycle; + } else { + Set subVisited = new LinkedHashSet(); + subVisited.addAll(visitedPlugins); + subVisited.add(dependency); + List cycle = findCycle(dependency, ignore, subVisited); + if (cycle != null) { + cycle.add(dependency); + return cycle; + } + } + } + return null; + } + + /** + * Returns the transient hull of dependencies for the given collection of + * artifacts. + * + * @param artifacts + * @return + */ + public Set getTransientHull(Collection artifacts) { + Set toAnalyze = new LinkedHashSet(); + toAnalyze.addAll(artifacts); + + Set result = new LinkedHashSet(); + while (!toAnalyze.isEmpty()) { + IDependable next = toAnalyze.iterator().next(); + result.add(next); + toAnalyze.remove(next); + Collection dependencies = next.getDependencies(); + for (IDependable dependency : dependencies) { + if (!result.contains(dependency)) { + toAnalyze.add(dependency); + } + } + } + return result; + } + + public List topologicalSort(List list) { + return topologicalSort(list, Collections.emptySet()); + } + + /** + * Sorts the given list of artifacts topologically according to their + * declared dependencies. + */ + public List topologicalSort(List artifacts, Set artifactsToIgnore) { + // check that set of artifacts is complete + Set transientHull = getTransientHull(artifacts); + transientHull.removeAll(artifactsToIgnore); + transientHull.removeAll(artifacts); + if (!transientHull.isEmpty()) { + throw new RuntimeException("Can't sort artifacts topologically, some dependencies are missing (" + transientHull + ")."); + } + + int totalListSize = artifacts.size(); + Map> graph = new LinkedHashMap>(); + Queue queue = new LinkedList(); + IDependable[] sorted = new IDependable[totalListSize]; + // create dependency graph + for (int i = 0; i < artifacts.size(); i++) { + graph.put(artifacts.get(i), new LinkedHashSet()); + + Collection requiredJobs = new LinkedHashSet(); + requiredJobs.addAll(artifacts.get(i).getDependencies()); + requiredJobs.removeAll(artifactsToIgnore); + + Set dependencySet = (Set) graph.get(artifacts.get(i)); + for (IDependable requiredJob : requiredJobs) { + dependencySet.add(requiredJob); + } + // artifacts that do not depend on other artifacts are the starting + // point for the creation of the topological order + if (dependencySet.isEmpty()) { + queue.add(artifacts.get(i)); + } + } + + // Getting the nodes in sorted order + int index = 0; + while (!queue.isEmpty()) { + IDependable next = queue.remove(); + sorted[index++] = next; + Iterator iter = graph.keySet().iterator(); + while (iter.hasNext()) { + // for each key in graph + // check if node is not already removed + IDependable key = iter.next(); + Set dependencySet = (Set) graph.get(key); + if (!dependencySet.isEmpty()) { + dependencySet.remove(next); + if (next instanceof Package) { + //TODO this is needed because the fairly complex package + // import/export mechanism of OSGi which allows multiple + // (re-)exports of the same package + removeAllSimilarPackages(dependencySet, (Package) next); + } + // if this node now has zero incoming edges + if (dependencySet.isEmpty()) { + queue.add(key); + } + } + } + } + + if (index < totalListSize) { + throw new RuntimeException("Cycle detected in plug-in dependencies or plug-in is missing from set of all plug-ins."); + } + + List result = new ArrayList(sorted.length); + for (IDependable next : sorted) { + result.add(next); + } + return result; + } + + private void removeAllSimilarPackages(Set dependencySet, Package p) { + for (Iterator i = dependencySet.iterator(); i.hasNext();) { + IDependable next = i.next(); + if (next instanceof Package && + ((Package) next).getIdentifier().endsWith(p.getIdentifier())) { + i.remove(); + } + } + } + + /** + * Sorts the given list of artifacts topologically and creates a bucket for + * each set of artifacts where artifacts are on the same topological level. + * + * @param artifacts + * @return + */ + public List> sortTopologicallyToBuckets( + List artifacts) { + List sorted = topologicalSort(artifacts); + List> buckets = new ArrayList>(); + List bucket = new ArrayList(); + for (IDependable next : sorted) { + // check whether the current bucket is a fresh one + if (bucket.isEmpty()) { + bucket.add(next); + continue; + } + // check whether the current bucket contains an artifact the + // current element depends on + for (IDependable nextInBucket : bucket) { + boolean hasDependencyToBucket = next.getDependencies().contains(nextInBucket); + if (hasDependencyToBucket) { + // create new bucket + buckets.add(bucket); + bucket = new ArrayList(); + break; + } + } + bucket.add(next); + } + if (!bucket.isEmpty()) { + buckets.add(bucket); + } + return buckets; + } +} diff --git a/Core/de.devboost.buildboost/src/de/devboost/buildboost/util/StreamUtil.java b/Core/de.devboost.buildboost/src/de/devboost/buildboost/util/StreamUtil.java index 28f6ac6..a7e8919 100644 --- a/Core/de.devboost.buildboost/src/de/devboost/buildboost/util/StreamUtil.java +++ b/Core/de.devboost.buildboost/src/de/devboost/buildboost/util/StreamUtil.java @@ -1,34 +1,34 @@ -/******************************************************************************* - * Copyright (c) 2006-2012 - * Software Technology Group, Dresden University of Technology - * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 - * - * All rights reserved. This program and the accompanying materials - * are 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 - * - * Contributors: - * Software Technology Group - TU Dresden, Germany; - * DevBoost GmbH - Berlin, Germany - * - initial API and implementation - ******************************************************************************/ -package de.devboost.buildboost.util; - -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; - -public class StreamUtil { - - public String getContentAsString(InputStream inputStream) throws IOException { - StringBuffer content = new StringBuffer(); - InputStreamReader reader = new InputStreamReader(inputStream); - int next = -1; - while ((next = reader.read()) >= 0) { - content.append((char) next); - } - // TODO close the stream? - return content.toString(); - } -} +/******************************************************************************* + * Copyright (c) 2006-2012 + * Software Technology Group, Dresden University of Technology + * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 + * + * All rights reserved. This program and the accompanying materials + * are 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 + * + * Contributors: + * Software Technology Group - TU Dresden, Germany; + * DevBoost GmbH - Berlin, Germany + * - initial API and implementation + ******************************************************************************/ +package de.devboost.buildboost.util; + +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; + +public class StreamUtil { + + public String getContentAsString(InputStream inputStream) throws IOException { + StringBuffer content = new StringBuffer(); + InputStreamReader reader = new InputStreamReader(inputStream); + int next = -1; + while ((next = reader.read()) >= 0) { + content.append((char) next); + } + // TODO close the stream? + return content.toString(); + } +} diff --git a/Core/de.devboost.buildboost/src/de/devboost/buildboost/util/StringUtil.java b/Core/de.devboost.buildboost/src/de/devboost/buildboost/util/StringUtil.java index b40c4a6..019d583 100644 --- a/Core/de.devboost.buildboost/src/de/devboost/buildboost/util/StringUtil.java +++ b/Core/de.devboost.buildboost/src/de/devboost/buildboost/util/StringUtil.java @@ -1,47 +1,47 @@ -/******************************************************************************* - * Copyright (c) 2006-2012 - * Software Technology Group, Dresden University of Technology - * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 - * - * All rights reserved. This program and the accompanying materials - * are 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 - * - * Contributors: - * Software Technology Group - TU Dresden, Germany; - * DevBoost GmbH - Berlin, Germany - * - initial API and implementation - ******************************************************************************/ -package de.devboost.buildboost.util; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.Iterator; -import java.util.List; - -public class StringUtil { - - public String explode(Object[] parts, String glue) { - List list = Arrays.asList(parts); - List stringList = new ArrayList(list.size()); - for (Object next : list) { - stringList.add(next.toString()); - } - return explode(stringList, glue); - } - - public String explode(Collection parts, String glue) { - StringBuffer result = new StringBuffer(); - int size = parts.size(); - Iterator iterator = parts.iterator(); - for (int i = 0; i < size; i++) { - result.append(iterator.next()); - if (i < size - 1) { - result.append(glue); - } - } - return result.toString(); - } -} +/******************************************************************************* + * Copyright (c) 2006-2012 + * Software Technology Group, Dresden University of Technology + * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 + * + * All rights reserved. This program and the accompanying materials + * are 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 + * + * Contributors: + * Software Technology Group - TU Dresden, Germany; + * DevBoost GmbH - Berlin, Germany + * - initial API and implementation + ******************************************************************************/ +package de.devboost.buildboost.util; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Iterator; +import java.util.List; + +public class StringUtil { + + public String explode(Object[] parts, String glue) { + List list = Arrays.asList(parts); + List stringList = new ArrayList(list.size()); + for (Object next : list) { + stringList.add(next.toString()); + } + return explode(stringList, glue); + } + + public String explode(Collection parts, String glue) { + StringBuffer result = new StringBuffer(); + int size = parts.size(); + Iterator iterator = parts.iterator(); + for (int i = 0; i < size; i++) { + result.append(iterator.next()); + if (i < size - 1) { + result.append(glue); + } + } + return result.toString(); + } +} diff --git a/Core/de.devboost.buildboost/src/de/devboost/buildboost/util/SystemOutListener.java b/Core/de.devboost.buildboost/src/de/devboost/buildboost/util/SystemOutListener.java index 69fad6b..d4e8840 100644 --- a/Core/de.devboost.buildboost/src/de/devboost/buildboost/util/SystemOutListener.java +++ b/Core/de.devboost.buildboost/src/de/devboost/buildboost/util/SystemOutListener.java @@ -1,30 +1,30 @@ -/******************************************************************************* - * Copyright (c) 2006-2012 - * Software Technology Group, Dresden University of Technology - * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 - * - * All rights reserved. This program and the accompanying materials - * are 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 - * - * Contributors: - * Software Technology Group - TU Dresden, Germany; - * DevBoost GmbH - Berlin, Germany - * - initial API and implementation - ******************************************************************************/ -package de.devboost.buildboost.util; - -import de.devboost.buildboost.model.BuildEventType; -import de.devboost.buildboost.model.IBuildListener; - -/** - * A basic implementation of the {@link IBuildListener} interface that prints - * all build events to System.out. - */ -public class SystemOutListener implements IBuildListener { - - public void handleBuildEvent(BuildEventType type, String message) { - System.out.println(type.name() + ": " + message); - } -} +/******************************************************************************* + * Copyright (c) 2006-2012 + * Software Technology Group, Dresden University of Technology + * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 + * + * All rights reserved. This program and the accompanying materials + * are 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 + * + * Contributors: + * Software Technology Group - TU Dresden, Germany; + * DevBoost GmbH - Berlin, Germany + * - initial API and implementation + ******************************************************************************/ +package de.devboost.buildboost.util; + +import de.devboost.buildboost.model.BuildEventType; +import de.devboost.buildboost.model.IBuildListener; + +/** + * A basic implementation of the {@link IBuildListener} interface that prints + * all build events to System.out. + */ +public class SystemOutListener implements IBuildListener { + + public void handleBuildEvent(BuildEventType type, String message) { + System.out.println(type.name() + ": " + message); + } +} diff --git a/Core/de.devboost.buildboost/src/de/devboost/buildboost/util/XMLContent.java b/Core/de.devboost.buildboost/src/de/devboost/buildboost/util/XMLContent.java index ca39082..5ce91be 100644 --- a/Core/de.devboost.buildboost/src/de/devboost/buildboost/util/XMLContent.java +++ b/Core/de.devboost.buildboost/src/de/devboost/buildboost/util/XMLContent.java @@ -1,102 +1,102 @@ -/******************************************************************************* - * Copyright (c) 2006-2012 - * Software Technology Group, Dresden University of Technology - * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 - * - * All rights reserved. This program and the accompanying materials - * are 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 - * - * Contributors: - * Software Technology Group - TU Dresden, Germany; - * DevBoost GmbH - Berlin, Germany - * - initial API and implementation - ******************************************************************************/ -package de.devboost.buildboost.util; - -import static de.devboost.buildboost.IConstants.NL; - -import java.util.ArrayList; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; - -/** - * XMLContent objects can be used to compose contents for XML files. The - * XMLContent class automatically handles line breaks and indentation. - */ -public class XMLContent { - - private List lines = new ArrayList(); - - public void append(String text) { - lines.add(text); - } - - public void append(XMLContent content) { - lines.addAll(content.lines); - } - - private String composeContent() { - int indentation = 0; - Map tabMap = new LinkedHashMap(); - StringBuilder content = new StringBuilder(); - - for (String text : lines) { - if (NL.equals(text)) { - content.append(NL); - continue; - } - // tag that is closed on the same line or comment or XML header - if (text.endsWith("/>") || text.endsWith("-->") || text.endsWith("?>") || text.matches(".*<.+>.+")) { - content.append(getTabs(indentation, tabMap)); - content.append(text); - content.append(NL); - } else if (text.endsWith(">") && !text.startsWith(" tabMap) { - String tabs = tabMap.get(indentation); - if (tabs == null) { - tabs = getTabString(indentation); - tabMap.put(indentation, tabs); - } - return tabs; - } - - private String getTabString(int indentation) { - StringBuilder tabs = new StringBuilder(); - for (int i = 0; i < indentation; i++) { - tabs.append('\t'); - } - return tabs.toString(); - } - - @Override - public String toString() { - return composeContent(); - } - - public void appendLineBreak() { - append(de.devboost.buildboost.IConstants.NL); - } -} +/******************************************************************************* + * Copyright (c) 2006-2012 + * Software Technology Group, Dresden University of Technology + * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 + * + * All rights reserved. This program and the accompanying materials + * are 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 + * + * Contributors: + * Software Technology Group - TU Dresden, Germany; + * DevBoost GmbH - Berlin, Germany + * - initial API and implementation + ******************************************************************************/ +package de.devboost.buildboost.util; + +import static de.devboost.buildboost.IConstants.NL; + +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; + +/** + * XMLContent objects can be used to compose contents for XML files. The + * XMLContent class automatically handles line breaks and indentation. + */ +public class XMLContent { + + private List lines = new ArrayList(); + + public void append(String text) { + lines.add(text); + } + + public void append(XMLContent content) { + lines.addAll(content.lines); + } + + private String composeContent() { + int indentation = 0; + Map tabMap = new LinkedHashMap(); + StringBuilder content = new StringBuilder(); + + for (String text : lines) { + if (NL.equals(text)) { + content.append(NL); + continue; + } + // tag that is closed on the same line or comment or XML header + if (text.endsWith("/>") || text.endsWith("-->") || text.endsWith("?>") || text.matches(".*<.+>.+")) { + content.append(getTabs(indentation, tabMap)); + content.append(text); + content.append(NL); + } else if (text.endsWith(">") && !text.startsWith(" tabMap) { + String tabs = tabMap.get(indentation); + if (tabs == null) { + tabs = getTabString(indentation); + tabMap.put(indentation, tabs); + } + return tabs; + } + + private String getTabString(int indentation) { + StringBuilder tabs = new StringBuilder(); + for (int i = 0; i < indentation; i++) { + tabs.append('\t'); + } + return tabs.toString(); + } + + @Override + public String toString() { + return composeContent(); + } + + public void appendLineBreak() { + append(de.devboost.buildboost.IConstants.NL); + } +} diff --git a/Extensions/EMF/de.devboost.buildboost.buildext.emf/.classpath b/Extensions/EMF/de.devboost.buildboost.buildext.emf/.classpath index ed2bc12..121e527 100644 --- a/Extensions/EMF/de.devboost.buildboost.buildext.emf/.classpath +++ b/Extensions/EMF/de.devboost.buildboost.buildext.emf/.classpath @@ -1,7 +1,7 @@ - - - - - - - + + + + + + + diff --git a/Extensions/EMF/de.devboost.buildboost.buildext.emf/.settings/org.eclipse.jdt.core.prefs b/Extensions/EMF/de.devboost.buildboost.buildext.emf/.settings/org.eclipse.jdt.core.prefs index 8f9a800..3032e86 100644 --- a/Extensions/EMF/de.devboost.buildboost.buildext.emf/.settings/org.eclipse.jdt.core.prefs +++ b/Extensions/EMF/de.devboost.buildboost.buildext.emf/.settings/org.eclipse.jdt.core.prefs @@ -1,12 +1,12 @@ -#Mon Dec 05 20:09:53 CET 2011 -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 -org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.6 -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.enumIdentifier=error -org.eclipse.jdt.core.compiler.source=1.6 +#Mon Dec 05 20:09:53 CET 2011 +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.6 +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.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.6 diff --git a/Extensions/EMF/de.devboost.buildboost.buildext.emf/build.properties b/Extensions/EMF/de.devboost.buildboost.buildext.emf/build.properties index a12d47e..b107977 100644 --- a/Extensions/EMF/de.devboost.buildboost.buildext.emf/build.properties +++ b/Extensions/EMF/de.devboost.buildboost.buildext.emf/build.properties @@ -1,3 +1,3 @@ -source.. = src/ -bin.includes = META-INF/,\ - . +source.. = src/ +bin.includes = META-INF/,\ + . diff --git a/Extensions/EMF/de.devboost.buildboost.buildext.emf/src/de/devboost/buildboost/buildext/emf/HeadlessCodeGenerator.java b/Extensions/EMF/de.devboost.buildboost.buildext.emf/src/de/devboost/buildboost/buildext/emf/HeadlessCodeGenerator.java index 3cf27af..5b36544 100644 --- a/Extensions/EMF/de.devboost.buildboost.buildext.emf/src/de/devboost/buildboost/buildext/emf/HeadlessCodeGenerator.java +++ b/Extensions/EMF/de.devboost.buildboost.buildext.emf/src/de/devboost/buildboost/buildext/emf/HeadlessCodeGenerator.java @@ -1,196 +1,222 @@ -/******************************************************************************* - * Copyright (c) 2006-2012 - * Software Technology Group, Dresden University of Technology - * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 - * - * All rights reserved. This program and the accompanying materials - * are 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 - * - * Contributors: - * Software Technology Group - TU Dresden, Germany; - * DevBoost GmbH - Berlin, Germany - * - initial API and implementation - ******************************************************************************/ -package de.devboost.buildboost.buildext.emf; - -import java.io.File; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -import org.eclipse.emf.codegen.ecore.generator.Generator; -import org.eclipse.emf.codegen.ecore.generator.GeneratorAdapterFactory; -import org.eclipse.emf.codegen.ecore.generator.GeneratorAdapterFactory.Descriptor.Registry; -import org.eclipse.emf.codegen.ecore.genmodel.GenModel; -import org.eclipse.emf.codegen.ecore.genmodel.GenModelPackage; -import org.eclipse.emf.codegen.ecore.genmodel.generator.GenBaseGeneratorAdapter; -import org.eclipse.emf.codegen.ecore.genmodel.generator.GenModelGeneratorAdapterFactory; -import org.eclipse.emf.common.util.BasicMonitor; -import org.eclipse.emf.common.util.Diagnostic; -import org.eclipse.emf.common.util.URI; -import org.eclipse.emf.ecore.EcorePackage; -import org.eclipse.emf.ecore.plugin.EcorePlugin; -import org.eclipse.emf.ecore.resource.Resource; -import org.eclipse.emf.ecore.resource.ResourceSet; -import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; -import org.eclipse.emf.ecore.xmi.impl.EcoreResourceFactoryImpl; - -import de.devboost.buildboost.artifacts.Plugin; -import de.devboost.buildboost.genext.emf.stages.GenerateEMFCodeStage; -import de.devboost.buildboost.genext.emf.steps.GenerateGenModelCodeStep; - -/** - * The {@link HeadlessCodeGenerator} is executed by build scripts that are - * generated by the {@link GenerateEMFCodeStage} or the - * {@link GenerateGenModelCodeStep}. It uses the EMF code generators to obtain - * Java code for given generator models. - */ -public class HeadlessCodeGenerator { - - public static void main(String[] args) throws Exception { - // TODO use properties file to pass arguments instead - // TODO add property 'generateEditCode' the is set to true by the - // build script generator if there is a respective edit plug-in. - String pathToGenModel = args[0]; - String projectName = args[1]; - String projectPath = args[2]; - List pluginPaths = new ArrayList(); - for (int i = 3; i < args.length; i++) { - pluginPaths.add(args[i]); - } - new HeadlessCodeGenerator().run(pathToGenModel, projectName, projectPath, pluginPaths); - } - - private void run(String pathToGenModel, String projectName, String projectPath, List pluginPaths) throws Exception { - ResourceSet rs = new ResourceSetImpl(); - - registerFactoriesAndPackages(rs); - registerURIMappings(rs, pluginPaths); - - EcorePlugin.getPlatformResourceMap().put( - projectName, - URI.createFileURI(projectPath + File.separator) - ); - - GenModel genModel = loadGenModel(pathToGenModel, rs); - registerCodeGenAdapter(); - generateCode(genModel, projectPath); - } - - private void generateCode(GenModel genModel, String projectPath) { - // Create the generator and set the model-level input object. - Generator generator = new Generator(); - generator.setInput(genModel); - genModel.setFacadeHelperClass(getClass().getName()); - - // Generator model code. - // EMF 2.8: This logs an exception to the console which is not a problem in our case. - // The logging was introduced in 2.8: https://bugs.eclipse.org/bugs/show_bug.cgi?id=359551 - Diagnostic result = generator.generate( - genModel, - GenBaseGeneratorAdapter.MODEL_PROJECT_TYPE, - new BasicMonitor.Printing(System.out) - ); - printDiagnostic(result); - - if (generateEditCode(genModel, projectPath)) { - result = generator.generate( - genModel, - GenBaseGeneratorAdapter.EDIT_PROJECT_TYPE, - new BasicMonitor.Printing(System.out) - ); - printDiagnostic(result); - } - } - - private boolean generateEditCode(GenModel genModel, String projectPath) { - File workDir = new File(projectPath).getParentFile(); - String editDirectory = genModel.getEditDirectory(); - if (!editDirectory.endsWith("src-gen")) { - return false; - } - - if (editDirectory.startsWith("/")) { - editDirectory = editDirectory.substring(1); - } - String editProjectName = editDirectory.substring(0, editDirectory.indexOf("/")); - File editProjectDir = new File(workDir, editProjectName); - if (!editProjectDir.exists()) { - return false; - } - - EcorePlugin.getPlatformResourceMap().put( - editProjectName, - URI.createFileURI(editProjectDir.getAbsolutePath() + File.separator) - ); - - - return editProjectDir.exists(); - } - - private void registerCodeGenAdapter() { - Registry adapterRegistry = GeneratorAdapterFactory.Descriptor.Registry.INSTANCE; - adapterRegistry.addDescriptor(GenModelPackage.eNS_URI, GenModelGeneratorAdapterFactory.DESCRIPTOR); - } - - private GenModel loadGenModel(String pathToGenModel, ResourceSet rs) { - URI uri = URI.createFileURI(pathToGenModel); - Resource resource = rs.getResource(uri, true); - // TODO add checks - GenModel genModel = (GenModel) resource.getContents().get(0); - // reconcile the GenModel: Since the IDE does also do this in the - // background on opening a GenModel, it can happen, that the model - // is not up-to-date w.r.t. the underlying Ecore model. - genModel.reconcile(); - genModel.setCanGenerate(true); - return genModel; - } - - private void registerURIMappings(ResourceSet rs, List pluginPaths) throws Exception { - Map uriMap = rs.getURIConverter().getURIMap(); - for (String pluginPath : pluginPaths) { - File pluginFile = new File(pluginPath); - if (pluginFile.isDirectory() && !pluginPath.endsWith("/")) { - pluginPath = pluginPath + "/"; - } - Plugin plugin = new Plugin(pluginFile); - String identifier = plugin.getIdentifier(); - URI from = URI.createPlatformPluginURI(identifier + "/", true); - URI to = URI.createFileURI(pluginPath); - if ("jar".equals(to.fileExtension())) { - to = URI.createURI("archive:" + to.toString() + "!/"); - } else if (!"".equals(to.lastSegment())) { - to = to.appendSegment(""); - } - //System.out.println("Mapping URI " + from + " to " + to); - uriMap.put( - from, - to - ); - } - } - - private void registerFactoriesAndPackages(ResourceSet rs) { - // TODO we must search the target platform for registered resource factories, - // generator models and EPackages. Currently we do solely register the - // resource factories and EPackages for the Ecore and the GenModel - // metamodels. - Map extensionToFactoryMap = rs.getResourceFactoryRegistry().getExtensionToFactoryMap(); - extensionToFactoryMap.put("ecore", new EcoreResourceFactoryImpl()); - extensionToFactoryMap.put("genmodel", new EcoreResourceFactoryImpl()); - - GenModelPackage.eINSTANCE.getGenModel(); - EcorePackage.eINSTANCE.getEPackage(); - } - - private void printDiagnostic(Diagnostic diagnostic) { - // TODO print only warnings and errors? - System.out.println("Diagnostic: " + diagnostic.getMessage()); - List children = diagnostic.getChildren(); - for (Diagnostic child : children) { - printDiagnostic(child); - } - } -} +/******************************************************************************* + * Copyright (c) 2006-2012 + * Software Technology Group, Dresden University of Technology + * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 + * + * All rights reserved. This program and the accompanying materials + * are 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 + * + * Contributors: + * Software Technology Group - TU Dresden, Germany; + * DevBoost GmbH - Berlin, Germany + * - initial API and implementation + ******************************************************************************/ +package de.devboost.buildboost.buildext.emf; + +import java.io.BufferedReader; +import java.io.File; +import java.io.FileReader; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +import org.eclipse.emf.codegen.ecore.generator.Generator; +import org.eclipse.emf.codegen.ecore.generator.GeneratorAdapterFactory; +import org.eclipse.emf.codegen.ecore.generator.GeneratorAdapterFactory.Descriptor.Registry; +import org.eclipse.emf.codegen.ecore.genmodel.GenModel; +import org.eclipse.emf.codegen.ecore.genmodel.GenModelPackage; +import org.eclipse.emf.codegen.ecore.genmodel.generator.GenBaseGeneratorAdapter; +import org.eclipse.emf.codegen.ecore.genmodel.generator.GenModelGeneratorAdapterFactory; +import org.eclipse.emf.common.util.BasicMonitor; +import org.eclipse.emf.common.util.Diagnostic; +import org.eclipse.emf.common.util.URI; +import org.eclipse.emf.ecore.EcorePackage; +import org.eclipse.emf.ecore.plugin.EcorePlugin; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.emf.ecore.resource.ResourceSet; +import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; +import org.eclipse.emf.ecore.xmi.impl.EcoreResourceFactoryImpl; + +import de.devboost.buildboost.artifacts.Plugin; +import de.devboost.buildboost.genext.emf.stages.GenerateEMFCodeStage; +import de.devboost.buildboost.genext.emf.steps.GenerateGenModelCodeStep; + +/** + * The {@link HeadlessCodeGenerator} is executed by build scripts that are + * generated by the {@link GenerateEMFCodeStage} or the + * {@link GenerateGenModelCodeStep}. It uses the EMF code generators to obtain + * Java code for given generator models. + */ +public class HeadlessCodeGenerator { + + public static void main(String[] args) throws Exception { + // TODO use properties file to pass arguments instead + // TODO add property 'generateEditCode' the is set to true by the + // build script generator if there is a respective edit plug-in. + String pathToGenModel = args[0]; + String projectName = args[1]; + String projectPath = args[2]; + List pluginPaths = readPluginPaths(args[3]); + new HeadlessCodeGenerator().run(pathToGenModel, projectName, + projectPath, pluginPaths); + } + + private static List readPluginPaths(final String paraFileName) { + List paths = new ArrayList(); + BufferedReader reader = null; + try { + final FileReader fin = new FileReader(paraFileName); + reader = new BufferedReader(fin); + String line = reader.readLine(); + while (line != null) { + paths.add(line); + line = reader.readLine(); + } + } catch (IOException ex) { + // TODO Auto-generated catch block + ex.printStackTrace(); + } finally { + if (reader != null) { + try { + reader.close(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + } + + return paths; + } + + private void run(String pathToGenModel, String projectName, + String projectPath, List pluginPaths) throws Exception { + ResourceSet rs = new ResourceSetImpl(); + + registerFactoriesAndPackages(rs); + registerURIMappings(rs, pluginPaths); + + EcorePlugin.getPlatformResourceMap().put(projectName, + URI.createFileURI(projectPath + File.separator)); + + GenModel genModel = loadGenModel(pathToGenModel, rs); + registerCodeGenAdapter(); + generateCode(genModel, projectPath); + } + + private void generateCode(GenModel genModel, String projectPath) { + // Create the generator and set the model-level input object. + Generator generator = new Generator(); + generator.setInput(genModel); + genModel.setFacadeHelperClass(getClass().getName()); + + // Generator model code. + // EMF 2.8: This logs an exception to the console which is not a problem + // in our case. + // The logging was introduced in 2.8: + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=359551 + Diagnostic result = generator.generate(genModel, + GenBaseGeneratorAdapter.MODEL_PROJECT_TYPE, + new BasicMonitor.Printing(System.out)); + printDiagnostic(result); + + if (generateEditCode(genModel, projectPath)) { + result = generator.generate(genModel, + GenBaseGeneratorAdapter.EDIT_PROJECT_TYPE, + new BasicMonitor.Printing(System.out)); + printDiagnostic(result); + } + } + + private boolean generateEditCode(GenModel genModel, String projectPath) { + File workDir = new File(projectPath).getParentFile(); + String editDirectory = genModel.getEditDirectory(); + if (!editDirectory.endsWith("src-gen")) { + return false; + } + + if (editDirectory.startsWith("/")) { + editDirectory = editDirectory.substring(1); + } + String editProjectName = editDirectory.substring(0, editDirectory.indexOf("/")); + File editProjectDir = new File(workDir, editProjectName); + if (!editProjectDir.exists()) { + return false; + } + + EcorePlugin.getPlatformResourceMap().put( + editProjectName, + URI.createFileURI(editProjectDir.getAbsolutePath() + + File.separator)); + + return editProjectDir.exists(); + } + + private void registerCodeGenAdapter() { + Registry adapterRegistry = GeneratorAdapterFactory.Descriptor.Registry.INSTANCE; + adapterRegistry.addDescriptor(GenModelPackage.eNS_URI, + GenModelGeneratorAdapterFactory.DESCRIPTOR); + } + + private GenModel loadGenModel(String pathToGenModel, ResourceSet rs) { + URI uri = URI.createFileURI(pathToGenModel); + Resource resource = rs.getResource(uri, true); + // TODO add checks + GenModel genModel = (GenModel) resource.getContents().get(0); + // reconcile the GenModel: Since the IDE does also do this in the + // background on opening a GenModel, it can happen, that the model + // is not up-to-date w.r.t. the underlying Ecore model. + genModel.reconcile(); + genModel.setCanGenerate(true); + return genModel; + } + + private void registerURIMappings(ResourceSet rs, List pluginPaths) + throws Exception { + Map uriMap = rs.getURIConverter().getURIMap(); + for (String pluginPath : pluginPaths) { + File pluginFile = new File(pluginPath); + if (pluginFile.isDirectory() && !pluginPath.endsWith("/")) { + pluginPath = pluginPath + "/"; + } + Plugin plugin = new Plugin(pluginFile); + String identifier = plugin.getIdentifier(); + URI from = URI.createPlatformPluginURI(identifier + "/", true); + URI to = URI.createFileURI(pluginPath); + if ("jar".equals(to.fileExtension())) { + to = URI.createURI("archive:" + to.toString() + "!/"); + } else if (!"".equals(to.lastSegment())) { + to = to.appendSegment(""); + } + // System.out.println("Mapping URI " + from + " to " + to); + uriMap.put(from, to); + } + } + + private void registerFactoriesAndPackages(ResourceSet rs) { + // TODO we must search the target platform for registered resource + // factories, + // generator models and EPackages. Currently we do solely register the + // resource factories and EPackages for the Ecore and the GenModel + // metamodels. + Map extensionToFactoryMap = rs + .getResourceFactoryRegistry().getExtensionToFactoryMap(); + extensionToFactoryMap.put("ecore", new EcoreResourceFactoryImpl()); + extensionToFactoryMap.put("genmodel", new EcoreResourceFactoryImpl()); + + GenModelPackage.eINSTANCE.getGenModel(); + EcorePackage.eINSTANCE.getEPackage(); + } + + private void printDiagnostic(Diagnostic diagnostic) { + // TODO print only warnings and errors? + System.out.println("Diagnostic: " + diagnostic.getMessage()); + List children = diagnostic.getChildren(); + for (Diagnostic child : children) { + printDiagnostic(child); + } + } +} diff --git a/Extensions/EMF/de.devboost.buildboost.genext.emf/src/de/devboost/buildboost/genext/emf/artifacts/GeneratorModel.java b/Extensions/EMF/de.devboost.buildboost.genext.emf/src/de/devboost/buildboost/genext/emf/artifacts/GeneratorModel.java index 818c959..3d7e300 100644 --- a/Extensions/EMF/de.devboost.buildboost.genext.emf/src/de/devboost/buildboost/genext/emf/artifacts/GeneratorModel.java +++ b/Extensions/EMF/de.devboost.buildboost.genext.emf/src/de/devboost/buildboost/genext/emf/artifacts/GeneratorModel.java @@ -1,62 +1,62 @@ -/******************************************************************************* - * Copyright (c) 2006-2012 - * Software Technology Group, Dresden University of Technology - * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 - * - * All rights reserved. This program and the accompanying materials - * are 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 - * - * Contributors: - * Software Technology Group - TU Dresden, Germany; - * DevBoost GmbH - Berlin, Germany - * - initial API and implementation - ******************************************************************************/ -package de.devboost.buildboost.genext.emf.artifacts; - -import java.io.File; - -import de.devboost.buildboost.artifacts.AbstractArtifact; -import de.devboost.buildboost.artifacts.Plugin; -import de.devboost.buildboost.genext.emf.IConstants; -import de.devboost.buildboost.model.UnresolvedDependency; -import de.devboost.buildboost.util.EclipsePluginHelper; - -/** - * A {@link GeneratorModel} represents a file with extension 'genmodel' that is - * used by the Eclipse Modeling Framework (EMF) to configure code generation for - * Ecore models. - */ -@SuppressWarnings("serial") -public class GeneratorModel extends AbstractArtifact { - - private File file; - private File projectDir; - - public GeneratorModel(File file) { - this.file = file; - this.projectDir = new EclipsePluginHelper().findProjectDir(file); - UnresolvedDependency buildBoostDependency = new UnresolvedDependency(Plugin.class, - IConstants.BUILDEXT_PLUGIN_ID, null, true, null, true, false, false); - getUnresolvedDependencies().add(buildBoostDependency); - } - - public String getIdentifier() { - // TODO this is not unique - return file.getName(); - } - - public File getFile() { - return file; - } - - public File getProjectDir() { - return projectDir; - } - - @Override - public long getTimestamp() { - return file.lastModified(); - } -} +/******************************************************************************* + * Copyright (c) 2006-2012 + * Software Technology Group, Dresden University of Technology + * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 + * + * All rights reserved. This program and the accompanying materials + * are 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 + * + * Contributors: + * Software Technology Group - TU Dresden, Germany; + * DevBoost GmbH - Berlin, Germany + * - initial API and implementation + ******************************************************************************/ +package de.devboost.buildboost.genext.emf.artifacts; + +import java.io.File; + +import de.devboost.buildboost.artifacts.AbstractArtifact; +import de.devboost.buildboost.artifacts.Plugin; +import de.devboost.buildboost.genext.emf.IConstants; +import de.devboost.buildboost.model.UnresolvedDependency; +import de.devboost.buildboost.util.EclipsePluginHelper; + +/** + * A {@link GeneratorModel} represents a file with extension 'genmodel' that is + * used by the Eclipse Modeling Framework (EMF) to configure code generation for + * Ecore models. + */ +@SuppressWarnings("serial") +public class GeneratorModel extends AbstractArtifact { + + private File file; + private File projectDir; + + public GeneratorModel(File file) { + this.file = file; + this.projectDir = new EclipsePluginHelper().findProjectDir(file); + UnresolvedDependency buildBoostDependency = new UnresolvedDependency(Plugin.class, + IConstants.BUILDEXT_PLUGIN_ID, null, true, null, true, false, false); + getUnresolvedDependencies().add(buildBoostDependency); + } + + public String getIdentifier() { + // TODO this is not unique + return file.getName(); + } + + public File getFile() { + return file; + } + + public File getProjectDir() { + return projectDir; + } + + @Override + public long getTimestamp() { + return file.lastModified(); + } +} diff --git a/Extensions/EMF/de.devboost.buildboost.genext.emf/src/de/devboost/buildboost/genext/emf/discovery/GenModelFinder.java b/Extensions/EMF/de.devboost.buildboost.genext.emf/src/de/devboost/buildboost/genext/emf/discovery/GenModelFinder.java index 64ac8bd..2401412 100644 --- a/Extensions/EMF/de.devboost.buildboost.genext.emf/src/de/devboost/buildboost/genext/emf/discovery/GenModelFinder.java +++ b/Extensions/EMF/de.devboost.buildboost.genext.emf/src/de/devboost/buildboost/genext/emf/discovery/GenModelFinder.java @@ -1,69 +1,69 @@ -/******************************************************************************* - * Copyright (c) 2006-2012 - * Software Technology Group, Dresden University of Technology - * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 - * - * All rights reserved. This program and the accompanying materials - * are 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 - * - * Contributors: - * Software Technology Group - TU Dresden, Germany; - * DevBoost GmbH - Berlin, Germany - * - initial API and implementation - ******************************************************************************/ -package de.devboost.buildboost.genext.emf.discovery; - -import java.io.File; -import java.io.FileFilter; -import java.util.ArrayList; -import java.util.Collection; - -import de.devboost.buildboost.BuildException; -import de.devboost.buildboost.discovery.AbstractFileFinder; -import de.devboost.buildboost.genext.emf.artifacts.GeneratorModel; -import de.devboost.buildboost.model.IArtifact; -import de.devboost.buildboost.model.IBuildContext; -import de.devboost.buildboost.util.ArtifactUtil; -import de.devboost.buildboost.util.EclipsePluginHelper; - -/** - * A {@link GenModelFinder} can be used to discover EMF generator models (i.e., - * file with extension 'genmodel'). - */ -public class GenModelFinder extends AbstractFileFinder { - - public String TEST_PROJECT_SUFFIX = ".test"; - - public GenModelFinder(File directory) { - super(directory); - } - - public Collection discoverArtifacts(IBuildContext context) throws BuildException { - Collection genModels = new ArrayList(); - traverse(context, genModels); - return new ArtifactUtil().getSetOfArtifacts(genModels); - } - - protected GeneratorModel createArtifactFromFile(File file) { - return new GeneratorModel(file); - } - - protected FileFilter getFileFilter() { - return new FileFilter() { - public boolean accept(File file) { - return file.getName().endsWith(".genmodel") && file.isFile() && - new EclipsePluginHelper().findProjectDir(file) != null; - } - }; - } - - protected FileFilter getDirectoryFilter() { - return new FileFilter() { - public boolean accept(File file) { - return file.isDirectory() && !file.getName().endsWith(TEST_PROJECT_SUFFIX); - } - }; - } -} +/******************************************************************************* + * Copyright (c) 2006-2012 + * Software Technology Group, Dresden University of Technology + * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 + * + * All rights reserved. This program and the accompanying materials + * are 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 + * + * Contributors: + * Software Technology Group - TU Dresden, Germany; + * DevBoost GmbH - Berlin, Germany + * - initial API and implementation + ******************************************************************************/ +package de.devboost.buildboost.genext.emf.discovery; + +import java.io.File; +import java.io.FileFilter; +import java.util.ArrayList; +import java.util.Collection; + +import de.devboost.buildboost.BuildException; +import de.devboost.buildboost.discovery.AbstractFileFinder; +import de.devboost.buildboost.genext.emf.artifacts.GeneratorModel; +import de.devboost.buildboost.model.IArtifact; +import de.devboost.buildboost.model.IBuildContext; +import de.devboost.buildboost.util.ArtifactUtil; +import de.devboost.buildboost.util.EclipsePluginHelper; + +/** + * A {@link GenModelFinder} can be used to discover EMF generator models (i.e., + * file with extension 'genmodel'). + */ +public class GenModelFinder extends AbstractFileFinder { + + public String TEST_PROJECT_SUFFIX = ".test"; + + public GenModelFinder(File directory) { + super(directory); + } + + public Collection discoverArtifacts(IBuildContext context) throws BuildException { + Collection genModels = new ArrayList(); + traverse(context, genModels); + return new ArtifactUtil().getSetOfArtifacts(genModels); + } + + protected GeneratorModel createArtifactFromFile(File file) { + return new GeneratorModel(file); + } + + protected FileFilter getFileFilter() { + return new FileFilter() { + public boolean accept(File file) { + return file.getName().endsWith(".genmodel") && file.isFile() && + new EclipsePluginHelper().findProjectDir(file) != null; + } + }; + } + + protected FileFilter getDirectoryFilter() { + return new FileFilter() { + public boolean accept(File file) { + return file.isDirectory() && !file.getName().endsWith(TEST_PROJECT_SUFFIX); + } + }; + } +} diff --git a/Extensions/EMF/de.devboost.buildboost.genext.emf/src/de/devboost/buildboost/genext/emf/stages/CompileEMFStage.java b/Extensions/EMF/de.devboost.buildboost.genext.emf/src/de/devboost/buildboost/genext/emf/stages/CompileEMFStage.java index 22b58cc..bbabe0a 100644 --- a/Extensions/EMF/de.devboost.buildboost.genext.emf/src/de/devboost/buildboost/genext/emf/stages/CompileEMFStage.java +++ b/Extensions/EMF/de.devboost.buildboost.genext.emf/src/de/devboost/buildboost/genext/emf/stages/CompileEMFStage.java @@ -1,69 +1,69 @@ -/******************************************************************************* - * Copyright (c) 2006-2012 - * Software Technology Group, Dresden University of Technology - * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 - * - * All rights reserved. This program and the accompanying materials - * are 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 - * - * Contributors: - * Software Technology Group - TU Dresden, Germany; - * DevBoost GmbH - Berlin, Germany - * - initial API and implementation - ******************************************************************************/ -package de.devboost.buildboost.genext.emf.stages; - -import java.io.File; -import java.util.LinkedHashSet; -import java.util.Set; - -import de.devboost.buildboost.AutoBuilder; -import de.devboost.buildboost.BuildContext; -import de.devboost.buildboost.BuildException; -import de.devboost.buildboost.ant.AntScript; -import de.devboost.buildboost.discovery.EclipseTargetPlatformAnalyzer; -import de.devboost.buildboost.discovery.PluginFinder; -import de.devboost.buildboost.filters.IdentifierFilter; -import de.devboost.buildboost.model.IUniversalBuildStage; -import de.devboost.buildboost.stages.AbstractBuildStage; -import de.devboost.buildboost.steps.compile.CompileProjectStepProvider; - -public class CompileEMFStage extends AbstractBuildStage implements IUniversalBuildStage { - - private static final Set EMF_BUILDEXT_PLUGIN_IDENTIFIERS = new LinkedHashSet(); - - static { - // also compile BuildBoost EMF plug-in - EMF_BUILDEXT_PLUGIN_IDENTIFIERS.add("de.devboost.buildboost.buildext.emf"); - } - - private String artifactsFolder; - - public void setArtifactsFolder(String artifactsFolder) { - this.artifactsFolder = artifactsFolder; - } - - public AntScript getScript() throws BuildException { - BuildContext context = createContext(false); - context.addBuildParticipant(new EclipseTargetPlatformAnalyzer(new File(artifactsFolder))); - context.addBuildParticipant(new PluginFinder(new File(artifactsFolder))); - - context.addBuildParticipant(new CompileProjectStepProvider()); - - context.addBuildParticipant(new IdentifierFilter(EMF_BUILDEXT_PLUGIN_IDENTIFIERS)); - - AutoBuilder builder = new AutoBuilder(context); - - AntScript script = new AntScript(); - script.setName("Compile EMF CodeGen Extension"); - script.addTargets(builder.generateAntTargets()); - return script; - } - - @Override - public int getPriority() { - return 95; - } -} +/******************************************************************************* + * Copyright (c) 2006-2012 + * Software Technology Group, Dresden University of Technology + * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 + * + * All rights reserved. This program and the accompanying materials + * are 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 + * + * Contributors: + * Software Technology Group - TU Dresden, Germany; + * DevBoost GmbH - Berlin, Germany + * - initial API and implementation + ******************************************************************************/ +package de.devboost.buildboost.genext.emf.stages; + +import java.io.File; +import java.util.LinkedHashSet; +import java.util.Set; + +import de.devboost.buildboost.AutoBuilder; +import de.devboost.buildboost.BuildContext; +import de.devboost.buildboost.BuildException; +import de.devboost.buildboost.ant.AntScript; +import de.devboost.buildboost.discovery.EclipseTargetPlatformAnalyzer; +import de.devboost.buildboost.discovery.PluginFinder; +import de.devboost.buildboost.filters.IdentifierFilter; +import de.devboost.buildboost.model.IUniversalBuildStage; +import de.devboost.buildboost.stages.AbstractBuildStage; +import de.devboost.buildboost.steps.compile.CompileProjectStepProvider; + +public class CompileEMFStage extends AbstractBuildStage implements IUniversalBuildStage { + + private static final Set EMF_BUILDEXT_PLUGIN_IDENTIFIERS = new LinkedHashSet(); + + static { + // also compile BuildBoost EMF plug-in + EMF_BUILDEXT_PLUGIN_IDENTIFIERS.add("de.devboost.buildboost.buildext.emf"); + } + + private String artifactsFolder; + + public void setArtifactsFolder(String artifactsFolder) { + this.artifactsFolder = artifactsFolder; + } + + public AntScript getScript() throws BuildException { + BuildContext context = createContext(false); + context.addBuildParticipant(new EclipseTargetPlatformAnalyzer(new File(artifactsFolder))); + context.addBuildParticipant(new PluginFinder(new File(artifactsFolder))); + + context.addBuildParticipant(new CompileProjectStepProvider()); + + context.addBuildParticipant(new IdentifierFilter(EMF_BUILDEXT_PLUGIN_IDENTIFIERS)); + + AutoBuilder builder = new AutoBuilder(context); + + AntScript script = new AntScript(); + script.setName("Compile EMF CodeGen Extension"); + script.addTargets(builder.generateAntTargets()); + return script; + } + + @Override + public int getPriority() { + return 95; + } +} diff --git a/Extensions/EMF/de.devboost.buildboost.genext.emf/src/de/devboost/buildboost/genext/emf/stages/GenerateEMFCodeStage.java b/Extensions/EMF/de.devboost.buildboost.genext.emf/src/de/devboost/buildboost/genext/emf/stages/GenerateEMFCodeStage.java index 6e85b9d..6060ff7 100644 --- a/Extensions/EMF/de.devboost.buildboost.genext.emf/src/de/devboost/buildboost/genext/emf/stages/GenerateEMFCodeStage.java +++ b/Extensions/EMF/de.devboost.buildboost.genext.emf/src/de/devboost/buildboost/genext/emf/stages/GenerateEMFCodeStage.java @@ -1,61 +1,61 @@ -/******************************************************************************* - * Copyright (c) 2006-2012 - * Software Technology Group, Dresden University of Technology - * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 - * - * All rights reserved. This program and the accompanying materials - * are 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 - * - * Contributors: - * Software Technology Group - TU Dresden, Germany; - * DevBoost GmbH - Berlin, Germany - * - initial API and implementation - ******************************************************************************/ -package de.devboost.buildboost.genext.emf.stages; - -import java.io.File; - -import de.devboost.buildboost.AutoBuilder; -import de.devboost.buildboost.BuildContext; -import de.devboost.buildboost.BuildException; -import de.devboost.buildboost.ant.AntScript; -import de.devboost.buildboost.discovery.EclipseTargetPlatformAnalyzer; -import de.devboost.buildboost.discovery.PluginFinder; -import de.devboost.buildboost.genext.emf.discovery.GenModelFinder; -import de.devboost.buildboost.genext.emf.steps.GenerateGenModelCodeStepProvider; -import de.devboost.buildboost.model.IUniversalBuildStage; -import de.devboost.buildboost.stages.AbstractBuildStage; - -public class GenerateEMFCodeStage extends AbstractBuildStage implements IUniversalBuildStage { - - private String artifactsFolder; - - public void setArtifactsFolder(String artifactsFolder) { - this.artifactsFolder = artifactsFolder; - } - - public AntScript getScript() throws BuildException { - File buildDir = new File(artifactsFolder); - - BuildContext context = createContext(false); - context.addBuildParticipant(new EclipseTargetPlatformAnalyzer(buildDir)); - context.addBuildParticipant(new PluginFinder(buildDir)); - context.addBuildParticipant(new GenModelFinder(buildDir)); - context.addBuildParticipant(new GenerateGenModelCodeStepProvider()); - - AutoBuilder builder = new AutoBuilder(context); - - AntScript script = new AntScript(); - script.setName("Generate code from EMF generator models"); - script.addTargets(builder.generateAntTargets()); - - return script; - } - - @Override - public int getPriority() { - return 1000; - } -} +/******************************************************************************* + * Copyright (c) 2006-2012 + * Software Technology Group, Dresden University of Technology + * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 + * + * All rights reserved. This program and the accompanying materials + * are 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 + * + * Contributors: + * Software Technology Group - TU Dresden, Germany; + * DevBoost GmbH - Berlin, Germany + * - initial API and implementation + ******************************************************************************/ +package de.devboost.buildboost.genext.emf.stages; + +import java.io.File; + +import de.devboost.buildboost.AutoBuilder; +import de.devboost.buildboost.BuildContext; +import de.devboost.buildboost.BuildException; +import de.devboost.buildboost.ant.AntScript; +import de.devboost.buildboost.discovery.EclipseTargetPlatformAnalyzer; +import de.devboost.buildboost.discovery.PluginFinder; +import de.devboost.buildboost.genext.emf.discovery.GenModelFinder; +import de.devboost.buildboost.genext.emf.steps.GenerateGenModelCodeStepProvider; +import de.devboost.buildboost.model.IUniversalBuildStage; +import de.devboost.buildboost.stages.AbstractBuildStage; + +public class GenerateEMFCodeStage extends AbstractBuildStage implements IUniversalBuildStage { + + private String artifactsFolder; + + public void setArtifactsFolder(String artifactsFolder) { + this.artifactsFolder = artifactsFolder; + } + + public AntScript getScript() throws BuildException { + File buildDir = new File(artifactsFolder); + + BuildContext context = createContext(false); + context.addBuildParticipant(new EclipseTargetPlatformAnalyzer(buildDir)); + context.addBuildParticipant(new PluginFinder(buildDir)); + context.addBuildParticipant(new GenModelFinder(buildDir)); + context.addBuildParticipant(new GenerateGenModelCodeStepProvider()); + + AutoBuilder builder = new AutoBuilder(context); + + AntScript script = new AntScript(); + script.setName("Generate code from EMF generator models"); + script.addTargets(builder.generateAntTargets()); + + return script; + } + + @Override + public int getPriority() { + return 1000; + } +} diff --git a/Extensions/EMF/de.devboost.buildboost.genext.emf/src/de/devboost/buildboost/genext/emf/steps/GenerateGenModelCodeStep.java b/Extensions/EMF/de.devboost.buildboost.genext.emf/src/de/devboost/buildboost/genext/emf/steps/GenerateGenModelCodeStep.java index fd8eb13..b484c1a 100644 --- a/Extensions/EMF/de.devboost.buildboost.genext.emf/src/de/devboost/buildboost/genext/emf/steps/GenerateGenModelCodeStep.java +++ b/Extensions/EMF/de.devboost.buildboost.genext.emf/src/de/devboost/buildboost/genext/emf/steps/GenerateGenModelCodeStep.java @@ -1,87 +1,116 @@ -/******************************************************************************* - * Copyright (c) 2006-2012 - * Software Technology Group, Dresden University of Technology - * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 - * - * All rights reserved. This program and the accompanying materials - * are 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 - * - * Contributors: - * Software Technology Group - TU Dresden, Germany; - * DevBoost GmbH - Berlin, Germany - * - initial API and implementation - ******************************************************************************/ -package de.devboost.buildboost.genext.emf.steps; - -import static de.devboost.buildboost.IConstants.NL; - -import java.io.File; -import java.util.Collection; -import java.util.Collections; -import java.util.List; - -import de.devboost.buildboost.BuildException; -import de.devboost.buildboost.ant.AbstractAntTargetGenerator; -import de.devboost.buildboost.ant.AntTarget; -import de.devboost.buildboost.artifacts.Plugin; -import de.devboost.buildboost.genext.emf.IConstants; -import de.devboost.buildboost.genext.emf.artifacts.GeneratorModel; -import de.devboost.buildboost.model.IDependable; -import de.devboost.buildboost.steps.ClasspathHelper; -import de.devboost.buildboost.util.XMLContent; - -/** - * The {@link GenerateGenModelCodeStep} generates a script that calls the EMF - * code generators to obtain code from Ecore models. - */ -public class GenerateGenModelCodeStep extends AbstractAntTargetGenerator { - - public final static String MAIN_TASK = "generate-emf-code"; - - private List plugins; - private GeneratorModel generatorModel; - - public GenerateGenModelCodeStep(List plugins, GeneratorModel generatorModel) { - this.plugins = plugins; - this.generatorModel = generatorModel; - } - - public Collection generateAntTargets() throws BuildException { - Collection dependencies = generatorModel.getDependencies(); - if (dependencies.isEmpty()) { - throw new BuildException("Generator models are expected to have a dependency to the BuildBoost EMF plug-in."); - } - XMLContent classpath = new ClasspathHelper().getClasspath(generatorModel, true); - - File genModelFile = generatorModel.getFile(); - String genModelPath = genModelFile.getAbsolutePath(); - - XMLContent sb = new XMLContent(); - sb.append(""); - sb.append(""); - sb.append(NL); - - sb.append(""); - // TODO use constant here - sb.append(""); - sb.append(""); - sb.append(""); - sb.append(""); - sb.append(""); - sb.append(""); - for (Plugin plugin : plugins) { - sb.append(""); - } - sb.append(""); - sb.append(classpath); - sb.append(""); - sb.append(""); - sb.append(NL); - - String genModelID = genModelPath.toString().replace(File.separator, "-"); - - return Collections.singleton(new AntTarget("emf-codegen-" + genModelID, sb)); - } -} +/******************************************************************************* + * Copyright (c) 2006-2012 + * Software Technology Group, Dresden University of Technology + * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 + * + * All rights reserved. This program and the accompanying materials + * are 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 + * + * Contributors: + * Software Technology Group - TU Dresden, Germany; + * DevBoost GmbH - Berlin, Germany + * - initial API and implementation + ******************************************************************************/ +package de.devboost.buildboost.genext.emf.steps; + +import static de.devboost.buildboost.IConstants.NL; + +import java.io.File; +import java.util.Collection; +import java.util.Collections; +import java.util.List; + +import de.devboost.buildboost.BuildException; +import de.devboost.buildboost.GlobalBuildConfiguration; +import de.devboost.buildboost.ant.AbstractAntTargetGenerator; +import de.devboost.buildboost.ant.AntTarget; +import de.devboost.buildboost.artifacts.Plugin; +import de.devboost.buildboost.genext.emf.IConstants; +import de.devboost.buildboost.genext.emf.artifacts.GeneratorModel; +import de.devboost.buildboost.model.IDependable; +import de.devboost.buildboost.steps.ClasspathHelper; +import de.devboost.buildboost.steps.clone.CloneRepositoriesBuildStep; +import de.devboost.buildboost.util.XMLContent; + +/** + * The {@link GenerateGenModelCodeStep} generates a script that calls the EMF + * code generators to obtain code from Ecore models. + */ +public class GenerateGenModelCodeStep extends AbstractAntTargetGenerator { + + public final static String MAIN_TASK = "generate-emf-code"; + + private final List plugins; + private final GeneratorModel generatorModel; + + public GenerateGenModelCodeStep(List plugins, + GeneratorModel generatorModel) { + this.plugins = plugins; + this.generatorModel = generatorModel; + } + + @Override + public Collection generateAntTargets() throws BuildException { + + final GlobalBuildConfiguration globalConfig = GlobalBuildConfiguration + .getInstance(); + + Collection dependencies = generatorModel.getDependencies(); + if (dependencies.isEmpty()) { + throw new BuildException( + "Generator models are expected to have a dependency to the BuildBoost EMF plug-in."); + } + XMLContent classpath = new ClasspathHelper().getClasspath( + generatorModel, true); + + File genModelFile = generatorModel.getFile(); + String genModelPath = genModelFile.getAbsolutePath(); + + XMLContent sb = new XMLContent(); + sb.append(""); + sb.append(""); + sb.append(NL); + + sb.append(""); + // TODO use constant here + sb.append(""); + sb.append(""); + sb.append(""); + if (globalConfig.isDebugEnabled()) { + sb.append(""); + } + sb.append(""); + sb.append(""); + sb.append(""); + String genModelID = genModelPath.toString() + .replace(File.separator, "-"); + String paraFileName = CloneRepositoriesBuildStep + .encodeFileOrFolderName(genModelID + ".properties"); + sb.append(""); + sb.append(""); + sb.append(classpath); + sb.append(""); + sb.append(""); + sb.append(NL); + + writeParaFile(paraFileName, plugins); + + return Collections.singleton(new AntTarget("emf-codegen-" + genModelID, + sb)); + } + +} diff --git a/Extensions/EMF/de.devboost.buildboost.genext.emf/src/de/devboost/buildboost/genext/emf/steps/GenerateGenModelCodeStepProvider.java b/Extensions/EMF/de.devboost.buildboost.genext.emf/src/de/devboost/buildboost/genext/emf/steps/GenerateGenModelCodeStepProvider.java index a746d3a..6a5084c 100644 --- a/Extensions/EMF/de.devboost.buildboost.genext.emf/src/de/devboost/buildboost/genext/emf/steps/GenerateGenModelCodeStepProvider.java +++ b/Extensions/EMF/de.devboost.buildboost.genext.emf/src/de/devboost/buildboost/genext/emf/steps/GenerateGenModelCodeStepProvider.java @@ -1,60 +1,60 @@ -/******************************************************************************* - * Copyright (c) 2006-2012 - * Software Technology Group, Dresden University of Technology - * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 - * - * All rights reserved. This program and the accompanying materials - * are 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 - * - * Contributors: - * Software Technology Group - TU Dresden, Germany; - * DevBoost GmbH - Berlin, Germany - * - initial API and implementation - ******************************************************************************/ -package de.devboost.buildboost.genext.emf.steps; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.List; - -import de.devboost.buildboost.ant.AbstractAntTargetGeneratorProvider; -import de.devboost.buildboost.ant.IAntTargetGenerator; -import de.devboost.buildboost.artifacts.Plugin; -import de.devboost.buildboost.genext.emf.artifacts.GeneratorModel; -import de.devboost.buildboost.model.IArtifact; -import de.devboost.buildboost.model.IBuildContext; - -/** - * The {@link GenerateGenModelCodeStepProvider} add a - * {@link GenerateGenModelCodeStep} for each EMF generator model. - */ -public class GenerateGenModelCodeStepProvider extends AbstractAntTargetGeneratorProvider { - - public List getAntTargetGenerators(IBuildContext context, IArtifact artifact) { - if (artifact instanceof GeneratorModel) { - List plugins = getDiscoveredPlugins(context); - - List steps = new ArrayList(1); - GeneratorModel generatorModel = (GeneratorModel) artifact; - steps.add(new GenerateGenModelCodeStep(plugins, generatorModel)); - return steps; - } else { - return Collections.emptyList(); - } - } - - private List getDiscoveredPlugins(IBuildContext context) { - Collection discoveredArtifacts = context.getDiscoveredArtifacts(); - List plugins = new ArrayList(); - for (IArtifact discoveredArtifact : discoveredArtifacts) { - if (discoveredArtifact instanceof Plugin) { - Plugin plugin = (Plugin) discoveredArtifact; - plugins.add(plugin); - } - } - return plugins; - } -} +/******************************************************************************* + * Copyright (c) 2006-2012 + * Software Technology Group, Dresden University of Technology + * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 + * + * All rights reserved. This program and the accompanying materials + * are 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 + * + * Contributors: + * Software Technology Group - TU Dresden, Germany; + * DevBoost GmbH - Berlin, Germany + * - initial API and implementation + ******************************************************************************/ +package de.devboost.buildboost.genext.emf.steps; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.List; + +import de.devboost.buildboost.ant.AbstractAntTargetGeneratorProvider; +import de.devboost.buildboost.ant.IAntTargetGenerator; +import de.devboost.buildboost.artifacts.Plugin; +import de.devboost.buildboost.genext.emf.artifacts.GeneratorModel; +import de.devboost.buildboost.model.IArtifact; +import de.devboost.buildboost.model.IBuildContext; + +/** + * The {@link GenerateGenModelCodeStepProvider} add a + * {@link GenerateGenModelCodeStep} for each EMF generator model. + */ +public class GenerateGenModelCodeStepProvider extends AbstractAntTargetGeneratorProvider { + + public List getAntTargetGenerators(IBuildContext context, IArtifact artifact) { + if (artifact instanceof GeneratorModel) { + List plugins = getDiscoveredPlugins(context); + + List steps = new ArrayList(1); + GeneratorModel generatorModel = (GeneratorModel) artifact; + steps.add(new GenerateGenModelCodeStep(plugins, generatorModel)); + return steps; + } else { + return Collections.emptyList(); + } + } + + private List getDiscoveredPlugins(IBuildContext context) { + Collection discoveredArtifacts = context.getDiscoveredArtifacts(); + List plugins = new ArrayList(); + for (IArtifact discoveredArtifact : discoveredArtifacts) { + if (discoveredArtifact instanceof Plugin) { + Plugin plugin = (Plugin) discoveredArtifact; + plugins.add(plugin); + } + } + return plugins; + } +} diff --git a/Extensions/EMFText/de.devboost.buildboost.buildext.emftext/.classpath b/Extensions/EMFText/de.devboost.buildboost.buildext.emftext/.classpath index ed2bc12..121e527 100644 --- a/Extensions/EMFText/de.devboost.buildboost.buildext.emftext/.classpath +++ b/Extensions/EMFText/de.devboost.buildboost.buildext.emftext/.classpath @@ -1,7 +1,7 @@ - - - - - - - + + + + + + + diff --git a/Extensions/EMFText/de.devboost.buildboost.buildext.emftext/.settings/org.eclipse.jdt.core.prefs b/Extensions/EMFText/de.devboost.buildboost.buildext.emftext/.settings/org.eclipse.jdt.core.prefs index 3d27715..ff8e333 100644 --- a/Extensions/EMFText/de.devboost.buildboost.buildext.emftext/.settings/org.eclipse.jdt.core.prefs +++ b/Extensions/EMFText/de.devboost.buildboost.buildext.emftext/.settings/org.eclipse.jdt.core.prefs @@ -1,12 +1,12 @@ -#Tue Dec 06 21:07:25 CET 2011 -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 -org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.6 -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.enumIdentifier=error -org.eclipse.jdt.core.compiler.source=1.6 +#Tue Dec 06 21:07:25 CET 2011 +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.6 +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.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.6 diff --git a/Extensions/EMFText/de.devboost.buildboost.buildext.emftext/build.properties b/Extensions/EMFText/de.devboost.buildboost.buildext.emftext/build.properties index a12d47e..b107977 100644 --- a/Extensions/EMFText/de.devboost.buildboost.buildext.emftext/build.properties +++ b/Extensions/EMFText/de.devboost.buildboost.buildext.emftext/build.properties @@ -1,3 +1,3 @@ -source.. = src/ -bin.includes = META-INF/,\ - . +source.. = src/ +bin.includes = META-INF/,\ + . diff --git a/Extensions/EMFText/de.devboost.buildboost.buildext.emftext/src/de/devboost/buildboost/buildext/emftext/BuildBoostGenerationContext.java b/Extensions/EMFText/de.devboost.buildboost.buildext.emftext/src/de/devboost/buildboost/buildext/emftext/BuildBoostGenerationContext.java index 149a6f1..3772a86 100644 --- a/Extensions/EMFText/de.devboost.buildboost.buildext.emftext/src/de/devboost/buildboost/buildext/emftext/BuildBoostGenerationContext.java +++ b/Extensions/EMFText/de.devboost.buildboost.buildext.emftext/src/de/devboost/buildboost/buildext/emftext/BuildBoostGenerationContext.java @@ -1,60 +1,60 @@ -/******************************************************************************* - * Copyright (c) 2006-2012 - * Software Technology Group, Dresden University of Technology - * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 - * - * All rights reserved. This program and the accompanying materials - * are 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 - * - * Contributors: - * Software Technology Group - TU Dresden, Germany; - * DevBoost GmbH - Berlin, Germany - * - initial API and implementation - ******************************************************************************/ -package de.devboost.buildboost.buildext.emftext; - -import java.io.File; - -import org.emftext.sdk.codegen.IFileSystemConnector; -import org.emftext.sdk.codegen.resource.GenerationContext; -import org.emftext.sdk.concretesyntax.ConcreteSyntax; - -public class BuildBoostGenerationContext extends GenerationContext { - - private String projectName; - private File rootFolder; - private String pathToCsFile; - - public BuildBoostGenerationContext( - IFileSystemConnector folderConnector, - BuildBoostProblemCollector problemCollector, - ConcreteSyntax syntax, - File rootFolder, - String pathToCsFile, - String projectName) { - - super(folderConnector, problemCollector, syntax); - this.projectName = projectName; - this.rootFolder = rootFolder; - this.pathToCsFile = pathToCsFile; - } - - @Override - public String getSyntaxProjectName() { - return projectName; - } - - @Override - public String getProjectRelativePathToSyntaxFile() { - String rootPath = rootFolder.getAbsolutePath(); - String relativePath = pathToCsFile.substring(rootPath.length()); - return relativePath; - } - - @Override - public boolean getGenerateANTLRPlugin() { - return true; - } -} +/******************************************************************************* + * Copyright (c) 2006-2012 + * Software Technology Group, Dresden University of Technology + * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 + * + * All rights reserved. This program and the accompanying materials + * are 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 + * + * Contributors: + * Software Technology Group - TU Dresden, Germany; + * DevBoost GmbH - Berlin, Germany + * - initial API and implementation + ******************************************************************************/ +package de.devboost.buildboost.buildext.emftext; + +import java.io.File; + +import org.emftext.sdk.codegen.IFileSystemConnector; +import org.emftext.sdk.codegen.resource.GenerationContext; +import org.emftext.sdk.concretesyntax.ConcreteSyntax; + +public class BuildBoostGenerationContext extends GenerationContext { + + private String projectName; + private File rootFolder; + private String pathToCsFile; + + public BuildBoostGenerationContext( + IFileSystemConnector folderConnector, + BuildBoostProblemCollector problemCollector, + ConcreteSyntax syntax, + File rootFolder, + String pathToCsFile, + String projectName) { + + super(folderConnector, problemCollector, syntax); + this.projectName = projectName; + this.rootFolder = rootFolder; + this.pathToCsFile = pathToCsFile; + } + + @Override + public String getSyntaxProjectName() { + return projectName; + } + + @Override + public String getProjectRelativePathToSyntaxFile() { + String rootPath = rootFolder.getAbsolutePath(); + String relativePath = pathToCsFile.substring(rootPath.length()); + return relativePath; + } + + @Override + public boolean getGenerateANTLRPlugin() { + return true; + } +} diff --git a/Extensions/EMFText/de.devboost.buildboost.buildext.emftext/src/de/devboost/buildboost/buildext/emftext/BuildBoostGenerator.java b/Extensions/EMFText/de.devboost.buildboost.buildext.emftext/src/de/devboost/buildboost/buildext/emftext/BuildBoostGenerator.java index 25836cc..6380f05 100644 --- a/Extensions/EMFText/de.devboost.buildboost.buildext.emftext/src/de/devboost/buildboost/buildext/emftext/BuildBoostGenerator.java +++ b/Extensions/EMFText/de.devboost.buildboost.buildext.emftext/src/de/devboost/buildboost/buildext/emftext/BuildBoostGenerator.java @@ -1,28 +1,28 @@ -/******************************************************************************* - * Copyright (c) 2006-2012 - * Software Technology Group, Dresden University of Technology - * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 - * - * All rights reserved. This program and the accompanying materials - * are 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 - * - * Contributors: - * Software Technology Group - TU Dresden, Germany; - * DevBoost GmbH - Berlin, Germany - * - initial API and implementation - ******************************************************************************/ -package de.devboost.buildboost.buildext.emftext; - -import org.eclipse.core.runtime.SubMonitor; -import org.emftext.sdk.IPluginDescriptor; -import org.emftext.sdk.codegen.resource.GenerationContext; -import org.emftext.sdk.codegen.resource.ui.CreateResourcePluginsJob; - -public class BuildBoostGenerator extends CreateResourcePluginsJob { - - @Override - public void createProject(IPluginDescriptor plugin, GenerationContext context, SubMonitor progress) { - } -} +/******************************************************************************* + * Copyright (c) 2006-2012 + * Software Technology Group, Dresden University of Technology + * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 + * + * All rights reserved. This program and the accompanying materials + * are 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 + * + * Contributors: + * Software Technology Group - TU Dresden, Germany; + * DevBoost GmbH - Berlin, Germany + * - initial API and implementation + ******************************************************************************/ +package de.devboost.buildboost.buildext.emftext; + +import org.eclipse.core.runtime.SubMonitor; +import org.emftext.sdk.IPluginDescriptor; +import org.emftext.sdk.codegen.resource.GenerationContext; +import org.emftext.sdk.codegen.resource.ui.CreateResourcePluginsJob; + +public class BuildBoostGenerator extends CreateResourcePluginsJob { + + @Override + public void createProject(IPluginDescriptor plugin, GenerationContext context, SubMonitor progress) { + } +} diff --git a/Extensions/EMFText/de.devboost.buildboost.buildext.emftext/src/de/devboost/buildboost/buildext/emftext/BuildBoostLogMarker.java b/Extensions/EMFText/de.devboost.buildboost.buildext.emftext/src/de/devboost/buildboost/buildext/emftext/BuildBoostLogMarker.java index fdd4670..cdd5cbb 100644 --- a/Extensions/EMFText/de.devboost.buildboost.buildext.emftext/src/de/devboost/buildboost/buildext/emftext/BuildBoostLogMarker.java +++ b/Extensions/EMFText/de.devboost.buildboost.buildext.emftext/src/de/devboost/buildboost/buildext/emftext/BuildBoostLogMarker.java @@ -1,34 +1,34 @@ -/******************************************************************************* - * Copyright (c) 2006-2012 - * Software Technology Group, Dresden University of Technology - * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 - * - * All rights reserved. This program and the accompanying materials - * are 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 - * - * Contributors: - * Software Technology Group - TU Dresden, Germany; - * DevBoost GmbH - Berlin, Germany - * - initial API and implementation - ******************************************************************************/ -package de.devboost.buildboost.buildext.emftext; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.emf.ecore.resource.Resource; -import org.emftext.sdk.codegen.IResourceMarker; - -public class BuildBoostLogMarker implements IResourceMarker { - - public void mark(Resource resource) throws CoreException { - // TODO Auto-generated method stub - - } - - public void unmark(Resource resource) throws CoreException { - // TODO Auto-generated method stub - - } - -} +/******************************************************************************* + * Copyright (c) 2006-2012 + * Software Technology Group, Dresden University of Technology + * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 + * + * All rights reserved. This program and the accompanying materials + * are 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 + * + * Contributors: + * Software Technology Group - TU Dresden, Germany; + * DevBoost GmbH - Berlin, Germany + * - initial API and implementation + ******************************************************************************/ +package de.devboost.buildboost.buildext.emftext; + +import org.eclipse.core.runtime.CoreException; +import org.eclipse.emf.ecore.resource.Resource; +import org.emftext.sdk.codegen.IResourceMarker; + +public class BuildBoostLogMarker implements IResourceMarker { + + public void mark(Resource resource) throws CoreException { + // TODO Auto-generated method stub + + } + + public void unmark(Resource resource) throws CoreException { + // TODO Auto-generated method stub + + } + +} diff --git a/Extensions/EMFText/de.devboost.buildboost.buildext.emftext/src/de/devboost/buildboost/buildext/emftext/BuildBoostProblemCollector.java b/Extensions/EMFText/de.devboost.buildboost.buildext.emftext/src/de/devboost/buildboost/buildext/emftext/BuildBoostProblemCollector.java index ad0dfde..418aed4 100644 --- a/Extensions/EMFText/de.devboost.buildboost.buildext.emftext/src/de/devboost/buildboost/buildext/emftext/BuildBoostProblemCollector.java +++ b/Extensions/EMFText/de.devboost.buildboost.buildext.emftext/src/de/devboost/buildboost/buildext/emftext/BuildBoostProblemCollector.java @@ -1,27 +1,27 @@ -/******************************************************************************* - * Copyright (c) 2006-2012 - * Software Technology Group, Dresden University of Technology - * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 - * - * All rights reserved. This program and the accompanying materials - * are 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 - * - * Contributors: - * Software Technology Group - TU Dresden, Germany; - * DevBoost GmbH - Berlin, Germany - * - initial API and implementation - ******************************************************************************/ -package de.devboost.buildboost.buildext.emftext; - -import org.emftext.sdk.codegen.GenerationProblem; -import org.emftext.sdk.codegen.IProblemCollector; - -public class BuildBoostProblemCollector implements IProblemCollector { - - public void addProblem(GenerationProblem problem) { - // TODO Auto-generated method stub - - } -} +/******************************************************************************* + * Copyright (c) 2006-2012 + * Software Technology Group, Dresden University of Technology + * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 + * + * All rights reserved. This program and the accompanying materials + * are 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 + * + * Contributors: + * Software Technology Group - TU Dresden, Germany; + * DevBoost GmbH - Berlin, Germany + * - initial API and implementation + ******************************************************************************/ +package de.devboost.buildboost.buildext.emftext; + +import org.emftext.sdk.codegen.GenerationProblem; +import org.emftext.sdk.codegen.IProblemCollector; + +public class BuildBoostProblemCollector implements IProblemCollector { + + public void addProblem(GenerationProblem problem) { + // TODO Auto-generated method stub + + } +} diff --git a/Extensions/EMFText/de.devboost.buildboost.buildext.emftext/src/de/devboost/buildboost/buildext/emftext/BuildBoostProgressMonitor.java b/Extensions/EMFText/de.devboost.buildboost.buildext.emftext/src/de/devboost/buildboost/buildext/emftext/BuildBoostProgressMonitor.java index 436d30a..f5c04e7 100644 --- a/Extensions/EMFText/de.devboost.buildboost.buildext.emftext/src/de/devboost/buildboost/buildext/emftext/BuildBoostProgressMonitor.java +++ b/Extensions/EMFText/de.devboost.buildboost.buildext.emftext/src/de/devboost/buildboost/buildext/emftext/BuildBoostProgressMonitor.java @@ -1,59 +1,59 @@ -/******************************************************************************* - * Copyright (c) 2006-2012 - * Software Technology Group, Dresden University of Technology - * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 - * - * All rights reserved. This program and the accompanying materials - * are 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 - * - * Contributors: - * Software Technology Group - TU Dresden, Germany; - * DevBoost GmbH - Berlin, Germany - * - initial API and implementation - ******************************************************************************/ -package de.devboost.buildboost.buildext.emftext; - -import org.eclipse.core.runtime.IProgressMonitor; - -public class BuildBoostProgressMonitor implements IProgressMonitor { - - public void beginTask(String name, int totalWork) { - System.out.println(name); - } - - public void done() { - // TODO Auto-generated method stub - } - - public void internalWorked(double work) { - // TODO Auto-generated method stub - } - - public boolean isCanceled() { - // TODO Auto-generated method stub - return false; - } - - public void setCanceled(boolean value) { - // TODO Auto-generated method stub - - } - - public void setTaskName(String name) { - // TODO Auto-generated method stub - - } - - public void subTask(String name) { - // TODO Auto-generated method stub - - } - - public void worked(int work) { - // TODO Auto-generated method stub - - } - -} +/******************************************************************************* + * Copyright (c) 2006-2012 + * Software Technology Group, Dresden University of Technology + * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 + * + * All rights reserved. This program and the accompanying materials + * are 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 + * + * Contributors: + * Software Technology Group - TU Dresden, Germany; + * DevBoost GmbH - Berlin, Germany + * - initial API and implementation + ******************************************************************************/ +package de.devboost.buildboost.buildext.emftext; + +import org.eclipse.core.runtime.IProgressMonitor; + +public class BuildBoostProgressMonitor implements IProgressMonitor { + + public void beginTask(String name, int totalWork) { + System.out.println(name); + } + + public void done() { + // TODO Auto-generated method stub + } + + public void internalWorked(double work) { + // TODO Auto-generated method stub + } + + public boolean isCanceled() { + // TODO Auto-generated method stub + return false; + } + + public void setCanceled(boolean value) { + // TODO Auto-generated method stub + + } + + public void setTaskName(String name) { + // TODO Auto-generated method stub + + } + + public void subTask(String name) { + // TODO Auto-generated method stub + + } + + public void worked(int work) { + // TODO Auto-generated method stub + + } + +} diff --git a/Extensions/EMFText/de.devboost.buildboost.buildext.emftext/src/de/devboost/buildboost/buildext/emftext/TextResourcePluginGenerator.java b/Extensions/EMFText/de.devboost.buildboost.buildext.emftext/src/de/devboost/buildboost/buildext/emftext/TextResourcePluginGenerator.java index c4d9f49..e209ded 100644 --- a/Extensions/EMFText/de.devboost.buildboost.buildext.emftext/src/de/devboost/buildboost/buildext/emftext/TextResourcePluginGenerator.java +++ b/Extensions/EMFText/de.devboost.buildboost.buildext.emftext/src/de/devboost/buildboost/buildext/emftext/TextResourcePluginGenerator.java @@ -1,173 +1,203 @@ -/******************************************************************************* - * Copyright (c) 2006-2012 - * Software Technology Group, Dresden University of Technology - * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 - * - * All rights reserved. This program and the accompanying materials - * are 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 - * - * Contributors: - * Software Technology Group - TU Dresden, Germany; - * DevBoost GmbH - Berlin, Germany - * - initial API and implementation - ******************************************************************************/ -package de.devboost.buildboost.buildext.emftext; - -import java.io.File; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.eclipse.emf.codegen.ecore.genmodel.GenModelPackage; -import org.eclipse.emf.common.util.URI; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.EcorePackage; -import org.eclipse.emf.ecore.InternalEObject; -import org.eclipse.emf.ecore.plugin.EcorePlugin; -import org.eclipse.emf.ecore.resource.Resource; -import org.eclipse.emf.ecore.resource.ResourceSet; -import org.eclipse.emf.ecore.resource.URIConverter; -import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; -import org.eclipse.emf.ecore.util.EcoreUtil; -import org.eclipse.emf.ecore.xmi.impl.EcoreResourceFactoryImpl; -import org.emftext.sdk.IPluginDescriptor; -import org.emftext.sdk.codegen.IFileSystemConnector; -import org.emftext.sdk.codegen.resource.ui.CreateResourcePluginsJob.Result; -import org.emftext.sdk.concretesyntax.ConcreteSyntax; -import org.emftext.sdk.concretesyntax.resource.cs.mopp.CsMetaInformation; -import org.emftext.sdk.concretesyntax.resource.cs.mopp.CsResourceFactory; -import org.emftext.sdk.concretesyntax.resource.cs.util.CsResourceUtil; - -import de.devboost.buildboost.BuildException; -import de.devboost.buildboost.artifacts.Plugin; - -/** - * The {@link TextResourcePluginGenerator} is executed by build scripts that are - * generated by the {@link GenerateEMFTextCodeStage} or the - * {@link GenerateResourcePluginsStep}. It runs the EMFText code generation for - * a given syntax specification. - */ -public class TextResourcePluginGenerator { - - // TODO use property file to pass arguments instead - public static void main(String[] args) throws Exception { - String pathToCsFile = args[0]; - String projectName = args[1]; - String buildDirPath = args[2]; - List pluginPaths = new ArrayList(); - for (int i = 3; i < args.length; i++) { - pluginPaths.add(args[i]); - } - new TextResourcePluginGenerator().run(pathToCsFile, projectName, buildDirPath, pluginPaths); - } - - public void run( - String pathToCsFile, - String projectName, - String buildDirPath, - List pluginPaths) throws Exception { - - final File rootFolder = new File(buildDirPath); - - URI uri = URI.createFileURI(pathToCsFile); - ResourceSet rs = new ResourceSetImpl(); - registerFactoriesAndPackages(); - registerURIMappings(pluginPaths); - // TODO add checks - Resource resource = rs.getResource(uri, true); - ConcreteSyntax syntax = (ConcreteSyntax) resource.getContents().get(0); - if (syntax == null) { - throw new BuildException("Generation failed, because the syntax file could not be loaded. Probably it contains syntactical errors."); - } - EcoreUtil.resolveAll(resource); - - Set unresolvedProxies = CsResourceUtil.findUnresolvedProxies(rs); - for (EObject unresolvedProxy : unresolvedProxies) { - System.out.println("Found unresolved proxy: " + unresolvedProxy); - } - if (unresolvedProxies.size() > 0) { - throw new BuildException("Generation failed, because the syntax file contains unresolved proxy objects."); - } - - IFileSystemConnector folderConnector = new IFileSystemConnector() { - - public File getProjectFolder(IPluginDescriptor plugin) { - return new File(rootFolder.getAbsolutePath() + File.separator + plugin.getName()); - } - }; - - BuildBoostGenerationContext context = new BuildBoostGenerationContext( - folderConnector, - new BuildBoostProblemCollector(), - syntax, - rootFolder, - pathToCsFile, - projectName); - Result result = new BuildBoostGenerator().run( - context, - new BuildBoostLogMarker(), - new BuildBoostProgressMonitor() - ); - if (result != Result.SUCCESS) { - if (result == Result.ERROR_FOUND_UNRESOLVED_PROXIES) { - for (EObject unresolvedProxy : result.getUnresolvedProxies()) { - System.out.println("Found unresolved proxy \"" + ((InternalEObject) unresolvedProxy).eProxyURI() + "\" in " + unresolvedProxy.eResource()); - } - throw new BuildException("Generation failed " + result); - } else { - throw new BuildException("Generation failed " + result); - } - } - } - - private void registerURIMappings(List pluginPaths) throws Exception { - // TODO this is a copy of this method from class HeadlessCodeGenerator - Map uriMap = URIConverter.URI_MAP; - for (String pluginPath : pluginPaths) { - File pluginFile = new File(pluginPath); - if (pluginFile.isDirectory() && !pluginPath.endsWith("/")) { - pluginPath = pluginPath + "/"; - } - Plugin plugin = new Plugin(pluginFile); - String identifier = plugin.getIdentifier(); - URI from = URI.createPlatformPluginURI(identifier + "/", true); - URI to = URI.createFileURI(pluginPath); - if ("jar".equals(to.fileExtension())) { - to = URI.createURI("archive:" + to.toString() + "!/"); - } else if (!"".equals(to.lastSegment())) { - to = to.appendSegment(""); - } - //System.out.println("Mapping URI " + from + " to " + to); - uriMap.put( - from, - to - ); - } - } - - private void registerFactoriesAndPackages() { - // TODO we must search the target platform for registered resource factories, - // generator models and EPackages - // TODO this is a MODIFIED copy of this method from class HeadlessCodeGenerator - Map extensionToFactoryMap = Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap(); - extensionToFactoryMap.put("ecore", new EcoreResourceFactoryImpl()); - extensionToFactoryMap.put("genmodel", new EcoreResourceFactoryImpl()); - extensionToFactoryMap.put(new CsMetaInformation().getSyntaxName(), new CsResourceFactory()); - - GenModelPackage genModelPackage = GenModelPackage.eINSTANCE; - EcorePackage ecorePackage = EcorePackage.eINSTANCE; - - URI ecoreGenModelURI = URI.createPlatformPluginURI( - "org.eclipse.emf.ecore/model/Ecore.genmodel", true); - URI genmodelGenModelURI = URI.createPlatformPluginURI( - "org.eclipse.emf.codegen.ecore/model/GenModel.genmodel", true); - - EcorePlugin.getEPackageNsURIToGenModelLocationMap().put( - ecorePackage.getNsURI(), ecoreGenModelURI); - EcorePlugin.getEPackageNsURIToGenModelLocationMap().put( - genModelPackage.getNsURI(), genmodelGenModelURI); - } -} +/******************************************************************************* + * Copyright (c) 2006-2012 + * Software Technology Group, Dresden University of Technology + * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 + * + * All rights reserved. This program and the accompanying materials + * are 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 + * + * Contributors: + * Software Technology Group - TU Dresden, Germany; + * DevBoost GmbH - Berlin, Germany + * - initial API and implementation + ******************************************************************************/ +package de.devboost.buildboost.buildext.emftext; + +import java.io.BufferedReader; +import java.io.File; +import java.io.FileReader; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import org.eclipse.emf.codegen.ecore.genmodel.GenModelPackage; +import org.eclipse.emf.common.util.URI; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EcorePackage; +import org.eclipse.emf.ecore.InternalEObject; +import org.eclipse.emf.ecore.plugin.EcorePlugin; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.emf.ecore.resource.ResourceSet; +import org.eclipse.emf.ecore.resource.URIConverter; +import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; +import org.eclipse.emf.ecore.util.EcoreUtil; +import org.eclipse.emf.ecore.xmi.impl.EcoreResourceFactoryImpl; +import org.emftext.sdk.IPluginDescriptor; +import org.emftext.sdk.codegen.IFileSystemConnector; +import org.emftext.sdk.codegen.resource.ui.CreateResourcePluginsJob.Result; +import org.emftext.sdk.concretesyntax.ConcreteSyntax; +import org.emftext.sdk.concretesyntax.resource.cs.mopp.CsMetaInformation; +import org.emftext.sdk.concretesyntax.resource.cs.mopp.CsResourceFactory; +import org.emftext.sdk.concretesyntax.resource.cs.util.CsResourceUtil; + +import de.devboost.buildboost.BuildException; +import de.devboost.buildboost.artifacts.Plugin; +import de.devboost.buildboost.genext.emftext.steps.GenerateResourcePluginsStep; + +/** + * The {@link TextResourcePluginGenerator} is executed by build scripts that are + * generated by the {@link GenerateEMFTextCodeStage} or the + * {@link GenerateResourcePluginsStep}. It runs the EMFText code generation for + * a given syntax specification. + */ +public class TextResourcePluginGenerator { + + // TODO use property file to pass arguments instead + public static void main(String[] args) throws Exception { + String pathToCsFile = args[0]; + String projectName = args[1]; + String buildDirPath = args[2]; + List pluginPaths = readPluginPaths(args[3]); + new TextResourcePluginGenerator().run(pathToCsFile, projectName, + buildDirPath, pluginPaths); + } + + // TODO Duplicate code + // @see de.devboost.buildboost.buildext.emf.HeadlessCodeGenerator + private static List readPluginPaths(final String paraFileName) { + List paths = new ArrayList(); + BufferedReader reader = null; + try { + final FileReader fin = new FileReader(paraFileName); + reader = new BufferedReader(fin); + String line = reader.readLine(); + while (line != null) { + paths.add(line); + line = reader.readLine(); + } + } catch (IOException ex) { + // TODO Auto-generated catch block + ex.printStackTrace(); + } finally { + if (reader != null) { + try { + reader.close(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + } + + return paths; + } + + public void run(String pathToCsFile, String projectName, + String buildDirPath, List pluginPaths) throws Exception { + + final File rootFolder = new File(buildDirPath); + + URI uri = URI.createFileURI(pathToCsFile); + ResourceSet rs = new ResourceSetImpl(); + registerFactoriesAndPackages(); + registerURIMappings(pluginPaths); + // TODO add checks + Resource resource = rs.getResource(uri, true); + ConcreteSyntax syntax = (ConcreteSyntax) resource.getContents().get(0); + if (syntax == null) { + throw new BuildException( + "Generation failed, because the syntax file could not be loaded. Probably it contains syntactical errors."); + } + EcoreUtil.resolveAll(resource); + + Set unresolvedProxies = CsResourceUtil + .findUnresolvedProxies(rs); + for (EObject unresolvedProxy : unresolvedProxies) { + System.out.println("Found unresolved proxy: " + unresolvedProxy); + } + if (unresolvedProxies.size() > 0) { + throw new BuildException( + "Generation failed, because the syntax file contains unresolved proxy objects."); + } + + IFileSystemConnector folderConnector = new IFileSystemConnector() { + + @Override + public File getProjectFolder(IPluginDescriptor plugin) { + return new File(rootFolder.getAbsolutePath() + File.separator + + plugin.getName()); + } + }; + + BuildBoostGenerationContext context = new BuildBoostGenerationContext( + folderConnector, new BuildBoostProblemCollector(), syntax, + rootFolder, pathToCsFile, projectName); + Result result = new BuildBoostGenerator().run(context, + new BuildBoostLogMarker(), new BuildBoostProgressMonitor()); + if (result != Result.SUCCESS) { + if (result == Result.ERROR_FOUND_UNRESOLVED_PROXIES) { + for (EObject unresolvedProxy : result.getUnresolvedProxies()) { + System.out.println("Found unresolved proxy \"" + + ((InternalEObject) unresolvedProxy).eProxyURI() + + "\" in " + unresolvedProxy.eResource()); + } + throw new BuildException("Generation failed " + result); + } else { + throw new BuildException("Generation failed " + result); + } + } + } + + private void registerURIMappings(List pluginPaths) throws Exception { + // TODO this is a copy of this method from class HeadlessCodeGenerator + Map uriMap = URIConverter.URI_MAP; + for (String pluginPath : pluginPaths) { + File pluginFile = new File(pluginPath); + if (pluginFile.isDirectory() + && !pluginPath.endsWith(File.separator)) { + pluginPath = pluginPath + File.separator; + } + Plugin plugin = new Plugin(pluginFile); + String identifier = plugin.getIdentifier(); + URI from = URI.createPlatformPluginURI(identifier + "/", true); + URI to = URI.createFileURI(pluginPath); + if ("jar".equals(to.fileExtension())) { + to = URI.createURI("archive:" + to.toString() + "!/"); + } else if (!"".equals(to.lastSegment())) { + to = to.appendSegment(""); + } + // System.out.println("Mapping URI " + from + " to " + to); + uriMap.put(from, to); + } + } + + private void registerFactoriesAndPackages() { + // TODO we must search the target platform for registered resource + // factories, + // generator models and EPackages + // TODO this is a MODIFIED copy of this method from class + // HeadlessCodeGenerator + Map extensionToFactoryMap = Resource.Factory.Registry.INSTANCE + .getExtensionToFactoryMap(); + extensionToFactoryMap.put("ecore", new EcoreResourceFactoryImpl()); + extensionToFactoryMap.put("genmodel", new EcoreResourceFactoryImpl()); + extensionToFactoryMap.put(new CsMetaInformation().getSyntaxName(), + new CsResourceFactory()); + GenModelPackage genModelPackage = GenModelPackage.eINSTANCE; + EcorePackage ecorePackage = EcorePackage.eINSTANCE; + + URI ecoreGenModelURI = URI.createPlatformPluginURI( + "org.eclipse.emf.ecore/model/Ecore.genmodel", true); + URI genmodelGenModelURI = URI.createPlatformPluginURI( + "org.eclipse.emf.codegen.ecore/model/GenModel.genmodel", true); + + EcorePlugin.getEPackageNsURIToGenModelLocationMap().put( + ecorePackage.getNsURI(), ecoreGenModelURI); + EcorePlugin.getEPackageNsURIToGenModelLocationMap().put( + genModelPackage.getNsURI(), genmodelGenModelURI); + } +} diff --git a/Extensions/EMFText/de.devboost.buildboost.genext.emftext/META-INF/MANIFEST.MF b/Extensions/EMFText/de.devboost.buildboost.genext.emftext/META-INF/MANIFEST.MF index 3131937..0392854 100644 --- a/Extensions/EMFText/de.devboost.buildboost.genext.emftext/META-INF/MANIFEST.MF +++ b/Extensions/EMFText/de.devboost.buildboost.genext.emftext/META-INF/MANIFEST.MF @@ -5,3 +5,4 @@ Bundle-SymbolicName: de.devboost.buildboost.genext.emftext Bundle-Version: 1.0.0.qualifier Bundle-RequiredExecutionEnvironment: JavaSE-1.6 Require-Bundle: de.devboost.buildboost +Export-Package: de.devboost.buildboost.genext.emftext.steps diff --git a/Extensions/EMFText/de.devboost.buildboost.genext.emftext/src/de/devboost/buildboost/genext/emftext/artifacts/ConcreteSyntaxDefinition.java b/Extensions/EMFText/de.devboost.buildboost.genext.emftext/src/de/devboost/buildboost/genext/emftext/artifacts/ConcreteSyntaxDefinition.java index fe41a5d..d1a2317 100644 --- a/Extensions/EMFText/de.devboost.buildboost.genext.emftext/src/de/devboost/buildboost/genext/emftext/artifacts/ConcreteSyntaxDefinition.java +++ b/Extensions/EMFText/de.devboost.buildboost.genext.emftext/src/de/devboost/buildboost/genext/emftext/artifacts/ConcreteSyntaxDefinition.java @@ -1,64 +1,64 @@ -/******************************************************************************* - * Copyright (c) 2006-2012 - * Software Technology Group, Dresden University of Technology - * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 - * - * All rights reserved. This program and the accompanying materials - * are 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 - * - * Contributors: - * Software Technology Group - TU Dresden, Germany; - * DevBoost GmbH - Berlin, Germany - * - initial API and implementation - ******************************************************************************/ -package de.devboost.buildboost.genext.emftext.artifacts; - -import java.io.File; - -import de.devboost.buildboost.artifacts.AbstractArtifact; -import de.devboost.buildboost.artifacts.EclipseFeature; -import de.devboost.buildboost.artifacts.Plugin; -import de.devboost.buildboost.genext.emftext.IConstants; -import de.devboost.buildboost.model.UnresolvedDependency; -import de.devboost.buildboost.util.EclipsePluginHelper; - -/** - * A ConcreteSyntaxDefinition represents an EMFText syntax specification (a - * file with extension 'cs'). - */ -@SuppressWarnings("serial") -public class ConcreteSyntaxDefinition extends AbstractArtifact { - - private File file; - private File projectDir; - - public ConcreteSyntaxDefinition(File file) { - super(); - this.file = file; - this.projectDir = new EclipsePluginHelper().findProjectDir(file); - - // TODO this is not a unique identifier - setIdentifier(file.getName()); - UnresolvedDependency buildBoostDependency = new UnresolvedDependency(Plugin.class, - IConstants.BUILDEXT_PLUGIN_ID, null, true, null, true, false, false); - UnresolvedDependency emftextSDKDependency = new UnresolvedDependency(EclipseFeature.class, - "org.emftext.sdk", null, true, null, true, false, false); - getUnresolvedDependencies().add(buildBoostDependency); - getUnresolvedDependencies().add(emftextSDKDependency); - } - - public File getFile() { - return file; - } - - public File getProjectDir() { - return projectDir; - } - - @Override - public long getTimestamp() { - return file.lastModified(); - } -} +/******************************************************************************* + * Copyright (c) 2006-2012 + * Software Technology Group, Dresden University of Technology + * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 + * + * All rights reserved. This program and the accompanying materials + * are 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 + * + * Contributors: + * Software Technology Group - TU Dresden, Germany; + * DevBoost GmbH - Berlin, Germany + * - initial API and implementation + ******************************************************************************/ +package de.devboost.buildboost.genext.emftext.artifacts; + +import java.io.File; + +import de.devboost.buildboost.artifacts.AbstractArtifact; +import de.devboost.buildboost.artifacts.EclipseFeature; +import de.devboost.buildboost.artifacts.Plugin; +import de.devboost.buildboost.genext.emftext.IConstants; +import de.devboost.buildboost.model.UnresolvedDependency; +import de.devboost.buildboost.util.EclipsePluginHelper; + +/** + * A ConcreteSyntaxDefinition represents an EMFText syntax specification (a + * file with extension 'cs'). + */ +@SuppressWarnings("serial") +public class ConcreteSyntaxDefinition extends AbstractArtifact { + + private File file; + private File projectDir; + + public ConcreteSyntaxDefinition(File file) { + super(); + this.file = file; + this.projectDir = new EclipsePluginHelper().findProjectDir(file); + + // TODO this is not a unique identifier + setIdentifier(file.getName()); + UnresolvedDependency buildBoostDependency = new UnresolvedDependency(Plugin.class, + IConstants.BUILDEXT_PLUGIN_ID, null, true, null, true, false, false); + UnresolvedDependency emftextSDKDependency = new UnresolvedDependency(EclipseFeature.class, + "org.emftext.sdk", null, true, null, true, false, false); + getUnresolvedDependencies().add(buildBoostDependency); + getUnresolvedDependencies().add(emftextSDKDependency); + } + + public File getFile() { + return file; + } + + public File getProjectDir() { + return projectDir; + } + + @Override + public long getTimestamp() { + return file.lastModified(); + } +} diff --git a/Extensions/EMFText/de.devboost.buildboost.genext.emftext/src/de/devboost/buildboost/genext/emftext/discovery/CsFinder.java b/Extensions/EMFText/de.devboost.buildboost.genext.emftext/src/de/devboost/buildboost/genext/emftext/discovery/CsFinder.java index e1ee8e1..e6377ea 100644 --- a/Extensions/EMFText/de.devboost.buildboost.genext.emftext/src/de/devboost/buildboost/genext/emftext/discovery/CsFinder.java +++ b/Extensions/EMFText/de.devboost.buildboost.genext.emftext/src/de/devboost/buildboost/genext/emftext/discovery/CsFinder.java @@ -1,67 +1,67 @@ -/******************************************************************************* - * Copyright (c) 2006-2012 - * Software Technology Group, Dresden University of Technology - * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 - * - * All rights reserved. This program and the accompanying materials - * are 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 - * - * Contributors: - * Software Technology Group - TU Dresden, Germany; - * DevBoost GmbH - Berlin, Germany - * - initial API and implementation - ******************************************************************************/ -package de.devboost.buildboost.genext.emftext.discovery; - -import java.io.File; -import java.io.FileFilter; -import java.util.ArrayList; -import java.util.Collection; - -import de.devboost.buildboost.BuildException; -import de.devboost.buildboost.discovery.AbstractFileFinder; -import de.devboost.buildboost.genext.emftext.artifacts.ConcreteSyntaxDefinition; -import de.devboost.buildboost.model.IArtifact; -import de.devboost.buildboost.model.IBuildContext; -import de.devboost.buildboost.util.ArtifactUtil; - -/** - * A {@link CsFinder} can be used to discover EMFText concrete syntax - * definitions. File with extension 'cs' are recognized as such. - */ -public class CsFinder extends AbstractFileFinder { - - public String TEST_PROJECT_SUFFIX = ".test"; - - public CsFinder(File directory) { - super(directory); - } - - public Collection discoverArtifacts(IBuildContext context) throws BuildException { - Collection csDefinitions = new ArrayList(); - traverse(context, csDefinitions); - return new ArtifactUtil().getSetOfArtifacts(csDefinitions); - } - - protected ConcreteSyntaxDefinition createArtifactFromFile(File file) { - return new ConcreteSyntaxDefinition(file); - } - - protected FileFilter getFileFilter() { - return new FileFilter() { - public boolean accept(File file) { - return file.getName().endsWith(".cs") && file.isFile(); - } - }; - } - - protected FileFilter getDirectoryFilter() { - return new FileFilter() { - public boolean accept(File file) { - return file.isDirectory() && !file.getName().endsWith(TEST_PROJECT_SUFFIX); - } - }; - } -} +/******************************************************************************* + * Copyright (c) 2006-2012 + * Software Technology Group, Dresden University of Technology + * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 + * + * All rights reserved. This program and the accompanying materials + * are 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 + * + * Contributors: + * Software Technology Group - TU Dresden, Germany; + * DevBoost GmbH - Berlin, Germany + * - initial API and implementation + ******************************************************************************/ +package de.devboost.buildboost.genext.emftext.discovery; + +import java.io.File; +import java.io.FileFilter; +import java.util.ArrayList; +import java.util.Collection; + +import de.devboost.buildboost.BuildException; +import de.devboost.buildboost.discovery.AbstractFileFinder; +import de.devboost.buildboost.genext.emftext.artifacts.ConcreteSyntaxDefinition; +import de.devboost.buildboost.model.IArtifact; +import de.devboost.buildboost.model.IBuildContext; +import de.devboost.buildboost.util.ArtifactUtil; + +/** + * A {@link CsFinder} can be used to discover EMFText concrete syntax + * definitions. File with extension 'cs' are recognized as such. + */ +public class CsFinder extends AbstractFileFinder { + + public String TEST_PROJECT_SUFFIX = ".test"; + + public CsFinder(File directory) { + super(directory); + } + + public Collection discoverArtifacts(IBuildContext context) throws BuildException { + Collection csDefinitions = new ArrayList(); + traverse(context, csDefinitions); + return new ArtifactUtil().getSetOfArtifacts(csDefinitions); + } + + protected ConcreteSyntaxDefinition createArtifactFromFile(File file) { + return new ConcreteSyntaxDefinition(file); + } + + protected FileFilter getFileFilter() { + return new FileFilter() { + public boolean accept(File file) { + return file.getName().endsWith(".cs") && file.isFile(); + } + }; + } + + protected FileFilter getDirectoryFilter() { + return new FileFilter() { + public boolean accept(File file) { + return file.isDirectory() && !file.getName().endsWith(TEST_PROJECT_SUFFIX); + } + }; + } +} diff --git a/Extensions/EMFText/de.devboost.buildboost.genext.emftext/src/de/devboost/buildboost/genext/emftext/stages/CompileEMFTextStage.java b/Extensions/EMFText/de.devboost.buildboost.genext.emftext/src/de/devboost/buildboost/genext/emftext/stages/CompileEMFTextStage.java index ffdbdbc..ba6c01e 100644 --- a/Extensions/EMFText/de.devboost.buildboost.genext.emftext/src/de/devboost/buildboost/genext/emftext/stages/CompileEMFTextStage.java +++ b/Extensions/EMFText/de.devboost.buildboost.genext.emftext/src/de/devboost/buildboost/genext/emftext/stages/CompileEMFTextStage.java @@ -1,88 +1,88 @@ -/******************************************************************************* - * Copyright (c) 2006-2012 - * Software Technology Group, Dresden University of Technology - * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 - * - * All rights reserved. This program and the accompanying materials - * are 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 - * - * Contributors: - * Software Technology Group - TU Dresden, Germany; - * DevBoost GmbH - Berlin, Germany - * - initial API and implementation - ******************************************************************************/ -package de.devboost.buildboost.genext.emftext.stages; - -import java.io.File; -import java.util.LinkedHashSet; -import java.util.Set; - -import de.devboost.buildboost.AutoBuilder; -import de.devboost.buildboost.BuildContext; -import de.devboost.buildboost.BuildException; -import de.devboost.buildboost.ant.AntScript; -import de.devboost.buildboost.artifacts.CompiledPlugin; -import de.devboost.buildboost.discovery.EclipseTargetPlatformAnalyzer; -import de.devboost.buildboost.discovery.PluginFinder; -import de.devboost.buildboost.filters.ArtifactTypeFilter; -import de.devboost.buildboost.filters.IdentifierFilter; -import de.devboost.buildboost.model.IUniversalBuildStage; -import de.devboost.buildboost.stages.AbstractBuildStage; -import de.devboost.buildboost.steps.compile.CompileProjectStepProvider; - -public class CompileEMFTextStage extends AbstractBuildStage implements IUniversalBuildStage { - - private static final Set EMFTEXT_SDK_PLUGIN_IDENTIFIERS = new LinkedHashSet(); - - static { - // EMFText core - EMFTEXT_SDK_PLUGIN_IDENTIFIERS.add("org.emftext.access"); - EMFTEXT_SDK_PLUGIN_IDENTIFIERS.add("org.emftext.sdk"); - EMFTEXT_SDK_PLUGIN_IDENTIFIERS.add("org.emftext.sdk.ant"); - EMFTEXT_SDK_PLUGIN_IDENTIFIERS.add("org.emftext.sdk.antlr3_4_0"); - EMFTEXT_SDK_PLUGIN_IDENTIFIERS.add("org.emftext.sdk.automaton"); - EMFTEXT_SDK_PLUGIN_IDENTIFIERS.add("org.emftext.sdk.codegen"); - EMFTEXT_SDK_PLUGIN_IDENTIFIERS.add("org.emftext.sdk.codegen.antlr"); - EMFTEXT_SDK_PLUGIN_IDENTIFIERS.add("org.emftext.sdk.codegen.newproject"); - EMFTEXT_SDK_PLUGIN_IDENTIFIERS.add("org.emftext.sdk.codegen.resource"); - EMFTEXT_SDK_PLUGIN_IDENTIFIERS.add("org.emftext.sdk.codegen.resource.ui"); - EMFTEXT_SDK_PLUGIN_IDENTIFIERS.add("org.emftext.sdk.concretesyntax"); - EMFTEXT_SDK_PLUGIN_IDENTIFIERS.add("org.emftext.sdk.concretesyntax.edit"); - EMFTEXT_SDK_PLUGIN_IDENTIFIERS.add("org.emftext.sdk.concretesyntax.resource.cs"); - EMFTEXT_SDK_PLUGIN_IDENTIFIERS.add("org.emftext.sdk.concretesyntax.resource.cs.ui"); - EMFTEXT_SDK_PLUGIN_IDENTIFIERS.add("org.emftext.sdk.ui"); - // BuildBoost EMFText plug-in - EMFTEXT_SDK_PLUGIN_IDENTIFIERS.add("de.devboost.buildboost.buildext.emftext"); - } - - private String artifactsFolder; - - public void setArtifactsFolder(String artifactsFolder) { - this.artifactsFolder = artifactsFolder; - } - - public AntScript getScript() throws BuildException { - BuildContext context = createContext(false); - context.addBuildParticipant(new EclipseTargetPlatformAnalyzer(new File(artifactsFolder))); - context.addBuildParticipant(new PluginFinder(new File(artifactsFolder))); - - context.addBuildParticipant(new CompileProjectStepProvider()); - - context.addBuildParticipant(new IdentifierFilter(EMFTEXT_SDK_PLUGIN_IDENTIFIERS).or( - new ArtifactTypeFilter(CompiledPlugin.class))); - - AutoBuilder builder = new AutoBuilder(context); - - AntScript script = new AntScript(); - script.setName("Compile EMFText SDK plug-ins"); - script.addTargets(builder.generateAntTargets()); - return script; - } - - @Override - public int getPriority() { - return 100; - } -} +/******************************************************************************* + * Copyright (c) 2006-2012 + * Software Technology Group, Dresden University of Technology + * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 + * + * All rights reserved. This program and the accompanying materials + * are 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 + * + * Contributors: + * Software Technology Group - TU Dresden, Germany; + * DevBoost GmbH - Berlin, Germany + * - initial API and implementation + ******************************************************************************/ +package de.devboost.buildboost.genext.emftext.stages; + +import java.io.File; +import java.util.LinkedHashSet; +import java.util.Set; + +import de.devboost.buildboost.AutoBuilder; +import de.devboost.buildboost.BuildContext; +import de.devboost.buildboost.BuildException; +import de.devboost.buildboost.ant.AntScript; +import de.devboost.buildboost.artifacts.CompiledPlugin; +import de.devboost.buildboost.discovery.EclipseTargetPlatformAnalyzer; +import de.devboost.buildboost.discovery.PluginFinder; +import de.devboost.buildboost.filters.ArtifactTypeFilter; +import de.devboost.buildboost.filters.IdentifierFilter; +import de.devboost.buildboost.model.IUniversalBuildStage; +import de.devboost.buildboost.stages.AbstractBuildStage; +import de.devboost.buildboost.steps.compile.CompileProjectStepProvider; + +public class CompileEMFTextStage extends AbstractBuildStage implements IUniversalBuildStage { + + private static final Set EMFTEXT_SDK_PLUGIN_IDENTIFIERS = new LinkedHashSet(); + + static { + // EMFText core + EMFTEXT_SDK_PLUGIN_IDENTIFIERS.add("org.emftext.access"); + EMFTEXT_SDK_PLUGIN_IDENTIFIERS.add("org.emftext.sdk"); + EMFTEXT_SDK_PLUGIN_IDENTIFIERS.add("org.emftext.sdk.ant"); + EMFTEXT_SDK_PLUGIN_IDENTIFIERS.add("org.emftext.sdk.antlr3_4_0"); + EMFTEXT_SDK_PLUGIN_IDENTIFIERS.add("org.emftext.sdk.automaton"); + EMFTEXT_SDK_PLUGIN_IDENTIFIERS.add("org.emftext.sdk.codegen"); + EMFTEXT_SDK_PLUGIN_IDENTIFIERS.add("org.emftext.sdk.codegen.antlr"); + EMFTEXT_SDK_PLUGIN_IDENTIFIERS.add("org.emftext.sdk.codegen.newproject"); + EMFTEXT_SDK_PLUGIN_IDENTIFIERS.add("org.emftext.sdk.codegen.resource"); + EMFTEXT_SDK_PLUGIN_IDENTIFIERS.add("org.emftext.sdk.codegen.resource.ui"); + EMFTEXT_SDK_PLUGIN_IDENTIFIERS.add("org.emftext.sdk.concretesyntax"); + EMFTEXT_SDK_PLUGIN_IDENTIFIERS.add("org.emftext.sdk.concretesyntax.edit"); + EMFTEXT_SDK_PLUGIN_IDENTIFIERS.add("org.emftext.sdk.concretesyntax.resource.cs"); + EMFTEXT_SDK_PLUGIN_IDENTIFIERS.add("org.emftext.sdk.concretesyntax.resource.cs.ui"); + EMFTEXT_SDK_PLUGIN_IDENTIFIERS.add("org.emftext.sdk.ui"); + // BuildBoost EMFText plug-in + EMFTEXT_SDK_PLUGIN_IDENTIFIERS.add("de.devboost.buildboost.buildext.emftext"); + } + + private String artifactsFolder; + + public void setArtifactsFolder(String artifactsFolder) { + this.artifactsFolder = artifactsFolder; + } + + public AntScript getScript() throws BuildException { + BuildContext context = createContext(false); + context.addBuildParticipant(new EclipseTargetPlatformAnalyzer(new File(artifactsFolder))); + context.addBuildParticipant(new PluginFinder(new File(artifactsFolder))); + + context.addBuildParticipant(new CompileProjectStepProvider()); + + context.addBuildParticipant(new IdentifierFilter(EMFTEXT_SDK_PLUGIN_IDENTIFIERS).or( + new ArtifactTypeFilter(CompiledPlugin.class))); + + AutoBuilder builder = new AutoBuilder(context); + + AntScript script = new AntScript(); + script.setName("Compile EMFText SDK plug-ins"); + script.addTargets(builder.generateAntTargets()); + return script; + } + + @Override + public int getPriority() { + return 100; + } +} diff --git a/Extensions/EMFText/de.devboost.buildboost.genext.emftext/src/de/devboost/buildboost/genext/emftext/stages/GenerateEMFTextCodeStage.java b/Extensions/EMFText/de.devboost.buildboost.genext.emftext/src/de/devboost/buildboost/genext/emftext/stages/GenerateEMFTextCodeStage.java index bb944c1..3cc19d4 100644 --- a/Extensions/EMFText/de.devboost.buildboost.genext.emftext/src/de/devboost/buildboost/genext/emftext/stages/GenerateEMFTextCodeStage.java +++ b/Extensions/EMFText/de.devboost.buildboost.genext.emftext/src/de/devboost/buildboost/genext/emftext/stages/GenerateEMFTextCodeStage.java @@ -1,78 +1,78 @@ -/******************************************************************************* - * Copyright (c) 2006-2012 - * Software Technology Group, Dresden University of Technology - * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 - * - * All rights reserved. This program and the accompanying materials - * are 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 - * - * Contributors: - * Software Technology Group - TU Dresden, Germany; - * DevBoost GmbH - Berlin, Germany - * - initial API and implementation - ******************************************************************************/ -package de.devboost.buildboost.genext.emftext.stages; - -import java.io.File; - -import de.devboost.buildboost.AutoBuilder; -import de.devboost.buildboost.BuildContext; -import de.devboost.buildboost.BuildException; -import de.devboost.buildboost.ant.AntScript; -import de.devboost.buildboost.discovery.EclipseFeatureFinder; -import de.devboost.buildboost.discovery.EclipseTargetPlatformAnalyzer; -import de.devboost.buildboost.discovery.PluginFinder; -import de.devboost.buildboost.filters.IdentifierFilter; -import de.devboost.buildboost.filters.NegatingFilter; -import de.devboost.buildboost.genext.emftext.discovery.CsFinder; -import de.devboost.buildboost.genext.emftext.steps.GenerateResourcePluginsStepProvider; -import de.devboost.buildboost.model.IUniversalBuildStage; -import de.devboost.buildboost.stages.AbstractBuildStage; - -public class GenerateEMFTextCodeStage extends AbstractBuildStage implements IUniversalBuildStage { - - private String artifactsFolder; - - public void setArtifactsFolder(String artifactsFolder) { - this.artifactsFolder = artifactsFolder; - } - - public AntScript getScript() throws BuildException { - File buildDir = new File(artifactsFolder); - - BuildContext context = createContext(true); - - addCSFilters(context); - - context.addBuildParticipant(new CsFinder(buildDir)); - context.addBuildParticipant(new EclipseTargetPlatformAnalyzer(buildDir)); - context.addBuildParticipant(new EclipseFeatureFinder(buildDir)); - context.addBuildParticipant(new PluginFinder(buildDir)); - - context.addBuildParticipant(new GenerateResourcePluginsStepProvider()); - - AutoBuilder builder = new AutoBuilder(context); - - AntScript script = new AntScript(); - script.setName("Generate code from concrete syntax definitions"); - script.addTargets(builder.generateAntTargets()); - - return script; - } - - protected void addCSFilters(BuildContext context) { - NegatingFilter filter1 = new NegatingFilter(new IdentifierFilter("concretesyntax.genmodel")); - NegatingFilter filter2 = new NegatingFilter(new IdentifierFilter("concretesyntax.cs")); - NegatingFilter filter3 = new NegatingFilter(new IdentifierFilter("concretesyntax.newfile.cs")); - context.addBuildParticipant(filter1); - context.addBuildParticipant(filter2); - context.addBuildParticipant(filter3); - } - - @Override - public int getPriority() { - return 1001; - } -} +/******************************************************************************* + * Copyright (c) 2006-2012 + * Software Technology Group, Dresden University of Technology + * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 + * + * All rights reserved. This program and the accompanying materials + * are 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 + * + * Contributors: + * Software Technology Group - TU Dresden, Germany; + * DevBoost GmbH - Berlin, Germany + * - initial API and implementation + ******************************************************************************/ +package de.devboost.buildboost.genext.emftext.stages; + +import java.io.File; + +import de.devboost.buildboost.AutoBuilder; +import de.devboost.buildboost.BuildContext; +import de.devboost.buildboost.BuildException; +import de.devboost.buildboost.ant.AntScript; +import de.devboost.buildboost.discovery.EclipseFeatureFinder; +import de.devboost.buildboost.discovery.EclipseTargetPlatformAnalyzer; +import de.devboost.buildboost.discovery.PluginFinder; +import de.devboost.buildboost.filters.IdentifierFilter; +import de.devboost.buildboost.filters.NegatingFilter; +import de.devboost.buildboost.genext.emftext.discovery.CsFinder; +import de.devboost.buildboost.genext.emftext.steps.GenerateResourcePluginsStepProvider; +import de.devboost.buildboost.model.IUniversalBuildStage; +import de.devboost.buildboost.stages.AbstractBuildStage; + +public class GenerateEMFTextCodeStage extends AbstractBuildStage implements IUniversalBuildStage { + + private String artifactsFolder; + + public void setArtifactsFolder(String artifactsFolder) { + this.artifactsFolder = artifactsFolder; + } + + public AntScript getScript() throws BuildException { + File buildDir = new File(artifactsFolder); + + BuildContext context = createContext(true); + + addCSFilters(context); + + context.addBuildParticipant(new CsFinder(buildDir)); + context.addBuildParticipant(new EclipseTargetPlatformAnalyzer(buildDir)); + context.addBuildParticipant(new EclipseFeatureFinder(buildDir)); + context.addBuildParticipant(new PluginFinder(buildDir)); + + context.addBuildParticipant(new GenerateResourcePluginsStepProvider()); + + AutoBuilder builder = new AutoBuilder(context); + + AntScript script = new AntScript(); + script.setName("Generate code from concrete syntax definitions"); + script.addTargets(builder.generateAntTargets()); + + return script; + } + + protected void addCSFilters(BuildContext context) { + NegatingFilter filter1 = new NegatingFilter(new IdentifierFilter("concretesyntax.genmodel")); + NegatingFilter filter2 = new NegatingFilter(new IdentifierFilter("concretesyntax.cs")); + NegatingFilter filter3 = new NegatingFilter(new IdentifierFilter("concretesyntax.newfile.cs")); + context.addBuildParticipant(filter1); + context.addBuildParticipant(filter2); + context.addBuildParticipant(filter3); + } + + @Override + public int getPriority() { + return 1001; + } +} diff --git a/Extensions/EMFText/de.devboost.buildboost.genext.emftext/src/de/devboost/buildboost/genext/emftext/steps/GenerateResourcePluginsStep.java b/Extensions/EMFText/de.devboost.buildboost.genext.emftext/src/de/devboost/buildboost/genext/emftext/steps/GenerateResourcePluginsStep.java index e179ba9..9281217 100644 --- a/Extensions/EMFText/de.devboost.buildboost.genext.emftext/src/de/devboost/buildboost/genext/emftext/steps/GenerateResourcePluginsStep.java +++ b/Extensions/EMFText/de.devboost.buildboost.genext.emftext/src/de/devboost/buildboost/genext/emftext/steps/GenerateResourcePluginsStep.java @@ -1,78 +1,115 @@ -/******************************************************************************* - * Copyright (c) 2006-2012 - * Software Technology Group, Dresden University of Technology - * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 - * - * All rights reserved. This program and the accompanying materials - * are 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 - * - * Contributors: - * Software Technology Group - TU Dresden, Germany; - * DevBoost GmbH - Berlin, Germany - * - initial API and implementation - ******************************************************************************/ -package de.devboost.buildboost.genext.emftext.steps; - -import java.io.File; -import java.util.Collection; -import java.util.Collections; -import java.util.List; - -import static de.devboost.buildboost.genext.emftext.IConstants.*; - -import de.devboost.buildboost.BuildException; -import de.devboost.buildboost.IConstants; -import de.devboost.buildboost.ant.AbstractAntTargetGenerator; -import de.devboost.buildboost.ant.AntTarget; -import de.devboost.buildboost.artifacts.Plugin; -import de.devboost.buildboost.genext.emftext.artifacts.ConcreteSyntaxDefinition; -import de.devboost.buildboost.model.IDependable; -import de.devboost.buildboost.steps.ClasspathHelper; -import de.devboost.buildboost.util.XMLContent; - -/** - * The {@link GenerateResourcePluginsStep} generates a build script the can be - * used to run the EMFText code generators for a syntax definition. - */ -public class GenerateResourcePluginsStep extends AbstractAntTargetGenerator { - - private ConcreteSyntaxDefinition syntaxDefinition; - private List plugins; - - public GenerateResourcePluginsStep(List plugins, ConcreteSyntaxDefinition syntaxDefinition) { - this.plugins = plugins; - this.syntaxDefinition = syntaxDefinition; - } - - public Collection generateAntTargets() throws BuildException { - Collection dependencies = syntaxDefinition.getDependencies(); - if (dependencies.isEmpty()) { - throw new BuildException("Concrete syntax definitions are expected to have a dependency to the EMFText SDK."); - } - XMLContent classpath = new ClasspathHelper().getClasspath(syntaxDefinition, true); - - String csFilePath = syntaxDefinition.getFile().getAbsolutePath(); - - XMLContent content = new XMLContent(); - content.append(""); - content.append(""); - content.append(""); - content.append(""); - content.append(""); - content.append(""); - content.append(""); - for (Plugin plugin : plugins) { - content.append(""); - } - content.append(""); - content.append(classpath); - content.append(""); - content.append(""); - content.append(IConstants.NL); - - String csID = csFilePath.replace(File.separator, "-"); - return Collections.singleton(new AntTarget("emftext-codegen-" + csID, content)); - } -} +/******************************************************************************* + * Copyright (c) 2006-2012 + * Software Technology Group, Dresden University of Technology + * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 + * + * All rights reserved. This program and the accompanying materials + * are 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 + * + * Contributors: + * Software Technology Group - TU Dresden, Germany; + * DevBoost GmbH - Berlin, Germany + * - initial API and implementation + ******************************************************************************/ +package de.devboost.buildboost.genext.emftext.steps; + +import static de.devboost.buildboost.genext.emftext.IConstants.BUILDEXT_EXECUTABLE; + +import java.io.File; +import java.util.Collection; +import java.util.Collections; +import java.util.List; + +import de.devboost.buildboost.BuildException; +import de.devboost.buildboost.GlobalBuildConfiguration; +import de.devboost.buildboost.IConstants; +import de.devboost.buildboost.ant.AbstractAntTargetGenerator; +import de.devboost.buildboost.ant.AntTarget; +import de.devboost.buildboost.artifacts.Plugin; +import de.devboost.buildboost.genext.emftext.artifacts.ConcreteSyntaxDefinition; +import de.devboost.buildboost.model.IDependable; +import de.devboost.buildboost.steps.ClasspathHelper; +import de.devboost.buildboost.steps.clone.CloneRepositoriesBuildStep; +import de.devboost.buildboost.util.XMLContent; + +/** + * The {@link GenerateResourcePluginsStep} generates a build script the can be + * used to run the EMFText code generators for a syntax definition. + */ +public class GenerateResourcePluginsStep extends AbstractAntTargetGenerator { + + private final ConcreteSyntaxDefinition syntaxDefinition; + private final List plugins; + + public GenerateResourcePluginsStep(List plugins, + ConcreteSyntaxDefinition syntaxDefinition) { + this.plugins = plugins; + this.syntaxDefinition = syntaxDefinition; + } + + @Override + public Collection generateAntTargets() throws BuildException { + + final GlobalBuildConfiguration globalConfig = GlobalBuildConfiguration + .getInstance(); + + Collection dependencies = syntaxDefinition + .getDependencies(); + if (dependencies.isEmpty()) { + throw new BuildException( + "Concrete syntax definitions are expected to have a dependency to the EMFText SDK."); + } + XMLContent classpath = new ClasspathHelper().getClasspath( + syntaxDefinition, true); + + String csFilePath = syntaxDefinition.getFile().getAbsolutePath(); + + XMLContent content = new XMLContent(); + content.append(""); + content.append(""); + content.append(""); + content.append(""); + if (globalConfig.isDebugEnabled()) { + content.append(""); + } + content.append(""); + content.append(""); + content.append(""); + + String csID = csFilePath.replace(File.separator, "-"); + String paraFileName = CloneRepositoriesBuildStep + .encodeFileOrFolderName(csID + ".properties"); + content.append(""); + + // for (Plugin plugin : plugins) { + // content.append(""); + // } + + content.append(""); + content.append(classpath); + content.append(""); + content.append(""); + content.append(IConstants.NL); + + writeParaFile(paraFileName, plugins); + + return Collections.singleton(new AntTarget("emftext-codegen-" + csID, + content)); + } +} diff --git a/Extensions/EMFText/de.devboost.buildboost.genext.emftext/src/de/devboost/buildboost/genext/emftext/steps/GenerateResourcePluginsStepProvider.java b/Extensions/EMFText/de.devboost.buildboost.genext.emftext/src/de/devboost/buildboost/genext/emftext/steps/GenerateResourcePluginsStepProvider.java index 7518fd7..0a7f01c 100644 --- a/Extensions/EMFText/de.devboost.buildboost.genext.emftext/src/de/devboost/buildboost/genext/emftext/steps/GenerateResourcePluginsStepProvider.java +++ b/Extensions/EMFText/de.devboost.buildboost.genext.emftext/src/de/devboost/buildboost/genext/emftext/steps/GenerateResourcePluginsStepProvider.java @@ -1,60 +1,60 @@ -/******************************************************************************* - * Copyright (c) 2006-2012 - * Software Technology Group, Dresden University of Technology - * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 - * - * All rights reserved. This program and the accompanying materials - * are 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 - * - * Contributors: - * Software Technology Group - TU Dresden, Germany; - * DevBoost GmbH - Berlin, Germany - * - initial API and implementation - ******************************************************************************/ -package de.devboost.buildboost.genext.emftext.steps; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.List; - -import de.devboost.buildboost.ant.AbstractAntTargetGeneratorProvider; -import de.devboost.buildboost.ant.IAntTargetGenerator; -import de.devboost.buildboost.artifacts.Plugin; -import de.devboost.buildboost.genext.emftext.artifacts.ConcreteSyntaxDefinition; -import de.devboost.buildboost.model.IArtifact; -import de.devboost.buildboost.model.IBuildContext; - -/** - * The {@link GenerateResourcePluginsStepProvider} add a - * {@link GenerateResourcePluginsStep} for each EMFText syntax definition. - */ -public class GenerateResourcePluginsStepProvider extends AbstractAntTargetGeneratorProvider { - - public List getAntTargetGenerators(IBuildContext context, IArtifact artifact) { - if (artifact instanceof ConcreteSyntaxDefinition) { - List plugins = getDiscoveredPlugins(context); - - ConcreteSyntaxDefinition syntaxDefinition = (ConcreteSyntaxDefinition) artifact; - List steps = new ArrayList(1); - steps.add(new GenerateResourcePluginsStep(plugins, syntaxDefinition)); - return steps; - } else { - return Collections.emptyList(); - } - } - - private List getDiscoveredPlugins(IBuildContext context) { - Collection discoveredArtifacts = context.getDiscoveredArtifacts(); - List plugins = new ArrayList(); - for (IArtifact discoveredArtifact : discoveredArtifacts) { - if (discoveredArtifact instanceof Plugin) { - Plugin plugin = (Plugin) discoveredArtifact; - plugins.add(plugin); - } - } - return plugins; - } -} +/******************************************************************************* + * Copyright (c) 2006-2012 + * Software Technology Group, Dresden University of Technology + * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 + * + * All rights reserved. This program and the accompanying materials + * are 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 + * + * Contributors: + * Software Technology Group - TU Dresden, Germany; + * DevBoost GmbH - Berlin, Germany + * - initial API and implementation + ******************************************************************************/ +package de.devboost.buildboost.genext.emftext.steps; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.List; + +import de.devboost.buildboost.ant.AbstractAntTargetGeneratorProvider; +import de.devboost.buildboost.ant.IAntTargetGenerator; +import de.devboost.buildboost.artifacts.Plugin; +import de.devboost.buildboost.genext.emftext.artifacts.ConcreteSyntaxDefinition; +import de.devboost.buildboost.model.IArtifact; +import de.devboost.buildboost.model.IBuildContext; + +/** + * The {@link GenerateResourcePluginsStepProvider} add a + * {@link GenerateResourcePluginsStep} for each EMFText syntax definition. + */ +public class GenerateResourcePluginsStepProvider extends AbstractAntTargetGeneratorProvider { + + public List getAntTargetGenerators(IBuildContext context, IArtifact artifact) { + if (artifact instanceof ConcreteSyntaxDefinition) { + List plugins = getDiscoveredPlugins(context); + + ConcreteSyntaxDefinition syntaxDefinition = (ConcreteSyntaxDefinition) artifact; + List steps = new ArrayList(1); + steps.add(new GenerateResourcePluginsStep(plugins, syntaxDefinition)); + return steps; + } else { + return Collections.emptyList(); + } + } + + private List getDiscoveredPlugins(IBuildContext context) { + Collection discoveredArtifacts = context.getDiscoveredArtifacts(); + List plugins = new ArrayList(); + for (IArtifact discoveredArtifact : discoveredArtifacts) { + if (discoveredArtifact instanceof Plugin) { + Plugin plugin = (Plugin) discoveredArtifact; + plugins.add(plugin); + } + } + return plugins; + } +} diff --git a/Extensions/EMFTextExamples/de.devboost.buildboost.genext.emftext.examples/src/de/devboost/buildboost/genext/emftext/examples/stages/PackageEMFTextExamplesStage.java b/Extensions/EMFTextExamples/de.devboost.buildboost.genext.emftext.examples/src/de/devboost/buildboost/genext/emftext/examples/stages/PackageEMFTextExamplesStage.java index ca947d3..c24d552 100644 --- a/Extensions/EMFTextExamples/de.devboost.buildboost.genext.emftext.examples/src/de/devboost/buildboost/genext/emftext/examples/stages/PackageEMFTextExamplesStage.java +++ b/Extensions/EMFTextExamples/de.devboost.buildboost.genext.emftext.examples/src/de/devboost/buildboost/genext/emftext/examples/stages/PackageEMFTextExamplesStage.java @@ -1,66 +1,66 @@ -/******************************************************************************* - * Copyright (c) 2006-2012 - * Software Technology Group, Dresden University of Technology - * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 - * - * All rights reserved. This program and the accompanying materials - * are 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 - * - * Contributors: - * Software Technology Group - TU Dresden, Germany; - * DevBoost GmbH - Berlin, Germany - * - initial API and implementation - ******************************************************************************/ -package de.devboost.buildboost.genext.emftext.examples.stages; - -import java.io.File; - -import de.devboost.buildboost.AutoBuilder; -import de.devboost.buildboost.BuildContext; -import de.devboost.buildboost.BuildException; -import de.devboost.buildboost.ant.AntScript; -import de.devboost.buildboost.discovery.PluginFinder; -import de.devboost.buildboost.filters.IdentifierRegexFilter; -import de.devboost.buildboost.genext.emftext.examples.steps.PackageEMFTextExamplesStepProvider; -import de.devboost.buildboost.model.IUniversalBuildStage; -import de.devboost.buildboost.stages.AbstractBuildStage; - -public class PackageEMFTextExamplesStage extends AbstractBuildStage implements IUniversalBuildStage { - - private String artifactsFolder; - - public void setArtifactsFolder(String artifactsFolder) { - this.artifactsFolder = artifactsFolder; - } - - public AntScript getScript() throws BuildException { - File buildDir = new File(artifactsFolder); - - BuildContext context = createContext(true); - context.setIgnoreUnresolvedDependencies(true); - - addUIProjectsFilters(context); - context.addBuildParticipant(new PluginFinder(buildDir)); - context.addBuildParticipant(new PackageEMFTextExamplesStepProvider()); - - AutoBuilder builder = new AutoBuilder(context); - - AntScript script = new AntScript(); - script.setName("Package EMFText example projects"); - script.addTargets(builder.generateAntTargets()); - - return script; - } - - protected void addUIProjectsFilters(BuildContext context) { - IdentifierRegexFilter uiProjectsFilter = new IdentifierRegexFilter(".*\\.ui"); - context.addBuildParticipant(uiProjectsFilter); - } - - @Override - public int getPriority() { - return 1010; - } -} +/******************************************************************************* + * Copyright (c) 2006-2012 + * Software Technology Group, Dresden University of Technology + * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 + * + * All rights reserved. This program and the accompanying materials + * are 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 + * + * Contributors: + * Software Technology Group - TU Dresden, Germany; + * DevBoost GmbH - Berlin, Germany + * - initial API and implementation + ******************************************************************************/ +package de.devboost.buildboost.genext.emftext.examples.stages; + +import java.io.File; + +import de.devboost.buildboost.AutoBuilder; +import de.devboost.buildboost.BuildContext; +import de.devboost.buildboost.BuildException; +import de.devboost.buildboost.ant.AntScript; +import de.devboost.buildboost.discovery.PluginFinder; +import de.devboost.buildboost.filters.IdentifierRegexFilter; +import de.devboost.buildboost.genext.emftext.examples.steps.PackageEMFTextExamplesStepProvider; +import de.devboost.buildboost.model.IUniversalBuildStage; +import de.devboost.buildboost.stages.AbstractBuildStage; + +public class PackageEMFTextExamplesStage extends AbstractBuildStage implements IUniversalBuildStage { + + private String artifactsFolder; + + public void setArtifactsFolder(String artifactsFolder) { + this.artifactsFolder = artifactsFolder; + } + + public AntScript getScript() throws BuildException { + File buildDir = new File(artifactsFolder); + + BuildContext context = createContext(true); + context.setIgnoreUnresolvedDependencies(true); + + addUIProjectsFilters(context); + context.addBuildParticipant(new PluginFinder(buildDir)); + context.addBuildParticipant(new PackageEMFTextExamplesStepProvider()); + + AutoBuilder builder = new AutoBuilder(context); + + AntScript script = new AntScript(); + script.setName("Package EMFText example projects"); + script.addTargets(builder.generateAntTargets()); + + return script; + } + + protected void addUIProjectsFilters(BuildContext context) { + IdentifierRegexFilter uiProjectsFilter = new IdentifierRegexFilter(".*\\.ui"); + context.addBuildParticipant(uiProjectsFilter); + } + + @Override + public int getPriority() { + return 1010; + } +} diff --git a/Extensions/EMFTextExamples/de.devboost.buildboost.genext.emftext.examples/src/de/devboost/buildboost/genext/emftext/examples/steps/PackageEMFTextExamplesStep.java b/Extensions/EMFTextExamples/de.devboost.buildboost.genext.emftext.examples/src/de/devboost/buildboost/genext/emftext/examples/steps/PackageEMFTextExamplesStep.java index 00038cc..9b3835b 100644 --- a/Extensions/EMFTextExamples/de.devboost.buildboost.genext.emftext.examples/src/de/devboost/buildboost/genext/emftext/examples/steps/PackageEMFTextExamplesStep.java +++ b/Extensions/EMFTextExamples/de.devboost.buildboost.genext.emftext.examples/src/de/devboost/buildboost/genext/emftext/examples/steps/PackageEMFTextExamplesStep.java @@ -1,50 +1,50 @@ -/******************************************************************************* - * Copyright (c) 2006-2012 - * Software Technology Group, Dresden University of Technology - * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 - * - * All rights reserved. This program and the accompanying materials - * are 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 - * - * Contributors: - * Software Technology Group - TU Dresden, Germany; - * DevBoost GmbH - Berlin, Germany - * - initial API and implementation - ******************************************************************************/ -package de.devboost.buildboost.genext.emftext.examples.steps; - -import java.io.File; -import java.util.Collection; -import java.util.Collections; - -import de.devboost.buildboost.BuildException; -import de.devboost.buildboost.ant.AbstractAntTargetGenerator; -import de.devboost.buildboost.ant.AntTarget; -import de.devboost.buildboost.artifacts.Plugin; -import de.devboost.buildboost.util.XMLContent; - -/** - * The {@link PackageEMFTextExamplesStep} generates a build script the can be - * used to run the EMFText code generators for a syntax definition. - */ -public class PackageEMFTextExamplesStep extends AbstractAntTargetGenerator { - - private File exampleDir; - private Plugin plugin; - - public PackageEMFTextExamplesStep(Plugin plugin, File exampleDir) { - this.plugin = plugin; - this.exampleDir = exampleDir; - } - - public Collection generateAntTargets() throws BuildException { - XMLContent content = new XMLContent(); - content.append(""); - content.append(""); - content.append(""); - - return Collections.singleton(new AntTarget("zipping-emftext-example-" + exampleDir.getName(), content)); - } -} +/******************************************************************************* + * Copyright (c) 2006-2012 + * Software Technology Group, Dresden University of Technology + * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 + * + * All rights reserved. This program and the accompanying materials + * are 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 + * + * Contributors: + * Software Technology Group - TU Dresden, Germany; + * DevBoost GmbH - Berlin, Germany + * - initial API and implementation + ******************************************************************************/ +package de.devboost.buildboost.genext.emftext.examples.steps; + +import java.io.File; +import java.util.Collection; +import java.util.Collections; + +import de.devboost.buildboost.BuildException; +import de.devboost.buildboost.ant.AbstractAntTargetGenerator; +import de.devboost.buildboost.ant.AntTarget; +import de.devboost.buildboost.artifacts.Plugin; +import de.devboost.buildboost.util.XMLContent; + +/** + * The {@link PackageEMFTextExamplesStep} generates a build script the can be + * used to run the EMFText code generators for a syntax definition. + */ +public class PackageEMFTextExamplesStep extends AbstractAntTargetGenerator { + + private File exampleDir; + private Plugin plugin; + + public PackageEMFTextExamplesStep(Plugin plugin, File exampleDir) { + this.plugin = plugin; + this.exampleDir = exampleDir; + } + + public Collection generateAntTargets() throws BuildException { + XMLContent content = new XMLContent(); + content.append(""); + content.append(""); + content.append(""); + + return Collections.singleton(new AntTarget("zipping-emftext-example-" + exampleDir.getName(), content)); + } +} diff --git a/Extensions/EMFTextExamples/de.devboost.buildboost.genext.emftext.examples/src/de/devboost/buildboost/genext/emftext/examples/steps/PackageEMFTextExamplesStepProvider.java b/Extensions/EMFTextExamples/de.devboost.buildboost.genext.emftext.examples/src/de/devboost/buildboost/genext/emftext/examples/steps/PackageEMFTextExamplesStepProvider.java index 63dbae5..c6358d0 100644 --- a/Extensions/EMFTextExamples/de.devboost.buildboost.genext.emftext.examples/src/de/devboost/buildboost/genext/emftext/examples/steps/PackageEMFTextExamplesStepProvider.java +++ b/Extensions/EMFTextExamples/de.devboost.buildboost.genext.emftext.examples/src/de/devboost/buildboost/genext/emftext/examples/steps/PackageEMFTextExamplesStepProvider.java @@ -1,55 +1,55 @@ -/******************************************************************************* - * Copyright (c) 2006-2012 - * Software Technology Group, Dresden University of Technology - * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 - * - * All rights reserved. This program and the accompanying materials - * are 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 - * - * Contributors: - * Software Technology Group - TU Dresden, Germany; - * DevBoost GmbH - Berlin, Germany - * - initial API and implementation - ******************************************************************************/ -package de.devboost.buildboost.genext.emftext.examples.steps; - -import java.io.File; -import java.util.Collections; -import java.util.List; - -import de.devboost.buildboost.ant.AbstractAntTargetGeneratorProvider; -import de.devboost.buildboost.ant.IAntTargetGenerator; -import de.devboost.buildboost.artifacts.Plugin; -import de.devboost.buildboost.model.IArtifact; -import de.devboost.buildboost.model.IBuildContext; - -/** - * The {@link PackageEMFTextExamplesStepProvider} add a - * {@link PackageEMFTextExamplesStep} for each example project found. - */ -public class PackageEMFTextExamplesStepProvider extends AbstractAntTargetGeneratorProvider { - - private String[] exampleExtensions = new String[] {".example", ".examples"}; - - public List getAntTargetGenerators(IBuildContext context, IArtifact artifact) { - if (artifact instanceof Plugin) { - Plugin plugin = (Plugin) artifact; - String languageID = plugin.getIdentifier(); - int idx = languageID.lastIndexOf(".resource."); - if (idx != -1) { - languageID = languageID.substring(0, idx); - for (String exampleExtension : exampleExtensions) { - String examplePlugin = languageID + exampleExtension; - File examplePluginDir = new File(plugin.getFile().getParent(), examplePlugin); - if (examplePluginDir.exists()) { - return Collections.singletonList( - new PackageEMFTextExamplesStep(plugin, examplePluginDir)); - } - } - } - } - return Collections.emptyList(); - } -} +/******************************************************************************* + * Copyright (c) 2006-2012 + * Software Technology Group, Dresden University of Technology + * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 + * + * All rights reserved. This program and the accompanying materials + * are 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 + * + * Contributors: + * Software Technology Group - TU Dresden, Germany; + * DevBoost GmbH - Berlin, Germany + * - initial API and implementation + ******************************************************************************/ +package de.devboost.buildboost.genext.emftext.examples.steps; + +import java.io.File; +import java.util.Collections; +import java.util.List; + +import de.devboost.buildboost.ant.AbstractAntTargetGeneratorProvider; +import de.devboost.buildboost.ant.IAntTargetGenerator; +import de.devboost.buildboost.artifacts.Plugin; +import de.devboost.buildboost.model.IArtifact; +import de.devboost.buildboost.model.IBuildContext; + +/** + * The {@link PackageEMFTextExamplesStepProvider} add a + * {@link PackageEMFTextExamplesStep} for each example project found. + */ +public class PackageEMFTextExamplesStepProvider extends AbstractAntTargetGeneratorProvider { + + private String[] exampleExtensions = new String[] {".example", ".examples"}; + + public List getAntTargetGenerators(IBuildContext context, IArtifact artifact) { + if (artifact instanceof Plugin) { + Plugin plugin = (Plugin) artifact; + String languageID = plugin.getIdentifier(); + int idx = languageID.lastIndexOf(".resource."); + if (idx != -1) { + languageID = languageID.substring(0, idx); + for (String exampleExtension : exampleExtensions) { + String examplePlugin = languageID + exampleExtension; + File examplePluginDir = new File(plugin.getFile().getParent(), examplePlugin); + if (examplePluginDir.exists()) { + return Collections.singletonList( + new PackageEMFTextExamplesStep(plugin, examplePluginDir)); + } + } + } + } + return Collections.emptyList(); + } +} diff --git a/Extensions/JUnit/de.devboost.buildboost.genext.test.junit/src/de/devboost/buildboost/genext/test/junit/stages/JUnitTestStage.java b/Extensions/JUnit/de.devboost.buildboost.genext.test.junit/src/de/devboost/buildboost/genext/test/junit/stages/JUnitTestStage.java index 841ff02..de2e14f 100644 --- a/Extensions/JUnit/de.devboost.buildboost.genext.test.junit/src/de/devboost/buildboost/genext/test/junit/stages/JUnitTestStage.java +++ b/Extensions/JUnit/de.devboost.buildboost.genext.test.junit/src/de/devboost/buildboost/genext/test/junit/stages/JUnitTestStage.java @@ -1,82 +1,82 @@ -/******************************************************************************* - * Copyright (c) 2006-2012 - * Software Technology Group, Dresden University of Technology - * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 - * - * All rights reserved. This program and the accompanying materials - * are 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 - * - * Contributors: - * Software Technology Group - TU Dresden, Germany; - * DevBoost GmbH - Berlin, Germany - * - initial API and implementation - ******************************************************************************/ -package de.devboost.buildboost.genext.test.junit.stages; - -import java.io.File; -import java.util.ArrayList; -import java.util.LinkedHashSet; -import java.util.Set; - -import de.devboost.buildboost.AutoBuilder; -import de.devboost.buildboost.BuildContext; -import de.devboost.buildboost.BuildException; -import de.devboost.buildboost.ant.AntScript; -import de.devboost.buildboost.discovery.EclipseTargetPlatformAnalyzer; -import de.devboost.buildboost.discovery.PluginFinder; -import de.devboost.buildboost.genext.test.junit.steps.RunJUnitTestsStepProvider; -import de.devboost.buildboost.genext.test.junit.steps.StopBuildIfJUnitTestsHaveFailedProvider; -import de.devboost.buildboost.model.IUniversalBuildStage; -import de.devboost.buildboost.stages.AbstractBuildStage; - -public class JUnitTestStage extends AbstractBuildStage implements IUniversalBuildStage { - - public static final String TEST_RESULTS_FOLDER = "test-results"; - - private String artifactsFolder; - - private Set excludedTestClasses = new LinkedHashSet(); - - public void setArtifactsFolder(String artifactsFolder) { - this.artifactsFolder = artifactsFolder; - } - - public void addExcludedTestClass(String classToExclude) { - this.excludedTestClasses.add(classToExclude); - } - - public AntScript getScript() throws BuildException { - checkConfiguration(); - - File buildDir = new File(artifactsFolder); - File testResultDir = new File(buildDir.getParentFile(), TEST_RESULTS_FOLDER); - - BuildContext context = createContext(false); - context.addBuildParticipant(new EclipseTargetPlatformAnalyzer(buildDir)); - context.addBuildParticipant(new PluginFinder(buildDir)); - - context.addBuildParticipant(new RunJUnitTestsStepProvider(testResultDir, new ArrayList(excludedTestClasses))); - context.addBuildParticipant(new StopBuildIfJUnitTestsHaveFailedProvider()); - - AutoBuilder builder = new AutoBuilder(context); - - AntScript script = new AntScript(); - script.setName("Run JUnit tests"); - script.addTargets(builder.generateAntTargets()); - - return script; - } - - private void checkConfiguration() throws BuildException { - if (artifactsFolder == null) { - throw new BuildException("buildDirPath is not set in " + this.getClass().getSimpleName()); - } - } - - @Override - public int getPriority() { - return 9000; - } -} +/******************************************************************************* + * Copyright (c) 2006-2012 + * Software Technology Group, Dresden University of Technology + * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 + * + * All rights reserved. This program and the accompanying materials + * are 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 + * + * Contributors: + * Software Technology Group - TU Dresden, Germany; + * DevBoost GmbH - Berlin, Germany + * - initial API and implementation + ******************************************************************************/ +package de.devboost.buildboost.genext.test.junit.stages; + +import java.io.File; +import java.util.ArrayList; +import java.util.LinkedHashSet; +import java.util.Set; + +import de.devboost.buildboost.AutoBuilder; +import de.devboost.buildboost.BuildContext; +import de.devboost.buildboost.BuildException; +import de.devboost.buildboost.ant.AntScript; +import de.devboost.buildboost.discovery.EclipseTargetPlatformAnalyzer; +import de.devboost.buildboost.discovery.PluginFinder; +import de.devboost.buildboost.genext.test.junit.steps.RunJUnitTestsStepProvider; +import de.devboost.buildboost.genext.test.junit.steps.StopBuildIfJUnitTestsHaveFailedProvider; +import de.devboost.buildboost.model.IUniversalBuildStage; +import de.devboost.buildboost.stages.AbstractBuildStage; + +public class JUnitTestStage extends AbstractBuildStage implements IUniversalBuildStage { + + public static final String TEST_RESULTS_FOLDER = "test-results"; + + private String artifactsFolder; + + private Set excludedTestClasses = new LinkedHashSet(); + + public void setArtifactsFolder(String artifactsFolder) { + this.artifactsFolder = artifactsFolder; + } + + public void addExcludedTestClass(String classToExclude) { + this.excludedTestClasses.add(classToExclude); + } + + public AntScript getScript() throws BuildException { + checkConfiguration(); + + File buildDir = new File(artifactsFolder); + File testResultDir = new File(buildDir.getParentFile(), TEST_RESULTS_FOLDER); + + BuildContext context = createContext(false); + context.addBuildParticipant(new EclipseTargetPlatformAnalyzer(buildDir)); + context.addBuildParticipant(new PluginFinder(buildDir)); + + context.addBuildParticipant(new RunJUnitTestsStepProvider(testResultDir, new ArrayList(excludedTestClasses))); + context.addBuildParticipant(new StopBuildIfJUnitTestsHaveFailedProvider()); + + AutoBuilder builder = new AutoBuilder(context); + + AntScript script = new AntScript(); + script.setName("Run JUnit tests"); + script.addTargets(builder.generateAntTargets()); + + return script; + } + + private void checkConfiguration() throws BuildException { + if (artifactsFolder == null) { + throw new BuildException("buildDirPath is not set in " + this.getClass().getSimpleName()); + } + } + + @Override + public int getPriority() { + return 9000; + } +} diff --git a/Extensions/JUnit/de.devboost.buildboost.genext.test.junit/src/de/devboost/buildboost/genext/test/junit/steps/JUnitTestProjectDetector.java b/Extensions/JUnit/de.devboost.buildboost.genext.test.junit/src/de/devboost/buildboost/genext/test/junit/steps/JUnitTestProjectDetector.java index 437039a..097f82c 100644 --- a/Extensions/JUnit/de.devboost.buildboost.genext.test.junit/src/de/devboost/buildboost/genext/test/junit/steps/JUnitTestProjectDetector.java +++ b/Extensions/JUnit/de.devboost.buildboost.genext.test.junit/src/de/devboost/buildboost/genext/test/junit/steps/JUnitTestProjectDetector.java @@ -1,87 +1,87 @@ -/******************************************************************************* - * Copyright (c) 2006-2012 - * Software Technology Group, Dresden University of Technology - * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 - * - * All rights reserved. This program and the accompanying materials - * are 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 - * - * Contributors: - * Software Technology Group - TU Dresden, Germany; - * DevBoost GmbH - Berlin, Germany - * - initial API and implementation - ******************************************************************************/ -package de.devboost.buildboost.genext.test.junit.steps; - -import java.io.File; -import java.io.FileFilter; -import java.util.Collection; - -import de.devboost.buildboost.artifacts.Plugin; - -/** - * The {@link JUnitTestProjectDetector} can be used to check whether a plug-in - * projects contains JUnit tests. The current implementation basically searches - * for classes where the name matches one from a given set of suffixes. - */ -public class JUnitTestProjectDetector { - - private Collection testClassSuffixes; - - public JUnitTestProjectDetector(Collection testClassSuffixes) { - super(); - this.testClassSuffixes = testClassSuffixes; - } - - public boolean containsTests(Plugin plugin) { - File[] sourceFolders = plugin.getSourceFolders(); - if (sourceFolders.length == 0) { - // we can skip projects without source folders, because these - // cannot contain test cases. - return false; - } - - boolean containsTestClasses = false; - for (File sourceFolder : sourceFolders) { - containsTestClasses |= containsTestClasses(sourceFolder); - } - - return containsTestClasses; - } - - private boolean containsTestClasses(File sourceFolder) { - File[] testFiles = sourceFolder.listFiles(new FileFilter() { - - public boolean accept(File file) { - String name = file.getName(); - boolean hasCorrectName = false; - for (String suffix : testClassSuffixes) { - hasCorrectName |= name.endsWith(suffix + ".java"); - } - return file.isFile() && hasCorrectName; - } - }); - if (testFiles == null) { - return false; - } - boolean folderContainsTestClasses = testFiles.length > 0; - if (folderContainsTestClasses) { - return true; - } - - File[] subFolders = sourceFolder.listFiles(new FileFilter() { - - public boolean accept(File file) { - return file.isDirectory() && !".".equals(file.getName()) && !"..".equals(file.getName()); - } - }); - for (File subFolder : subFolders) { - if (containsTestClasses(subFolder)) { - return true; - } - } - return false; - } -} +/******************************************************************************* + * Copyright (c) 2006-2012 + * Software Technology Group, Dresden University of Technology + * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 + * + * All rights reserved. This program and the accompanying materials + * are 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 + * + * Contributors: + * Software Technology Group - TU Dresden, Germany; + * DevBoost GmbH - Berlin, Germany + * - initial API and implementation + ******************************************************************************/ +package de.devboost.buildboost.genext.test.junit.steps; + +import java.io.File; +import java.io.FileFilter; +import java.util.Collection; + +import de.devboost.buildboost.artifacts.Plugin; + +/** + * The {@link JUnitTestProjectDetector} can be used to check whether a plug-in + * projects contains JUnit tests. The current implementation basically searches + * for classes where the name matches one from a given set of suffixes. + */ +public class JUnitTestProjectDetector { + + private Collection testClassSuffixes; + + public JUnitTestProjectDetector(Collection testClassSuffixes) { + super(); + this.testClassSuffixes = testClassSuffixes; + } + + public boolean containsTests(Plugin plugin) { + File[] sourceFolders = plugin.getSourceFolders(); + if (sourceFolders.length == 0) { + // we can skip projects without source folders, because these + // cannot contain test cases. + return false; + } + + boolean containsTestClasses = false; + for (File sourceFolder : sourceFolders) { + containsTestClasses |= containsTestClasses(sourceFolder); + } + + return containsTestClasses; + } + + private boolean containsTestClasses(File sourceFolder) { + File[] testFiles = sourceFolder.listFiles(new FileFilter() { + + public boolean accept(File file) { + String name = file.getName(); + boolean hasCorrectName = false; + for (String suffix : testClassSuffixes) { + hasCorrectName |= name.endsWith(suffix + ".java"); + } + return file.isFile() && hasCorrectName; + } + }); + if (testFiles == null) { + return false; + } + boolean folderContainsTestClasses = testFiles.length > 0; + if (folderContainsTestClasses) { + return true; + } + + File[] subFolders = sourceFolder.listFiles(new FileFilter() { + + public boolean accept(File file) { + return file.isDirectory() && !".".equals(file.getName()) && !"..".equals(file.getName()); + } + }); + for (File subFolder : subFolders) { + if (containsTestClasses(subFolder)) { + return true; + } + } + return false; + } +} diff --git a/Extensions/JUnit/de.devboost.buildboost.genext.test.junit/src/de/devboost/buildboost/genext/test/junit/steps/JUnitTestScriptGenerator.java b/Extensions/JUnit/de.devboost.buildboost.genext.test.junit/src/de/devboost/buildboost/genext/test/junit/steps/JUnitTestScriptGenerator.java index 9a64749..dcf7ce9 100644 --- a/Extensions/JUnit/de.devboost.buildboost.genext.test.junit/src/de/devboost/buildboost/genext/test/junit/steps/JUnitTestScriptGenerator.java +++ b/Extensions/JUnit/de.devboost.buildboost.genext.test.junit/src/de/devboost/buildboost/genext/test/junit/steps/JUnitTestScriptGenerator.java @@ -1,101 +1,101 @@ -/******************************************************************************* - * Copyright (c) 2006-2012 - * Software Technology Group, Dresden University of Technology - * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 - * - * All rights reserved. This program and the accompanying materials - * are 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 - * - * Contributors: - * Software Technology Group - TU Dresden, Germany; - * DevBoost GmbH - Berlin, Germany - * - initial API and implementation - ******************************************************************************/ -package de.devboost.buildboost.genext.test.junit.steps; - -import static de.devboost.buildboost.IConstants.NL; - -import java.io.File; -import java.util.ArrayList; -import java.util.LinkedHashSet; -import java.util.List; -import java.util.Set; - -import de.devboost.buildboost.artifacts.Plugin; -import de.devboost.buildboost.util.XMLContent; - -/** - * A utility class to generate scripts that run JUnit test. - */ -public class JUnitTestScriptGenerator { - - public String getTestRunnerScript(File buildDir, Set testPlugins, String[] excludedTestClasses) { - final String prefix = RunJUnitTestsStep.PREFIX; - - XMLContent content = new XMLContent(); - content.append(""); - content.append(""); - // TODO this does not belong here - /* - content.append(""); - content.append(NL); - */ - - // TODO this does not belong here - Set excludedPlugins = new LinkedHashSet(); - /* - excludedPlugins.add("org.emftext.refactoring.rolemodelmatching.long.test"); - excludedPlugins.add("org.emftext.refactoring.rolemodelmatching.test"); - excludedPlugins.add("org.emftext.language.java.test.bulk"); - excludedPlugins.add("org.reuseware.application.ticketshop.test"); - */ - - String allNames = getCommaSeparatedList(testPlugins, prefix, excludedPlugins); - content.append(""); - - for (Plugin testPlugin : testPlugins) { - if (excludedPlugins.contains(testPlugin.getIdentifier())) { - continue; - } - content.append(""); - } - content.append(""); - content.append(NL); - - for (Plugin testPlugin : testPlugins) { - content.append(""); - content.append(new RunJUnitTestsStep(testPlugin, new File(buildDir, "test_results"), RunJUnitTestsStepProvider.DEFAULT_TEST_CLASS_SUFFIXES).generate(excludedTestClasses)); - content.append(""); - } - content.append(""); - return content.toString(); - } - - protected String getCommaSeparatedList(Set pluginSet, String prefix, Set excludedPlugins) { - List pluginList = new ArrayList(); - pluginList.addAll(pluginSet); - - List pluginNames = new ArrayList(); - for (Plugin plugin : pluginList) { - String name = plugin.getIdentifier(); - if (excludedPlugins.contains(name)) { - continue; - } - pluginNames.add(name); - } - - StringBuffer nameList = new StringBuffer(); - int size = pluginNames.size(); - for (int i = 0; i < size; i++) { - nameList.append(prefix); - String name = pluginNames.get(i); - nameList.append(name); - if (i < size - 1) { - nameList.append(","); - } - } - return nameList.toString(); - } -} +/******************************************************************************* + * Copyright (c) 2006-2012 + * Software Technology Group, Dresden University of Technology + * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 + * + * All rights reserved. This program and the accompanying materials + * are 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 + * + * Contributors: + * Software Technology Group - TU Dresden, Germany; + * DevBoost GmbH - Berlin, Germany + * - initial API and implementation + ******************************************************************************/ +package de.devboost.buildboost.genext.test.junit.steps; + +import static de.devboost.buildboost.IConstants.NL; + +import java.io.File; +import java.util.ArrayList; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Set; + +import de.devboost.buildboost.artifacts.Plugin; +import de.devboost.buildboost.util.XMLContent; + +/** + * A utility class to generate scripts that run JUnit test. + */ +public class JUnitTestScriptGenerator { + + public String getTestRunnerScript(File buildDir, Set testPlugins, String[] excludedTestClasses) { + final String prefix = RunJUnitTestsStep.PREFIX; + + XMLContent content = new XMLContent(); + content.append(""); + content.append(""); + // TODO this does not belong here + /* + content.append(""); + content.append(NL); + */ + + // TODO this does not belong here + Set excludedPlugins = new LinkedHashSet(); + /* + excludedPlugins.add("org.emftext.refactoring.rolemodelmatching.long.test"); + excludedPlugins.add("org.emftext.refactoring.rolemodelmatching.test"); + excludedPlugins.add("org.emftext.language.java.test.bulk"); + excludedPlugins.add("org.reuseware.application.ticketshop.test"); + */ + + String allNames = getCommaSeparatedList(testPlugins, prefix, excludedPlugins); + content.append(""); + + for (Plugin testPlugin : testPlugins) { + if (excludedPlugins.contains(testPlugin.getIdentifier())) { + continue; + } + content.append(""); + } + content.append(""); + content.append(NL); + + for (Plugin testPlugin : testPlugins) { + content.append(""); + content.append(new RunJUnitTestsStep(testPlugin, new File(buildDir, "test_results"), RunJUnitTestsStepProvider.DEFAULT_TEST_CLASS_SUFFIXES).generate(excludedTestClasses)); + content.append(""); + } + content.append(""); + return content.toString(); + } + + protected String getCommaSeparatedList(Set pluginSet, String prefix, Set excludedPlugins) { + List pluginList = new ArrayList(); + pluginList.addAll(pluginSet); + + List pluginNames = new ArrayList(); + for (Plugin plugin : pluginList) { + String name = plugin.getIdentifier(); + if (excludedPlugins.contains(name)) { + continue; + } + pluginNames.add(name); + } + + StringBuffer nameList = new StringBuffer(); + int size = pluginNames.size(); + for (int i = 0; i < size; i++) { + nameList.append(prefix); + String name = pluginNames.get(i); + nameList.append(name); + if (i < size - 1) { + nameList.append(","); + } + } + return nameList.toString(); + } +} diff --git a/Extensions/JUnit/de.devboost.buildboost.genext.test.junit/src/de/devboost/buildboost/genext/test/junit/steps/RunJUnitTestsStep.java b/Extensions/JUnit/de.devboost.buildboost.genext.test.junit/src/de/devboost/buildboost/genext/test/junit/steps/RunJUnitTestsStep.java index 64ebb56..f87a0fa 100644 --- a/Extensions/JUnit/de.devboost.buildboost.genext.test.junit/src/de/devboost/buildboost/genext/test/junit/steps/RunJUnitTestsStep.java +++ b/Extensions/JUnit/de.devboost.buildboost.genext.test.junit/src/de/devboost/buildboost/genext/test/junit/steps/RunJUnitTestsStep.java @@ -1,138 +1,138 @@ -/******************************************************************************* - * Copyright (c) 2006-2012 - * Software Technology Group, Dresden University of Technology - * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 - * - * All rights reserved. This program and the accompanying materials - * are 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 - * - * Contributors: - * Software Technology Group - TU Dresden, Germany; - * DevBoost GmbH - Berlin, Germany - * - initial API and implementation - ******************************************************************************/ -package de.devboost.buildboost.genext.test.junit.steps; - -import static de.devboost.buildboost.IConstants.NL; - -import java.io.File; -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; -import java.util.List; - -import de.devboost.buildboost.ant.AbstractAntTargetGenerator; -import de.devboost.buildboost.ant.AntTarget; -import de.devboost.buildboost.artifacts.Plugin; -import de.devboost.buildboost.steps.ClasspathHelper; -import de.devboost.buildboost.util.XMLContent; - -/** - * The {@link RunJUnitTestsStep} creates a script that runs all JUnit tests in - * a given plug-in project. The results of the test are collected in a result - * directory. - */ -public class RunJUnitTestsStep extends AbstractAntTargetGenerator { - - public static final String PREFIX = "run-tests-"; - - private Plugin testPlugin; - private File testResultDir; - - private Collection testClassSuffixes; - - private List excludedTestClasses; - - // TODO use inclusion patterns instead of test class suffixes - public RunJUnitTestsStep(Plugin testPlugin, File testResultDir, Collection testClassSuffixes) { - this(testPlugin, testResultDir, testClassSuffixes, Collections.emptyList()); - } - - public RunJUnitTestsStep(Plugin testPlugin, File testResultDir, Collection testClassSuffixes, List excludedTestClasses) { - super(); - this.testPlugin = testPlugin; - this.testResultDir = testResultDir; - this.testClassSuffixes = testClassSuffixes; - this.excludedTestClasses = excludedTestClasses; - } - - public Collection generateAntTargets() { - return Collections.singleton(new AntTarget(PREFIX + testPlugin.getIdentifier(), generate(excludedTestClasses))); - } - - public XMLContent generate(String[] excludedTestClasses) { - return generate(Arrays.asList(excludedTestClasses)); - } - - public XMLContent generate(List excludedTestClasses) { - XMLContent sb = new XMLContent(); - File[] sourceFolders = testPlugin.getSourceFolders(); - String name = testPlugin.getIdentifier(); - String projectTestResultDir = getTestResultDir(testPlugin); - String pathName = "test-classpath-" + testPlugin.getIdentifier(); - - sb.append(""); - // remove results directory - sb.append(""); - sb.append(""); - sb.append(new ClasspathHelper().getClasspath(testPlugin, true)); - sb.append(""); - sb.append(NL); - String propertyName = "prop-" + pathName; - sb.append(""); - sb.append(""); - sb.append(""); - sb.append(NL); - sb.append(""); - sb.append(""); - sb.append(""); - sb.append(""); - sb.append(""); - sb.append(NL); - sb.append(""); - sb.append(""); - sb.append(NL); - sb.append(""); - sb.append(""); - sb.append(""); - sb.append(""); - sb.append(""); - sb.append(""); - sb.append(""); - sb.append(""); - sb.append(""); - for (File sourceFolder : sourceFolders) { - sb.append(""); - for (String suffix : testClassSuffixes) { - sb.append(""); - } - for (String excludedTestClass : excludedTestClasses) { - sb.append(""); - } - sb.append(""); - } - sb.append(""); - sb.append(""); - sb.append(NL); - sb.append(""); - sb.append(""); - sb.append(""); - sb.append("" + NL); - sb.append(""); - sb.append(""); - sb.append(NL); - return sb; - } - - protected String getTestResultDir(Plugin plugin) { - String testResultsName = getTestResultDirName(plugin); - String projectTestResultDir = testResultDir.getAbsolutePath() + File.separator + testResultsName; - return projectTestResultDir; - } - - private String getTestResultDirName(Plugin plugin) { - return "results-" + plugin.getIdentifier(); - } -} +/******************************************************************************* + * Copyright (c) 2006-2012 + * Software Technology Group, Dresden University of Technology + * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 + * + * All rights reserved. This program and the accompanying materials + * are 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 + * + * Contributors: + * Software Technology Group - TU Dresden, Germany; + * DevBoost GmbH - Berlin, Germany + * - initial API and implementation + ******************************************************************************/ +package de.devboost.buildboost.genext.test.junit.steps; + +import static de.devboost.buildboost.IConstants.NL; + +import java.io.File; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.List; + +import de.devboost.buildboost.ant.AbstractAntTargetGenerator; +import de.devboost.buildboost.ant.AntTarget; +import de.devboost.buildboost.artifacts.Plugin; +import de.devboost.buildboost.steps.ClasspathHelper; +import de.devboost.buildboost.util.XMLContent; + +/** + * The {@link RunJUnitTestsStep} creates a script that runs all JUnit tests in + * a given plug-in project. The results of the test are collected in a result + * directory. + */ +public class RunJUnitTestsStep extends AbstractAntTargetGenerator { + + public static final String PREFIX = "run-tests-"; + + private Plugin testPlugin; + private File testResultDir; + + private Collection testClassSuffixes; + + private List excludedTestClasses; + + // TODO use inclusion patterns instead of test class suffixes + public RunJUnitTestsStep(Plugin testPlugin, File testResultDir, Collection testClassSuffixes) { + this(testPlugin, testResultDir, testClassSuffixes, Collections.emptyList()); + } + + public RunJUnitTestsStep(Plugin testPlugin, File testResultDir, Collection testClassSuffixes, List excludedTestClasses) { + super(); + this.testPlugin = testPlugin; + this.testResultDir = testResultDir; + this.testClassSuffixes = testClassSuffixes; + this.excludedTestClasses = excludedTestClasses; + } + + public Collection generateAntTargets() { + return Collections.singleton(new AntTarget(PREFIX + testPlugin.getIdentifier(), generate(excludedTestClasses))); + } + + public XMLContent generate(String[] excludedTestClasses) { + return generate(Arrays.asList(excludedTestClasses)); + } + + public XMLContent generate(List excludedTestClasses) { + XMLContent sb = new XMLContent(); + File[] sourceFolders = testPlugin.getSourceFolders(); + String name = testPlugin.getIdentifier(); + String projectTestResultDir = getTestResultDir(testPlugin); + String pathName = "test-classpath-" + testPlugin.getIdentifier(); + + sb.append(""); + // remove results directory + sb.append(""); + sb.append(""); + sb.append(new ClasspathHelper().getClasspath(testPlugin, true)); + sb.append(""); + sb.append(NL); + String propertyName = "prop-" + pathName; + sb.append(""); + sb.append(""); + sb.append(""); + sb.append(NL); + sb.append(""); + sb.append(""); + sb.append(""); + sb.append(""); + sb.append(""); + sb.append(NL); + sb.append(""); + sb.append(""); + sb.append(NL); + sb.append(""); + sb.append(""); + sb.append(""); + sb.append(""); + sb.append(""); + sb.append(""); + sb.append(""); + sb.append(""); + sb.append(""); + for (File sourceFolder : sourceFolders) { + sb.append(""); + for (String suffix : testClassSuffixes) { + sb.append(""); + } + for (String excludedTestClass : excludedTestClasses) { + sb.append(""); + } + sb.append(""); + } + sb.append(""); + sb.append(""); + sb.append(NL); + sb.append(""); + sb.append(""); + sb.append(""); + sb.append("" + NL); + sb.append(""); + sb.append(""); + sb.append(NL); + return sb; + } + + protected String getTestResultDir(Plugin plugin) { + String testResultsName = getTestResultDirName(plugin); + String projectTestResultDir = testResultDir.getAbsolutePath() + File.separator + testResultsName; + return projectTestResultDir; + } + + private String getTestResultDirName(Plugin plugin) { + return "results-" + plugin.getIdentifier(); + } +} diff --git a/Extensions/JUnit/de.devboost.buildboost.genext.test.junit/src/de/devboost/buildboost/genext/test/junit/steps/RunJUnitTestsStepProvider.java b/Extensions/JUnit/de.devboost.buildboost.genext.test.junit/src/de/devboost/buildboost/genext/test/junit/steps/RunJUnitTestsStepProvider.java index 0643348..4808c6b 100644 --- a/Extensions/JUnit/de.devboost.buildboost.genext.test.junit/src/de/devboost/buildboost/genext/test/junit/steps/RunJUnitTestsStepProvider.java +++ b/Extensions/JUnit/de.devboost.buildboost.genext.test.junit/src/de/devboost/buildboost/genext/test/junit/steps/RunJUnitTestsStepProvider.java @@ -1,77 +1,77 @@ -/******************************************************************************* - * Copyright (c) 2006-2012 - * Software Technology Group, Dresden University of Technology - * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 - * - * All rights reserved. This program and the accompanying materials - * are 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 - * - * Contributors: - * Software Technology Group - TU Dresden, Germany; - * DevBoost GmbH - Berlin, Germany - * - initial API and implementation - ******************************************************************************/ -package de.devboost.buildboost.genext.test.junit.steps; - -import java.io.File; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.LinkedHashSet; -import java.util.List; - -import de.devboost.buildboost.ant.AbstractAntTargetGeneratorProvider; -import de.devboost.buildboost.ant.IAntTargetGenerator; -import de.devboost.buildboost.artifacts.Plugin; -import de.devboost.buildboost.model.IArtifact; -import de.devboost.buildboost.model.IBuildContext; - -/** - * The {@link RunJUnitTestsStepProvider} add a {@link RunJUnitTestsStep} for - * every plug-in project that contains JUnit test classes. - */ -public class RunJUnitTestsStepProvider extends AbstractAntTargetGeneratorProvider { - - public static final Collection DEFAULT_TEST_CLASS_SUFFIXES = new LinkedHashSet(); - static { - DEFAULT_TEST_CLASS_SUFFIXES.add("Test"); - DEFAULT_TEST_CLASS_SUFFIXES.add("Tests"); - DEFAULT_TEST_CLASS_SUFFIXES.add("TestSuite"); - } - - private File testResultDir; - private Collection testClassSuffixes; - private List excludedTestClasses; - - public RunJUnitTestsStepProvider(File testResultDir) { - this(testResultDir, Collections.emptyList()); - } - - // TODO use test class patterns instead of test class suffixes - public RunJUnitTestsStepProvider(File testResultDir, List excludedTestClasses) { - this(testResultDir, excludedTestClasses, DEFAULT_TEST_CLASS_SUFFIXES); - } - - public RunJUnitTestsStepProvider(File testResultDir, List excludedTestClasses, Collection testClassSuffixes) { - this.testResultDir = testResultDir; - this.testClassSuffixes = testClassSuffixes; - this.excludedTestClasses = excludedTestClasses; - } - - public List getAntTargetGenerators(IBuildContext context, IArtifact artifact) { - JUnitTestProjectDetector helper = new JUnitTestProjectDetector(testClassSuffixes); - - if (artifact instanceof Plugin) { - Plugin plugin = (Plugin) artifact; - // check if this plug-in contains JUnit test cases - if (helper.containsTests(plugin)) { - List steps = new ArrayList(1); - steps.add(new RunJUnitTestsStep(plugin, testResultDir, testClassSuffixes, excludedTestClasses)); - return steps; - } - } - return Collections.emptyList(); - } -} +/******************************************************************************* + * Copyright (c) 2006-2012 + * Software Technology Group, Dresden University of Technology + * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 + * + * All rights reserved. This program and the accompanying materials + * are 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 + * + * Contributors: + * Software Technology Group - TU Dresden, Germany; + * DevBoost GmbH - Berlin, Germany + * - initial API and implementation + ******************************************************************************/ +package de.devboost.buildboost.genext.test.junit.steps; + +import java.io.File; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.LinkedHashSet; +import java.util.List; + +import de.devboost.buildboost.ant.AbstractAntTargetGeneratorProvider; +import de.devboost.buildboost.ant.IAntTargetGenerator; +import de.devboost.buildboost.artifacts.Plugin; +import de.devboost.buildboost.model.IArtifact; +import de.devboost.buildboost.model.IBuildContext; + +/** + * The {@link RunJUnitTestsStepProvider} add a {@link RunJUnitTestsStep} for + * every plug-in project that contains JUnit test classes. + */ +public class RunJUnitTestsStepProvider extends AbstractAntTargetGeneratorProvider { + + public static final Collection DEFAULT_TEST_CLASS_SUFFIXES = new LinkedHashSet(); + static { + DEFAULT_TEST_CLASS_SUFFIXES.add("Test"); + DEFAULT_TEST_CLASS_SUFFIXES.add("Tests"); + DEFAULT_TEST_CLASS_SUFFIXES.add("TestSuite"); + } + + private File testResultDir; + private Collection testClassSuffixes; + private List excludedTestClasses; + + public RunJUnitTestsStepProvider(File testResultDir) { + this(testResultDir, Collections.emptyList()); + } + + // TODO use test class patterns instead of test class suffixes + public RunJUnitTestsStepProvider(File testResultDir, List excludedTestClasses) { + this(testResultDir, excludedTestClasses, DEFAULT_TEST_CLASS_SUFFIXES); + } + + public RunJUnitTestsStepProvider(File testResultDir, List excludedTestClasses, Collection testClassSuffixes) { + this.testResultDir = testResultDir; + this.testClassSuffixes = testClassSuffixes; + this.excludedTestClasses = excludedTestClasses; + } + + public List getAntTargetGenerators(IBuildContext context, IArtifact artifact) { + JUnitTestProjectDetector helper = new JUnitTestProjectDetector(testClassSuffixes); + + if (artifact instanceof Plugin) { + Plugin plugin = (Plugin) artifact; + // check if this plug-in contains JUnit test cases + if (helper.containsTests(plugin)) { + List steps = new ArrayList(1); + steps.add(new RunJUnitTestsStep(plugin, testResultDir, testClassSuffixes, excludedTestClasses)); + return steps; + } + } + return Collections.emptyList(); + } +} diff --git a/Extensions/JUnit/de.devboost.buildboost.genext.test.junit/src/de/devboost/buildboost/genext/test/junit/steps/StopBuildIfJUnitTestsHaveFailedProvider.java b/Extensions/JUnit/de.devboost.buildboost.genext.test.junit/src/de/devboost/buildboost/genext/test/junit/steps/StopBuildIfJUnitTestsHaveFailedProvider.java index 2350c6c..1a4fb09 100644 --- a/Extensions/JUnit/de.devboost.buildboost.genext.test.junit/src/de/devboost/buildboost/genext/test/junit/steps/StopBuildIfJUnitTestsHaveFailedProvider.java +++ b/Extensions/JUnit/de.devboost.buildboost.genext.test.junit/src/de/devboost/buildboost/genext/test/junit/steps/StopBuildIfJUnitTestsHaveFailedProvider.java @@ -1,61 +1,61 @@ -/******************************************************************************* - * Copyright (c) 2006-2012 - * Software Technology Group, Dresden University of Technology - * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 - * - * All rights reserved. This program and the accompanying materials - * are 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 - * - * Contributors: - * Software Technology Group - TU Dresden, Germany; - * DevBoost GmbH - Berlin, Germany - * - initial API and implementation - ******************************************************************************/ -package de.devboost.buildboost.genext.test.junit.steps; - -import java.util.Collection; -import java.util.Collections; -import java.util.List; - -import de.devboost.buildboost.BuildException; -import de.devboost.buildboost.ant.AbstractAntTargetGenerator; -import de.devboost.buildboost.ant.AbstractAntTargetGeneratorProvider; -import de.devboost.buildboost.ant.AntTarget; -import de.devboost.buildboost.ant.IAntTargetGenerator; -import de.devboost.buildboost.artifacts.Plugin; -import de.devboost.buildboost.model.IArtifact; -import de.devboost.buildboost.model.IBuildContext; -import de.devboost.buildboost.util.XMLContent; - -public class StopBuildIfJUnitTestsHaveFailedProvider extends AbstractAntTargetGeneratorProvider { - - private JUnitTestProjectDetector helper = new JUnitTestProjectDetector(RunJUnitTestsStepProvider.DEFAULT_TEST_CLASS_SUFFIXES); - - @Override - public List getAntTargetGenerators( - IBuildContext context, IArtifact artifact) { - - if (artifact instanceof Plugin) { - Plugin plugin = (Plugin) artifact; - if (helper.containsTests(plugin)) { - XMLContent content = new XMLContent(); - content.append(""); - - final AntTarget target = new AntTarget("check-junit-failures-" + plugin.getIdentifier(), content); - target.getRequiredTargets().add(RunJUnitTestsStep.PREFIX + plugin.getIdentifier()); - - IAntTargetGenerator generator = new AbstractAntTargetGenerator() { - - @Override - public Collection generateAntTargets() throws BuildException { - return Collections.singletonList(target); - } - }; - return Collections.singletonList(generator); - } - } - return Collections.emptyList(); - } -} +/******************************************************************************* + * Copyright (c) 2006-2012 + * Software Technology Group, Dresden University of Technology + * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 + * + * All rights reserved. This program and the accompanying materials + * are 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 + * + * Contributors: + * Software Technology Group - TU Dresden, Germany; + * DevBoost GmbH - Berlin, Germany + * - initial API and implementation + ******************************************************************************/ +package de.devboost.buildboost.genext.test.junit.steps; + +import java.util.Collection; +import java.util.Collections; +import java.util.List; + +import de.devboost.buildboost.BuildException; +import de.devboost.buildboost.ant.AbstractAntTargetGenerator; +import de.devboost.buildboost.ant.AbstractAntTargetGeneratorProvider; +import de.devboost.buildboost.ant.AntTarget; +import de.devboost.buildboost.ant.IAntTargetGenerator; +import de.devboost.buildboost.artifacts.Plugin; +import de.devboost.buildboost.model.IArtifact; +import de.devboost.buildboost.model.IBuildContext; +import de.devboost.buildboost.util.XMLContent; + +public class StopBuildIfJUnitTestsHaveFailedProvider extends AbstractAntTargetGeneratorProvider { + + private JUnitTestProjectDetector helper = new JUnitTestProjectDetector(RunJUnitTestsStepProvider.DEFAULT_TEST_CLASS_SUFFIXES); + + @Override + public List getAntTargetGenerators( + IBuildContext context, IArtifact artifact) { + + if (artifact instanceof Plugin) { + Plugin plugin = (Plugin) artifact; + if (helper.containsTests(plugin)) { + XMLContent content = new XMLContent(); + content.append(""); + + final AntTarget target = new AntTarget("check-junit-failures-" + plugin.getIdentifier(), content); + target.getRequiredTargets().add(RunJUnitTestsStep.PREFIX + plugin.getIdentifier()); + + IAntTargetGenerator generator = new AbstractAntTargetGenerator() { + + @Override + public Collection generateAntTargets() throws BuildException { + return Collections.singletonList(target); + } + }; + return Collections.singletonList(generator); + } + } + return Collections.emptyList(); + } +} diff --git a/Extensions/Maven/de.devboost.buildboost.genext.maven/src/de/devboost/buildboost/genext/maven/stages/BuildMavenRepositoryStage.java b/Extensions/Maven/de.devboost.buildboost.genext.maven/src/de/devboost/buildboost/genext/maven/stages/BuildMavenRepositoryStage.java index 1a02ae4..041bacc 100644 --- a/Extensions/Maven/de.devboost.buildboost.genext.maven/src/de/devboost/buildboost/genext/maven/stages/BuildMavenRepositoryStage.java +++ b/Extensions/Maven/de.devboost.buildboost.genext.maven/src/de/devboost/buildboost/genext/maven/stages/BuildMavenRepositoryStage.java @@ -1,71 +1,71 @@ -/******************************************************************************* - * Copyright (c) 2006-2012 - * Software Technology Group, Dresden University of Technology - * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 - * - * All rights reserved. This program and the accompanying materials - * are 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 - * - * Contributors: - * Software Technology Group - TU Dresden, Germany; - * DevBoost GmbH - Berlin, Germany - * - initial API and implementation - ******************************************************************************/ -package de.devboost.buildboost.genext.maven.stages; - -import java.io.File; - -import de.devboost.buildboost.AutoBuilder; -import de.devboost.buildboost.BuildContext; -import de.devboost.buildboost.BuildException; -import de.devboost.buildboost.ant.AntScript; -import de.devboost.buildboost.discovery.EclipseFeatureFinder; -import de.devboost.buildboost.discovery.EclipseTargetPlatformAnalyzer; -import de.devboost.buildboost.discovery.PluginFinder; -import de.devboost.buildboost.genext.maven.steps.BuildMavenRepositoryStepProvider; -import de.devboost.buildboost.genext.updatesite.discovery.EclipseUpdateSiteDeploymentSpecFinder; -import de.devboost.buildboost.genext.updatesite.discovery.EclipseUpdateSiteFinder; -import de.devboost.buildboost.model.IUniversalBuildStage; -import de.devboost.buildboost.stages.AbstractBuildStage; - -public class BuildMavenRepositoryStage extends AbstractBuildStage implements IUniversalBuildStage { - - private String artifactsFolder; - - public void setArtifactsFolder(String artifactsFolder) { - this.artifactsFolder = artifactsFolder; - } - - @Override - public AntScript getScript() throws BuildException { - File buildProjectsDir = new File(new File(artifactsFolder), "projects"); - File buildTargetPlatformDir = new File(new File(artifactsFolder), "target-platform"); - - BuildContext context = createContext(false); - - context.addBuildParticipant(new EclipseTargetPlatformAnalyzer(buildTargetPlatformDir)); - - context.addBuildParticipant(new PluginFinder(buildProjectsDir)); - context.addBuildParticipant(new EclipseFeatureFinder(buildProjectsDir)); - context.addBuildParticipant(new EclipseUpdateSiteFinder(buildProjectsDir)); - context.addBuildParticipant(new EclipseUpdateSiteDeploymentSpecFinder(buildProjectsDir)); - - context.addBuildParticipant(new BuildMavenRepositoryStepProvider( - buildProjectsDir.getParentFile())); - - AutoBuilder builder = new AutoBuilder(context); - - AntScript script = new AntScript(); - script.setName("Build maven repository"); - script.addTargets(builder.generateAntTargets()); - - return script; - } - - @Override - public int getPriority() { - return 10100; - } -} +/******************************************************************************* + * Copyright (c) 2006-2012 + * Software Technology Group, Dresden University of Technology + * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 + * + * All rights reserved. This program and the accompanying materials + * are 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 + * + * Contributors: + * Software Technology Group - TU Dresden, Germany; + * DevBoost GmbH - Berlin, Germany + * - initial API and implementation + ******************************************************************************/ +package de.devboost.buildboost.genext.maven.stages; + +import java.io.File; + +import de.devboost.buildboost.AutoBuilder; +import de.devboost.buildboost.BuildContext; +import de.devboost.buildboost.BuildException; +import de.devboost.buildboost.ant.AntScript; +import de.devboost.buildboost.discovery.EclipseFeatureFinder; +import de.devboost.buildboost.discovery.EclipseTargetPlatformAnalyzer; +import de.devboost.buildboost.discovery.PluginFinder; +import de.devboost.buildboost.genext.maven.steps.BuildMavenRepositoryStepProvider; +import de.devboost.buildboost.genext.updatesite.discovery.EclipseUpdateSiteDeploymentSpecFinder; +import de.devboost.buildboost.genext.updatesite.discovery.EclipseUpdateSiteFinder; +import de.devboost.buildboost.model.IUniversalBuildStage; +import de.devboost.buildboost.stages.AbstractBuildStage; + +public class BuildMavenRepositoryStage extends AbstractBuildStage implements IUniversalBuildStage { + + private String artifactsFolder; + + public void setArtifactsFolder(String artifactsFolder) { + this.artifactsFolder = artifactsFolder; + } + + @Override + public AntScript getScript() throws BuildException { + File buildProjectsDir = new File(new File(artifactsFolder), "projects"); + File buildTargetPlatformDir = new File(new File(artifactsFolder), "target-platform"); + + BuildContext context = createContext(false); + + context.addBuildParticipant(new EclipseTargetPlatformAnalyzer(buildTargetPlatformDir)); + + context.addBuildParticipant(new PluginFinder(buildProjectsDir)); + context.addBuildParticipant(new EclipseFeatureFinder(buildProjectsDir)); + context.addBuildParticipant(new EclipseUpdateSiteFinder(buildProjectsDir)); + context.addBuildParticipant(new EclipseUpdateSiteDeploymentSpecFinder(buildProjectsDir)); + + context.addBuildParticipant(new BuildMavenRepositoryStepProvider( + buildProjectsDir.getParentFile())); + + AutoBuilder builder = new AutoBuilder(context); + + AntScript script = new AntScript(); + script.setName("Build maven repository"); + script.addTargets(builder.generateAntTargets()); + + return script; + } + + @Override + public int getPriority() { + return 10100; + } +} diff --git a/Extensions/Maven/de.devboost.buildboost.genext.maven/src/de/devboost/buildboost/genext/maven/steps/BuildMavenRepositoryStep.java b/Extensions/Maven/de.devboost.buildboost.genext.maven/src/de/devboost/buildboost/genext/maven/steps/BuildMavenRepositoryStep.java index 89bbd02..1db1bb0 100644 --- a/Extensions/Maven/de.devboost.buildboost.genext.maven/src/de/devboost/buildboost/genext/maven/steps/BuildMavenRepositoryStep.java +++ b/Extensions/Maven/de.devboost.buildboost.genext.maven/src/de/devboost/buildboost/genext/maven/steps/BuildMavenRepositoryStep.java @@ -1,409 +1,409 @@ -/******************************************************************************* - * Copyright (c) 2006-2012 - * Software Technology Group, Dresden University of Technology - * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 - * - * All rights reserved. This program and the accompanying materials - * are 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 - * - * Contributors: - * Software Technology Group - TU Dresden, Germany; - * DevBoost GmbH - Berlin, Germany - * - initial API and implementation - ******************************************************************************/ -package de.devboost.buildboost.genext.maven.steps; - -import java.io.File; -import java.io.FileOutputStream; -import java.util.Collection; -import java.util.Collections; -import java.util.LinkedHashMap; -import java.util.LinkedHashSet; -import java.util.Map; -import java.util.Set; - -import de.devboost.buildboost.BuildException; -import de.devboost.buildboost.ant.AbstractAntTargetGenerator; -import de.devboost.buildboost.ant.AntTarget; -import de.devboost.buildboost.artifacts.CompiledPlugin; -import de.devboost.buildboost.artifacts.EclipseFeature; -import de.devboost.buildboost.artifacts.Plugin; -import de.devboost.buildboost.genext.updatesite.artifacts.EclipseUpdateSite; -import de.devboost.buildboost.genext.updatesite.artifacts.EclipseUpdateSiteDeploymentSpec; -import de.devboost.buildboost.model.IDependable; -import de.devboost.buildboost.model.UnresolvedDependency; -import de.devboost.buildboost.util.XMLContent; - -public class BuildMavenRepositoryStep extends AbstractAntTargetGenerator { - - protected EclipseUpdateSiteDeploymentSpec updateSiteSpec; - protected File targetDir; - protected String usernameProperty = null; - protected String passwordProperty = null; - - public BuildMavenRepositoryStep(EclipseUpdateSiteDeploymentSpec updateSiteSpec, File targetDir) { - super(); - this.updateSiteSpec = updateSiteSpec; - this.targetDir = targetDir; - } - - @Override - public Collection generateAntTargets() throws BuildException { - if (usernameProperty == null) { - usernameProperty = updateSiteSpec.getValue("site", "usernameProperty"); - System.out.println("Using user: " + usernameProperty); - } - if (passwordProperty == null) { - passwordProperty = updateSiteSpec.getValue("site", "passwordProperty"); - System.out.println("Using password: " + passwordProperty); - } - - AntTarget mavenRepositoryTarget = generateMavenRepositoryAntTarget(); - return Collections.singletonList(mavenRepositoryTarget); - } - - protected AntTarget generateMavenRepositoryAntTarget() throws BuildException { - EclipseUpdateSite updateSite = updateSiteSpec.getUpdateSite(); - if (updateSite == null) { - throw new BuildException("Can't find update site for update site specification."); - } - - String distDir = targetDir.getAbsolutePath() + File.separator + "dist"; - - XMLContent content = new XMLContent(); - - String repositoryID = updateSite.getIdentifier(); - String jarsDir = distDir + File.separator + "jars" + File.separator + repositoryID; - String mavenRespoitoryDir = distDir + File.separator + "maven-repository" + File.separator + repositoryID; - - content.append(""); - content.append(""); - content.append(""); - content.append(""); - content.append(""); - content.appendLineBreak(); - - content.append(""); - content.append(""); - content.append(""); - content.appendLineBreak(); - - content.append(""); - boolean deployedSomething = false; - - Set pluginsToRepack = new LinkedHashSet(); - Map plugin2VersionMap = new LinkedHashMap(); - for (EclipseFeature feature : updateSite.getFeatures()) { - String featureVersion = updateSiteSpec.getFeatureVersion(feature.getIdentifier()); - for (Plugin plugin : feature.getPlugins()) { - String pluginID = plugin.getIdentifier(); - String pluginVersion = updateSiteSpec.getValue("plugin", pluginID, "version"); - if (pluginVersion == null) { - pluginVersion = featureVersion; - } - plugin2VersionMap.put(pluginID, pluginVersion); - addDependenciesRecursively(plugin, pluginsToRepack, plugin2VersionMap); - } - } - - for (EclipseFeature feature : updateSite.getFeatures()) { - String featureVersion = updateSiteSpec.getFeatureVersion(feature.getIdentifier()); - String featureVendor = updateSiteSpec.getFeatureVendor(feature.getIdentifier()); - for (Plugin plugin : feature.getPlugins()) { - String pluginID = plugin.getIdentifier(); - File pluginDirectory = plugin.getFile(); - String pluginPath = pluginDirectory.getAbsolutePath(); - - String pluginVersion = updateSiteSpec.getValue("plugin", pluginID, "version"); - if (pluginVersion == null) { - pluginVersion = featureVersion; - } - String pluginVendor = updateSiteSpec.getValue("plugin", pluginID, "vendor"); - if (pluginVendor == null) { - pluginVendor = featureVendor; - } - String pluginName = updateSiteSpec.getValue("plugin", pluginID, "name"); - if (pluginName == null) { - pluginName = idToName(pluginID); - } - - String snapshotValue = updateSiteSpec.getValue("site", "snapshot"); - boolean snapshot = true; - if (snapshotValue != null) { - snapshot = Boolean.parseBoolean(snapshotValue); - } - - if (snapshot) { - pluginVersion = pluginVersion + "-SNAPSHOT"; - } - - String pomXMLContent = generatePomXML(plugin, pluginVersion, pluginName, pluginVendor, plugin2VersionMap); - if (pomXMLContent == null) { - continue; - } - String pomPropertiesContent = generatePomProperties(plugin, pluginVersion); - - String pomFile = writePomFile(pomXMLContent, pluginDirectory, pluginID, "xml").getAbsolutePath(); - writePomFile(pomPropertiesContent, pluginDirectory, pluginID, "properties"); - - // package plugin(s) - content.append(""); - String destBinJarFile = jarsDir + "/" + pluginID + "-" + pluginVersion + ".jar"; - content.append(""); - content.append(""); - content.append(""); - content.append(""); - content.append(""); - content.append(""); - content.append(""); - String destSrcJarFile = jarsDir + "/" + pluginID + "-" + pluginVersion + "-sources.jar"; - content.append(""); - for (File childFolder : pluginDirectory.listFiles()) { - //TODO read .classpath for src-folders instead - if (childFolder.isDirectory() && childFolder.getName().startsWith("src")) { - content.append(""); - } - } - content.append(""); - - deployBinInRepository(content, jarsDir, mavenRespoitoryDir, pomFile, destBinJarFile); - deploySrcInRepository(content, jarsDir, mavenRespoitoryDir, plugin, pluginVersion, destSrcJarFile); - - content.appendLineBreak(); - - deployedSomething = true; - } - } - - for (CompiledPlugin compiledPlugin : pluginsToRepack) { - String pluginID = compiledPlugin.getIdentifier(); - String pluginPath = compiledPlugin.getFile().getAbsolutePath(); - String pluginVersion = compiledPlugin.getVersion(); - - //TODO we could read this from plugin.properties - String pluginName = idToName(pluginID); - String pluginVendor = "Eclipse Modeling Project"; - - String pomXMLContent = generatePomXML(compiledPlugin, pluginVersion, pluginName, pluginVendor, plugin2VersionMap); - if (pomXMLContent == null) { - continue; - } - String pomPropertiesContent = generatePomProperties(compiledPlugin, pluginVersion); - - String dirName = compiledPlugin.getFile().getName().replace(".jar", ""); - File pluginDirectory = new File(compiledPlugin.getFile().getParent(), dirName); - String pomFile = writePomFile(pomXMLContent, pluginDirectory, pluginID, "xml").getAbsolutePath(); - writePomFile(pomPropertiesContent, pluginDirectory, pluginID, "properties").getAbsolutePath(); - - content.append(""); - String destBinJarFile = jarsDir + "/" + pluginID + "-" + pluginVersion + ".jar"; - content.append(""); - content.append(""); - content.append(""); - content.append(""); - content.append(""); - content.append(""); - - //src version - String srcPluginFile = compiledPlugin.getFile().getName().replace(pluginID, pluginID + ".source"); - pluginPath = new File(compiledPlugin.getFile().getParent(), srcPluginFile).getAbsolutePath(); - String destSrcJarFile = jarsDir + "/" + pluginID + "-" + pluginVersion + "-sources.jar"; - content.append(""); - content.append(""); - content.append(""); - content.append(""); - content.append(""); - - deployBinInRepository(content, jarsDir, mavenRespoitoryDir, pomFile, destBinJarFile); - deploySrcInRepository(content, jarsDir, mavenRespoitoryDir, compiledPlugin, pluginVersion, destSrcJarFile); - - content.appendLineBreak(); - } - - if (deployedSomething) { - String targetPath = updateSiteSpec.getValue("site", "uploadPath"); - if (targetPath != null) { - String repoPath = targetPath.substring(0, targetPath.lastIndexOf('/') + 1) + "maven-repository" ; - - content.append(""); - content.append(""); - content.append(""); - content.append(""); - } - } - - AntTarget target = new AntTarget("build-maven-repository", content); - return target; - } - - protected void deployBinInRepository(XMLContent content, String jarsDir, - String mavenRespoitoryDir, String pomFile, String destBinJarFile) { - - content.append(""); - content.append(""); - content.append(""); - content.append(""); - content.append(""); - content.append(""); - } - - protected void deploySrcInRepository(XMLContent content, String jarsDir, - String mavenRespoitoryDir, Plugin plugin, String pluginVersion, String destSrcJarFile) { - - content.append(""); - content.append(""); - content.append(""); - content.append(""); - content.append(""); - content.append(""); - content.append(""); - content.append(""); - content.append(""); - content.append(""); - } - - protected void addDependenciesRecursively(Plugin plugin, - Set pluginsToRepack, Map plugin2VersionMap) { - for (IDependable dependency : plugin.getDependencies()) { - if (dependency instanceof CompiledPlugin) { - CompiledPlugin compiledPlugin = (CompiledPlugin) dependency; - if (includeInMavenRepository(compiledPlugin)) { - plugin2VersionMap.put( - compiledPlugin.getIdentifier(), compiledPlugin.getVersion()); - pluginsToRepack.add(compiledPlugin); - addDependenciesRecursively(compiledPlugin, pluginsToRepack, plugin2VersionMap); - } - } - } - } - - protected String generatePomXML(Plugin plugin, String pluginVersion, - String pluginName, String pluginVendor, Map plugin2VersionMap) { - XMLContent content = new XMLContent(); - - content.append(""); - content.append(""); - content.append("4.0.0"); - content.append("" + getMavenGroup(plugin.getIdentifier()) + ""); - content.append("" + plugin.getIdentifier() + ""); - content.append("" + pluginVersion + ""); - content.append("" + pluginName + ""); - content.append(""); - content.append("" + pluginVendor + ""); - content.append(""); - content.append(""); - content.append(""); - content.append("Eclipse Public License - v 1.0"); - content.append("http://www.eclipse.org/org/documents/epl-v10.html"); - content.append(""); - content.append(""); - content.append(""); - for (UnresolvedDependency dependency : plugin.getResolvedDependencies()) { - if (isOptional(dependency)) { - continue; - } - String dependencyVersion = plugin2VersionMap.get(dependency.getIdentifier()); - if (dependencyVersion == null) { - System.out.println("Can not create maven artifact for " + plugin.getIdentifier() - + " since " + dependency.getIdentifier() + " is not versioned"); - return null; - } - content.append(""); - content.append("" + getMavenGroup(dependency.getIdentifier()) + ""); - content.append("" + dependency.getIdentifier() + ""); - content.append("" + dependencyVersion + ""); - content.append(""); - } - content.append(""); - content.append(""); - return content.toString(); - } - - protected String generatePomProperties(Plugin plugin, String pluginVersion) { - String content = ""; - content += "version=" + pluginVersion + "\n"; - content += "groupId=" + getMavenGroup(plugin.getIdentifier()) + "\n"; - content += "artifactId=" + plugin.getIdentifier() + "\n"; - return content; - } - - protected File writePomFile(String pomXMLContent, File pluginDirectory, String pluginID, String extension) { - File pomFolder = new File(pluginDirectory.getAbsolutePath() + File.separator + "META-INF" - + File.separator + "maven" + File.separator + getMavenGroup(pluginID) - + File.separator + pluginID); - pomFolder.mkdirs(); - File pomXMLFile = new File(pomFolder, "pom." + extension); - - try { - new FileOutputStream(pomXMLFile).write(pomXMLContent.getBytes()); - } catch (Exception e) { - e.printStackTrace(); - } - return pomXMLFile; - } - - protected String getMavenGroup(String identifier) { - String groupID = ""; - String[] idSegments = identifier.split("\\."); - for (int i = 0; i < idSegments.length && i < 3; i++) { - if ("".equals(groupID)) { - groupID = idSegments[i]; - } else { - groupID = groupID + "." + idSegments[i]; - } - } - return groupID; - } - - protected boolean isOptional(UnresolvedDependency dependency) { - if (dependency.isOptional()) { - return true; - } - //This dependency is not marked optional in EMF plugins although it is optional. - //See also: https://bugs.eclipse.org/bugs/show_bug.cgi?id=328227 - if (dependency.getIdentifier().equals("org.eclipse.core.runtime")) { - return true; - } - return false; - } - - protected boolean includeInMavenRepository(CompiledPlugin compiledPlugin) { - // TODO This selects the EMF core plugins, could be moved to an external spec - String id = compiledPlugin.getIdentifier(); - if (id.equals("org.eclipse.emf.common")) { - return true; - } - if (id.equals("org.eclipse.emf.ecore")) { - return true; - } - if (id.equals("org.eclipse.emf.ecore.change")) { - return true; - } - if (id.equals("org.eclipse.emf.xmi")) { - return true; - } - return false; - } - - protected String idToName(String pluginID) { - String name = ""; - String[] segements = pluginID.split("\\."); - for (int i = 1; i < segements.length; i++) { - String s = segements[i]; - name = name + firstToUpper(s) + " "; - } - if ("".equals(name)) { - return pluginID; - } - return name.trim(); - } - - private String firstToUpper(String s) { - return s.substring(0,1).toUpperCase() + s.substring(1); - } - - -} +/******************************************************************************* + * Copyright (c) 2006-2012 + * Software Technology Group, Dresden University of Technology + * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 + * + * All rights reserved. This program and the accompanying materials + * are 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 + * + * Contributors: + * Software Technology Group - TU Dresden, Germany; + * DevBoost GmbH - Berlin, Germany + * - initial API and implementation + ******************************************************************************/ +package de.devboost.buildboost.genext.maven.steps; + +import java.io.File; +import java.io.FileOutputStream; +import java.util.Collection; +import java.util.Collections; +import java.util.LinkedHashMap; +import java.util.LinkedHashSet; +import java.util.Map; +import java.util.Set; + +import de.devboost.buildboost.BuildException; +import de.devboost.buildboost.ant.AbstractAntTargetGenerator; +import de.devboost.buildboost.ant.AntTarget; +import de.devboost.buildboost.artifacts.CompiledPlugin; +import de.devboost.buildboost.artifacts.EclipseFeature; +import de.devboost.buildboost.artifacts.Plugin; +import de.devboost.buildboost.genext.updatesite.artifacts.EclipseUpdateSite; +import de.devboost.buildboost.genext.updatesite.artifacts.EclipseUpdateSiteDeploymentSpec; +import de.devboost.buildboost.model.IDependable; +import de.devboost.buildboost.model.UnresolvedDependency; +import de.devboost.buildboost.util.XMLContent; + +public class BuildMavenRepositoryStep extends AbstractAntTargetGenerator { + + protected EclipseUpdateSiteDeploymentSpec updateSiteSpec; + protected File targetDir; + protected String usernameProperty = null; + protected String passwordProperty = null; + + public BuildMavenRepositoryStep(EclipseUpdateSiteDeploymentSpec updateSiteSpec, File targetDir) { + super(); + this.updateSiteSpec = updateSiteSpec; + this.targetDir = targetDir; + } + + @Override + public Collection generateAntTargets() throws BuildException { + if (usernameProperty == null) { + usernameProperty = updateSiteSpec.getValue("site", "usernameProperty"); + System.out.println("Using user: " + usernameProperty); + } + if (passwordProperty == null) { + passwordProperty = updateSiteSpec.getValue("site", "passwordProperty"); + System.out.println("Using password: " + passwordProperty); + } + + AntTarget mavenRepositoryTarget = generateMavenRepositoryAntTarget(); + return Collections.singletonList(mavenRepositoryTarget); + } + + protected AntTarget generateMavenRepositoryAntTarget() throws BuildException { + EclipseUpdateSite updateSite = updateSiteSpec.getUpdateSite(); + if (updateSite == null) { + throw new BuildException("Can't find update site for update site specification."); + } + + String distDir = targetDir.getAbsolutePath() + File.separator + "dist"; + + XMLContent content = new XMLContent(); + + String repositoryID = updateSite.getIdentifier(); + String jarsDir = distDir + File.separator + "jars" + File.separator + repositoryID; + String mavenRespoitoryDir = distDir + File.separator + "maven-repository" + File.separator + repositoryID; + + content.append(""); + content.append(""); + content.append(""); + content.append(""); + content.append(""); + content.appendLineBreak(); + + content.append(""); + content.append(""); + content.append(""); + content.appendLineBreak(); + + content.append(""); + boolean deployedSomething = false; + + Set pluginsToRepack = new LinkedHashSet(); + Map plugin2VersionMap = new LinkedHashMap(); + for (EclipseFeature feature : updateSite.getFeatures()) { + String featureVersion = updateSiteSpec.getFeatureVersion(feature.getIdentifier()); + for (Plugin plugin : feature.getPlugins()) { + String pluginID = plugin.getIdentifier(); + String pluginVersion = updateSiteSpec.getValue("plugin", pluginID, "version"); + if (pluginVersion == null) { + pluginVersion = featureVersion; + } + plugin2VersionMap.put(pluginID, pluginVersion); + addDependenciesRecursively(plugin, pluginsToRepack, plugin2VersionMap); + } + } + + for (EclipseFeature feature : updateSite.getFeatures()) { + String featureVersion = updateSiteSpec.getFeatureVersion(feature.getIdentifier()); + String featureVendor = updateSiteSpec.getFeatureVendor(feature.getIdentifier()); + for (Plugin plugin : feature.getPlugins()) { + String pluginID = plugin.getIdentifier(); + File pluginDirectory = plugin.getFile(); + String pluginPath = pluginDirectory.getAbsolutePath(); + + String pluginVersion = updateSiteSpec.getValue("plugin", pluginID, "version"); + if (pluginVersion == null) { + pluginVersion = featureVersion; + } + String pluginVendor = updateSiteSpec.getValue("plugin", pluginID, "vendor"); + if (pluginVendor == null) { + pluginVendor = featureVendor; + } + String pluginName = updateSiteSpec.getValue("plugin", pluginID, "name"); + if (pluginName == null) { + pluginName = idToName(pluginID); + } + + String snapshotValue = updateSiteSpec.getValue("site", "snapshot"); + boolean snapshot = true; + if (snapshotValue != null) { + snapshot = Boolean.parseBoolean(snapshotValue); + } + + if (snapshot) { + pluginVersion = pluginVersion + "-SNAPSHOT"; + } + + String pomXMLContent = generatePomXML(plugin, pluginVersion, pluginName, pluginVendor, plugin2VersionMap); + if (pomXMLContent == null) { + continue; + } + String pomPropertiesContent = generatePomProperties(plugin, pluginVersion); + + String pomFile = writePomFile(pomXMLContent, pluginDirectory, pluginID, "xml").getAbsolutePath(); + writePomFile(pomPropertiesContent, pluginDirectory, pluginID, "properties"); + + // package plugin(s) + content.append(""); + String destBinJarFile = jarsDir + "/" + pluginID + "-" + pluginVersion + ".jar"; + content.append(""); + content.append(""); + content.append(""); + content.append(""); + content.append(""); + content.append(""); + content.append(""); + String destSrcJarFile = jarsDir + "/" + pluginID + "-" + pluginVersion + "-sources.jar"; + content.append(""); + for (File childFolder : pluginDirectory.listFiles()) { + //TODO read .classpath for src-folders instead + if (childFolder.isDirectory() && childFolder.getName().startsWith("src")) { + content.append(""); + } + } + content.append(""); + + deployBinInRepository(content, jarsDir, mavenRespoitoryDir, pomFile, destBinJarFile); + deploySrcInRepository(content, jarsDir, mavenRespoitoryDir, plugin, pluginVersion, destSrcJarFile); + + content.appendLineBreak(); + + deployedSomething = true; + } + } + + for (CompiledPlugin compiledPlugin : pluginsToRepack) { + String pluginID = compiledPlugin.getIdentifier(); + String pluginPath = compiledPlugin.getFile().getAbsolutePath(); + String pluginVersion = compiledPlugin.getVersion(); + + //TODO we could read this from plugin.properties + String pluginName = idToName(pluginID); + String pluginVendor = "Eclipse Modeling Project"; + + String pomXMLContent = generatePomXML(compiledPlugin, pluginVersion, pluginName, pluginVendor, plugin2VersionMap); + if (pomXMLContent == null) { + continue; + } + String pomPropertiesContent = generatePomProperties(compiledPlugin, pluginVersion); + + String dirName = compiledPlugin.getFile().getName().replace(".jar", ""); + File pluginDirectory = new File(compiledPlugin.getFile().getParent(), dirName); + String pomFile = writePomFile(pomXMLContent, pluginDirectory, pluginID, "xml").getAbsolutePath(); + writePomFile(pomPropertiesContent, pluginDirectory, pluginID, "properties").getAbsolutePath(); + + content.append(""); + String destBinJarFile = jarsDir + "/" + pluginID + "-" + pluginVersion + ".jar"; + content.append(""); + content.append(""); + content.append(""); + content.append(""); + content.append(""); + content.append(""); + + //src version + String srcPluginFile = compiledPlugin.getFile().getName().replace(pluginID, pluginID + ".source"); + pluginPath = new File(compiledPlugin.getFile().getParent(), srcPluginFile).getAbsolutePath(); + String destSrcJarFile = jarsDir + "/" + pluginID + "-" + pluginVersion + "-sources.jar"; + content.append(""); + content.append(""); + content.append(""); + content.append(""); + content.append(""); + + deployBinInRepository(content, jarsDir, mavenRespoitoryDir, pomFile, destBinJarFile); + deploySrcInRepository(content, jarsDir, mavenRespoitoryDir, compiledPlugin, pluginVersion, destSrcJarFile); + + content.appendLineBreak(); + } + + if (deployedSomething) { + String targetPath = updateSiteSpec.getValue("site", "uploadPath"); + if (targetPath != null) { + String repoPath = targetPath.substring(0, targetPath.lastIndexOf('/') + 1) + "maven-repository" ; + + content.append(""); + content.append(""); + content.append(""); + content.append(""); + } + } + + AntTarget target = new AntTarget("build-maven-repository", content); + return target; + } + + protected void deployBinInRepository(XMLContent content, String jarsDir, + String mavenRespoitoryDir, String pomFile, String destBinJarFile) { + + content.append(""); + content.append(""); + content.append(""); + content.append(""); + content.append(""); + content.append(""); + } + + protected void deploySrcInRepository(XMLContent content, String jarsDir, + String mavenRespoitoryDir, Plugin plugin, String pluginVersion, String destSrcJarFile) { + + content.append(""); + content.append(""); + content.append(""); + content.append(""); + content.append(""); + content.append(""); + content.append(""); + content.append(""); + content.append(""); + content.append(""); + } + + protected void addDependenciesRecursively(Plugin plugin, + Set pluginsToRepack, Map plugin2VersionMap) { + for (IDependable dependency : plugin.getDependencies()) { + if (dependency instanceof CompiledPlugin) { + CompiledPlugin compiledPlugin = (CompiledPlugin) dependency; + if (includeInMavenRepository(compiledPlugin)) { + plugin2VersionMap.put( + compiledPlugin.getIdentifier(), compiledPlugin.getVersion()); + pluginsToRepack.add(compiledPlugin); + addDependenciesRecursively(compiledPlugin, pluginsToRepack, plugin2VersionMap); + } + } + } + } + + protected String generatePomXML(Plugin plugin, String pluginVersion, + String pluginName, String pluginVendor, Map plugin2VersionMap) { + XMLContent content = new XMLContent(); + + content.append(""); + content.append(""); + content.append("4.0.0"); + content.append("" + getMavenGroup(plugin.getIdentifier()) + ""); + content.append("" + plugin.getIdentifier() + ""); + content.append("" + pluginVersion + ""); + content.append("" + pluginName + ""); + content.append(""); + content.append("" + pluginVendor + ""); + content.append(""); + content.append(""); + content.append(""); + content.append("Eclipse Public License - v 1.0"); + content.append("http://www.eclipse.org/org/documents/epl-v10.html"); + content.append(""); + content.append(""); + content.append(""); + for (UnresolvedDependency dependency : plugin.getResolvedDependencies()) { + if (isOptional(dependency)) { + continue; + } + String dependencyVersion = plugin2VersionMap.get(dependency.getIdentifier()); + if (dependencyVersion == null) { + System.out.println("Can not create maven artifact for " + plugin.getIdentifier() + + " since " + dependency.getIdentifier() + " is not versioned"); + return null; + } + content.append(""); + content.append("" + getMavenGroup(dependency.getIdentifier()) + ""); + content.append("" + dependency.getIdentifier() + ""); + content.append("" + dependencyVersion + ""); + content.append(""); + } + content.append(""); + content.append(""); + return content.toString(); + } + + protected String generatePomProperties(Plugin plugin, String pluginVersion) { + String content = ""; + content += "version=" + pluginVersion + "\n"; + content += "groupId=" + getMavenGroup(plugin.getIdentifier()) + "\n"; + content += "artifactId=" + plugin.getIdentifier() + "\n"; + return content; + } + + protected File writePomFile(String pomXMLContent, File pluginDirectory, String pluginID, String extension) { + File pomFolder = new File(pluginDirectory.getAbsolutePath() + File.separator + "META-INF" + + File.separator + "maven" + File.separator + getMavenGroup(pluginID) + + File.separator + pluginID); + pomFolder.mkdirs(); + File pomXMLFile = new File(pomFolder, "pom." + extension); + + try { + new FileOutputStream(pomXMLFile).write(pomXMLContent.getBytes()); + } catch (Exception e) { + e.printStackTrace(); + } + return pomXMLFile; + } + + protected String getMavenGroup(String identifier) { + String groupID = ""; + String[] idSegments = identifier.split("\\."); + for (int i = 0; i < idSegments.length && i < 3; i++) { + if ("".equals(groupID)) { + groupID = idSegments[i]; + } else { + groupID = groupID + "." + idSegments[i]; + } + } + return groupID; + } + + protected boolean isOptional(UnresolvedDependency dependency) { + if (dependency.isOptional()) { + return true; + } + //This dependency is not marked optional in EMF plugins although it is optional. + //See also: https://bugs.eclipse.org/bugs/show_bug.cgi?id=328227 + if (dependency.getIdentifier().equals("org.eclipse.core.runtime")) { + return true; + } + return false; + } + + protected boolean includeInMavenRepository(CompiledPlugin compiledPlugin) { + // TODO This selects the EMF core plugins, could be moved to an external spec + String id = compiledPlugin.getIdentifier(); + if (id.equals("org.eclipse.emf.common")) { + return true; + } + if (id.equals("org.eclipse.emf.ecore")) { + return true; + } + if (id.equals("org.eclipse.emf.ecore.change")) { + return true; + } + if (id.equals("org.eclipse.emf.xmi")) { + return true; + } + return false; + } + + protected String idToName(String pluginID) { + String name = ""; + String[] segements = pluginID.split("\\."); + for (int i = 1; i < segements.length; i++) { + String s = segements[i]; + name = name + firstToUpper(s) + " "; + } + if ("".equals(name)) { + return pluginID; + } + return name.trim(); + } + + private String firstToUpper(String s) { + return s.substring(0,1).toUpperCase() + s.substring(1); + } + + +} diff --git a/Extensions/Maven/de.devboost.buildboost.genext.maven/src/de/devboost/buildboost/genext/maven/steps/BuildMavenRepositoryStepProvider.java b/Extensions/Maven/de.devboost.buildboost.genext.maven/src/de/devboost/buildboost/genext/maven/steps/BuildMavenRepositoryStepProvider.java index eba8afe..747c65f 100644 --- a/Extensions/Maven/de.devboost.buildboost.genext.maven/src/de/devboost/buildboost/genext/maven/steps/BuildMavenRepositoryStepProvider.java +++ b/Extensions/Maven/de.devboost.buildboost.genext.maven/src/de/devboost/buildboost/genext/maven/steps/BuildMavenRepositoryStepProvider.java @@ -1,45 +1,45 @@ -/******************************************************************************* - * Copyright (c) 2006-2012 - * Software Technology Group, Dresden University of Technology - * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 - * - * All rights reserved. This program and the accompanying materials - * are 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 - * - * Contributors: - * Software Technology Group - TU Dresden, Germany; - * DevBoost GmbH - Berlin, Germany - * - initial API and implementation - ******************************************************************************/ -package de.devboost.buildboost.genext.maven.steps; - -import java.io.File; -import java.util.Collections; -import java.util.List; - -import de.devboost.buildboost.ant.AbstractAntTargetGeneratorProvider; -import de.devboost.buildboost.ant.IAntTargetGenerator; -import de.devboost.buildboost.genext.updatesite.artifacts.EclipseUpdateSiteDeploymentSpec; -import de.devboost.buildboost.model.IArtifact; -import de.devboost.buildboost.model.IBuildContext; - -public class BuildMavenRepositoryStepProvider extends AbstractAntTargetGeneratorProvider { - - private File targetDir; - - public BuildMavenRepositoryStepProvider(File targetDir) { - super(); - this.targetDir = targetDir; - } - - public List getAntTargetGenerators(IBuildContext context, IArtifact artifact) { - if (artifact instanceof EclipseUpdateSiteDeploymentSpec) { - EclipseUpdateSiteDeploymentSpec updateSite = (EclipseUpdateSiteDeploymentSpec) artifact; - IAntTargetGenerator step = new BuildMavenRepositoryStep(updateSite, targetDir); - return Collections.singletonList(step); - } - return Collections.emptyList(); - } -} +/******************************************************************************* + * Copyright (c) 2006-2012 + * Software Technology Group, Dresden University of Technology + * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 + * + * All rights reserved. This program and the accompanying materials + * are 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 + * + * Contributors: + * Software Technology Group - TU Dresden, Germany; + * DevBoost GmbH - Berlin, Germany + * - initial API and implementation + ******************************************************************************/ +package de.devboost.buildboost.genext.maven.steps; + +import java.io.File; +import java.util.Collections; +import java.util.List; + +import de.devboost.buildboost.ant.AbstractAntTargetGeneratorProvider; +import de.devboost.buildboost.ant.IAntTargetGenerator; +import de.devboost.buildboost.genext.updatesite.artifacts.EclipseUpdateSiteDeploymentSpec; +import de.devboost.buildboost.model.IArtifact; +import de.devboost.buildboost.model.IBuildContext; + +public class BuildMavenRepositoryStepProvider extends AbstractAntTargetGeneratorProvider { + + private File targetDir; + + public BuildMavenRepositoryStepProvider(File targetDir) { + super(); + this.targetDir = targetDir; + } + + public List getAntTargetGenerators(IBuildContext context, IArtifact artifact) { + if (artifact instanceof EclipseUpdateSiteDeploymentSpec) { + EclipseUpdateSiteDeploymentSpec updateSite = (EclipseUpdateSiteDeploymentSpec) artifact; + IAntTargetGenerator step = new BuildMavenRepositoryStep(updateSite, targetDir); + return Collections.singletonList(step); + } + return Collections.emptyList(); + } +} diff --git a/Extensions/Product/de.devboost.buildboost.genext.product/src/de/devboost/buildboost/genext/product/artifacts/EclipseProduct.java b/Extensions/Product/de.devboost.buildboost.genext.product/src/de/devboost/buildboost/genext/product/artifacts/EclipseProduct.java index 9a462fe..4c5e2a3 100644 --- a/Extensions/Product/de.devboost.buildboost.genext.product/src/de/devboost/buildboost/genext/product/artifacts/EclipseProduct.java +++ b/Extensions/Product/de.devboost.buildboost.genext.product/src/de/devboost/buildboost/genext/product/artifacts/EclipseProduct.java @@ -1,104 +1,104 @@ -/******************************************************************************* - * Copyright (c) 2006-2012 - * Software Technology Group, Dresden University of Technology - * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 - * - * All rights reserved. This program and the accompanying materials - * are 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 - * - * Contributors: - * Software Technology Group - TU Dresden, Germany; - * DevBoost GmbH - Berlin, Germany - * - initial API and implementation - ******************************************************************************/ -package de.devboost.buildboost.genext.product.artifacts; - -import java.io.File; -import java.util.Collection; -import java.util.Collections; -import java.util.LinkedHashSet; -import java.util.Set; - -import javax.xml.xpath.XPath; -import javax.xml.xpath.XPathExpressionException; - -import org.w3c.dom.Document; -import org.w3c.dom.Element; - -import de.devboost.buildboost.artifacts.AbstractArtifact; -import de.devboost.buildboost.artifacts.EclipseFeature; -import de.devboost.buildboost.genext.updatesite.artifacts.EclipseUpdateSiteDeploymentSpec; -import de.devboost.buildboost.model.IDependable; -import de.devboost.buildboost.model.UnresolvedDependency; -import de.devboost.buildboost.util.AbstractXMLReader; - -@SuppressWarnings("serial") -public class EclipseProduct extends AbstractArtifact { - - private File file; - - public EclipseProduct(File file) { - this.file = file; - readProductFile(); - setIdentifier(file.getName()); - String parentIdentifier = file.getParentFile().getName(); - getUnresolvedDependencies().add(new UnresolvedDependency(EclipseUpdateSiteDeploymentSpec.class, parentIdentifier, null, true, null, true, false, false)); - } - - private void readProductFile() { - AbstractXMLReader xmlUtil = new AbstractXMLReader() { - - @Override - protected void process(Document document, XPath xpath) - throws XPathExpressionException { - findFeatureDependencies(document, xpath); - } - - @Override - protected void addUnresolvedDependencies(Element element, - UnresolvedDependency unresolvedDependency) { - getUnresolvedDependencies().add(unresolvedDependency); - } - - private void findFeatureDependencies(Document document, XPath xpath) - throws XPathExpressionException { - findDependencies(document, xpath, "//feature", "id", null, EclipseFeature.class); - } - }; - - xmlUtil.readXMLFile(file); - } - - public Collection getFeatures() { - Set features = new LinkedHashSet(); - Collection dependencies = getDependencies(); - for (IDependable dependency : dependencies) { - if (dependency instanceof EclipseFeature) { - EclipseFeature feature = (EclipseFeature) dependency; - features.add(feature); - } - } - return Collections.unmodifiableSet(features); - } - - public File getFile() { - return file; - } - - @Override - public long getTimestamp() { - return file.lastModified(); - } - - public EclipseUpdateSiteDeploymentSpec getDeploymentSpec() { - for (IDependable dependency : getDependencies()) { - if (dependency instanceof EclipseUpdateSiteDeploymentSpec) { - EclipseUpdateSiteDeploymentSpec spec = (EclipseUpdateSiteDeploymentSpec) dependency; - return spec; - } - } - return null; - } -} +/******************************************************************************* + * Copyright (c) 2006-2012 + * Software Technology Group, Dresden University of Technology + * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 + * + * All rights reserved. This program and the accompanying materials + * are 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 + * + * Contributors: + * Software Technology Group - TU Dresden, Germany; + * DevBoost GmbH - Berlin, Germany + * - initial API and implementation + ******************************************************************************/ +package de.devboost.buildboost.genext.product.artifacts; + +import java.io.File; +import java.util.Collection; +import java.util.Collections; +import java.util.LinkedHashSet; +import java.util.Set; + +import javax.xml.xpath.XPath; +import javax.xml.xpath.XPathExpressionException; + +import org.w3c.dom.Document; +import org.w3c.dom.Element; + +import de.devboost.buildboost.artifacts.AbstractArtifact; +import de.devboost.buildboost.artifacts.EclipseFeature; +import de.devboost.buildboost.genext.updatesite.artifacts.EclipseUpdateSiteDeploymentSpec; +import de.devboost.buildboost.model.IDependable; +import de.devboost.buildboost.model.UnresolvedDependency; +import de.devboost.buildboost.util.AbstractXMLReader; + +@SuppressWarnings("serial") +public class EclipseProduct extends AbstractArtifact { + + private File file; + + public EclipseProduct(File file) { + this.file = file; + readProductFile(); + setIdentifier(file.getName()); + String parentIdentifier = file.getParentFile().getName(); + getUnresolvedDependencies().add(new UnresolvedDependency(EclipseUpdateSiteDeploymentSpec.class, parentIdentifier, null, true, null, true, false, false)); + } + + private void readProductFile() { + AbstractXMLReader xmlUtil = new AbstractXMLReader() { + + @Override + protected void process(Document document, XPath xpath) + throws XPathExpressionException { + findFeatureDependencies(document, xpath); + } + + @Override + protected void addUnresolvedDependencies(Element element, + UnresolvedDependency unresolvedDependency) { + getUnresolvedDependencies().add(unresolvedDependency); + } + + private void findFeatureDependencies(Document document, XPath xpath) + throws XPathExpressionException { + findDependencies(document, xpath, "//feature", "id", null, EclipseFeature.class); + } + }; + + xmlUtil.readXMLFile(file); + } + + public Collection getFeatures() { + Set features = new LinkedHashSet(); + Collection dependencies = getDependencies(); + for (IDependable dependency : dependencies) { + if (dependency instanceof EclipseFeature) { + EclipseFeature feature = (EclipseFeature) dependency; + features.add(feature); + } + } + return Collections.unmodifiableSet(features); + } + + public File getFile() { + return file; + } + + @Override + public long getTimestamp() { + return file.lastModified(); + } + + public EclipseUpdateSiteDeploymentSpec getDeploymentSpec() { + for (IDependable dependency : getDependencies()) { + if (dependency instanceof EclipseUpdateSiteDeploymentSpec) { + EclipseUpdateSiteDeploymentSpec spec = (EclipseUpdateSiteDeploymentSpec) dependency; + return spec; + } + } + return null; + } +} diff --git a/Extensions/Product/de.devboost.buildboost.genext.product/src/de/devboost/buildboost/genext/product/discovery/EclipseProductFinder.java b/Extensions/Product/de.devboost.buildboost.genext.product/src/de/devboost/buildboost/genext/product/discovery/EclipseProductFinder.java index 7ec48e6..33aa5e2 100644 --- a/Extensions/Product/de.devboost.buildboost.genext.product/src/de/devboost/buildboost/genext/product/discovery/EclipseProductFinder.java +++ b/Extensions/Product/de.devboost.buildboost.genext.product/src/de/devboost/buildboost/genext/product/discovery/EclipseProductFinder.java @@ -1,67 +1,67 @@ -/******************************************************************************* - * Copyright (c) 2006-2012 - * Software Technology Group, Dresden University of Technology - * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 - * - * All rights reserved. This program and the accompanying materials - * are 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 - * - * Contributors: - * Software Technology Group - TU Dresden, Germany; - * DevBoost GmbH - Berlin, Germany - * - initial API and implementation - ******************************************************************************/ -package de.devboost.buildboost.genext.product.discovery; - -import java.io.File; -import java.io.FileFilter; -import java.util.ArrayList; -import java.util.Collection; - -import de.devboost.buildboost.BuildException; -import de.devboost.buildboost.discovery.AbstractFileFinder; -import de.devboost.buildboost.genext.product.artifacts.EclipseProduct; -import de.devboost.buildboost.model.BuildEventType; -import de.devboost.buildboost.model.IArtifact; -import de.devboost.buildboost.model.IBuildContext; -import de.devboost.buildboost.model.IBuildListener; -import de.devboost.buildboost.util.ArtifactUtil; - -public class EclipseProductFinder extends AbstractFileFinder { - - private IBuildListener buildListener; - - public EclipseProductFinder(File directory) { - super(directory); - } - - public Collection discoverArtifacts(IBuildContext context) throws BuildException { - buildListener = context.getBuildListener(); - Collection updateSites = new ArrayList(); - traverse(context, updateSites); - return new ArtifactUtil().getSetOfArtifacts(updateSites); - } - - protected EclipseProduct createArtifactFromFile(File file) { - if (buildListener != null) { - buildListener.handleBuildEvent(BuildEventType.INFO, "Discovered product spec: " + file.getAbsolutePath()); - } - return new EclipseProduct(file); - } - - protected FileFilter getFileFilter() { - return new FileFilter() { - - public boolean accept(File file) { - return file.getName().endsWith(".product") && file.isFile(); - } - }; - } - - @Override - public String toString() { - return getClass().getSimpleName() + " [" + directory.getAbsolutePath() + "]"; - } -} +/******************************************************************************* + * Copyright (c) 2006-2012 + * Software Technology Group, Dresden University of Technology + * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 + * + * All rights reserved. This program and the accompanying materials + * are 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 + * + * Contributors: + * Software Technology Group - TU Dresden, Germany; + * DevBoost GmbH - Berlin, Germany + * - initial API and implementation + ******************************************************************************/ +package de.devboost.buildboost.genext.product.discovery; + +import java.io.File; +import java.io.FileFilter; +import java.util.ArrayList; +import java.util.Collection; + +import de.devboost.buildboost.BuildException; +import de.devboost.buildboost.discovery.AbstractFileFinder; +import de.devboost.buildboost.genext.product.artifacts.EclipseProduct; +import de.devboost.buildboost.model.BuildEventType; +import de.devboost.buildboost.model.IArtifact; +import de.devboost.buildboost.model.IBuildContext; +import de.devboost.buildboost.model.IBuildListener; +import de.devboost.buildboost.util.ArtifactUtil; + +public class EclipseProductFinder extends AbstractFileFinder { + + private IBuildListener buildListener; + + public EclipseProductFinder(File directory) { + super(directory); + } + + public Collection discoverArtifacts(IBuildContext context) throws BuildException { + buildListener = context.getBuildListener(); + Collection updateSites = new ArrayList(); + traverse(context, updateSites); + return new ArtifactUtil().getSetOfArtifacts(updateSites); + } + + protected EclipseProduct createArtifactFromFile(File file) { + if (buildListener != null) { + buildListener.handleBuildEvent(BuildEventType.INFO, "Discovered product spec: " + file.getAbsolutePath()); + } + return new EclipseProduct(file); + } + + protected FileFilter getFileFilter() { + return new FileFilter() { + + public boolean accept(File file) { + return file.getName().endsWith(".product") && file.isFile(); + } + }; + } + + @Override + public String toString() { + return getClass().getSimpleName() + " [" + directory.getAbsolutePath() + "]"; + } +} diff --git a/Extensions/Product/de.devboost.buildboost.genext.product/src/de/devboost/buildboost/genext/product/stages/BuildProductStage.java b/Extensions/Product/de.devboost.buildboost.genext.product/src/de/devboost/buildboost/genext/product/stages/BuildProductStage.java index dcf1a5f..5d7a004 100644 --- a/Extensions/Product/de.devboost.buildboost.genext.product/src/de/devboost/buildboost/genext/product/stages/BuildProductStage.java +++ b/Extensions/Product/de.devboost.buildboost.genext.product/src/de/devboost/buildboost/genext/product/stages/BuildProductStage.java @@ -1,74 +1,74 @@ -/******************************************************************************* - * Copyright (c) 2006-2012 - * Software Technology Group, Dresden University of Technology - * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 - * - * All rights reserved. This program and the accompanying materials - * are 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 - * - * Contributors: - * Software Technology Group - TU Dresden, Germany; - * DevBoost GmbH - Berlin, Germany - * - initial API and implementation - ******************************************************************************/ -package de.devboost.buildboost.genext.product.stages; - -import java.io.File; - -import de.devboost.buildboost.AutoBuilder; -import de.devboost.buildboost.BuildContext; -import de.devboost.buildboost.BuildException; -import de.devboost.buildboost.ant.AntScript; -import de.devboost.buildboost.discovery.EclipseFeatureFinder; -import de.devboost.buildboost.discovery.EclipseTargetPlatformAnalyzer; -import de.devboost.buildboost.discovery.PluginFinder; -import de.devboost.buildboost.genext.product.discovery.EclipseProductFinder; -import de.devboost.buildboost.genext.product.steps.BuildProductStepProvider; -import de.devboost.buildboost.genext.updatesite.discovery.EclipseUpdateSiteDeploymentSpecFinder; -import de.devboost.buildboost.genext.updatesite.discovery.EclipseUpdateSiteFinder; -import de.devboost.buildboost.model.IUniversalBuildStage; -import de.devboost.buildboost.stages.AbstractBuildStage; - -public class BuildProductStage extends AbstractBuildStage implements IUniversalBuildStage { - - private String artifactsFolder; - - public void setArtifactsFolder(String artifactsFolder) { - this.artifactsFolder = artifactsFolder; - } - - @Override - public AntScript getScript() throws BuildException { - File buildDir = new File(artifactsFolder); - - BuildContext context = createContext(false); - - context.addBuildParticipant(new EclipseTargetPlatformAnalyzer(buildDir)); - - context.addBuildParticipant(new PluginFinder(buildDir)); - context.addBuildParticipant(new EclipseFeatureFinder(buildDir)); - context.addBuildParticipant(new EclipseProductFinder(buildDir)); - - context.addBuildParticipant(new EclipseUpdateSiteDeploymentSpecFinder(buildDir)); - - File distDir = new File(buildDir, "dist"); - context.addBuildParticipant(new EclipseUpdateSiteFinder(distDir)); - - context.addBuildParticipant(new BuildProductStepProvider(buildDir)); - - AutoBuilder builder = new AutoBuilder(context); - - AntScript script = new AntScript(); - script.setName("Build Eclipse product(s)"); - script.addTargets(builder.generateAntTargets()); - - return script; - } - - @Override - public int getPriority() { - return 15000; - } -} +/******************************************************************************* + * Copyright (c) 2006-2012 + * Software Technology Group, Dresden University of Technology + * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 + * + * All rights reserved. This program and the accompanying materials + * are 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 + * + * Contributors: + * Software Technology Group - TU Dresden, Germany; + * DevBoost GmbH - Berlin, Germany + * - initial API and implementation + ******************************************************************************/ +package de.devboost.buildboost.genext.product.stages; + +import java.io.File; + +import de.devboost.buildboost.AutoBuilder; +import de.devboost.buildboost.BuildContext; +import de.devboost.buildboost.BuildException; +import de.devboost.buildboost.ant.AntScript; +import de.devboost.buildboost.discovery.EclipseFeatureFinder; +import de.devboost.buildboost.discovery.EclipseTargetPlatformAnalyzer; +import de.devboost.buildboost.discovery.PluginFinder; +import de.devboost.buildboost.genext.product.discovery.EclipseProductFinder; +import de.devboost.buildboost.genext.product.steps.BuildProductStepProvider; +import de.devboost.buildboost.genext.updatesite.discovery.EclipseUpdateSiteDeploymentSpecFinder; +import de.devboost.buildboost.genext.updatesite.discovery.EclipseUpdateSiteFinder; +import de.devboost.buildboost.model.IUniversalBuildStage; +import de.devboost.buildboost.stages.AbstractBuildStage; + +public class BuildProductStage extends AbstractBuildStage implements IUniversalBuildStage { + + private String artifactsFolder; + + public void setArtifactsFolder(String artifactsFolder) { + this.artifactsFolder = artifactsFolder; + } + + @Override + public AntScript getScript() throws BuildException { + File buildDir = new File(artifactsFolder); + + BuildContext context = createContext(false); + + context.addBuildParticipant(new EclipseTargetPlatformAnalyzer(buildDir)); + + context.addBuildParticipant(new PluginFinder(buildDir)); + context.addBuildParticipant(new EclipseFeatureFinder(buildDir)); + context.addBuildParticipant(new EclipseProductFinder(buildDir)); + + context.addBuildParticipant(new EclipseUpdateSiteDeploymentSpecFinder(buildDir)); + + File distDir = new File(buildDir, "dist"); + context.addBuildParticipant(new EclipseUpdateSiteFinder(distDir)); + + context.addBuildParticipant(new BuildProductStepProvider(buildDir)); + + AutoBuilder builder = new AutoBuilder(context); + + AntScript script = new AntScript(); + script.setName("Build Eclipse product(s)"); + script.addTargets(builder.generateAntTargets()); + + return script; + } + + @Override + public int getPriority() { + return 15000; + } +} diff --git a/Extensions/Product/de.devboost.buildboost.genext.product/src/de/devboost/buildboost/genext/product/steps/BuildProductStep.java b/Extensions/Product/de.devboost.buildboost.genext.product/src/de/devboost/buildboost/genext/product/steps/BuildProductStep.java index beb8b34..b2812fd 100644 --- a/Extensions/Product/de.devboost.buildboost.genext.product/src/de/devboost/buildboost/genext/product/steps/BuildProductStep.java +++ b/Extensions/Product/de.devboost.buildboost.genext.product/src/de/devboost/buildboost/genext/product/steps/BuildProductStep.java @@ -1,171 +1,171 @@ -/******************************************************************************* - * Copyright (c) 2006-2012 - * Software Technology Group, Dresden University of Technology - * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 - * - * All rights reserved. This program and the accompanying materials - * are 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 - * - * Contributors: - * Software Technology Group - TU Dresden, Germany; - * DevBoost GmbH - Berlin, Germany - * - initial API and implementation - ******************************************************************************/ -package de.devboost.buildboost.genext.product.steps; - -import java.io.File; -import java.util.Collection; -import java.util.Collections; - -import de.devboost.buildboost.BuildException; -import de.devboost.buildboost.ant.AbstractAntTargetGenerator; -import de.devboost.buildboost.ant.AntTarget; -import de.devboost.buildboost.genext.product.artifacts.EclipseProduct; -import de.devboost.buildboost.genext.updatesite.artifacts.EclipseUpdateSiteDeploymentSpec; -import de.devboost.buildboost.util.XMLContent; - -public class BuildProductStep extends AbstractAntTargetGenerator { - - private EclipseProduct productSpec; - private File targetDir; - - public BuildProductStep(EclipseProduct productSpec, File targetDir) { - super(); - this.productSpec = productSpec; - this.targetDir = targetDir; - } - - @Override - public Collection generateAntTargets() throws BuildException { - AntTarget updateSiteTarget = generateUpdateSiteAntTarget(); - return Collections.singletonList(updateSiteTarget); - } - - protected AntTarget generateUpdateSiteAntTarget() throws BuildException { - EclipseUpdateSiteDeploymentSpec deploymentSpec = productSpec.getDeploymentSpec(); - if (deploymentSpec == null) { - throw new BuildException("Can't find deployment spec site for product specification."); - } - - XMLContent content = new XMLContent(); - - String siteVersion = deploymentSpec.getSiteVersion(); - String productSpecPath = productSpec.getFile().getAbsolutePath(); - - content.append(""); - content.append(""); - content.append(""); - content.append(""); - content.append(""); - content.appendLineBreak(); - - //TODO this is not good, because the tstamp should not be stage dependent - content.append(""); - content.append(""); - content.append(""); - content.appendLineBreak(); - - //set version in product file - content.append(""); - - String updateSiteID = deploymentSpec.getUpdateSite().getIdentifier(); - - File repoBaseFolder = deploymentSpec.getUpdateSite().getFile().getParentFile().getParentFile(); - - File tempDirFile = new File(targetDir.getParentFile(), "pde-build-temp"); - tempDirFile.mkdir(); - String tempDir = tempDirFile.getAbsolutePath(); - String eclipseDir = new File(new File(targetDir, "target-platform"), "eclipse").getAbsolutePath(); - String p2ProductRepo = new File(new File(repoBaseFolder.getParentFile(), "products-p2"), updateSiteID).getAbsolutePath(); - String productsDir = new File(repoBaseFolder.getParentFile(), "products-zip").getAbsolutePath(); - - //call PDE product build - content.append(""); //TODO this is a platform dependent executable in the PATH - content.append(""); - content.append(""); - content.append(""); - content.append(""); - content.append(""); - content.append(""); //TODO pde.build version might differ - - content.append(""); - - content.append(""); - - content.append(""); - content.append(""); - content.append(""); - - content.append(""); - - content.append(""); - content.append(""); - content.append(""); - - content.append(""); - content.append(""); - content.append(""); - content.append(""); - content.append(""); - content.append(""); - content.append(""); - - String configs = deploymentSpec.getValue("site", "configs"); - content.append(""); - - content.append(""); - - //call director for publishing - String[] configArray = configs.split("\\&"); - for (String conf : configArray) { - String[] split = conf.split(","); - String os = split[0]; - String ws = split[1]; - String arch = split[2]; - - String productFileName = productSpec.getIdentifier() + "-" + os + "-" + ws + "-" + arch; - - content.append(""); - content.append(""); - content.append(""); - content.append(""); - content.append(""); - - String siteDependencies = deploymentSpec.getValue("site", "dependencies"); - content.append(""); - content.append(""); - content.append(""); - content.append(""); - content.append(""); - content.append(""); - content.append(""); - content.append(""); - content.append(""); - content.append(""); - content.append(""); - content.append(""); - content.append(""); - content.append(""); - content.append(""); - content.append(""); - content.append(""); - - content.append(""); - content.append(""); - content.append(""); - content.append(""); - content.append(""); - content.append(""); - - content.append(""); - } - - AntTarget target = new AntTarget("build-eclipse-product-" + updateSiteID, content); - return target; - } - - - -} +/******************************************************************************* + * Copyright (c) 2006-2012 + * Software Technology Group, Dresden University of Technology + * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 + * + * All rights reserved. This program and the accompanying materials + * are 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 + * + * Contributors: + * Software Technology Group - TU Dresden, Germany; + * DevBoost GmbH - Berlin, Germany + * - initial API and implementation + ******************************************************************************/ +package de.devboost.buildboost.genext.product.steps; + +import java.io.File; +import java.util.Collection; +import java.util.Collections; + +import de.devboost.buildboost.BuildException; +import de.devboost.buildboost.ant.AbstractAntTargetGenerator; +import de.devboost.buildboost.ant.AntTarget; +import de.devboost.buildboost.genext.product.artifacts.EclipseProduct; +import de.devboost.buildboost.genext.updatesite.artifacts.EclipseUpdateSiteDeploymentSpec; +import de.devboost.buildboost.util.XMLContent; + +public class BuildProductStep extends AbstractAntTargetGenerator { + + private EclipseProduct productSpec; + private File targetDir; + + public BuildProductStep(EclipseProduct productSpec, File targetDir) { + super(); + this.productSpec = productSpec; + this.targetDir = targetDir; + } + + @Override + public Collection generateAntTargets() throws BuildException { + AntTarget updateSiteTarget = generateUpdateSiteAntTarget(); + return Collections.singletonList(updateSiteTarget); + } + + protected AntTarget generateUpdateSiteAntTarget() throws BuildException { + EclipseUpdateSiteDeploymentSpec deploymentSpec = productSpec.getDeploymentSpec(); + if (deploymentSpec == null) { + throw new BuildException("Can't find deployment spec site for product specification."); + } + + XMLContent content = new XMLContent(); + + String siteVersion = deploymentSpec.getSiteVersion(); + String productSpecPath = productSpec.getFile().getAbsolutePath(); + + content.append(""); + content.append(""); + content.append(""); + content.append(""); + content.append(""); + content.appendLineBreak(); + + //TODO this is not good, because the tstamp should not be stage dependent + content.append(""); + content.append(""); + content.append(""); + content.appendLineBreak(); + + //set version in product file + content.append(""); + + String updateSiteID = deploymentSpec.getUpdateSite().getIdentifier(); + + File repoBaseFolder = deploymentSpec.getUpdateSite().getFile().getParentFile().getParentFile(); + + File tempDirFile = new File(targetDir.getParentFile(), "pde-build-temp"); + tempDirFile.mkdir(); + String tempDir = tempDirFile.getAbsolutePath(); + String eclipseDir = new File(new File(targetDir, "target-platform"), "eclipse").getAbsolutePath(); + String p2ProductRepo = new File(new File(repoBaseFolder.getParentFile(), "products-p2"), updateSiteID).getAbsolutePath(); + String productsDir = new File(repoBaseFolder.getParentFile(), "products-zip").getAbsolutePath(); + + //call PDE product build + content.append(""); //TODO this is a platform dependent executable in the PATH + content.append(""); + content.append(""); + content.append(""); + content.append(""); + content.append(""); + content.append(""); //TODO pde.build version might differ + + content.append(""); + + content.append(""); + + content.append(""); + content.append(""); + content.append(""); + + content.append(""); + + content.append(""); + content.append(""); + content.append(""); + + content.append(""); + content.append(""); + content.append(""); + content.append(""); + content.append(""); + content.append(""); + content.append(""); + + String configs = deploymentSpec.getValue("site", "configs"); + content.append(""); + + content.append(""); + + //call director for publishing + String[] configArray = configs.split("\\&"); + for (String conf : configArray) { + String[] split = conf.split(","); + String os = split[0]; + String ws = split[1]; + String arch = split[2]; + + String productFileName = productSpec.getIdentifier() + "-" + os + "-" + ws + "-" + arch; + + content.append(""); + content.append(""); + content.append(""); + content.append(""); + content.append(""); + + String siteDependencies = deploymentSpec.getValue("site", "dependencies"); + content.append(""); + content.append(""); + content.append(""); + content.append(""); + content.append(""); + content.append(""); + content.append(""); + content.append(""); + content.append(""); + content.append(""); + content.append(""); + content.append(""); + content.append(""); + content.append(""); + content.append(""); + content.append(""); + content.append(""); + + content.append(""); + content.append(""); + content.append(""); + content.append(""); + content.append(""); + content.append(""); + + content.append(""); + } + + AntTarget target = new AntTarget("build-eclipse-product-" + updateSiteID, content); + return target; + } + + + +} diff --git a/Extensions/Product/de.devboost.buildboost.genext.product/src/de/devboost/buildboost/genext/product/steps/BuildProductStepProvider.java b/Extensions/Product/de.devboost.buildboost.genext.product/src/de/devboost/buildboost/genext/product/steps/BuildProductStepProvider.java index 8d97c26..b9ab323 100644 --- a/Extensions/Product/de.devboost.buildboost.genext.product/src/de/devboost/buildboost/genext/product/steps/BuildProductStepProvider.java +++ b/Extensions/Product/de.devboost.buildboost.genext.product/src/de/devboost/buildboost/genext/product/steps/BuildProductStepProvider.java @@ -1,45 +1,45 @@ -/******************************************************************************* - * Copyright (c) 2006-2012 - * Software Technology Group, Dresden University of Technology - * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 - * - * All rights reserved. This program and the accompanying materials - * are 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 - * - * Contributors: - * Software Technology Group - TU Dresden, Germany; - * DevBoost GmbH - Berlin, Germany - * - initial API and implementation - ******************************************************************************/ -package de.devboost.buildboost.genext.product.steps; - -import java.io.File; -import java.util.Collections; -import java.util.List; - -import de.devboost.buildboost.ant.AbstractAntTargetGeneratorProvider; -import de.devboost.buildboost.ant.IAntTargetGenerator; -import de.devboost.buildboost.genext.product.artifacts.EclipseProduct; -import de.devboost.buildboost.model.IArtifact; -import de.devboost.buildboost.model.IBuildContext; - -public class BuildProductStepProvider extends AbstractAntTargetGeneratorProvider { - - private File targetDir; - - public BuildProductStepProvider(File targetDir) { - super(); - this.targetDir = targetDir; - } - - public List getAntTargetGenerators(IBuildContext context, IArtifact artifact) { - if (artifact instanceof EclipseProduct) { - EclipseProduct productSpec = (EclipseProduct) artifact; - IAntTargetGenerator step = new BuildProductStep(productSpec, targetDir); - return Collections.singletonList(step); - } - return Collections.emptyList(); - } -} +/******************************************************************************* + * Copyright (c) 2006-2012 + * Software Technology Group, Dresden University of Technology + * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 + * + * All rights reserved. This program and the accompanying materials + * are 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 + * + * Contributors: + * Software Technology Group - TU Dresden, Germany; + * DevBoost GmbH - Berlin, Germany + * - initial API and implementation + ******************************************************************************/ +package de.devboost.buildboost.genext.product.steps; + +import java.io.File; +import java.util.Collections; +import java.util.List; + +import de.devboost.buildboost.ant.AbstractAntTargetGeneratorProvider; +import de.devboost.buildboost.ant.IAntTargetGenerator; +import de.devboost.buildboost.genext.product.artifacts.EclipseProduct; +import de.devboost.buildboost.model.IArtifact; +import de.devboost.buildboost.model.IBuildContext; + +public class BuildProductStepProvider extends AbstractAntTargetGeneratorProvider { + + private File targetDir; + + public BuildProductStepProvider(File targetDir) { + super(); + this.targetDir = targetDir; + } + + public List getAntTargetGenerators(IBuildContext context, IArtifact artifact) { + if (artifact instanceof EclipseProduct) { + EclipseProduct productSpec = (EclipseProduct) artifact; + IAntTargetGenerator step = new BuildProductStep(productSpec, targetDir); + return Collections.singletonList(step); + } + return Collections.emptyList(); + } +} diff --git a/Extensions/ToolProduct/de.devboost.buildboost.genext.toolproduct/src/de/devboost/buildboost/genext/toolproduct/stages/BuildToolProductStage.java b/Extensions/ToolProduct/de.devboost.buildboost.genext.toolproduct/src/de/devboost/buildboost/genext/toolproduct/stages/BuildToolProductStage.java index 02940c6..fdec81b 100644 --- a/Extensions/ToolProduct/de.devboost.buildboost.genext.toolproduct/src/de/devboost/buildboost/genext/toolproduct/stages/BuildToolProductStage.java +++ b/Extensions/ToolProduct/de.devboost.buildboost.genext.toolproduct/src/de/devboost/buildboost/genext/toolproduct/stages/BuildToolProductStage.java @@ -1,72 +1,72 @@ -/******************************************************************************* - * Copyright (c) 2006-2012 - * Software Technology Group, Dresden University of Technology - * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 - * - * All rights reserved. This program and the accompanying materials - * are 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 - * - * Contributors: - * Software Technology Group - TU Dresden, Germany; - * DevBoost GmbH - Berlin, Germany - * - initial API and implementation - ******************************************************************************/ -package de.devboost.buildboost.genext.toolproduct.stages; - -import java.io.File; - -import de.devboost.buildboost.AutoBuilder; -import de.devboost.buildboost.BuildContext; -import de.devboost.buildboost.BuildException; -import de.devboost.buildboost.ant.AntScript; -import de.devboost.buildboost.discovery.EclipseFeatureFinder; -import de.devboost.buildboost.discovery.EclipseTargetPlatformAnalyzer; -import de.devboost.buildboost.discovery.PluginFinder; -import de.devboost.buildboost.genext.toolproduct.steps.BuildToolProductStepProvider; -import de.devboost.buildboost.genext.updatesite.discovery.EclipseUpdateSiteDeploymentSpecFinder; -import de.devboost.buildboost.genext.updatesite.discovery.EclipseUpdateSiteFinder; -import de.devboost.buildboost.model.IUniversalBuildStage; -import de.devboost.buildboost.stages.AbstractBuildStage; - -public class BuildToolProductStage extends AbstractBuildStage implements IUniversalBuildStage { - - private String artifactsFolder; - - public void setArtifactsFolder(String artifactsFolder) { - this.artifactsFolder = artifactsFolder; - } - - @Override - public AntScript getScript() throws BuildException { - File buildDir = new File(artifactsFolder); - - BuildContext context = createContext(false); - - context.addBuildParticipant(new EclipseTargetPlatformAnalyzer(buildDir)); - - context.addBuildParticipant(new PluginFinder(buildDir)); - context.addBuildParticipant(new EclipseFeatureFinder(buildDir)); - - context.addBuildParticipant(new EclipseUpdateSiteDeploymentSpecFinder(buildDir)); - - File distDir = new File(buildDir, "dist"); - context.addBuildParticipant(new EclipseUpdateSiteFinder(distDir)); - - context.addBuildParticipant(new BuildToolProductStepProvider(buildDir)); - - AutoBuilder builder = new AutoBuilder(context); - - AntScript script = new AntScript(); - script.setName("Build Eclipse product(s)"); - script.addTargets(builder.generateAntTargets()); - - return script; - } - - @Override - public int getPriority() { - return 15000; - } -} +/******************************************************************************* + * Copyright (c) 2006-2012 + * Software Technology Group, Dresden University of Technology + * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 + * + * All rights reserved. This program and the accompanying materials + * are 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 + * + * Contributors: + * Software Technology Group - TU Dresden, Germany; + * DevBoost GmbH - Berlin, Germany + * - initial API and implementation + ******************************************************************************/ +package de.devboost.buildboost.genext.toolproduct.stages; + +import java.io.File; + +import de.devboost.buildboost.AutoBuilder; +import de.devboost.buildboost.BuildContext; +import de.devboost.buildboost.BuildException; +import de.devboost.buildboost.ant.AntScript; +import de.devboost.buildboost.discovery.EclipseFeatureFinder; +import de.devboost.buildboost.discovery.EclipseTargetPlatformAnalyzer; +import de.devboost.buildboost.discovery.PluginFinder; +import de.devboost.buildboost.genext.toolproduct.steps.BuildToolProductStepProvider; +import de.devboost.buildboost.genext.updatesite.discovery.EclipseUpdateSiteDeploymentSpecFinder; +import de.devboost.buildboost.genext.updatesite.discovery.EclipseUpdateSiteFinder; +import de.devboost.buildboost.model.IUniversalBuildStage; +import de.devboost.buildboost.stages.AbstractBuildStage; + +public class BuildToolProductStage extends AbstractBuildStage implements IUniversalBuildStage { + + private String artifactsFolder; + + public void setArtifactsFolder(String artifactsFolder) { + this.artifactsFolder = artifactsFolder; + } + + @Override + public AntScript getScript() throws BuildException { + File buildDir = new File(artifactsFolder); + + BuildContext context = createContext(false); + + context.addBuildParticipant(new EclipseTargetPlatformAnalyzer(buildDir)); + + context.addBuildParticipant(new PluginFinder(buildDir)); + context.addBuildParticipant(new EclipseFeatureFinder(buildDir)); + + context.addBuildParticipant(new EclipseUpdateSiteDeploymentSpecFinder(buildDir)); + + File distDir = new File(buildDir, "dist"); + context.addBuildParticipant(new EclipseUpdateSiteFinder(distDir)); + + context.addBuildParticipant(new BuildToolProductStepProvider(buildDir)); + + AutoBuilder builder = new AutoBuilder(context); + + AntScript script = new AntScript(); + script.setName("Build Eclipse product(s)"); + script.addTargets(builder.generateAntTargets()); + + return script; + } + + @Override + public int getPriority() { + return 15000; + } +} diff --git a/Extensions/ToolProduct/de.devboost.buildboost.genext.toolproduct/src/de/devboost/buildboost/genext/toolproduct/steps/BuildToolProductStep.java b/Extensions/ToolProduct/de.devboost.buildboost.genext.toolproduct/src/de/devboost/buildboost/genext/toolproduct/steps/BuildToolProductStep.java index a469df8..e5c1bb3 100644 --- a/Extensions/ToolProduct/de.devboost.buildboost.genext.toolproduct/src/de/devboost/buildboost/genext/toolproduct/steps/BuildToolProductStep.java +++ b/Extensions/ToolProduct/de.devboost.buildboost.genext.toolproduct/src/de/devboost/buildboost/genext/toolproduct/steps/BuildToolProductStep.java @@ -1,145 +1,145 @@ -/******************************************************************************* - * Copyright (c) 2006-2012 - * Software Technology Group, Dresden University of Technology - * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 - * - * All rights reserved. This program and the accompanying materials - * are 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 - * - * Contributors: - * Software Technology Group - TU Dresden, Germany; - * DevBoost GmbH - Berlin, Germany - * - initial API and implementation - ******************************************************************************/ -package de.devboost.buildboost.genext.toolproduct.steps; - -import java.io.File; -import java.util.Collection; -import java.util.Collections; -import java.util.Map; -import java.util.Map.Entry; - -import de.devboost.buildboost.BuildException; -import de.devboost.buildboost.ant.AbstractAntTargetGenerator; -import de.devboost.buildboost.ant.AntTarget; -import de.devboost.buildboost.genext.updatesite.artifacts.EclipseUpdateSiteDeploymentSpec; -import de.devboost.buildboost.util.XMLContent; -import de.devboost.buildboost.util.AntScriptUtil; - -public class BuildToolProductStep extends AbstractAntTargetGenerator { - - private EclipseUpdateSiteDeploymentSpec deploymentSpec; - private File targetDir; - - public BuildToolProductStep(EclipseUpdateSiteDeploymentSpec deploymentSpec, File targetDir) { - super(); - this.deploymentSpec = deploymentSpec; - this.targetDir = targetDir; - } - - @Override - public Collection generateAntTargets() throws BuildException { - AntTarget updateSiteTarget = generateUpdateSiteAntTarget(); - return Collections.singletonList(updateSiteTarget); - } - - protected AntTarget generateUpdateSiteAntTarget() throws BuildException { - if (deploymentSpec == null) { - throw new BuildException("Can't find deployment spec site for product specification."); - } - - XMLContent content = new XMLContent(); - - content.append(""); - content.append(""); - content.append(""); - content.append(""); - content.append(""); - content.appendLineBreak(); - //TODO this is not good, because the tstamp should not be stage dependent - content.append(""); - content.append(""); - content.append(""); - content.appendLineBreak(); - - File updateSiteFolder = deploymentSpec.getUpdateSite().getFile().getParentFile(); - - File productBuildDir = new File(targetDir, "products"); - productBuildDir.mkdir(); - - String productName = deploymentSpec.getValue("product", "name"); - String productFeatureID = deploymentSpec.getValue("product", "feature"); - String siteVersion = deploymentSpec.getFeatureVersion(productFeatureID); - - File sdkFolder = new File(targetDir.getParentFile().getParentFile(), "eclipse-sdks"); - File productFolder = new File(productBuildDir, productName); - sdkFolder.mkdir(); - productFolder.mkdir(); - - //call director for publishing - Map configs = deploymentSpec.getValues("product", "type"); - for (Entry conf : configs.entrySet()) { - String productType = conf.getKey(); - String url = conf.getValue(); - String sdkZipName = url.substring(url.lastIndexOf("/") + 1); - File sdkZipFile = new File(sdkFolder, sdkZipName); - - if (!sdkZipFile.exists()) { - AntScriptUtil.addDownloadFileScript(content, url, sdkFolder.getAbsolutePath()); - } - content.appendLineBreak(); - - File productInstallationFolder = new File(productFolder, productType); - productInstallationFolder.mkdir(); - AntScriptUtil.addZipFileExtractionScript(content, sdkZipFile, productInstallationFolder); - content.appendLineBreak(); - - content.append(""); - - content.append(""); - content.append(""); - content.append(""); - content.append(""); - - content.append(""); - //TODO Juno and Feedback update-sites are hard coded as dependency here - content.append(""); - content.append(""); - content.append(""); - content.append(""); - content.append(""); - content.append(""); - content.append(""); - content.append(""); - content.append(""); - - content.append(""); - content.appendLineBreak(); - - //TODO do more stuff: - // - rename "eclipse" base folder - // - add workspace (put 'osgi.instance.area.default=../../../workspace' into config.ini) - // - replace eclipse launcher file/folder by custom launcher (or rename launcher) - // - configure splash screen - - - File productsDistFolder = new File(updateSiteFolder.getParentFile().getParentFile(), "products"); - String productZipPath = new File(productsDistFolder, productName + "-" + siteVersion + "-" + productType + ".zip").getAbsolutePath(); - productsDistFolder.mkdir(); - //TODO this needs to use native tar.gz for unix systems in order to preserve file flags - content.append(""); - content.appendLineBreak(); - - //TODO upload ZIP - } - - String updateSiteID = deploymentSpec.getUpdateSite().getIdentifier(); - AntTarget target = new AntTarget("build-eclipse-tool-product-" + updateSiteID, content); - return target; - } - - - -} +/******************************************************************************* + * Copyright (c) 2006-2012 + * Software Technology Group, Dresden University of Technology + * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 + * + * All rights reserved. This program and the accompanying materials + * are 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 + * + * Contributors: + * Software Technology Group - TU Dresden, Germany; + * DevBoost GmbH - Berlin, Germany + * - initial API and implementation + ******************************************************************************/ +package de.devboost.buildboost.genext.toolproduct.steps; + +import java.io.File; +import java.util.Collection; +import java.util.Collections; +import java.util.Map; +import java.util.Map.Entry; + +import de.devboost.buildboost.BuildException; +import de.devboost.buildboost.ant.AbstractAntTargetGenerator; +import de.devboost.buildboost.ant.AntTarget; +import de.devboost.buildboost.genext.updatesite.artifacts.EclipseUpdateSiteDeploymentSpec; +import de.devboost.buildboost.util.XMLContent; +import de.devboost.buildboost.util.AntScriptUtil; + +public class BuildToolProductStep extends AbstractAntTargetGenerator { + + private EclipseUpdateSiteDeploymentSpec deploymentSpec; + private File targetDir; + + public BuildToolProductStep(EclipseUpdateSiteDeploymentSpec deploymentSpec, File targetDir) { + super(); + this.deploymentSpec = deploymentSpec; + this.targetDir = targetDir; + } + + @Override + public Collection generateAntTargets() throws BuildException { + AntTarget updateSiteTarget = generateUpdateSiteAntTarget(); + return Collections.singletonList(updateSiteTarget); + } + + protected AntTarget generateUpdateSiteAntTarget() throws BuildException { + if (deploymentSpec == null) { + throw new BuildException("Can't find deployment spec site for product specification."); + } + + XMLContent content = new XMLContent(); + + content.append(""); + content.append(""); + content.append(""); + content.append(""); + content.append(""); + content.appendLineBreak(); + //TODO this is not good, because the tstamp should not be stage dependent + content.append(""); + content.append(""); + content.append(""); + content.appendLineBreak(); + + File updateSiteFolder = deploymentSpec.getUpdateSite().getFile().getParentFile(); + + File productBuildDir = new File(targetDir, "products"); + productBuildDir.mkdir(); + + String productName = deploymentSpec.getValue("product", "name"); + String productFeatureID = deploymentSpec.getValue("product", "feature"); + String siteVersion = deploymentSpec.getFeatureVersion(productFeatureID); + + File sdkFolder = new File(targetDir.getParentFile().getParentFile(), "eclipse-sdks"); + File productFolder = new File(productBuildDir, productName); + sdkFolder.mkdir(); + productFolder.mkdir(); + + //call director for publishing + Map configs = deploymentSpec.getValues("product", "type"); + for (Entry conf : configs.entrySet()) { + String productType = conf.getKey(); + String url = conf.getValue(); + String sdkZipName = url.substring(url.lastIndexOf("/") + 1); + File sdkZipFile = new File(sdkFolder, sdkZipName); + + if (!sdkZipFile.exists()) { + AntScriptUtil.addDownloadFileScript(content, url, sdkFolder.getAbsolutePath()); + } + content.appendLineBreak(); + + File productInstallationFolder = new File(productFolder, productType); + productInstallationFolder.mkdir(); + AntScriptUtil.addZipFileExtractionScript(content, sdkZipFile, productInstallationFolder); + content.appendLineBreak(); + + content.append(""); + + content.append(""); + content.append(""); + content.append(""); + content.append(""); + + content.append(""); + //TODO Juno and Feedback update-sites are hard coded as dependency here + content.append(""); + content.append(""); + content.append(""); + content.append(""); + content.append(""); + content.append(""); + content.append(""); + content.append(""); + content.append(""); + + content.append(""); + content.appendLineBreak(); + + //TODO do more stuff: + // - rename "eclipse" base folder + // - add workspace (put 'osgi.instance.area.default=../../../workspace' into config.ini) + // - replace eclipse launcher file/folder by custom launcher (or rename launcher) + // - configure splash screen + + + File productsDistFolder = new File(updateSiteFolder.getParentFile().getParentFile(), "products"); + String productZipPath = new File(productsDistFolder, productName + "-" + siteVersion + "-" + productType + ".zip").getAbsolutePath(); + productsDistFolder.mkdir(); + //TODO this needs to use native tar.gz for unix systems in order to preserve file flags + content.append(""); + content.appendLineBreak(); + + //TODO upload ZIP + } + + String updateSiteID = deploymentSpec.getUpdateSite().getIdentifier(); + AntTarget target = new AntTarget("build-eclipse-tool-product-" + updateSiteID, content); + return target; + } + + + +} diff --git a/Extensions/ToolProduct/de.devboost.buildboost.genext.toolproduct/src/de/devboost/buildboost/genext/toolproduct/steps/BuildToolProductStepProvider.java b/Extensions/ToolProduct/de.devboost.buildboost.genext.toolproduct/src/de/devboost/buildboost/genext/toolproduct/steps/BuildToolProductStepProvider.java index 6e24043..46211bf 100644 --- a/Extensions/ToolProduct/de.devboost.buildboost.genext.toolproduct/src/de/devboost/buildboost/genext/toolproduct/steps/BuildToolProductStepProvider.java +++ b/Extensions/ToolProduct/de.devboost.buildboost.genext.toolproduct/src/de/devboost/buildboost/genext/toolproduct/steps/BuildToolProductStepProvider.java @@ -1,45 +1,45 @@ -/******************************************************************************* - * Copyright (c) 2006-2012 - * Software Technology Group, Dresden University of Technology - * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 - * - * All rights reserved. This program and the accompanying materials - * are 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 - * - * Contributors: - * Software Technology Group - TU Dresden, Germany; - * DevBoost GmbH - Berlin, Germany - * - initial API and implementation - ******************************************************************************/ -package de.devboost.buildboost.genext.toolproduct.steps; - -import java.io.File; -import java.util.Collections; -import java.util.List; - -import de.devboost.buildboost.ant.AbstractAntTargetGeneratorProvider; -import de.devboost.buildboost.ant.IAntTargetGenerator; -import de.devboost.buildboost.genext.updatesite.artifacts.EclipseUpdateSiteDeploymentSpec; -import de.devboost.buildboost.model.IArtifact; -import de.devboost.buildboost.model.IBuildContext; - -public class BuildToolProductStepProvider extends AbstractAntTargetGeneratorProvider { - - private File targetDir; - - public BuildToolProductStepProvider(File targetDir) { - super(); - this.targetDir = targetDir; - } - - public List getAntTargetGenerators(IBuildContext context, IArtifact artifact) { - if (artifact instanceof EclipseUpdateSiteDeploymentSpec) { - EclipseUpdateSiteDeploymentSpec deploymentSpec = (EclipseUpdateSiteDeploymentSpec) artifact; - IAntTargetGenerator step = new BuildToolProductStep(deploymentSpec, targetDir); - return Collections.singletonList(step); - } - return Collections.emptyList(); - } -} +/******************************************************************************* + * Copyright (c) 2006-2012 + * Software Technology Group, Dresden University of Technology + * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 + * + * All rights reserved. This program and the accompanying materials + * are 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 + * + * Contributors: + * Software Technology Group - TU Dresden, Germany; + * DevBoost GmbH - Berlin, Germany + * - initial API and implementation + ******************************************************************************/ +package de.devboost.buildboost.genext.toolproduct.steps; + +import java.io.File; +import java.util.Collections; +import java.util.List; + +import de.devboost.buildboost.ant.AbstractAntTargetGeneratorProvider; +import de.devboost.buildboost.ant.IAntTargetGenerator; +import de.devboost.buildboost.genext.updatesite.artifacts.EclipseUpdateSiteDeploymentSpec; +import de.devboost.buildboost.model.IArtifact; +import de.devboost.buildboost.model.IBuildContext; + +public class BuildToolProductStepProvider extends AbstractAntTargetGeneratorProvider { + + private File targetDir; + + public BuildToolProductStepProvider(File targetDir) { + super(); + this.targetDir = targetDir; + } + + public List getAntTargetGenerators(IBuildContext context, IArtifact artifact) { + if (artifact instanceof EclipseUpdateSiteDeploymentSpec) { + EclipseUpdateSiteDeploymentSpec deploymentSpec = (EclipseUpdateSiteDeploymentSpec) artifact; + IAntTargetGenerator step = new BuildToolProductStep(deploymentSpec, targetDir); + return Collections.singletonList(step); + } + return Collections.emptyList(); + } +} diff --git a/Extensions/UpdateSite/de.devboost.buildboost.genext.updatesite/src/de/devboost/buildboost/genext/updatesite/artifacts/EclipseUpdateSite.java b/Extensions/UpdateSite/de.devboost.buildboost.genext.updatesite/src/de/devboost/buildboost/genext/updatesite/artifacts/EclipseUpdateSite.java index c5ae2d1..76cc912 100644 --- a/Extensions/UpdateSite/de.devboost.buildboost.genext.updatesite/src/de/devboost/buildboost/genext/updatesite/artifacts/EclipseUpdateSite.java +++ b/Extensions/UpdateSite/de.devboost.buildboost.genext.updatesite/src/de/devboost/buildboost/genext/updatesite/artifacts/EclipseUpdateSite.java @@ -1,92 +1,92 @@ -/******************************************************************************* - * Copyright (c) 2006-2012 - * Software Technology Group, Dresden University of Technology - * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 - * - * All rights reserved. This program and the accompanying materials - * are 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 - * - * Contributors: - * Software Technology Group - TU Dresden, Germany; - * DevBoost GmbH - Berlin, Germany - * - initial API and implementation - ******************************************************************************/ -package de.devboost.buildboost.genext.updatesite.artifacts; - -import java.io.File; -import java.util.Collection; -import java.util.Collections; -import java.util.LinkedHashSet; -import java.util.Set; - -import javax.xml.xpath.XPath; -import javax.xml.xpath.XPathExpressionException; - -import org.w3c.dom.Document; -import org.w3c.dom.Element; - -import de.devboost.buildboost.artifacts.AbstractArtifact; -import de.devboost.buildboost.artifacts.EclipseFeature; -import de.devboost.buildboost.model.IDependable; -import de.devboost.buildboost.model.UnresolvedDependency; -import de.devboost.buildboost.util.AbstractXMLReader; - -@SuppressWarnings("serial") -public class EclipseUpdateSite extends AbstractArtifact { - - private File file; - - public EclipseUpdateSite(File file) { - this.file = file; - readUpdateSiteFile(); - // use parent directory name as identifier - setIdentifier(file.getParentFile().getName()); - } - - private void readUpdateSiteFile() { - AbstractXMLReader xmlUtil = new AbstractXMLReader() { - - @Override - protected void process(Document document, XPath xpath) - throws XPathExpressionException { - findFeatureDependencies(document, xpath); - } - - @Override - protected void addUnresolvedDependencies(Element element, - UnresolvedDependency unresolvedDependency) { - getUnresolvedDependencies().add(unresolvedDependency); - } - - private void findFeatureDependencies(Document document, XPath xpath) - throws XPathExpressionException { - findDependencies(document, xpath, "//feature", "id", null, EclipseFeature.class); - } - }; - - xmlUtil.readXMLFile(file); - } - - public Collection getFeatures() { - Set features = new LinkedHashSet(); - Collection dependencies = getDependencies(); - for (IDependable dependency : dependencies) { - if (dependency instanceof EclipseFeature) { - EclipseFeature feature = (EclipseFeature) dependency; - features.add(feature); - } - } - return Collections.unmodifiableSet(features); - } - - public File getFile() { - return file; - } - - @Override - public long getTimestamp() { - return file.lastModified(); - } -} +/******************************************************************************* + * Copyright (c) 2006-2012 + * Software Technology Group, Dresden University of Technology + * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 + * + * All rights reserved. This program and the accompanying materials + * are 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 + * + * Contributors: + * Software Technology Group - TU Dresden, Germany; + * DevBoost GmbH - Berlin, Germany + * - initial API and implementation + ******************************************************************************/ +package de.devboost.buildboost.genext.updatesite.artifacts; + +import java.io.File; +import java.util.Collection; +import java.util.Collections; +import java.util.LinkedHashSet; +import java.util.Set; + +import javax.xml.xpath.XPath; +import javax.xml.xpath.XPathExpressionException; + +import org.w3c.dom.Document; +import org.w3c.dom.Element; + +import de.devboost.buildboost.artifacts.AbstractArtifact; +import de.devboost.buildboost.artifacts.EclipseFeature; +import de.devboost.buildboost.model.IDependable; +import de.devboost.buildboost.model.UnresolvedDependency; +import de.devboost.buildboost.util.AbstractXMLReader; + +@SuppressWarnings("serial") +public class EclipseUpdateSite extends AbstractArtifact { + + private File file; + + public EclipseUpdateSite(File file) { + this.file = file; + readUpdateSiteFile(); + // use parent directory name as identifier + setIdentifier(file.getParentFile().getName()); + } + + private void readUpdateSiteFile() { + AbstractXMLReader xmlUtil = new AbstractXMLReader() { + + @Override + protected void process(Document document, XPath xpath) + throws XPathExpressionException { + findFeatureDependencies(document, xpath); + } + + @Override + protected void addUnresolvedDependencies(Element element, + UnresolvedDependency unresolvedDependency) { + getUnresolvedDependencies().add(unresolvedDependency); + } + + private void findFeatureDependencies(Document document, XPath xpath) + throws XPathExpressionException { + findDependencies(document, xpath, "//feature", "id", null, EclipseFeature.class); + } + }; + + xmlUtil.readXMLFile(file); + } + + public Collection getFeatures() { + Set features = new LinkedHashSet(); + Collection dependencies = getDependencies(); + for (IDependable dependency : dependencies) { + if (dependency instanceof EclipseFeature) { + EclipseFeature feature = (EclipseFeature) dependency; + features.add(feature); + } + } + return Collections.unmodifiableSet(features); + } + + public File getFile() { + return file; + } + + @Override + public long getTimestamp() { + return file.lastModified(); + } +} diff --git a/Extensions/UpdateSite/de.devboost.buildboost.genext.updatesite/src/de/devboost/buildboost/genext/updatesite/artifacts/EclipseUpdateSiteDeploymentSpec.java b/Extensions/UpdateSite/de.devboost.buildboost.genext.updatesite/src/de/devboost/buildboost/genext/updatesite/artifacts/EclipseUpdateSiteDeploymentSpec.java index 1f8adbd..f720356 100644 --- a/Extensions/UpdateSite/de.devboost.buildboost.genext.updatesite/src/de/devboost/buildboost/genext/updatesite/artifacts/EclipseUpdateSiteDeploymentSpec.java +++ b/Extensions/UpdateSite/de.devboost.buildboost.genext.updatesite/src/de/devboost/buildboost/genext/updatesite/artifacts/EclipseUpdateSiteDeploymentSpec.java @@ -1,143 +1,143 @@ -/******************************************************************************* - * Copyright (c) 2006-2012 - * Software Technology Group, Dresden University of Technology - * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 - * - * All rights reserved. This program and the accompanying materials - * are 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 - * - * Contributors: - * Software Technology Group - TU Dresden, Germany; - * DevBoost GmbH - Berlin, Germany - * - initial API and implementation - ******************************************************************************/ -package de.devboost.buildboost.genext.updatesite.artifacts; - -import java.io.File; -import java.io.FileReader; -import java.io.IOException; -import java.io.Reader; -import java.util.LinkedHashMap; -import java.util.Map; -import java.util.Properties; - -import de.devboost.buildboost.artifacts.AbstractArtifact; -import de.devboost.buildboost.model.IDependable; -import de.devboost.buildboost.model.UnresolvedDependency; - -@SuppressWarnings("serial") -public class EclipseUpdateSiteDeploymentSpec extends AbstractArtifact { - - private File file; - private Properties properties; - - public EclipseUpdateSiteDeploymentSpec(File file) { - this.file = file; - readVersionFile(); - // use parent directory name as identifier - String identifier = file.getParentFile().getName(); - setIdentifier(identifier); - getUnresolvedDependencies().add(new UnresolvedDependency(EclipseUpdateSite.class, identifier, null, true, null, true, false, false)); - } - - private void readVersionFile() { - properties = new Properties(); - try { - Reader reader = new FileReader(file); - properties.load(reader); - reader.close(); - } catch (IOException e) { - throw new RuntimeException("Exception while reading deployment specificiation: " + e.getMessage()); - } - } - - public String getValue(String... path) { - StringBuilder key = new StringBuilder(); - for (int i = 0; i < path.length - 1; i++) { - key.append(path[i]); - key.append("/"); - } - if (path.length > 0) { - key.append(path[path.length - 1]); - } - return getValue(key.toString()); - } - - private String getValue(String key) { - String value = properties.getProperty(key); - if (value == null) { - return null; - } - if (value.startsWith("$")) { - return getValue(value.substring(1)); - } - return value; - } - - public Map getValues(String... path) { - StringBuilder key = new StringBuilder(); - Map values = new LinkedHashMap(); - for (int i = 0; i < path.length; i++) { - key.append(path[i]); - key.append("/"); - } - for(Map.Entry entry : properties.entrySet()) { - if (entry.getKey().toString().startsWith(key.toString())) { - String subKey = entry.getKey().toString().substring( - key.toString().length()); - if (!subKey.contains("/")) { - values.put(subKey, entry.getValue().toString()); - } - } - } - return values; - } - - public EclipseUpdateSite getUpdateSite() { - for (IDependable dependency : getDependencies()) { - if (dependency instanceof EclipseUpdateSite) { - EclipseUpdateSite eclipseUpdateSite = (EclipseUpdateSite) dependency; - return eclipseUpdateSite; - } - } - return null; - } - - - public String getSiteVendor() { - return getValue("site", "vendor"); - } - - public String getFeatureVendor(String featureID) { - String featureVendor = getValue("feature", featureID, "vendor"); - if (featureVendor == null) { - featureVendor = getSiteVendor(); - } - if (featureVendor == null) { - featureVendor = "Unknown vendor"; - } - return featureVendor; - } - - public String getSiteVersion() { - return getValue("site", "version"); - } - - public String getFeatureVersion(String featureID) { - String featureVersion = getValue("feature", featureID, "version"); - if (featureVersion == null) { - featureVersion = getSiteVersion(); - } - if (featureVersion == null) { - featureVersion = "0.0.1"; - } - return featureVersion; - } - - @Override - public long getTimestamp() { - return file.lastModified(); - } -} +/******************************************************************************* + * Copyright (c) 2006-2012 + * Software Technology Group, Dresden University of Technology + * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 + * + * All rights reserved. This program and the accompanying materials + * are 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 + * + * Contributors: + * Software Technology Group - TU Dresden, Germany; + * DevBoost GmbH - Berlin, Germany + * - initial API and implementation + ******************************************************************************/ +package de.devboost.buildboost.genext.updatesite.artifacts; + +import java.io.File; +import java.io.FileReader; +import java.io.IOException; +import java.io.Reader; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Properties; + +import de.devboost.buildboost.artifacts.AbstractArtifact; +import de.devboost.buildboost.model.IDependable; +import de.devboost.buildboost.model.UnresolvedDependency; + +@SuppressWarnings("serial") +public class EclipseUpdateSiteDeploymentSpec extends AbstractArtifact { + + private File file; + private Properties properties; + + public EclipseUpdateSiteDeploymentSpec(File file) { + this.file = file; + readVersionFile(); + // use parent directory name as identifier + String identifier = file.getParentFile().getName(); + setIdentifier(identifier); + getUnresolvedDependencies().add(new UnresolvedDependency(EclipseUpdateSite.class, identifier, null, true, null, true, false, false)); + } + + private void readVersionFile() { + properties = new Properties(); + try { + Reader reader = new FileReader(file); + properties.load(reader); + reader.close(); + } catch (IOException e) { + throw new RuntimeException("Exception while reading deployment specificiation: " + e.getMessage()); + } + } + + public String getValue(String... path) { + StringBuilder key = new StringBuilder(); + for (int i = 0; i < path.length - 1; i++) { + key.append(path[i]); + key.append("/"); + } + if (path.length > 0) { + key.append(path[path.length - 1]); + } + return getValue(key.toString()); + } + + private String getValue(String key) { + String value = properties.getProperty(key); + if (value == null) { + return null; + } + if (value.startsWith("$")) { + return getValue(value.substring(1)); + } + return value; + } + + public Map getValues(String... path) { + StringBuilder key = new StringBuilder(); + Map values = new LinkedHashMap(); + for (int i = 0; i < path.length; i++) { + key.append(path[i]); + key.append("/"); + } + for(Map.Entry entry : properties.entrySet()) { + if (entry.getKey().toString().startsWith(key.toString())) { + String subKey = entry.getKey().toString().substring( + key.toString().length()); + if (!subKey.contains("/")) { + values.put(subKey, entry.getValue().toString()); + } + } + } + return values; + } + + public EclipseUpdateSite getUpdateSite() { + for (IDependable dependency : getDependencies()) { + if (dependency instanceof EclipseUpdateSite) { + EclipseUpdateSite eclipseUpdateSite = (EclipseUpdateSite) dependency; + return eclipseUpdateSite; + } + } + return null; + } + + + public String getSiteVendor() { + return getValue("site", "vendor"); + } + + public String getFeatureVendor(String featureID) { + String featureVendor = getValue("feature", featureID, "vendor"); + if (featureVendor == null) { + featureVendor = getSiteVendor(); + } + if (featureVendor == null) { + featureVendor = "Unknown vendor"; + } + return featureVendor; + } + + public String getSiteVersion() { + return getValue("site", "version"); + } + + public String getFeatureVersion(String featureID) { + String featureVersion = getValue("feature", featureID, "version"); + if (featureVersion == null) { + featureVersion = getSiteVersion(); + } + if (featureVersion == null) { + featureVersion = "0.0.1"; + } + return featureVersion; + } + + @Override + public long getTimestamp() { + return file.lastModified(); + } +} diff --git a/Extensions/UpdateSite/de.devboost.buildboost.genext.updatesite/src/de/devboost/buildboost/genext/updatesite/discovery/EclipseUpdateSiteDeploymentSpecFinder.java b/Extensions/UpdateSite/de.devboost.buildboost.genext.updatesite/src/de/devboost/buildboost/genext/updatesite/discovery/EclipseUpdateSiteDeploymentSpecFinder.java index db1b776..dcfa278 100644 --- a/Extensions/UpdateSite/de.devboost.buildboost.genext.updatesite/src/de/devboost/buildboost/genext/updatesite/discovery/EclipseUpdateSiteDeploymentSpecFinder.java +++ b/Extensions/UpdateSite/de.devboost.buildboost.genext.updatesite/src/de/devboost/buildboost/genext/updatesite/discovery/EclipseUpdateSiteDeploymentSpecFinder.java @@ -1,62 +1,62 @@ -/******************************************************************************* - * Copyright (c) 2006-2012 - * Software Technology Group, Dresden University of Technology - * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 - * - * All rights reserved. This program and the accompanying materials - * are 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 - * - * Contributors: - * Software Technology Group - TU Dresden, Germany; - * DevBoost GmbH - Berlin, Germany - * - initial API and implementation - ******************************************************************************/ -package de.devboost.buildboost.genext.updatesite.discovery; - -import java.io.File; -import java.io.FileFilter; -import java.util.ArrayList; -import java.util.Collection; - -import de.devboost.buildboost.BuildException; -import de.devboost.buildboost.discovery.AbstractFileFinder; -import de.devboost.buildboost.genext.updatesite.artifacts.EclipseUpdateSiteDeploymentSpec; -import de.devboost.buildboost.model.BuildEventType; -import de.devboost.buildboost.model.IArtifact; -import de.devboost.buildboost.model.IBuildContext; -import de.devboost.buildboost.model.IBuildListener; -import de.devboost.buildboost.util.ArtifactUtil; - -public class EclipseUpdateSiteDeploymentSpecFinder extends AbstractFileFinder { - - private IBuildListener buildListener; - - public EclipseUpdateSiteDeploymentSpecFinder(File directory) { - super(directory); - } - - public Collection discoverArtifacts(IBuildContext context) throws BuildException { - buildListener = context.getBuildListener(); - Collection updateSites = new ArrayList(); - traverse(context, updateSites); - return new ArtifactUtil().getSetOfArtifacts(updateSites); - } - - protected EclipseUpdateSiteDeploymentSpec createArtifactFromFile(File file) { - if (buildListener != null) { - buildListener.handleBuildEvent(BuildEventType.INFO, "Discovered update site specification: " + file.getAbsolutePath()); - } - return new EclipseUpdateSiteDeploymentSpec(file); - } - - protected FileFilter getFileFilter() { - return new FileFilter() { - - public boolean accept(File file) { - return file.getName().equals("site.deployment") && file.isFile(); - } - }; - } -} +/******************************************************************************* + * Copyright (c) 2006-2012 + * Software Technology Group, Dresden University of Technology + * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 + * + * All rights reserved. This program and the accompanying materials + * are 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 + * + * Contributors: + * Software Technology Group - TU Dresden, Germany; + * DevBoost GmbH - Berlin, Germany + * - initial API and implementation + ******************************************************************************/ +package de.devboost.buildboost.genext.updatesite.discovery; + +import java.io.File; +import java.io.FileFilter; +import java.util.ArrayList; +import java.util.Collection; + +import de.devboost.buildboost.BuildException; +import de.devboost.buildboost.discovery.AbstractFileFinder; +import de.devboost.buildboost.genext.updatesite.artifacts.EclipseUpdateSiteDeploymentSpec; +import de.devboost.buildboost.model.BuildEventType; +import de.devboost.buildboost.model.IArtifact; +import de.devboost.buildboost.model.IBuildContext; +import de.devboost.buildboost.model.IBuildListener; +import de.devboost.buildboost.util.ArtifactUtil; + +public class EclipseUpdateSiteDeploymentSpecFinder extends AbstractFileFinder { + + private IBuildListener buildListener; + + public EclipseUpdateSiteDeploymentSpecFinder(File directory) { + super(directory); + } + + public Collection discoverArtifacts(IBuildContext context) throws BuildException { + buildListener = context.getBuildListener(); + Collection updateSites = new ArrayList(); + traverse(context, updateSites); + return new ArtifactUtil().getSetOfArtifacts(updateSites); + } + + protected EclipseUpdateSiteDeploymentSpec createArtifactFromFile(File file) { + if (buildListener != null) { + buildListener.handleBuildEvent(BuildEventType.INFO, "Discovered update site specification: " + file.getAbsolutePath()); + } + return new EclipseUpdateSiteDeploymentSpec(file); + } + + protected FileFilter getFileFilter() { + return new FileFilter() { + + public boolean accept(File file) { + return file.getName().equals("site.deployment") && file.isFile(); + } + }; + } +} diff --git a/Extensions/UpdateSite/de.devboost.buildboost.genext.updatesite/src/de/devboost/buildboost/genext/updatesite/discovery/EclipseUpdateSiteFinder.java b/Extensions/UpdateSite/de.devboost.buildboost.genext.updatesite/src/de/devboost/buildboost/genext/updatesite/discovery/EclipseUpdateSiteFinder.java index f983c6a..84711f1 100644 --- a/Extensions/UpdateSite/de.devboost.buildboost.genext.updatesite/src/de/devboost/buildboost/genext/updatesite/discovery/EclipseUpdateSiteFinder.java +++ b/Extensions/UpdateSite/de.devboost.buildboost.genext.updatesite/src/de/devboost/buildboost/genext/updatesite/discovery/EclipseUpdateSiteFinder.java @@ -1,67 +1,67 @@ -/******************************************************************************* - * Copyright (c) 2006-2012 - * Software Technology Group, Dresden University of Technology - * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 - * - * All rights reserved. This program and the accompanying materials - * are 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 - * - * Contributors: - * Software Technology Group - TU Dresden, Germany; - * DevBoost GmbH - Berlin, Germany - * - initial API and implementation - ******************************************************************************/ -package de.devboost.buildboost.genext.updatesite.discovery; - -import java.io.File; -import java.io.FileFilter; -import java.util.ArrayList; -import java.util.Collection; - -import de.devboost.buildboost.BuildException; -import de.devboost.buildboost.discovery.AbstractFileFinder; -import de.devboost.buildboost.genext.updatesite.artifacts.EclipseUpdateSite; -import de.devboost.buildboost.model.BuildEventType; -import de.devboost.buildboost.model.IArtifact; -import de.devboost.buildboost.model.IBuildContext; -import de.devboost.buildboost.model.IBuildListener; -import de.devboost.buildboost.util.ArtifactUtil; - -public class EclipseUpdateSiteFinder extends AbstractFileFinder { - - private IBuildListener buildListener; - - public EclipseUpdateSiteFinder(File directory) { - super(directory); - } - - public Collection discoverArtifacts(IBuildContext context) throws BuildException { - buildListener = context.getBuildListener(); - Collection updateSites = new ArrayList(); - traverse(context, updateSites); - return new ArtifactUtil().getSetOfArtifacts(updateSites); - } - - protected EclipseUpdateSite createArtifactFromFile(File file) { - if (buildListener != null) { - buildListener.handleBuildEvent(BuildEventType.INFO, "Discovered update site: " + file.getAbsolutePath()); - } - return new EclipseUpdateSite(file); - } - - protected FileFilter getFileFilter() { - return new FileFilter() { - - public boolean accept(File file) { - return file.getName().equals("site.xml") && file.isFile(); - } - }; - } - - @Override - public String toString() { - return getClass().getSimpleName() + " [" + directory.getAbsolutePath() + "]"; - } -} +/******************************************************************************* + * Copyright (c) 2006-2012 + * Software Technology Group, Dresden University of Technology + * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 + * + * All rights reserved. This program and the accompanying materials + * are 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 + * + * Contributors: + * Software Technology Group - TU Dresden, Germany; + * DevBoost GmbH - Berlin, Germany + * - initial API and implementation + ******************************************************************************/ +package de.devboost.buildboost.genext.updatesite.discovery; + +import java.io.File; +import java.io.FileFilter; +import java.util.ArrayList; +import java.util.Collection; + +import de.devboost.buildboost.BuildException; +import de.devboost.buildboost.discovery.AbstractFileFinder; +import de.devboost.buildboost.genext.updatesite.artifacts.EclipseUpdateSite; +import de.devboost.buildboost.model.BuildEventType; +import de.devboost.buildboost.model.IArtifact; +import de.devboost.buildboost.model.IBuildContext; +import de.devboost.buildboost.model.IBuildListener; +import de.devboost.buildboost.util.ArtifactUtil; + +public class EclipseUpdateSiteFinder extends AbstractFileFinder { + + private IBuildListener buildListener; + + public EclipseUpdateSiteFinder(File directory) { + super(directory); + } + + public Collection discoverArtifacts(IBuildContext context) throws BuildException { + buildListener = context.getBuildListener(); + Collection updateSites = new ArrayList(); + traverse(context, updateSites); + return new ArtifactUtil().getSetOfArtifacts(updateSites); + } + + protected EclipseUpdateSite createArtifactFromFile(File file) { + if (buildListener != null) { + buildListener.handleBuildEvent(BuildEventType.INFO, "Discovered update site: " + file.getAbsolutePath()); + } + return new EclipseUpdateSite(file); + } + + protected FileFilter getFileFilter() { + return new FileFilter() { + + public boolean accept(File file) { + return file.getName().equals("site.xml") && file.isFile(); + } + }; + } + + @Override + public String toString() { + return getClass().getSimpleName() + " [" + directory.getAbsolutePath() + "]"; + } +} diff --git a/Extensions/UpdateSite/de.devboost.buildboost.genext.updatesite/src/de/devboost/buildboost/genext/updatesite/stages/BuildUpdateSiteStage.java b/Extensions/UpdateSite/de.devboost.buildboost.genext.updatesite/src/de/devboost/buildboost/genext/updatesite/stages/BuildUpdateSiteStage.java index 6e35a89..4f78717 100644 --- a/Extensions/UpdateSite/de.devboost.buildboost.genext.updatesite/src/de/devboost/buildboost/genext/updatesite/stages/BuildUpdateSiteStage.java +++ b/Extensions/UpdateSite/de.devboost.buildboost.genext.updatesite/src/de/devboost/buildboost/genext/updatesite/stages/BuildUpdateSiteStage.java @@ -1,69 +1,69 @@ -/******************************************************************************* - * Copyright (c) 2006-2012 - * Software Technology Group, Dresden University of Technology - * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 - * - * All rights reserved. This program and the accompanying materials - * are 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 - * - * Contributors: - * Software Technology Group - TU Dresden, Germany; - * DevBoost GmbH - Berlin, Germany - * - initial API and implementation - ******************************************************************************/ -package de.devboost.buildboost.genext.updatesite.stages; - -import java.io.File; - -import de.devboost.buildboost.AutoBuilder; -import de.devboost.buildboost.BuildContext; -import de.devboost.buildboost.BuildException; -import de.devboost.buildboost.ant.AntScript; -import de.devboost.buildboost.discovery.EclipseFeatureFinder; -import de.devboost.buildboost.discovery.EclipseTargetPlatformAnalyzer; -import de.devboost.buildboost.discovery.PluginFinder; -import de.devboost.buildboost.genext.updatesite.discovery.EclipseUpdateSiteDeploymentSpecFinder; -import de.devboost.buildboost.genext.updatesite.discovery.EclipseUpdateSiteFinder; -import de.devboost.buildboost.genext.updatesite.steps.BuildUpdateSiteStepProvider; -import de.devboost.buildboost.model.IUniversalBuildStage; -import de.devboost.buildboost.stages.AbstractBuildStage; - -public class BuildUpdateSiteStage extends AbstractBuildStage implements IUniversalBuildStage { - - private String artifactsFolder; - - public void setArtifactsFolder(String artifactsFolder) { - this.artifactsFolder = artifactsFolder; - } - - @Override - public AntScript getScript() throws BuildException { - File buildDir = new File(artifactsFolder); - - BuildContext context = createContext(false); - - context.addBuildParticipant(new EclipseTargetPlatformAnalyzer(buildDir)); - - context.addBuildParticipant(new PluginFinder(buildDir)); - context.addBuildParticipant(new EclipseFeatureFinder(buildDir)); - context.addBuildParticipant(new EclipseUpdateSiteFinder(buildDir)); - context.addBuildParticipant(new EclipseUpdateSiteDeploymentSpecFinder(buildDir)); - - context.addBuildParticipant(new BuildUpdateSiteStepProvider(buildDir)); - - AutoBuilder builder = new AutoBuilder(context); - - AntScript script = new AntScript(); - script.setName("Build update site(s)"); - script.addTargets(builder.generateAntTargets()); - - return script; - } - - @Override - public int getPriority() { - return 10000; - } -} +/******************************************************************************* + * Copyright (c) 2006-2012 + * Software Technology Group, Dresden University of Technology + * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 + * + * All rights reserved. This program and the accompanying materials + * are 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 + * + * Contributors: + * Software Technology Group - TU Dresden, Germany; + * DevBoost GmbH - Berlin, Germany + * - initial API and implementation + ******************************************************************************/ +package de.devboost.buildboost.genext.updatesite.stages; + +import java.io.File; + +import de.devboost.buildboost.AutoBuilder; +import de.devboost.buildboost.BuildContext; +import de.devboost.buildboost.BuildException; +import de.devboost.buildboost.ant.AntScript; +import de.devboost.buildboost.discovery.EclipseFeatureFinder; +import de.devboost.buildboost.discovery.EclipseTargetPlatformAnalyzer; +import de.devboost.buildboost.discovery.PluginFinder; +import de.devboost.buildboost.genext.updatesite.discovery.EclipseUpdateSiteDeploymentSpecFinder; +import de.devboost.buildboost.genext.updatesite.discovery.EclipseUpdateSiteFinder; +import de.devboost.buildboost.genext.updatesite.steps.BuildUpdateSiteStepProvider; +import de.devboost.buildboost.model.IUniversalBuildStage; +import de.devboost.buildboost.stages.AbstractBuildStage; + +public class BuildUpdateSiteStage extends AbstractBuildStage implements IUniversalBuildStage { + + private String artifactsFolder; + + public void setArtifactsFolder(String artifactsFolder) { + this.artifactsFolder = artifactsFolder; + } + + @Override + public AntScript getScript() throws BuildException { + File buildDir = new File(artifactsFolder); + + BuildContext context = createContext(false); + + context.addBuildParticipant(new EclipseTargetPlatformAnalyzer(buildDir)); + + context.addBuildParticipant(new PluginFinder(buildDir)); + context.addBuildParticipant(new EclipseFeatureFinder(buildDir)); + context.addBuildParticipant(new EclipseUpdateSiteFinder(buildDir)); + context.addBuildParticipant(new EclipseUpdateSiteDeploymentSpecFinder(buildDir)); + + context.addBuildParticipant(new BuildUpdateSiteStepProvider(buildDir)); + + AutoBuilder builder = new AutoBuilder(context); + + AntScript script = new AntScript(); + script.setName("Build update site(s)"); + script.addTargets(builder.generateAntTargets()); + + return script; + } + + @Override + public int getPriority() { + return 10000; + } +} diff --git a/Extensions/UpdateSite/de.devboost.buildboost.genext.updatesite/src/de/devboost/buildboost/genext/updatesite/steps/BuildUpdateSiteStep.java b/Extensions/UpdateSite/de.devboost.buildboost.genext.updatesite/src/de/devboost/buildboost/genext/updatesite/steps/BuildUpdateSiteStep.java index 0767188..8d7f311 100644 --- a/Extensions/UpdateSite/de.devboost.buildboost.genext.updatesite/src/de/devboost/buildboost/genext/updatesite/steps/BuildUpdateSiteStep.java +++ b/Extensions/UpdateSite/de.devboost.buildboost.genext.updatesite/src/de/devboost/buildboost/genext/updatesite/steps/BuildUpdateSiteStep.java @@ -1,205 +1,205 @@ -/******************************************************************************* - * Copyright (c) 2006-2012 - * Software Technology Group, Dresden University of Technology - * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 - * - * All rights reserved. This program and the accompanying materials - * are 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 - * - * Contributors: - * Software Technology Group - TU Dresden, Germany; - * DevBoost GmbH - Berlin, Germany - * - initial API and implementation - ******************************************************************************/ -package de.devboost.buildboost.genext.updatesite.steps; - -import java.io.File; -import java.util.Collection; -import java.util.Collections; - -import de.devboost.buildboost.BuildException; -import de.devboost.buildboost.ant.AbstractAntTargetGenerator; -import de.devboost.buildboost.ant.AntTarget; -import de.devboost.buildboost.artifacts.EclipseFeature; -import de.devboost.buildboost.artifacts.Plugin; -import de.devboost.buildboost.genext.updatesite.artifacts.EclipseUpdateSite; -import de.devboost.buildboost.genext.updatesite.artifacts.EclipseUpdateSiteDeploymentSpec; -import de.devboost.buildboost.util.XMLContent; - -public class BuildUpdateSiteStep extends AbstractAntTargetGenerator { - - private EclipseUpdateSiteDeploymentSpec updateSiteSpec; - private File targetDir; - private String usernameProperty = null; - private String passwordProperty = null; - - public BuildUpdateSiteStep(EclipseUpdateSiteDeploymentSpec updateSiteSpec, File targetDir) { - super(); - this.updateSiteSpec = updateSiteSpec; - this.targetDir = targetDir; - } - - @Override - public Collection generateAntTargets() throws BuildException { - if (usernameProperty == null) { - usernameProperty = updateSiteSpec.getValue("site", "usernameProperty"); - } - if (passwordProperty == null) { - passwordProperty = updateSiteSpec.getValue("site", "passwordProperty"); - } - - AntTarget updateSiteTarget = generateUpdateSiteAntTarget(); - return Collections.singletonList(updateSiteTarget); - } - - protected AntTarget generateUpdateSiteAntTarget() throws BuildException { - EclipseUpdateSite updateSite = updateSiteSpec.getUpdateSite(); - if (updateSite == null) { - throw new BuildException("Can't find update site for update site specification."); - } - - String distDir = targetDir.getAbsolutePath() + File.separator + "dist"; - - XMLContent content = new XMLContent(); - - String updateSiteID = updateSite.getIdentifier(); - File updateSiteFile = updateSite.getFile(); - String updateSiteDir = distDir + File.separator + "updatesites" + File.separator + updateSiteID; - - content.append(""); - content.append(""); - content.append(""); - content.append(""); - content.append(""); - content.appendLineBreak(); - - content.append(""); - content.append(""); - content.append(""); - content.appendLineBreak(); - - content.append(""); - content.append(""); - content.append(""); - content.append(""); - content.append(""); - File associatedSitesXML = new File(updateSiteFile.getParent(), "associateSites.xml"); - if (associatedSitesXML.exists()) { - content.append(""); - } - content.appendLineBreak(); - - String updateSiteVendor = updateSiteSpec.getValue("site", "vendor"); - if (updateSiteVendor == null) { - updateSiteVendor = "Unknown vendor"; - } - String excludeSrc = updateSiteSpec.getValue("site", "excludeSources"); - if (excludeSrc == null) { - excludeSrc = "false"; - } - - Collection features = updateSite.getFeatures(); - for (EclipseFeature feature : features) { - String featureID = feature.getIdentifier(); - File featureFile = feature.getFile(); - String tempDir = distDir + File.separator + "temp_features"; - String tempFeatureDir = tempDir + "/" + featureID; - String featureVersion = updateSiteSpec.getFeatureVersion(featureID); - String featureVendor = updateSiteSpec.getFeatureVendor(featureID); - - content.append(""); - content.append(""); - content.append(""); - content.append(""); - content.append(""); - content.append(""); - content.append(""); - content.append(""); - content.append(""); - content.append(""); - content.append(""); - content.append(""); - content.append(""); - content.append(""); - content.append(""); - content.append(""); - content.append(""); - content.append(""); - content.appendLineBreak(); - - Collection plugins = feature.getPlugins(); - for (Plugin plugin : plugins) { - String pluginID = plugin.getIdentifier(); - File pluginDirectory = plugin.getFile(); - String pluginPath = pluginDirectory.getAbsolutePath(); - - String pluginVersion = updateSiteSpec.getValue("plugin", pluginID, "version"); - if (pluginVersion == null) { - pluginVersion = featureVersion; - } - String pluginVendor = updateSiteSpec.getValue("plugin", pluginID, "vendor"); - if (pluginVendor == null) { - pluginVendor = featureVendor; - } - String pluginName = updateSiteSpec.getValue("plugin", pluginID, "name"); - if (pluginName == null) { - pluginName = "Unknown"; - } - - // package plugin(s) - content.append(""); - content.append(""); - content.append(""); - content.append(""); - content.append(""); - content.append(""); - content.append(""); - content.appendLineBreak(); - content.append(""); - content.append(""); - // TODO make this configurable or read the build.properties file for this - content.append(""); - if (Boolean.parseBoolean(excludeSrc)) { - content.append(""); - } - content.append(""); - content.append(""); - content.appendLineBreak(); - } - } - - String targetPath = updateSiteSpec.getValue("site", "uploadPath"); - if (targetPath != null) { - // TODO this requires that jsch-0.1.48.jar is in ANTs classpath. we - // should figure out a way to provide this JAR together with BuildBoost. - content.append(""); - content.append(""); - content.append(""); - content.append(""); - content.append(""); - content.append(""); - content.append(""); - content.append(""); - content.append(""); - content.append(""); - content.append(""); - content.append(""); - content.append(""); - content.append(""); - content.append(""); - content.append(""); - content.append(""); - content.append(""); - } - - AntTarget target = new AntTarget("build-update-site-" + updateSiteID, content); - return target; - } - - - -} +/******************************************************************************* + * Copyright (c) 2006-2012 + * Software Technology Group, Dresden University of Technology + * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 + * + * All rights reserved. This program and the accompanying materials + * are 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 + * + * Contributors: + * Software Technology Group - TU Dresden, Germany; + * DevBoost GmbH - Berlin, Germany + * - initial API and implementation + ******************************************************************************/ +package de.devboost.buildboost.genext.updatesite.steps; + +import java.io.File; +import java.util.Collection; +import java.util.Collections; + +import de.devboost.buildboost.BuildException; +import de.devboost.buildboost.ant.AbstractAntTargetGenerator; +import de.devboost.buildboost.ant.AntTarget; +import de.devboost.buildboost.artifacts.EclipseFeature; +import de.devboost.buildboost.artifacts.Plugin; +import de.devboost.buildboost.genext.updatesite.artifacts.EclipseUpdateSite; +import de.devboost.buildboost.genext.updatesite.artifacts.EclipseUpdateSiteDeploymentSpec; +import de.devboost.buildboost.util.XMLContent; + +public class BuildUpdateSiteStep extends AbstractAntTargetGenerator { + + private EclipseUpdateSiteDeploymentSpec updateSiteSpec; + private File targetDir; + private String usernameProperty = null; + private String passwordProperty = null; + + public BuildUpdateSiteStep(EclipseUpdateSiteDeploymentSpec updateSiteSpec, File targetDir) { + super(); + this.updateSiteSpec = updateSiteSpec; + this.targetDir = targetDir; + } + + @Override + public Collection generateAntTargets() throws BuildException { + if (usernameProperty == null) { + usernameProperty = updateSiteSpec.getValue("site", "usernameProperty"); + } + if (passwordProperty == null) { + passwordProperty = updateSiteSpec.getValue("site", "passwordProperty"); + } + + AntTarget updateSiteTarget = generateUpdateSiteAntTarget(); + return Collections.singletonList(updateSiteTarget); + } + + protected AntTarget generateUpdateSiteAntTarget() throws BuildException { + EclipseUpdateSite updateSite = updateSiteSpec.getUpdateSite(); + if (updateSite == null) { + throw new BuildException("Can't find update site for update site specification."); + } + + String distDir = targetDir.getAbsolutePath() + File.separator + "dist"; + + XMLContent content = new XMLContent(); + + String updateSiteID = updateSite.getIdentifier(); + File updateSiteFile = updateSite.getFile(); + String updateSiteDir = distDir + File.separator + "updatesites" + File.separator + updateSiteID; + + content.append(""); + content.append(""); + content.append(""); + content.append(""); + content.append(""); + content.appendLineBreak(); + + content.append(""); + content.append(""); + content.append(""); + content.appendLineBreak(); + + content.append(""); + content.append(""); + content.append(""); + content.append(""); + content.append(""); + File associatedSitesXML = new File(updateSiteFile.getParent(), "associateSites.xml"); + if (associatedSitesXML.exists()) { + content.append(""); + } + content.appendLineBreak(); + + String updateSiteVendor = updateSiteSpec.getValue("site", "vendor"); + if (updateSiteVendor == null) { + updateSiteVendor = "Unknown vendor"; + } + String excludeSrc = updateSiteSpec.getValue("site", "excludeSources"); + if (excludeSrc == null) { + excludeSrc = "false"; + } + + Collection features = updateSite.getFeatures(); + for (EclipseFeature feature : features) { + String featureID = feature.getIdentifier(); + File featureFile = feature.getFile(); + String tempDir = distDir + File.separator + "temp_features"; + String tempFeatureDir = tempDir + "/" + featureID; + String featureVersion = updateSiteSpec.getFeatureVersion(featureID); + String featureVendor = updateSiteSpec.getFeatureVendor(featureID); + + content.append(""); + content.append(""); + content.append(""); + content.append(""); + content.append(""); + content.append(""); + content.append(""); + content.append(""); + content.append(""); + content.append(""); + content.append(""); + content.append(""); + content.append(""); + content.append(""); + content.append(""); + content.append(""); + content.append(""); + content.append(""); + content.appendLineBreak(); + + Collection plugins = feature.getPlugins(); + for (Plugin plugin : plugins) { + String pluginID = plugin.getIdentifier(); + File pluginDirectory = plugin.getFile(); + String pluginPath = pluginDirectory.getAbsolutePath(); + + String pluginVersion = updateSiteSpec.getValue("plugin", pluginID, "version"); + if (pluginVersion == null) { + pluginVersion = featureVersion; + } + String pluginVendor = updateSiteSpec.getValue("plugin", pluginID, "vendor"); + if (pluginVendor == null) { + pluginVendor = featureVendor; + } + String pluginName = updateSiteSpec.getValue("plugin", pluginID, "name"); + if (pluginName == null) { + pluginName = "Unknown"; + } + + // package plugin(s) + content.append(""); + content.append(""); + content.append(""); + content.append(""); + content.append(""); + content.append(""); + content.append(""); + content.appendLineBreak(); + content.append(""); + content.append(""); + // TODO make this configurable or read the build.properties file for this + content.append(""); + if (Boolean.parseBoolean(excludeSrc)) { + content.append(""); + } + content.append(""); + content.append(""); + content.appendLineBreak(); + } + } + + String targetPath = updateSiteSpec.getValue("site", "uploadPath"); + if (targetPath != null) { + // TODO this requires that jsch-0.1.48.jar is in ANTs classpath. we + // should figure out a way to provide this JAR together with BuildBoost. + content.append(""); + content.append(""); + content.append(""); + content.append(""); + content.append(""); + content.append(""); + content.append(""); + content.append(""); + content.append(""); + content.append(""); + content.append(""); + content.append(""); + content.append(""); + content.append(""); + content.append(""); + content.append(""); + content.append(""); + content.append(""); + } + + AntTarget target = new AntTarget("build-update-site-" + updateSiteID, content); + return target; + } + + + +} diff --git a/Extensions/UpdateSite/de.devboost.buildboost.genext.updatesite/src/de/devboost/buildboost/genext/updatesite/steps/BuildUpdateSiteStepProvider.java b/Extensions/UpdateSite/de.devboost.buildboost.genext.updatesite/src/de/devboost/buildboost/genext/updatesite/steps/BuildUpdateSiteStepProvider.java index 370f35b..685c6f3 100644 --- a/Extensions/UpdateSite/de.devboost.buildboost.genext.updatesite/src/de/devboost/buildboost/genext/updatesite/steps/BuildUpdateSiteStepProvider.java +++ b/Extensions/UpdateSite/de.devboost.buildboost.genext.updatesite/src/de/devboost/buildboost/genext/updatesite/steps/BuildUpdateSiteStepProvider.java @@ -1,45 +1,45 @@ -/******************************************************************************* - * Copyright (c) 2006-2012 - * Software Technology Group, Dresden University of Technology - * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 - * - * All rights reserved. This program and the accompanying materials - * are 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 - * - * Contributors: - * Software Technology Group - TU Dresden, Germany; - * DevBoost GmbH - Berlin, Germany - * - initial API and implementation - ******************************************************************************/ -package de.devboost.buildboost.genext.updatesite.steps; - -import java.io.File; -import java.util.Collections; -import java.util.List; - -import de.devboost.buildboost.ant.AbstractAntTargetGeneratorProvider; -import de.devboost.buildboost.ant.IAntTargetGenerator; -import de.devboost.buildboost.genext.updatesite.artifacts.EclipseUpdateSiteDeploymentSpec; -import de.devboost.buildboost.model.IArtifact; -import de.devboost.buildboost.model.IBuildContext; - -public class BuildUpdateSiteStepProvider extends AbstractAntTargetGeneratorProvider { - - private File targetDir; - - public BuildUpdateSiteStepProvider(File targetDir) { - super(); - this.targetDir = targetDir; - } - - public List getAntTargetGenerators(IBuildContext context, IArtifact artifact) { - if (artifact instanceof EclipseUpdateSiteDeploymentSpec) { - EclipseUpdateSiteDeploymentSpec updateSite = (EclipseUpdateSiteDeploymentSpec) artifact; - IAntTargetGenerator step = new BuildUpdateSiteStep(updateSite, targetDir); - return Collections.singletonList(step); - } - return Collections.emptyList(); - } -} +/******************************************************************************* + * Copyright (c) 2006-2012 + * Software Technology Group, Dresden University of Technology + * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 + * + * All rights reserved. This program and the accompanying materials + * are 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 + * + * Contributors: + * Software Technology Group - TU Dresden, Germany; + * DevBoost GmbH - Berlin, Germany + * - initial API and implementation + ******************************************************************************/ +package de.devboost.buildboost.genext.updatesite.steps; + +import java.io.File; +import java.util.Collections; +import java.util.List; + +import de.devboost.buildboost.ant.AbstractAntTargetGeneratorProvider; +import de.devboost.buildboost.ant.IAntTargetGenerator; +import de.devboost.buildboost.genext.updatesite.artifacts.EclipseUpdateSiteDeploymentSpec; +import de.devboost.buildboost.model.IArtifact; +import de.devboost.buildboost.model.IBuildContext; + +public class BuildUpdateSiteStepProvider extends AbstractAntTargetGeneratorProvider { + + private File targetDir; + + public BuildUpdateSiteStepProvider(File targetDir) { + super(); + this.targetDir = targetDir; + } + + public List getAntTargetGenerators(IBuildContext context, IArtifact artifact) { + if (artifact instanceof EclipseUpdateSiteDeploymentSpec) { + EclipseUpdateSiteDeploymentSpec updateSite = (EclipseUpdateSiteDeploymentSpec) artifact; + IAntTargetGenerator step = new BuildUpdateSiteStep(updateSite, targetDir); + return Collections.singletonList(step); + } + return Collections.emptyList(); + } +} diff --git a/Extensions/WebAppPackaging/de.devboost.buildboost.genext.webapps/.classpath b/Extensions/WebAppPackaging/de.devboost.buildboost.genext.webapps/.classpath index ed2bc12..121e527 100644 --- a/Extensions/WebAppPackaging/de.devboost.buildboost.genext.webapps/.classpath +++ b/Extensions/WebAppPackaging/de.devboost.buildboost.genext.webapps/.classpath @@ -1,7 +1,7 @@ - - - - - - - + + + + + + + diff --git a/Extensions/WebAppPackaging/de.devboost.buildboost.genext.webapps/.settings/org.eclipse.jdt.core.prefs b/Extensions/WebAppPackaging/de.devboost.buildboost.genext.webapps/.settings/org.eclipse.jdt.core.prefs index c954dd5..dbc07ca 100644 --- a/Extensions/WebAppPackaging/de.devboost.buildboost.genext.webapps/.settings/org.eclipse.jdt.core.prefs +++ b/Extensions/WebAppPackaging/de.devboost.buildboost.genext.webapps/.settings/org.eclipse.jdt.core.prefs @@ -1,12 +1,12 @@ -#Tue Dec 13 11:22:47 CET 2011 -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 -org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.6 -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.enumIdentifier=error -org.eclipse.jdt.core.compiler.source=1.6 +#Tue Dec 13 11:22:47 CET 2011 +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.6 +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.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.6 diff --git a/Extensions/WebAppPackaging/de.devboost.buildboost.genext.webapps/build.properties b/Extensions/WebAppPackaging/de.devboost.buildboost.genext.webapps/build.properties index a12d47e..b107977 100644 --- a/Extensions/WebAppPackaging/de.devboost.buildboost.genext.webapps/build.properties +++ b/Extensions/WebAppPackaging/de.devboost.buildboost.genext.webapps/build.properties @@ -1,3 +1,3 @@ -source.. = src/ -bin.includes = META-INF/,\ - . +source.. = src/ +bin.includes = META-INF/,\ + . diff --git a/Extensions/WebAppPackaging/de.devboost.buildboost.genext.webapps/src/de/devboost/buildboost/genext/webapps/discovery/WebAppFinder.java b/Extensions/WebAppPackaging/de.devboost.buildboost.genext.webapps/src/de/devboost/buildboost/genext/webapps/discovery/WebAppFinder.java index b12117b..f7d198e 100644 --- a/Extensions/WebAppPackaging/de.devboost.buildboost.genext.webapps/src/de/devboost/buildboost/genext/webapps/discovery/WebAppFinder.java +++ b/Extensions/WebAppPackaging/de.devboost.buildboost.genext.webapps/src/de/devboost/buildboost/genext/webapps/discovery/WebAppFinder.java @@ -1,56 +1,56 @@ -/******************************************************************************* - * Copyright (c) 2006-2012 - * Software Technology Group, Dresden University of Technology - * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 - * - * All rights reserved. This program and the accompanying materials - * are 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 - * - * Contributors: - * Software Technology Group - TU Dresden, Germany; - * DevBoost GmbH - Berlin, Germany - * - initial API and implementation - ******************************************************************************/ -package de.devboost.buildboost.genext.webapps.discovery; - -import java.util.Collection; -import java.util.Collections; - - -import de.devboost.buildboost.artifacts.Plugin; -import de.devboost.buildboost.discovery.AbstractArtifactDiscoverer; -import de.devboost.buildboost.discovery.PluginFinder; -import de.devboost.buildboost.genext.webapps.util.WebAppUtil; -import de.devboost.buildboost.model.IArtifact; -import de.devboost.buildboost.model.IBuildContext; -import de.devboost.buildboost.model.UnresolvedDependency; - -/** - * A {@link WebAppFinder} can be used to find web applications among the set - * of previously discovered projects. Thus, it must be used after the - * {@link PluginFinder}. - */ -public class WebAppFinder extends AbstractArtifactDiscoverer { - - private Collection webAppDependencies; - - public WebAppFinder(Collection webAppDependencies) { - super(); - this.webAppDependencies = webAppDependencies; - } - - public Collection discoverArtifacts(IBuildContext context) { - Collection discoveredArtifacts = context.getDiscoveredArtifacts(); - for (IArtifact artifact : discoveredArtifacts) { - if (artifact instanceof Plugin) { - Plugin plugin = (Plugin) artifact; - if (plugin.isProject() && new WebAppUtil().isWebApp(plugin)) { - plugin.getUnresolvedDependencies().addAll(webAppDependencies); - } - } - } - return Collections.emptySet(); - } -} +/******************************************************************************* + * Copyright (c) 2006-2012 + * Software Technology Group, Dresden University of Technology + * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 + * + * All rights reserved. This program and the accompanying materials + * are 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 + * + * Contributors: + * Software Technology Group - TU Dresden, Germany; + * DevBoost GmbH - Berlin, Germany + * - initial API and implementation + ******************************************************************************/ +package de.devboost.buildboost.genext.webapps.discovery; + +import java.util.Collection; +import java.util.Collections; + + +import de.devboost.buildboost.artifacts.Plugin; +import de.devboost.buildboost.discovery.AbstractArtifactDiscoverer; +import de.devboost.buildboost.discovery.PluginFinder; +import de.devboost.buildboost.genext.webapps.util.WebAppUtil; +import de.devboost.buildboost.model.IArtifact; +import de.devboost.buildboost.model.IBuildContext; +import de.devboost.buildboost.model.UnresolvedDependency; + +/** + * A {@link WebAppFinder} can be used to find web applications among the set + * of previously discovered projects. Thus, it must be used after the + * {@link PluginFinder}. + */ +public class WebAppFinder extends AbstractArtifactDiscoverer { + + private Collection webAppDependencies; + + public WebAppFinder(Collection webAppDependencies) { + super(); + this.webAppDependencies = webAppDependencies; + } + + public Collection discoverArtifacts(IBuildContext context) { + Collection discoveredArtifacts = context.getDiscoveredArtifacts(); + for (IArtifact artifact : discoveredArtifacts) { + if (artifact instanceof Plugin) { + Plugin plugin = (Plugin) artifact; + if (plugin.isProject() && new WebAppUtil().isWebApp(plugin)) { + plugin.getUnresolvedDependencies().addAll(webAppDependencies); + } + } + } + return Collections.emptySet(); + } +} diff --git a/Extensions/WebAppPackaging/de.devboost.buildboost.genext.webapps/src/de/devboost/buildboost/genext/webapps/stages/WebAppPackagingStage.java b/Extensions/WebAppPackaging/de.devboost.buildboost.genext.webapps/src/de/devboost/buildboost/genext/webapps/stages/WebAppPackagingStage.java index 8845b8d..21ad6ed 100644 --- a/Extensions/WebAppPackaging/de.devboost.buildboost.genext.webapps/src/de/devboost/buildboost/genext/webapps/stages/WebAppPackagingStage.java +++ b/Extensions/WebAppPackaging/de.devboost.buildboost.genext.webapps/src/de/devboost/buildboost/genext/webapps/stages/WebAppPackagingStage.java @@ -1,80 +1,80 @@ -/******************************************************************************* - * Copyright (c) 2006-2012 - * Software Technology Group, Dresden University of Technology - * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 - * - * All rights reserved. This program and the accompanying materials - * are 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 - * - * Contributors: - * Software Technology Group - TU Dresden, Germany; - * DevBoost GmbH - Berlin, Germany - * - initial API and implementation - ******************************************************************************/ -package de.devboost.buildboost.genext.webapps.stages; - -import java.io.File; -import java.util.Collection; -import java.util.Collections; - - -import de.devboost.buildboost.AutoBuilder; -import de.devboost.buildboost.BuildContext; -import de.devboost.buildboost.BuildException; -import de.devboost.buildboost.ant.AntScript; -import de.devboost.buildboost.artifacts.Plugin; -import de.devboost.buildboost.discovery.EclipseTargetPlatformAnalyzer; -import de.devboost.buildboost.discovery.PluginFinder; -import de.devboost.buildboost.genext.webapps.discovery.WebAppFinder; -import de.devboost.buildboost.genext.webapps.steps.WebAppPackagingStepProvider; -import de.devboost.buildboost.model.IUniversalBuildStage; -import de.devboost.buildboost.model.UnresolvedDependency; -import de.devboost.buildboost.stages.AbstractBuildStage; - -public class WebAppPackagingStage extends AbstractBuildStage implements IUniversalBuildStage { - - private String artifactsFolder; - - public void setArtifactsFolder(String artifactsFolder) { - this.artifactsFolder = artifactsFolder; - } - - @Override - public AntScript getScript() throws BuildException { - Collection webAppDendencies = getWebAppDendencies(); - - BuildContext context = createContext(false); - context.addBuildParticipant(new EclipseTargetPlatformAnalyzer(new File(artifactsFolder))); - context.addBuildParticipant(new PluginFinder(new File(artifactsFolder))); - context.addBuildParticipant(new WebAppFinder(webAppDendencies)); - - context.addBuildParticipant(new WebAppPackagingStepProvider(webAppDendencies)); - - AutoBuilder builder = new AutoBuilder(context); - AntScript script = new AntScript(); - script.setName("Package web application as WAR files"); - script.addTargets(builder.generateAntTargets()); - - return script; - } - - private Collection getWebAppDendencies() { - UnresolvedDependency dependency = new UnresolvedDependency( - Plugin.class, - "org.apache.tomcat_6_0_32", // TODO make this configurable - null, - true, - null, - true, - false, - false); - return Collections.singletonList(dependency); - } - - @Override - public int getPriority() { - return 11000; - } -} +/******************************************************************************* + * Copyright (c) 2006-2012 + * Software Technology Group, Dresden University of Technology + * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 + * + * All rights reserved. This program and the accompanying materials + * are 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 + * + * Contributors: + * Software Technology Group - TU Dresden, Germany; + * DevBoost GmbH - Berlin, Germany + * - initial API and implementation + ******************************************************************************/ +package de.devboost.buildboost.genext.webapps.stages; + +import java.io.File; +import java.util.Collection; +import java.util.Collections; + + +import de.devboost.buildboost.AutoBuilder; +import de.devboost.buildboost.BuildContext; +import de.devboost.buildboost.BuildException; +import de.devboost.buildboost.ant.AntScript; +import de.devboost.buildboost.artifacts.Plugin; +import de.devboost.buildboost.discovery.EclipseTargetPlatformAnalyzer; +import de.devboost.buildboost.discovery.PluginFinder; +import de.devboost.buildboost.genext.webapps.discovery.WebAppFinder; +import de.devboost.buildboost.genext.webapps.steps.WebAppPackagingStepProvider; +import de.devboost.buildboost.model.IUniversalBuildStage; +import de.devboost.buildboost.model.UnresolvedDependency; +import de.devboost.buildboost.stages.AbstractBuildStage; + +public class WebAppPackagingStage extends AbstractBuildStage implements IUniversalBuildStage { + + private String artifactsFolder; + + public void setArtifactsFolder(String artifactsFolder) { + this.artifactsFolder = artifactsFolder; + } + + @Override + public AntScript getScript() throws BuildException { + Collection webAppDendencies = getWebAppDendencies(); + + BuildContext context = createContext(false); + context.addBuildParticipant(new EclipseTargetPlatformAnalyzer(new File(artifactsFolder))); + context.addBuildParticipant(new PluginFinder(new File(artifactsFolder))); + context.addBuildParticipant(new WebAppFinder(webAppDendencies)); + + context.addBuildParticipant(new WebAppPackagingStepProvider(webAppDendencies)); + + AutoBuilder builder = new AutoBuilder(context); + AntScript script = new AntScript(); + script.setName("Package web application as WAR files"); + script.addTargets(builder.generateAntTargets()); + + return script; + } + + private Collection getWebAppDendencies() { + UnresolvedDependency dependency = new UnresolvedDependency( + Plugin.class, + "org.apache.tomcat_6_0_32", // TODO make this configurable + null, + true, + null, + true, + false, + false); + return Collections.singletonList(dependency); + } + + @Override + public int getPriority() { + return 11000; + } +} diff --git a/Extensions/WebAppPackaging/de.devboost.buildboost.genext.webapps/src/de/devboost/buildboost/genext/webapps/steps/WebAppPackagingStep.java b/Extensions/WebAppPackaging/de.devboost.buildboost.genext.webapps/src/de/devboost/buildboost/genext/webapps/steps/WebAppPackagingStep.java index 4b701c2..8c60179 100644 --- a/Extensions/WebAppPackaging/de.devboost.buildboost.genext.webapps/src/de/devboost/buildboost/genext/webapps/steps/WebAppPackagingStep.java +++ b/Extensions/WebAppPackaging/de.devboost.buildboost.genext.webapps/src/de/devboost/buildboost/genext/webapps/steps/WebAppPackagingStep.java @@ -1,97 +1,97 @@ -/******************************************************************************* - * Copyright (c) 2006-2012 - * Software Technology Group, Dresden University of Technology - * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 - * - * All rights reserved. This program and the accompanying materials - * are 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 - * - * Contributors: - * Software Technology Group - TU Dresden, Germany; - * DevBoost GmbH - Berlin, Germany - * - initial API and implementation - ******************************************************************************/ -package de.devboost.buildboost.genext.webapps.steps; - -import java.io.File; -import java.util.Collection; -import java.util.Collections; -import java.util.Set; - -import de.devboost.buildboost.BuildException; -import de.devboost.buildboost.ant.AbstractAntTargetGenerator; -import de.devboost.buildboost.ant.AntTarget; -import de.devboost.buildboost.artifacts.Plugin; -import de.devboost.buildboost.model.UnresolvedDependency; -import de.devboost.buildboost.steps.ClasspathHelper; -import de.devboost.buildboost.util.XMLContent; - -public class WebAppPackagingStep extends AbstractAntTargetGenerator { - - private Plugin plugin; - private Collection webAppDependencies; - - public WebAppPackagingStep(Plugin plugin, Collection webAppDependencies) { - super(); - this.plugin = plugin; - this.webAppDependencies = webAppDependencies; - } - - public Collection generateAntTargets() throws BuildException { - XMLContent content = new XMLContent(); - - File webContentDir = new File(plugin.getLocation(), "WebContent"); - File webXmlFile = new File(new File(webContentDir, "WEB-INF"), "web.xml"); - - content.append(""); - content.append(""); - content.append(""); - content.append(""); - Set dependencies = plugin.getAllDependencies(); - for (Plugin dependency : dependencies) { - boolean isArtificalDependency = false; - for (UnresolvedDependency webAppDependency : webAppDependencies) { - if (webAppDependency.isFulfilledBy(dependency)) { - isArtificalDependency = true; - break; - } - } - // we do not include artificial dependencies that have been only - // added to compile correctly - if (isArtificalDependency) { - continue; - } - File location = dependency.getLocation(); - if (dependency.isProject()) { - content.append(""); - content.append(""); - content.append(""); - content.append(""); - content.append(""); - content.append(""); - for (String lib : dependency.getLibs()) { - String absoluteLibPath = dependency.getAbsoluteLibPath(lib); - File libFile = new File(absoluteLibPath); - content.append(""); - content.append(""); - content.append(""); - } - } else { - if (location.isFile()) { - // target platform plug-ins must be included as whole JAR - content.append(""); - content.append(""); - content.append(""); - } else { - // TODO handle plug-in dependencies that are extracted - } - } - } - content.append(""); - - AntTarget target = new AntTarget("package-webapp-" + plugin.getIdentifier(), content); - return Collections.singleton(target); - } -} +/******************************************************************************* + * Copyright (c) 2006-2012 + * Software Technology Group, Dresden University of Technology + * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 + * + * All rights reserved. This program and the accompanying materials + * are 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 + * + * Contributors: + * Software Technology Group - TU Dresden, Germany; + * DevBoost GmbH - Berlin, Germany + * - initial API and implementation + ******************************************************************************/ +package de.devboost.buildboost.genext.webapps.steps; + +import java.io.File; +import java.util.Collection; +import java.util.Collections; +import java.util.Set; + +import de.devboost.buildboost.BuildException; +import de.devboost.buildboost.ant.AbstractAntTargetGenerator; +import de.devboost.buildboost.ant.AntTarget; +import de.devboost.buildboost.artifacts.Plugin; +import de.devboost.buildboost.model.UnresolvedDependency; +import de.devboost.buildboost.steps.ClasspathHelper; +import de.devboost.buildboost.util.XMLContent; + +public class WebAppPackagingStep extends AbstractAntTargetGenerator { + + private Plugin plugin; + private Collection webAppDependencies; + + public WebAppPackagingStep(Plugin plugin, Collection webAppDependencies) { + super(); + this.plugin = plugin; + this.webAppDependencies = webAppDependencies; + } + + public Collection generateAntTargets() throws BuildException { + XMLContent content = new XMLContent(); + + File webContentDir = new File(plugin.getLocation(), "WebContent"); + File webXmlFile = new File(new File(webContentDir, "WEB-INF"), "web.xml"); + + content.append(""); + content.append(""); + content.append(""); + content.append(""); + Set dependencies = plugin.getAllDependencies(); + for (Plugin dependency : dependencies) { + boolean isArtificalDependency = false; + for (UnresolvedDependency webAppDependency : webAppDependencies) { + if (webAppDependency.isFulfilledBy(dependency)) { + isArtificalDependency = true; + break; + } + } + // we do not include artificial dependencies that have been only + // added to compile correctly + if (isArtificalDependency) { + continue; + } + File location = dependency.getLocation(); + if (dependency.isProject()) { + content.append(""); + content.append(""); + content.append(""); + content.append(""); + content.append(""); + content.append(""); + for (String lib : dependency.getLibs()) { + String absoluteLibPath = dependency.getAbsoluteLibPath(lib); + File libFile = new File(absoluteLibPath); + content.append(""); + content.append(""); + content.append(""); + } + } else { + if (location.isFile()) { + // target platform plug-ins must be included as whole JAR + content.append(""); + content.append(""); + content.append(""); + } else { + // TODO handle plug-in dependencies that are extracted + } + } + } + content.append(""); + + AntTarget target = new AntTarget("package-webapp-" + plugin.getIdentifier(), content); + return Collections.singleton(target); + } +} diff --git a/Extensions/WebAppPackaging/de.devboost.buildboost.genext.webapps/src/de/devboost/buildboost/genext/webapps/steps/WebAppPackagingStepProvider.java b/Extensions/WebAppPackaging/de.devboost.buildboost.genext.webapps/src/de/devboost/buildboost/genext/webapps/steps/WebAppPackagingStepProvider.java index f0bde39..6acc1ae 100644 --- a/Extensions/WebAppPackaging/de.devboost.buildboost.genext.webapps/src/de/devboost/buildboost/genext/webapps/steps/WebAppPackagingStepProvider.java +++ b/Extensions/WebAppPackaging/de.devboost.buildboost.genext.webapps/src/de/devboost/buildboost/genext/webapps/steps/WebAppPackagingStepProvider.java @@ -1,52 +1,52 @@ -/******************************************************************************* - * Copyright (c) 2006-2012 - * Software Technology Group, Dresden University of Technology - * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 - * - * All rights reserved. This program and the accompanying materials - * are 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 - * - * Contributors: - * Software Technology Group - TU Dresden, Germany; - * DevBoost GmbH - Berlin, Germany - * - initial API and implementation - ******************************************************************************/ -package de.devboost.buildboost.genext.webapps.steps; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; - - -import de.devboost.buildboost.ant.AbstractAntTargetGeneratorProvider; -import de.devboost.buildboost.ant.IAntTargetGenerator; -import de.devboost.buildboost.artifacts.Plugin; -import de.devboost.buildboost.genext.webapps.util.WebAppUtil; -import de.devboost.buildboost.model.IArtifact; -import de.devboost.buildboost.model.IBuildContext; -import de.devboost.buildboost.model.UnresolvedDependency; - -public class WebAppPackagingStepProvider extends AbstractAntTargetGeneratorProvider { - - private Collection webAppDependencies; - - public WebAppPackagingStepProvider(Collection webAppDependencies) { - super(); - this.webAppDependencies = webAppDependencies; - } - - public List getAntTargetGenerators(IBuildContext context, IArtifact artifact) { - List steps = new ArrayList(1); - if (artifact instanceof Plugin) { - Plugin plugin = (Plugin) artifact; - if (plugin.isProject()) { - if (new WebAppUtil().isWebApp(plugin)) { - steps.add(new WebAppPackagingStep(plugin, webAppDependencies)); - } - } - } - return steps; - } -} +/******************************************************************************* + * Copyright (c) 2006-2012 + * Software Technology Group, Dresden University of Technology + * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 + * + * All rights reserved. This program and the accompanying materials + * are 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 + * + * Contributors: + * Software Technology Group - TU Dresden, Germany; + * DevBoost GmbH - Berlin, Germany + * - initial API and implementation + ******************************************************************************/ +package de.devboost.buildboost.genext.webapps.steps; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + + +import de.devboost.buildboost.ant.AbstractAntTargetGeneratorProvider; +import de.devboost.buildboost.ant.IAntTargetGenerator; +import de.devboost.buildboost.artifacts.Plugin; +import de.devboost.buildboost.genext.webapps.util.WebAppUtil; +import de.devboost.buildboost.model.IArtifact; +import de.devboost.buildboost.model.IBuildContext; +import de.devboost.buildboost.model.UnresolvedDependency; + +public class WebAppPackagingStepProvider extends AbstractAntTargetGeneratorProvider { + + private Collection webAppDependencies; + + public WebAppPackagingStepProvider(Collection webAppDependencies) { + super(); + this.webAppDependencies = webAppDependencies; + } + + public List getAntTargetGenerators(IBuildContext context, IArtifact artifact) { + List steps = new ArrayList(1); + if (artifact instanceof Plugin) { + Plugin plugin = (Plugin) artifact; + if (plugin.isProject()) { + if (new WebAppUtil().isWebApp(plugin)) { + steps.add(new WebAppPackagingStep(plugin, webAppDependencies)); + } + } + } + return steps; + } +} diff --git a/Extensions/WebAppPackaging/de.devboost.buildboost.genext.webapps/src/de/devboost/buildboost/genext/webapps/util/WebAppUtil.java b/Extensions/WebAppPackaging/de.devboost.buildboost.genext.webapps/src/de/devboost/buildboost/genext/webapps/util/WebAppUtil.java index 7555842..4be47df 100644 --- a/Extensions/WebAppPackaging/de.devboost.buildboost.genext.webapps/src/de/devboost/buildboost/genext/webapps/util/WebAppUtil.java +++ b/Extensions/WebAppPackaging/de.devboost.buildboost.genext.webapps/src/de/devboost/buildboost/genext/webapps/util/WebAppUtil.java @@ -1,29 +1,29 @@ -/******************************************************************************* - * Copyright (c) 2006-2012 - * Software Technology Group, Dresden University of Technology - * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 - * - * All rights reserved. This program and the accompanying materials - * are 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 - * - * Contributors: - * Software Technology Group - TU Dresden, Germany; - * DevBoost GmbH - Berlin, Germany - * - initial API and implementation - ******************************************************************************/ -package de.devboost.buildboost.genext.webapps.util; - -import de.devboost.buildboost.artifacts.Plugin; - -public class WebAppUtil { - - public boolean isWebApp(Plugin plugin) { - String identifier = plugin.getIdentifier(); - if (identifier.endsWith(".web") || identifier.endsWith(".webapp")) { - return true; - } - return false; - } -} +/******************************************************************************* + * Copyright (c) 2006-2012 + * Software Technology Group, Dresden University of Technology + * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 + * + * All rights reserved. This program and the accompanying materials + * are 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 + * + * Contributors: + * Software Technology Group - TU Dresden, Germany; + * DevBoost GmbH - Berlin, Germany + * - initial API and implementation + ******************************************************************************/ +package de.devboost.buildboost.genext.webapps.util; + +import de.devboost.buildboost.artifacts.Plugin; + +public class WebAppUtil { + + public boolean isWebApp(Plugin plugin) { + String identifier = plugin.getIdentifier(); + if (identifier.endsWith(".web") || identifier.endsWith(".webapp")) { + return true; + } + return false; + } +} diff --git a/JenkinsPlugin/org.buildboost.hudson.plugins.boostscm/.classpath b/JenkinsPlugin/org.buildboost.hudson.plugins.boostscm/.classpath index 160a4e4..13728dc 100644 --- a/JenkinsPlugin/org.buildboost.hudson.plugins.boostscm/.classpath +++ b/JenkinsPlugin/org.buildboost.hudson.plugins.boostscm/.classpath @@ -1,607 +1,607 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/JenkinsPlugin/org.buildboost.hudson.plugins.boostscm/.project b/JenkinsPlugin/org.buildboost.hudson.plugins.boostscm/.project index ebdaf71..f9da871 100644 --- a/JenkinsPlugin/org.buildboost.hudson.plugins.boostscm/.project +++ b/JenkinsPlugin/org.buildboost.hudson.plugins.boostscm/.project @@ -1,17 +1,17 @@ - - - org.buildboost.hudson.plugins.boostscm - NO_M2ECLIPSE_SUPPORT: Project files created with the maven-eclipse-plugin are not supported in M2Eclipse. - - - - - org.eclipse.jdt.core.javabuilder - - - - - - org.eclipse.jdt.core.javanature - - + + + org.buildboost.hudson.plugins.boostscm + NO_M2ECLIPSE_SUPPORT: Project files created with the maven-eclipse-plugin are not supported in M2Eclipse. + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/JenkinsPlugin/org.buildboost.hudson.plugins.boostscm/.settings/org.eclipse.jdt.core.prefs b/JenkinsPlugin/org.buildboost.hudson.plugins.boostscm/.settings/org.eclipse.jdt.core.prefs index c753874..1f5d739 100644 --- a/JenkinsPlugin/org.buildboost.hudson.plugins.boostscm/.settings/org.eclipse.jdt.core.prefs +++ b/JenkinsPlugin/org.buildboost.hudson.plugins.boostscm/.settings/org.eclipse.jdt.core.prefs @@ -1,5 +1,5 @@ -#Fri Aug 17 13:05:26 CEST 2012 -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.source=1.5 -org.eclipse.jdt.core.compiler.compliance=1.5 +#Fri Aug 17 13:05:26 CEST 2012 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.source=1.5 +org.eclipse.jdt.core.compiler.compliance=1.5 diff --git a/JenkinsPlugin/org.buildboost.hudson.plugins.boostscm/src/main/java/org/buildboost/hudson/plugins/boostscm/BuildBoostRepository.java b/JenkinsPlugin/org.buildboost.hudson.plugins.boostscm/src/main/java/org/buildboost/hudson/plugins/boostscm/BuildBoostRepository.java index 62b7e81..3b9ed17 100644 --- a/JenkinsPlugin/org.buildboost.hudson.plugins.boostscm/src/main/java/org/buildboost/hudson/plugins/boostscm/BuildBoostRepository.java +++ b/JenkinsPlugin/org.buildboost.hudson.plugins.boostscm/src/main/java/org/buildboost/hudson/plugins/boostscm/BuildBoostRepository.java @@ -1,51 +1,51 @@ -/******************************************************************************* - * Copyright (c) 2012 - * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 - * - * All rights reserved. This program and the accompanying materials - * are 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 - * - * Contributors: - * DevBoost GmbH - Berlin, Germany - * - initial API and implementation - ******************************************************************************/ -package org.buildboost.hudson.plugins.boostscm; - -public class BuildBoostRepository { - - private String remoteURL; - private String localPath; - private String type; - - public BuildBoostRepository(String type, String remoteURL, String localPath) { - super(); - System.out.println("BuildBoostRepository() type = " + type); - System.out.println("BuildBoostRepository() remoteURL = " + remoteURL); - System.out.println("BuildBoostRepository() localPath = " + localPath); - this.type = type; - this.remoteURL = remoteURL; - this.localPath = localPath; - } - - public String getRemoteURL() { - return remoteURL; - } - - public String getLocalPath() { - return localPath; - } - - public boolean isGit() { - return "git".equals(type); - } - - public boolean isSvn() { - return "svn".equals(type); - } - - public String toString() { - return type + ": " + remoteURL + " - " + localPath; - } -} +/******************************************************************************* + * Copyright (c) 2012 + * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 + * + * All rights reserved. This program and the accompanying materials + * are 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 + * + * Contributors: + * DevBoost GmbH - Berlin, Germany + * - initial API and implementation + ******************************************************************************/ +package org.buildboost.hudson.plugins.boostscm; + +public class BuildBoostRepository { + + private String remoteURL; + private String localPath; + private String type; + + public BuildBoostRepository(String type, String remoteURL, String localPath) { + super(); + System.out.println("BuildBoostRepository() type = " + type); + System.out.println("BuildBoostRepository() remoteURL = " + remoteURL); + System.out.println("BuildBoostRepository() localPath = " + localPath); + this.type = type; + this.remoteURL = remoteURL; + this.localPath = localPath; + } + + public String getRemoteURL() { + return remoteURL; + } + + public String getLocalPath() { + return localPath; + } + + public boolean isGit() { + return "git".equals(type); + } + + public boolean isSvn() { + return "svn".equals(type); + } + + public String toString() { + return type + ": " + remoteURL + " - " + localPath; + } +} diff --git a/JenkinsPlugin/org.buildboost.hudson.plugins.boostscm/src/main/java/org/buildboost/hudson/plugins/boostscm/BuildBoostRepositoryState.java b/JenkinsPlugin/org.buildboost.hudson.plugins.boostscm/src/main/java/org/buildboost/hudson/plugins/boostscm/BuildBoostRepositoryState.java index 556ed6e..5c4e273 100644 --- a/JenkinsPlugin/org.buildboost.hudson.plugins.boostscm/src/main/java/org/buildboost/hudson/plugins/boostscm/BuildBoostRepositoryState.java +++ b/JenkinsPlugin/org.buildboost.hudson.plugins.boostscm/src/main/java/org/buildboost/hudson/plugins/boostscm/BuildBoostRepositoryState.java @@ -1,46 +1,46 @@ -/******************************************************************************* - * Copyright (c) 2012 - * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 - * - * All rights reserved. This program and the accompanying materials - * are 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 - * - * Contributors: - * DevBoost GmbH - Berlin, Germany - * - initial API and implementation - ******************************************************************************/ -package org.buildboost.hudson.plugins.boostscm; - -import java.util.logging.Logger; - -public class BuildBoostRepositoryState { - - private static final Logger logger = Logger.getLogger(BuildBoostRepositoryState.class.getName()); - - private BuildBoostRepository repository; - private String revision; - - public BuildBoostRepositoryState(BuildBoostRepository repository, String revision) { - super(); - logger.info("repository = " + repository); - logger.info("revision = " + revision); - this.repository = repository; - this.revision = revision; - } - - public BuildBoostRepository getRepository() { - return repository; - } - - public String getRevision() { - return revision; - } - - @Override - public String toString() { - return "BuildBoostRepositoryState [repository=" + repository - + ", revision=" + revision + "]"; - } -} +/******************************************************************************* + * Copyright (c) 2012 + * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 + * + * All rights reserved. This program and the accompanying materials + * are 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 + * + * Contributors: + * DevBoost GmbH - Berlin, Germany + * - initial API and implementation + ******************************************************************************/ +package org.buildboost.hudson.plugins.boostscm; + +import java.util.logging.Logger; + +public class BuildBoostRepositoryState { + + private static final Logger logger = Logger.getLogger(BuildBoostRepositoryState.class.getName()); + + private BuildBoostRepository repository; + private String revision; + + public BuildBoostRepositoryState(BuildBoostRepository repository, String revision) { + super(); + logger.info("repository = " + repository); + logger.info("revision = " + revision); + this.repository = repository; + this.revision = revision; + } + + public BuildBoostRepository getRepository() { + return repository; + } + + public String getRevision() { + return revision; + } + + @Override + public String toString() { + return "BuildBoostRepositoryState [repository=" + repository + + ", revision=" + revision + "]"; + } +} diff --git a/JenkinsPlugin/org.buildboost.hudson.plugins.boostscm/src/main/java/org/buildboost/hudson/plugins/boostscm/BuildBoostRevisionState.java b/JenkinsPlugin/org.buildboost.hudson.plugins.boostscm/src/main/java/org/buildboost/hudson/plugins/boostscm/BuildBoostRevisionState.java index 5467b09..6a78745 100644 --- a/JenkinsPlugin/org.buildboost.hudson.plugins.boostscm/src/main/java/org/buildboost/hudson/plugins/boostscm/BuildBoostRevisionState.java +++ b/JenkinsPlugin/org.buildboost.hudson.plugins.boostscm/src/main/java/org/buildboost/hudson/plugins/boostscm/BuildBoostRevisionState.java @@ -1,52 +1,52 @@ -/******************************************************************************* - * Copyright (c) 2012 - * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 - * - * All rights reserved. This program and the accompanying materials - * are 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 - * - * Contributors: - * DevBoost GmbH - Berlin, Germany - * - initial API and implementation - ******************************************************************************/ -package org.buildboost.hudson.plugins.boostscm; - -import hudson.scm.SCMRevisionState; - -import java.util.ArrayList; -import java.util.List; - -public class BuildBoostRevisionState extends SCMRevisionState { - - private List states = new ArrayList(); - - public void addRepositoryState(BuildBoostRepository repository, String revision) { - String remoteURL = repository.getRemoteURL(); - // do not add duplicate states - BuildBoostRepositoryState state = getRepositoryState(remoteURL); - if (state == null) { - states.add(new BuildBoostRepositoryState(repository, revision)); - } - } - - private BuildBoostRepositoryState getRepositoryState(String remoteURL) { - for (BuildBoostRepositoryState state : states) { - String nextRemoteURL = state.getRepository().getRemoteURL(); - if (nextRemoteURL != null && nextRemoteURL.equals(remoteURL)) { - return state; - } - } - return null; - } - - public List getRepositoryStates() { - return states; - } - - @Override - public String toString() { - return "BuildBoostRevisionState [states=" + states + "]"; - } -} +/******************************************************************************* + * Copyright (c) 2012 + * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 + * + * All rights reserved. This program and the accompanying materials + * are 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 + * + * Contributors: + * DevBoost GmbH - Berlin, Germany + * - initial API and implementation + ******************************************************************************/ +package org.buildboost.hudson.plugins.boostscm; + +import hudson.scm.SCMRevisionState; + +import java.util.ArrayList; +import java.util.List; + +public class BuildBoostRevisionState extends SCMRevisionState { + + private List states = new ArrayList(); + + public void addRepositoryState(BuildBoostRepository repository, String revision) { + String remoteURL = repository.getRemoteURL(); + // do not add duplicate states + BuildBoostRepositoryState state = getRepositoryState(remoteURL); + if (state == null) { + states.add(new BuildBoostRepositoryState(repository, revision)); + } + } + + private BuildBoostRepositoryState getRepositoryState(String remoteURL) { + for (BuildBoostRepositoryState state : states) { + String nextRemoteURL = state.getRepository().getRemoteURL(); + if (nextRemoteURL != null && nextRemoteURL.equals(remoteURL)) { + return state; + } + } + return null; + } + + public List getRepositoryStates() { + return states; + } + + @Override + public String toString() { + return "BuildBoostRevisionState [states=" + states + "]"; + } +} diff --git a/JenkinsPlugin/org.buildboost.hudson.plugins.boostscm/src/main/java/org/buildboost/hudson/plugins/boostscm/BuildBoostSCM.java b/JenkinsPlugin/org.buildboost.hudson.plugins.boostscm/src/main/java/org/buildboost/hudson/plugins/boostscm/BuildBoostSCM.java index e7878ae..e18c508 100644 --- a/JenkinsPlugin/org.buildboost.hudson.plugins.boostscm/src/main/java/org/buildboost/hudson/plugins/boostscm/BuildBoostSCM.java +++ b/JenkinsPlugin/org.buildboost.hudson.plugins.boostscm/src/main/java/org/buildboost/hudson/plugins/boostscm/BuildBoostSCM.java @@ -1,460 +1,460 @@ -/******************************************************************************* - * Copyright (c) 2012 - * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 - * - * All rights reserved. This program and the accompanying materials - * are 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 - * - * Contributors: - * DevBoost GmbH - Berlin, Germany - * - initial API and implementation - ******************************************************************************/ -package org.buildboost.hudson.plugins.boostscm; - -import hudson.Extension; -import hudson.FilePath; -import hudson.Launcher; -import hudson.model.BuildListener; -import hudson.model.TaskListener; -import hudson.model.AbstractBuild; -import hudson.model.AbstractProject; -import hudson.scm.ChangeLogParser; -import hudson.scm.PollingResult; -import hudson.scm.PollingResult.Change; -import hudson.scm.SCMDescriptor; -import hudson.scm.SCMRevisionState; -import hudson.scm.SCM; - -import java.io.BufferedReader; -import java.io.ByteArrayInputStream; -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.net.MalformedURLException; -import java.net.URL; -import java.util.ArrayList; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -import java.util.logging.Logger; - -import org.apache.commons.io.output.ByteArrayOutputStream; -import org.kohsuke.stapler.DataBoundConstructor; - -/** - * The BuildBoostSCM extends Jenkins with the ability to poll all repositories - * that are referenced by a BuildBoost build. This includes the root repository - * and all transitively referenced repositories. - * - * To poll the repositories a list of all used repositories is created by the - * BuildBoost CloneStep. - */ -public class BuildBoostSCM extends SCM { - - private static final String ROOT_REPOSITORIES_FILE = "repos/root.repositories"; - - private static final String MAIN_BUILD_SCRIPT = "build.xml"; - - private static final String UNIVERSAL_BUILD_SCRIPT_URL = "https://raw.github.com/DevBoost/BuildBoost/master/Universal/de.devboost.buildboost.universal.build/boost/build.xml"; - - private static final Logger logger = Logger.getLogger(BuildBoostSCM.class.getName()); - - private static final String GIT_CMD_WINDOWS = "git.cmd"; - private static final String GIT_CMD_OTHER = "git"; - - private static final String REPOSITORY_FOLDER_NAME = "repos"; - private static final String BUILDBOOST_REVISIONS_FILE_NAME = "buildboost_repository_list.txt"; - - private static final String URL_PREFIX = "BuildBoost-Repository-URL: "; - private static final String TYPE_PREFIX = "BuildBoost-Repository-Type: "; - private static final String LOCAL_PREFIX = "BuildBoost-Repository-Local: "; - - private static final String COMMIT_PREFIX = "commit "; - private static final String SVN_REVISION_PREFIX = " Rev: "; - private static final String SVN_REVISION_REGEX = "^r[0-9]+ .*"; - - public static class DescriptorImpl extends SCMDescriptor { - - public DescriptorImpl() { - super(BuildBoostSCM.class, null); - load(); - } - - @Override - public String getDisplayName() { - return "BuildBoostSCM"; - } - } - - @Extension - public final static DescriptorImpl descriptor = new DescriptorImpl(); - - private String rootRepositoryURL; - - @Override - public SCMDescriptor getDescriptor() { - return descriptor; - } - - @DataBoundConstructor - public BuildBoostSCM(String rootRepositoryURL) { - super(); - this.rootRepositoryURL = rootRepositoryURL; - } - - public String getRootRepositoryURL() { - return rootRepositoryURL; - } - - @Override - public SCMRevisionState calcRevisionsFromBuild( - AbstractBuild build, - Launcher launcher, - TaskListener listener) - throws IOException, InterruptedException { - logger.info("calcRevisionsFromBuild()"); - return getBuildState(build); - } - - /** - * Creates the build state using the list of repositories. Each of the - * repository working copies is examined for its revision. - */ - private SCMRevisionState getBuildState(AbstractBuild build) - throws IOException, InterruptedException { - - BuildBoostRevisionState state = new BuildBoostRevisionState(); - List repositories = getRepositories(build); - for (BuildBoostRepository repository : repositories) { - String revision = getLocalRevision(repository); - state.addRepositoryState(repository, revision); - } - return state; - } - - /** - * Determines the list of repositories the was created by the BuildBoost - * CloneStage. - */ - private List getRepositories(AbstractBuild build) - throws IOException, InterruptedException { - - Map repositories = new LinkedHashMap(); - - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - FilePath workspace = build.getWorkspace(); - FilePath revisionsFile = workspace.child(REPOSITORY_FOLDER_NAME).child(BUILDBOOST_REVISIONS_FILE_NAME); - - if (revisionsFile.exists()) { - revisionsFile.copyTo(baos); - BufferedReader br = new BufferedReader(new InputStreamReader(new ByteArrayInputStream(baos.toByteArray()))); - try { - String remoteURL = null; - String type = null; - String localPath = null; - String line; - while((line=br.readLine()) != null) { - if (line.startsWith(TYPE_PREFIX)) { - type = line.substring(TYPE_PREFIX.length()); - logger.info("found type"); - } - if (line.startsWith(URL_PREFIX)) { - remoteURL = line.substring(URL_PREFIX.length()); - logger.info("found currentURL"); - } - if (line.startsWith(LOCAL_PREFIX) && type != null && remoteURL != null) { - localPath = line.substring(LOCAL_PREFIX.length()); - logger.info("found localPath"); - repositories.put(remoteURL, new BuildBoostRepository(type, remoteURL, localPath)); - } - } - } finally { - br.close(); - } - } else { - System.out.println("BuildBoostSCM.getRepositories() Can't find " + revisionsFile); - } - return new ArrayList(repositories.values()); - } - - @Override - protected PollingResult compareRemoteRevisionWith( - AbstractProject project, - Launcher launcher, - FilePath workspace, - TaskListener listener, - SCMRevisionState baseline) - throws IOException, InterruptedException { - - logger.info("compareRemoteRevisionWith(" + baseline + ")"); - if (baseline instanceof BuildBoostRevisionState) { - BuildBoostRevisionState state = (BuildBoostRevisionState) baseline; - List states = state.getRepositoryStates(); - boolean foundUpdates = checkForUpdates(states); - if (foundUpdates) { - return new PollingResult(Change.SIGNIFICANT); - } - } - return new PollingResult(Change.NONE); - } - - /** - * Checks whether one of the given repositories is not up-to-date. - * - * @param states the repositories to check - * @return true if an update is available, false if not - */ - private boolean checkForUpdates(List states) { - logger.info("checkForUpdates(" + states + ")"); - boolean foundUpdate = false; - for (BuildBoostRepositoryState state : states) { - BuildBoostRepository repository = state.getRepository(); - String newRevision = getRemoteRevision(repository); - String oldRevision = state.getRevision(); - - logger.info("new revision for repository " + repository + " is " + newRevision); - logger.info("old revision for repository " + repository + " is " + oldRevision); - - if (newRevision != null && !newRevision.equals(oldRevision)) { - foundUpdate = true; - } - } - return foundUpdate; - } - - /** - * Returns the revision of the working copy of the given repository. - */ - private String getLocalRevision(BuildBoostRepository repository) { - if (repository.isGit()) { - return getLocalGitRevision(repository.getLocalPath()); - } else if (repository.isSvn()) { - return getLocalSvnRevision(repository.getLocalPath()); - } else { - return null; - } - } - - /** - * Returns the hash code of the GIT working tree at 'localPath'. - */ - private String getLocalGitRevision(String localPath) { - return exectureGitLog(localPath, false); - } - - /** - * Returns the revision of the SVN working copy at 'localPath'. - */ - private String getLocalSvnRevision(String localPath) { - return executeSvnInfo(localPath); - } - - /** - * Returns the latest revision/hash code of the given repository. - */ - private String getRemoteRevision(BuildBoostRepository repository) { - logger.info("getRemoteRevision(" + repository + ")"); - - if (repository.isGit()) { - return getRemoteGitRevision(repository.getLocalPath()); - } else if (repository.isSvn()) { - return executeSvnLog(repository.getRemoteURL()); - } else { - return null; - } - } - - /** - * Returns the hash code of the latest commit at the origin. - */ - private String getRemoteGitRevision(String localPath) { - exectureGitFetch(localPath); - return exectureGitLog(localPath, true); - } - - /** - * Executes the Git fetch command to retrieve the changes from the origin - * this repository was cloned from. - */ - private void exectureGitFetch(String localPath) { - List command = new ArrayList(); - command.add(getGitCommand()); - command.add("fetch"); - //command.add("--dry-run"); - - executeNativeBinary(localPath, command, null); - } - - /** - * Returns the name of the Git executable for the OS we're running on. - */ - private String getGitCommand() { - if (System.getProperty("os.name").contains("Windows")) { - return GIT_CMD_WINDOWS; - } else { - return GIT_CMD_OTHER; - } - } - - /** - * Executes the Git log command and returns the hash code of the last - * commit. - */ - private String exectureGitLog(String localPath, boolean useOrigin) { - List command = new ArrayList(); - command.add(getGitCommand()); - command.add("log"); - command.add("-1"); - if (useOrigin) { - command.add("origin"); - } - - final String[] revision = new String[1]; - executeNativeBinary(localPath, command, new IFunction() { - - public Boolean call(String line) { - if (line.startsWith(COMMIT_PREFIX)) { - revision[0] = line.substring(COMMIT_PREFIX.length()); - return false; - } - return true; - } - }); - return revision[0]; - } - - /** - * Executes the SVN info command and returns the revision of the working - * copy. - */ - private String executeSvnInfo(String localPath) { - List command = new ArrayList(); - command.add("svn"); - command.add("info"); - - final String[] revision = new String[1]; - executeNativeBinary(localPath, command, new IFunction() { - - public Boolean call(String line) { - if (line.contains(SVN_REVISION_PREFIX)) { - revision[0] = "r" + line.substring(line.indexOf(SVN_REVISION_PREFIX) + SVN_REVISION_PREFIX.length()); - return false; - } - return true; - } - }); - return revision[0]; - } - - /** - * Executes the SVN log command and returns the revision of the last commit. - */ - private String executeSvnLog(String remotePath) { - List command = new ArrayList(); - command.add("svn"); - command.add("log"); - command.add("--limit"); - command.add("1"); - command.add(remotePath); - - final String[] revision = new String[1]; - executeNativeBinary(null, command, new IFunction() { - - public Boolean call(String line) { - if (line.matches(SVN_REVISION_REGEX)) { - revision[0] = line.substring(0, line.indexOf(" ")); - return false; - } - return true; - } - }); - return revision[0]; - } - - private void executeNativeBinary(String localPath, - List command, IFunction readerCallback) { - ProcessBuilder pb = new ProcessBuilder(command); - if (localPath != null) { - pb.directory(new File(localPath)); - } - try { - logger.info("executing " + command + " in " + localPath); - Process process = pb.start(); - InputStream inputStream = process.getInputStream(); - BufferedReader isr = new BufferedReader(new InputStreamReader(inputStream)); - String line; - while((line = isr.readLine()) != null) { - logger.info("output: " + line); - if (readerCallback == null) { - continue; - } - boolean continueReading = readerCallback.call(line); - if (!continueReading) { - break; - } - } - int exitCode = process.waitFor(); - logger.info("exitCode " + exitCode); - } catch (InterruptedException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - - /** - * This method does very little as the actual check out of project is - * performed by BuildBoost during the CloneStage. - * - * We simply write the URL of the root repository to a file in the workspace - * to allow the universal build script to use it. Also, we download the - * lastest version of the universal build script. - */ - @Override - public boolean checkout( - AbstractBuild build, - Launcher launcher, - FilePath workspace, - BuildListener listener, - File changelogFile) - throws IOException, InterruptedException { - - logger.info("checkout()"); - - if (rootRepositoryURL != null) { - FilePath rootRepositoryFile = workspace.child(ROOT_REPOSITORIES_FILE); - rootRepositoryFile.write(rootRepositoryURL, "UTF-8"); - } - - downloadUniversalBuildScript(workspace); - - return true; - } - - private void downloadUniversalBuildScript(FilePath workspace) - throws MalformedURLException, IOException, InterruptedException { - StringBuilder scriptContent = new StringBuilder(); - URL url = new URL(UNIVERSAL_BUILD_SCRIPT_URL); - InputStream stream = url.openStream(); - BufferedReader reader = new BufferedReader(new InputStreamReader(stream)); - String inputLine; - while ((inputLine = reader.readLine()) != null) { - scriptContent.append(inputLine); - } - reader.close(); - FilePath mainBuildFile = workspace.child(MAIN_BUILD_SCRIPT); - mainBuildFile.write(scriptContent.toString(), "UTF-8"); - } - - @Override - public ChangeLogParser createChangeLogParser() { - logger.info("createChangeLogParser()"); - // TODO implement this - return null; - } -} +/******************************************************************************* + * Copyright (c) 2012 + * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 + * + * All rights reserved. This program and the accompanying materials + * are 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 + * + * Contributors: + * DevBoost GmbH - Berlin, Germany + * - initial API and implementation + ******************************************************************************/ +package org.buildboost.hudson.plugins.boostscm; + +import hudson.Extension; +import hudson.FilePath; +import hudson.Launcher; +import hudson.model.BuildListener; +import hudson.model.TaskListener; +import hudson.model.AbstractBuild; +import hudson.model.AbstractProject; +import hudson.scm.ChangeLogParser; +import hudson.scm.PollingResult; +import hudson.scm.PollingResult.Change; +import hudson.scm.SCMDescriptor; +import hudson.scm.SCMRevisionState; +import hudson.scm.SCM; + +import java.io.BufferedReader; +import java.io.ByteArrayInputStream; +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.net.MalformedURLException; +import java.net.URL; +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.logging.Logger; + +import org.apache.commons.io.output.ByteArrayOutputStream; +import org.kohsuke.stapler.DataBoundConstructor; + +/** + * The BuildBoostSCM extends Jenkins with the ability to poll all repositories + * that are referenced by a BuildBoost build. This includes the root repository + * and all transitively referenced repositories. + * + * To poll the repositories a list of all used repositories is created by the + * BuildBoost CloneStep. + */ +public class BuildBoostSCM extends SCM { + + private static final String ROOT_REPOSITORIES_FILE = "repos/root.repositories"; + + private static final String MAIN_BUILD_SCRIPT = "build.xml"; + + private static final String UNIVERSAL_BUILD_SCRIPT_URL = "https://raw.github.com/DevBoost/BuildBoost/master/Universal/de.devboost.buildboost.universal.build/boost/build.xml"; + + private static final Logger logger = Logger.getLogger(BuildBoostSCM.class.getName()); + + private static final String GIT_CMD_WINDOWS = "git.cmd"; + private static final String GIT_CMD_OTHER = "git"; + + private static final String REPOSITORY_FOLDER_NAME = "repos"; + private static final String BUILDBOOST_REVISIONS_FILE_NAME = "buildboost_repository_list.txt"; + + private static final String URL_PREFIX = "BuildBoost-Repository-URL: "; + private static final String TYPE_PREFIX = "BuildBoost-Repository-Type: "; + private static final String LOCAL_PREFIX = "BuildBoost-Repository-Local: "; + + private static final String COMMIT_PREFIX = "commit "; + private static final String SVN_REVISION_PREFIX = " Rev: "; + private static final String SVN_REVISION_REGEX = "^r[0-9]+ .*"; + + public static class DescriptorImpl extends SCMDescriptor { + + public DescriptorImpl() { + super(BuildBoostSCM.class, null); + load(); + } + + @Override + public String getDisplayName() { + return "BuildBoostSCM"; + } + } + + @Extension + public final static DescriptorImpl descriptor = new DescriptorImpl(); + + private String rootRepositoryURL; + + @Override + public SCMDescriptor getDescriptor() { + return descriptor; + } + + @DataBoundConstructor + public BuildBoostSCM(String rootRepositoryURL) { + super(); + this.rootRepositoryURL = rootRepositoryURL; + } + + public String getRootRepositoryURL() { + return rootRepositoryURL; + } + + @Override + public SCMRevisionState calcRevisionsFromBuild( + AbstractBuild build, + Launcher launcher, + TaskListener listener) + throws IOException, InterruptedException { + logger.info("calcRevisionsFromBuild()"); + return getBuildState(build); + } + + /** + * Creates the build state using the list of repositories. Each of the + * repository working copies is examined for its revision. + */ + private SCMRevisionState getBuildState(AbstractBuild build) + throws IOException, InterruptedException { + + BuildBoostRevisionState state = new BuildBoostRevisionState(); + List repositories = getRepositories(build); + for (BuildBoostRepository repository : repositories) { + String revision = getLocalRevision(repository); + state.addRepositoryState(repository, revision); + } + return state; + } + + /** + * Determines the list of repositories the was created by the BuildBoost + * CloneStage. + */ + private List getRepositories(AbstractBuild build) + throws IOException, InterruptedException { + + Map repositories = new LinkedHashMap(); + + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + FilePath workspace = build.getWorkspace(); + FilePath revisionsFile = workspace.child(REPOSITORY_FOLDER_NAME).child(BUILDBOOST_REVISIONS_FILE_NAME); + + if (revisionsFile.exists()) { + revisionsFile.copyTo(baos); + BufferedReader br = new BufferedReader(new InputStreamReader(new ByteArrayInputStream(baos.toByteArray()))); + try { + String remoteURL = null; + String type = null; + String localPath = null; + String line; + while((line=br.readLine()) != null) { + if (line.startsWith(TYPE_PREFIX)) { + type = line.substring(TYPE_PREFIX.length()); + logger.info("found type"); + } + if (line.startsWith(URL_PREFIX)) { + remoteURL = line.substring(URL_PREFIX.length()); + logger.info("found currentURL"); + } + if (line.startsWith(LOCAL_PREFIX) && type != null && remoteURL != null) { + localPath = line.substring(LOCAL_PREFIX.length()); + logger.info("found localPath"); + repositories.put(remoteURL, new BuildBoostRepository(type, remoteURL, localPath)); + } + } + } finally { + br.close(); + } + } else { + System.out.println("BuildBoostSCM.getRepositories() Can't find " + revisionsFile); + } + return new ArrayList(repositories.values()); + } + + @Override + protected PollingResult compareRemoteRevisionWith( + AbstractProject project, + Launcher launcher, + FilePath workspace, + TaskListener listener, + SCMRevisionState baseline) + throws IOException, InterruptedException { + + logger.info("compareRemoteRevisionWith(" + baseline + ")"); + if (baseline instanceof BuildBoostRevisionState) { + BuildBoostRevisionState state = (BuildBoostRevisionState) baseline; + List states = state.getRepositoryStates(); + boolean foundUpdates = checkForUpdates(states); + if (foundUpdates) { + return new PollingResult(Change.SIGNIFICANT); + } + } + return new PollingResult(Change.NONE); + } + + /** + * Checks whether one of the given repositories is not up-to-date. + * + * @param states the repositories to check + * @return true if an update is available, false if not + */ + private boolean checkForUpdates(List states) { + logger.info("checkForUpdates(" + states + ")"); + boolean foundUpdate = false; + for (BuildBoostRepositoryState state : states) { + BuildBoostRepository repository = state.getRepository(); + String newRevision = getRemoteRevision(repository); + String oldRevision = state.getRevision(); + + logger.info("new revision for repository " + repository + " is " + newRevision); + logger.info("old revision for repository " + repository + " is " + oldRevision); + + if (newRevision != null && !newRevision.equals(oldRevision)) { + foundUpdate = true; + } + } + return foundUpdate; + } + + /** + * Returns the revision of the working copy of the given repository. + */ + private String getLocalRevision(BuildBoostRepository repository) { + if (repository.isGit()) { + return getLocalGitRevision(repository.getLocalPath()); + } else if (repository.isSvn()) { + return getLocalSvnRevision(repository.getLocalPath()); + } else { + return null; + } + } + + /** + * Returns the hash code of the GIT working tree at 'localPath'. + */ + private String getLocalGitRevision(String localPath) { + return exectureGitLog(localPath, false); + } + + /** + * Returns the revision of the SVN working copy at 'localPath'. + */ + private String getLocalSvnRevision(String localPath) { + return executeSvnInfo(localPath); + } + + /** + * Returns the latest revision/hash code of the given repository. + */ + private String getRemoteRevision(BuildBoostRepository repository) { + logger.info("getRemoteRevision(" + repository + ")"); + + if (repository.isGit()) { + return getRemoteGitRevision(repository.getLocalPath()); + } else if (repository.isSvn()) { + return executeSvnLog(repository.getRemoteURL()); + } else { + return null; + } + } + + /** + * Returns the hash code of the latest commit at the origin. + */ + private String getRemoteGitRevision(String localPath) { + exectureGitFetch(localPath); + return exectureGitLog(localPath, true); + } + + /** + * Executes the Git fetch command to retrieve the changes from the origin + * this repository was cloned from. + */ + private void exectureGitFetch(String localPath) { + List command = new ArrayList(); + command.add(getGitCommand()); + command.add("fetch"); + //command.add("--dry-run"); + + executeNativeBinary(localPath, command, null); + } + + /** + * Returns the name of the Git executable for the OS we're running on. + */ + private String getGitCommand() { + if (System.getProperty("os.name").contains("Windows")) { + return GIT_CMD_WINDOWS; + } else { + return GIT_CMD_OTHER; + } + } + + /** + * Executes the Git log command and returns the hash code of the last + * commit. + */ + private String exectureGitLog(String localPath, boolean useOrigin) { + List command = new ArrayList(); + command.add(getGitCommand()); + command.add("log"); + command.add("-1"); + if (useOrigin) { + command.add("origin"); + } + + final String[] revision = new String[1]; + executeNativeBinary(localPath, command, new IFunction() { + + public Boolean call(String line) { + if (line.startsWith(COMMIT_PREFIX)) { + revision[0] = line.substring(COMMIT_PREFIX.length()); + return false; + } + return true; + } + }); + return revision[0]; + } + + /** + * Executes the SVN info command and returns the revision of the working + * copy. + */ + private String executeSvnInfo(String localPath) { + List command = new ArrayList(); + command.add("svn"); + command.add("info"); + + final String[] revision = new String[1]; + executeNativeBinary(localPath, command, new IFunction() { + + public Boolean call(String line) { + if (line.contains(SVN_REVISION_PREFIX)) { + revision[0] = "r" + line.substring(line.indexOf(SVN_REVISION_PREFIX) + SVN_REVISION_PREFIX.length()); + return false; + } + return true; + } + }); + return revision[0]; + } + + /** + * Executes the SVN log command and returns the revision of the last commit. + */ + private String executeSvnLog(String remotePath) { + List command = new ArrayList(); + command.add("svn"); + command.add("log"); + command.add("--limit"); + command.add("1"); + command.add(remotePath); + + final String[] revision = new String[1]; + executeNativeBinary(null, command, new IFunction() { + + public Boolean call(String line) { + if (line.matches(SVN_REVISION_REGEX)) { + revision[0] = line.substring(0, line.indexOf(" ")); + return false; + } + return true; + } + }); + return revision[0]; + } + + private void executeNativeBinary(String localPath, + List command, IFunction readerCallback) { + ProcessBuilder pb = new ProcessBuilder(command); + if (localPath != null) { + pb.directory(new File(localPath)); + } + try { + logger.info("executing " + command + " in " + localPath); + Process process = pb.start(); + InputStream inputStream = process.getInputStream(); + BufferedReader isr = new BufferedReader(new InputStreamReader(inputStream)); + String line; + while((line = isr.readLine()) != null) { + logger.info("output: " + line); + if (readerCallback == null) { + continue; + } + boolean continueReading = readerCallback.call(line); + if (!continueReading) { + break; + } + } + int exitCode = process.waitFor(); + logger.info("exitCode " + exitCode); + } catch (InterruptedException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + /** + * This method does very little as the actual check out of project is + * performed by BuildBoost during the CloneStage. + * + * We simply write the URL of the root repository to a file in the workspace + * to allow the universal build script to use it. Also, we download the + * lastest version of the universal build script. + */ + @Override + public boolean checkout( + AbstractBuild build, + Launcher launcher, + FilePath workspace, + BuildListener listener, + File changelogFile) + throws IOException, InterruptedException { + + logger.info("checkout()"); + + if (rootRepositoryURL != null) { + FilePath rootRepositoryFile = workspace.child(ROOT_REPOSITORIES_FILE); + rootRepositoryFile.write(rootRepositoryURL, "UTF-8"); + } + + downloadUniversalBuildScript(workspace); + + return true; + } + + private void downloadUniversalBuildScript(FilePath workspace) + throws MalformedURLException, IOException, InterruptedException { + StringBuilder scriptContent = new StringBuilder(); + URL url = new URL(UNIVERSAL_BUILD_SCRIPT_URL); + InputStream stream = url.openStream(); + BufferedReader reader = new BufferedReader(new InputStreamReader(stream)); + String inputLine; + while ((inputLine = reader.readLine()) != null) { + scriptContent.append(inputLine); + } + reader.close(); + FilePath mainBuildFile = workspace.child(MAIN_BUILD_SCRIPT); + mainBuildFile.write(scriptContent.toString(), "UTF-8"); + } + + @Override + public ChangeLogParser createChangeLogParser() { + logger.info("createChangeLogParser()"); + // TODO implement this + return null; + } +} diff --git a/JenkinsPlugin/org.buildboost.hudson.plugins.boostscm/src/main/java/org/buildboost/hudson/plugins/boostscm/IFunction.java b/JenkinsPlugin/org.buildboost.hudson.plugins.boostscm/src/main/java/org/buildboost/hudson/plugins/boostscm/IFunction.java index f0e7f89..d514c54 100644 --- a/JenkinsPlugin/org.buildboost.hudson.plugins.boostscm/src/main/java/org/buildboost/hudson/plugins/boostscm/IFunction.java +++ b/JenkinsPlugin/org.buildboost.hudson.plugins.boostscm/src/main/java/org/buildboost/hudson/plugins/boostscm/IFunction.java @@ -1,19 +1,19 @@ -/******************************************************************************* - * Copyright (c) 2012 - * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 - * - * All rights reserved. This program and the accompanying materials - * are 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 - * - * Contributors: - * DevBoost GmbH - Berlin, Germany - * - initial API and implementation - ******************************************************************************/ -package org.buildboost.hudson.plugins.boostscm; - -public interface IFunction { - - public ReturnType call(ArgumentType1 arg1); -} +/******************************************************************************* + * Copyright (c) 2012 + * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 + * + * All rights reserved. This program and the accompanying materials + * are 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 + * + * Contributors: + * DevBoost GmbH - Berlin, Germany + * - initial API and implementation + ******************************************************************************/ +package org.buildboost.hudson.plugins.boostscm; + +public interface IFunction { + + public ReturnType call(ArgumentType1 arg1); +} diff --git a/Tests/de.devboost.buildboost.test/.classpath b/Tests/de.devboost.buildboost.test/.classpath index ed2bc12..121e527 100644 --- a/Tests/de.devboost.buildboost.test/.classpath +++ b/Tests/de.devboost.buildboost.test/.classpath @@ -1,7 +1,7 @@ - - - - - - - + + + + + + + diff --git a/Tests/de.devboost.buildboost.test/.project b/Tests/de.devboost.buildboost.test/.project index e63e840..6f03081 100644 --- a/Tests/de.devboost.buildboost.test/.project +++ b/Tests/de.devboost.buildboost.test/.project @@ -1,28 +1,28 @@ - - - de.devboost.buildboost.test - - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.pde.ManifestBuilder - - - - - org.eclipse.pde.SchemaBuilder - - - - - - org.eclipse.jdt.core.javanature - org.eclipse.pde.PluginNature - - + + + de.devboost.buildboost.test + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + + org.eclipse.jdt.core.javanature + org.eclipse.pde.PluginNature + + diff --git a/Tests/de.devboost.buildboost.test/.settings/org.eclipse.jdt.core.prefs b/Tests/de.devboost.buildboost.test/.settings/org.eclipse.jdt.core.prefs index 33dfb2a..f58e1fc 100644 --- a/Tests/de.devboost.buildboost.test/.settings/org.eclipse.jdt.core.prefs +++ b/Tests/de.devboost.buildboost.test/.settings/org.eclipse.jdt.core.prefs @@ -1,12 +1,12 @@ -#Mon Dec 19 16:37:39 CET 2011 -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 -org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.6 -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.enumIdentifier=error -org.eclipse.jdt.core.compiler.source=1.6 +#Mon Dec 19 16:37:39 CET 2011 +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.6 +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.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.6 diff --git a/Tests/de.devboost.buildboost.test/build.properties b/Tests/de.devboost.buildboost.test/build.properties index a12d47e..b107977 100644 --- a/Tests/de.devboost.buildboost.test/build.properties +++ b/Tests/de.devboost.buildboost.test/build.properties @@ -1,3 +1,3 @@ -source.. = src/ -bin.includes = META-INF/,\ - . +source.. = src/ +bin.includes = META-INF/,\ + . diff --git a/Tests/de.devboost.buildboost.test/input/org.emftext.sdk.MF b/Tests/de.devboost.buildboost.test/input/org.emftext.sdk.MF index fde1058..ae1bd2f 100644 --- a/Tests/de.devboost.buildboost.test/input/org.emftext.sdk.MF +++ b/Tests/de.devboost.buildboost.test/input/org.emftext.sdk.MF @@ -1,22 +1,22 @@ -Manifest-Version: 1.0 -Ant-Version: Apache Ant 1.7.0 -Created-By: 1.5.0_16-133 (Apple Inc.) -Bundle-ManifestVersion: 2 -Bundle-Name: EMFText SDK -Bundle-SymbolicName: org.emftext.sdk; singleton:=true -Bundle-Version: 1.2.0.qualifier -Bundle-RequiredExecutionEnvironment: J2SE-1.5 -Require-Bundle: org.eclipse.emf.codegen.ecore;visibility:=reexport,org - .eclipse.emf.workspace,org.eclipse.jdt.core,org.eclipse.jdt.launching - ,org.emftext.sdk.antlr3_4_0,org.emftext.sdk.concretesyntax;visibility:=ree - xport,org.emftext.access;resolution:=optional,org.junit4,org.emftext. - sdk.automaton,org.eclipse.emf,org.eclipse.emf.edit.ui,org.eclipse.emf - .ecore,org.eclipse.emf.ecore.edit,org.eclipse.ui,org.eclipse.ui.views - ,org.eclipse.ui.ide,org.eclipse.ui.editors,org.eclipse.jface,org.ecli - pse.jface.text,org.eclipse.core.resources,org.eclipse.core.runtime -Export-Package: org.emftext.sdk,org.emftext.sdk.finders,org.emftext.sd - k.regex,org.emftext.sdk.util -Bundle-Vendor: Software Technology Group - TU Dresden Germany -Bundle-ActivationPolicy: lazy -Bundle-Activator: org.emftext.sdk.EMFTextSDKPlugin - +Manifest-Version: 1.0 +Ant-Version: Apache Ant 1.7.0 +Created-By: 1.5.0_16-133 (Apple Inc.) +Bundle-ManifestVersion: 2 +Bundle-Name: EMFText SDK +Bundle-SymbolicName: org.emftext.sdk; singleton:=true +Bundle-Version: 1.2.0.qualifier +Bundle-RequiredExecutionEnvironment: J2SE-1.5 +Require-Bundle: org.eclipse.emf.codegen.ecore;visibility:=reexport,org + .eclipse.emf.workspace,org.eclipse.jdt.core,org.eclipse.jdt.launching + ,org.emftext.sdk.antlr3_4_0,org.emftext.sdk.concretesyntax;visibility:=ree + xport,org.emftext.access;resolution:=optional,org.junit4,org.emftext. + sdk.automaton,org.eclipse.emf,org.eclipse.emf.edit.ui,org.eclipse.emf + .ecore,org.eclipse.emf.ecore.edit,org.eclipse.ui,org.eclipse.ui.views + ,org.eclipse.ui.ide,org.eclipse.ui.editors,org.eclipse.jface,org.ecli + pse.jface.text,org.eclipse.core.resources,org.eclipse.core.runtime +Export-Package: org.emftext.sdk,org.emftext.sdk.finders,org.emftext.sd + k.regex,org.emftext.sdk.util +Bundle-Vendor: Software Technology Group - TU Dresden Germany +Bundle-ActivationPolicy: lazy +Bundle-Activator: org.emftext.sdk.EMFTextSDKPlugin + diff --git a/Tests/de.devboost.buildboost.test/src/de/devboost/buildboost/test/ManifestReaderTest.java b/Tests/de.devboost.buildboost.test/src/de/devboost/buildboost/test/ManifestReaderTest.java index 25af83b..f468ef1 100644 --- a/Tests/de.devboost.buildboost.test/src/de/devboost/buildboost/test/ManifestReaderTest.java +++ b/Tests/de.devboost.buildboost.test/src/de/devboost/buildboost/test/ManifestReaderTest.java @@ -1,197 +1,197 @@ -/******************************************************************************* - * Copyright (c) 2006-2012 - * Software Technology Group, Dresden University of Technology - * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 - * - * All rights reserved. This program and the accompanying materials - * are 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 - * - * Contributors: - * Software Technology Group - TU Dresden, Germany; - * DevBoost GmbH - Berlin, Germany - * - initial API and implementation - ******************************************************************************/ -package de.devboost.buildboost.test; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -import java.io.ByteArrayInputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.util.Iterator; -import java.util.Set; - -import org.junit.Test; - -import de.devboost.buildboost.discovery.reader.ManifestReader; -import de.devboost.buildboost.model.UnresolvedDependency; - -public class ManifestReaderTest { - - @Test - public void testReading() { - try { - String plugin = "org.emftext.sdk"; - getDependencies(plugin); - } catch (IOException e) { - fail(e.getMessage()); - } - - try { - String plugin = "org.dropsbox"; - Set dependencies = getDependencies(plugin); - assertEquals(2, dependencies.size()); - Iterator iterator = dependencies.iterator(); - UnresolvedDependency first = iterator.next(); - UnresolvedDependency second = iterator.next(); - assertEquals("org.emftext.sdk", first.getIdentifier()); - assertEquals("org.apache.ant", second.getIdentifier()); - } catch (IOException e) { - fail(e.getMessage()); - } - } - - @Test - public void testBundleName() throws IOException { - String input = "Bundle-SymbolicName: com.mysql.connector-java5_1_16\n"; - ByteArrayInputStream bais = new ByteArrayInputStream(input.getBytes()); - String symbolicName = new ManifestReader(bais).getSymbolicName(); - assertEquals("com.mysql.connector-java5_1_16", symbolicName); - } - - @Test - public void testDependency3() throws IOException { - String input = "Require-Bundle: com.mysql.connector-java5_1_16\n"; - ByteArrayInputStream bais = new ByteArrayInputStream(input.getBytes()); - Set dependencies = new ManifestReader(bais).getDependencies(); - assertEquals(1, dependencies.size()); - assertEquals("com.mysql.connector-java5_1_16", dependencies.iterator().next().getIdentifier()); - } - - @Test - public void testDependency4() throws IOException { - String input = "Require-Bundle: org.eclipse.core.runtime,\n org.eclipse.emf.ecore;visibility:=reexport\n"; - ByteArrayInputStream bais = new ByteArrayInputStream(input.getBytes()); - Set dependencies = new ManifestReader(bais).getDependencies(); - assertEquals(2, dependencies.size()); - Iterator iterator = dependencies.iterator(); - UnresolvedDependency dependency1 = iterator.next(); - UnresolvedDependency dependency2 = iterator.next(); - assertEquals("org.eclipse.core.runtime", dependency1.getIdentifier()); - assertEquals("org.eclipse.emf.ecore", dependency2.getIdentifier()); - } - - @Test - public void testRegex() throws IOException { - String input = ManifestReader.NAME_PREFIX + "myplugin; singleton:=true\n"; - ByteArrayInputStream bais = new ByteArrayInputStream(input.getBytes()); - String symbolicName = new ManifestReader(bais).getSymbolicName(); - assertEquals("myplugin", symbolicName); - } - - @Test - public void testRegex2() throws IOException { - assertTrue("org.apache.commons".matches(ManifestReader.QUALIFIED_NAME_REGEX)); - assertTrue("2.0.0".matches(ManifestReader.QUALIFIED_NUMBER_REGEX)); - - assertTrue("bundle-version=\"2.0.0\"".matches(ManifestReader.BUNDLE_VERSION_REGEX)); - assertTrue("bundle-version=\"[2.0.0,3.0.0)\"".matches(ManifestReader.BUNDLE_VERSION_REGEX)); - assertFalse("bundle-version=\"[2.0.0,3.0.0)\",".matches(ManifestReader.BUNDLE_VERSION_REGEX)); - - assertTrue("-".matches("-")); - assertTrue("bundle-version".matches(ManifestReader.OPTION_NAME_REGEX)); - assertTrue("\"[2.0.0,3.0.0)\"".matches(ManifestReader.OPTION_VALUE_REGEX)); - assertTrue("optional".matches(ManifestReader.OPTION_VALUE_REGEX)); - - assertTrue(";bundle-version=\"[2.0.0,3.0.0)\"".matches(ManifestReader.OPTION_REGEX)); - assertFalse(";bundle-version=\"[2.0.0,3.0.0)\";".matches(ManifestReader.OPTION_REGEX)); - - assertTrue(";resolution:=optional".matches(ManifestReader.OPTION_REGEX)); - assertTrue(";resolution:=\"optional\"".matches(ManifestReader.OPTION_REGEX)); - assertTrue(";visibility:=reexport".matches(ManifestReader.OPTION_REGEX)); - - assertTrue("com.mysql.connector-java5_1_16".matches(ManifestReader.OPTION_VALUE_REGEX)); - } - - @Test - public void testDependencies() throws IOException { - String input = - "Require-Bundle: org.apache.commons.lang;bundle-version=\"[2.0.0,3.0.0)\"" + - ",org.apache.commons.logging;bundle-version=\"[1.0.0,2.0.0)\";resolution:=optional;visibility:=reexport\n"; - - ByteArrayInputStream bais = new ByteArrayInputStream(input.getBytes()); - Set dependencies = new ManifestReader(bais).getDependencies(); - System.out.println(dependencies); - assertEquals(2, dependencies.size()); - - Iterator iterator = dependencies.iterator(); - UnresolvedDependency first = iterator.next(); - UnresolvedDependency second = iterator.next(); - assertEquals("org.apache.commons.lang", first.getIdentifier()); - assertFalse(first.isOptional()); - assertFalse(first.isReexported()); - - assertEquals("org.apache.commons.logging", second.getIdentifier()); - assertTrue(second.isOptional()); - assertTrue(second.isReexported()); - } - - @Test - public void testDependencies2() throws IOException { - - String input = "Require-Bundle: org.eclipse.core.runtime; bundle-version=\"[3.4.0,4.0.0)\"\n"; - ByteArrayInputStream bais = new ByteArrayInputStream(input.getBytes()); - Set dependencies = new ManifestReader(bais).getDependencies(); - System.out.println(dependencies); - assertEquals(1, dependencies.size()); - - Iterator iterator = dependencies.iterator(); - UnresolvedDependency first = iterator.next(); - assertEquals("org.eclipse.core.runtime", first.getIdentifier()); - assertEquals("3.4.0", first.getMinVersion()); - assertEquals("4.0.0", first.getMaxVersion()); - } - - @Test - public void testGetVersion() throws IOException { - String input = "Require-Bundle: org.hamcrest.core;bundle-version=\"1.1.0\";visibility:=r\n" + - " eexport,org.junit;bundle-version=\"4.8.1\";visibility:=reexport\n" + - "Bundle-Version: 4.8.1.v20100525\n"+ - "Bundle-ManifestVersion: 2\n"; - ByteArrayInputStream bais = new ByteArrayInputStream(input.getBytes()); - ManifestReader reader = new ManifestReader(bais); - assertEquals("4.8.1", reader.getVersion()); - } - - public void testGetOptional() throws IOException { - String input = "Require-Bundle: org.eclipse.core.resources;resolution:=\"optional\"\n"; - ByteArrayInputStream bais = new ByteArrayInputStream(input.getBytes()); - ManifestReader reader = new ManifestReader(bais); - Set dependencies = reader.getDependencies(); - UnresolvedDependency dependency = dependencies.iterator().next(); - assertTrue("Resolution must be optional.", dependency.isOptional()); - } - - @Test - public void testGetFragmentHost() throws IOException { - String input = "Fragment-Host: org.eclipse.swt; bundle-version=\"[3.0.0,4.0.0)\"\n" + - "Bundle-Name: %fragmentName\n" + - "Bundle-SymbolicName: org.eclipse.swt.gtk.linux.x86_64; singleton:=true\n" + - "Bundle-Version: 3.7.0.v3735b\n"; - ByteArrayInputStream bais = new ByteArrayInputStream(input.getBytes()); - ManifestReader reader = new ManifestReader(bais); - assertEquals("org.eclipse.swt", reader.getFragmentHost().getIdentifier()); - } - - private Set getDependencies(String plugin) throws IOException { - File file = new File("input", plugin + ".MF"); - FileInputStream fis = new FileInputStream(file); - return new ManifestReader(fis).getDependencies(); - } -} +/******************************************************************************* + * Copyright (c) 2006-2012 + * Software Technology Group, Dresden University of Technology + * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 + * + * All rights reserved. This program and the accompanying materials + * are 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 + * + * Contributors: + * Software Technology Group - TU Dresden, Germany; + * DevBoost GmbH - Berlin, Germany + * - initial API and implementation + ******************************************************************************/ +package de.devboost.buildboost.test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +import java.io.ByteArrayInputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.util.Iterator; +import java.util.Set; + +import org.junit.Test; + +import de.devboost.buildboost.discovery.reader.ManifestReader; +import de.devboost.buildboost.model.UnresolvedDependency; + +public class ManifestReaderTest { + + @Test + public void testReading() { + try { + String plugin = "org.emftext.sdk"; + getDependencies(plugin); + } catch (IOException e) { + fail(e.getMessage()); + } + + try { + String plugin = "org.dropsbox"; + Set dependencies = getDependencies(plugin); + assertEquals(2, dependencies.size()); + Iterator iterator = dependencies.iterator(); + UnresolvedDependency first = iterator.next(); + UnresolvedDependency second = iterator.next(); + assertEquals("org.emftext.sdk", first.getIdentifier()); + assertEquals("org.apache.ant", second.getIdentifier()); + } catch (IOException e) { + fail(e.getMessage()); + } + } + + @Test + public void testBundleName() throws IOException { + String input = "Bundle-SymbolicName: com.mysql.connector-java5_1_16\n"; + ByteArrayInputStream bais = new ByteArrayInputStream(input.getBytes()); + String symbolicName = new ManifestReader(bais).getSymbolicName(); + assertEquals("com.mysql.connector-java5_1_16", symbolicName); + } + + @Test + public void testDependency3() throws IOException { + String input = "Require-Bundle: com.mysql.connector-java5_1_16\n"; + ByteArrayInputStream bais = new ByteArrayInputStream(input.getBytes()); + Set dependencies = new ManifestReader(bais).getDependencies(); + assertEquals(1, dependencies.size()); + assertEquals("com.mysql.connector-java5_1_16", dependencies.iterator().next().getIdentifier()); + } + + @Test + public void testDependency4() throws IOException { + String input = "Require-Bundle: org.eclipse.core.runtime,\n org.eclipse.emf.ecore;visibility:=reexport\n"; + ByteArrayInputStream bais = new ByteArrayInputStream(input.getBytes()); + Set dependencies = new ManifestReader(bais).getDependencies(); + assertEquals(2, dependencies.size()); + Iterator iterator = dependencies.iterator(); + UnresolvedDependency dependency1 = iterator.next(); + UnresolvedDependency dependency2 = iterator.next(); + assertEquals("org.eclipse.core.runtime", dependency1.getIdentifier()); + assertEquals("org.eclipse.emf.ecore", dependency2.getIdentifier()); + } + + @Test + public void testRegex() throws IOException { + String input = ManifestReader.NAME_PREFIX + "myplugin; singleton:=true\n"; + ByteArrayInputStream bais = new ByteArrayInputStream(input.getBytes()); + String symbolicName = new ManifestReader(bais).getSymbolicName(); + assertEquals("myplugin", symbolicName); + } + + @Test + public void testRegex2() throws IOException { + assertTrue("org.apache.commons".matches(ManifestReader.QUALIFIED_NAME_REGEX)); + assertTrue("2.0.0".matches(ManifestReader.QUALIFIED_NUMBER_REGEX)); + + assertTrue("bundle-version=\"2.0.0\"".matches(ManifestReader.BUNDLE_VERSION_REGEX)); + assertTrue("bundle-version=\"[2.0.0,3.0.0)\"".matches(ManifestReader.BUNDLE_VERSION_REGEX)); + assertFalse("bundle-version=\"[2.0.0,3.0.0)\",".matches(ManifestReader.BUNDLE_VERSION_REGEX)); + + assertTrue("-".matches("-")); + assertTrue("bundle-version".matches(ManifestReader.OPTION_NAME_REGEX)); + assertTrue("\"[2.0.0,3.0.0)\"".matches(ManifestReader.OPTION_VALUE_REGEX)); + assertTrue("optional".matches(ManifestReader.OPTION_VALUE_REGEX)); + + assertTrue(";bundle-version=\"[2.0.0,3.0.0)\"".matches(ManifestReader.OPTION_REGEX)); + assertFalse(";bundle-version=\"[2.0.0,3.0.0)\";".matches(ManifestReader.OPTION_REGEX)); + + assertTrue(";resolution:=optional".matches(ManifestReader.OPTION_REGEX)); + assertTrue(";resolution:=\"optional\"".matches(ManifestReader.OPTION_REGEX)); + assertTrue(";visibility:=reexport".matches(ManifestReader.OPTION_REGEX)); + + assertTrue("com.mysql.connector-java5_1_16".matches(ManifestReader.OPTION_VALUE_REGEX)); + } + + @Test + public void testDependencies() throws IOException { + String input = + "Require-Bundle: org.apache.commons.lang;bundle-version=\"[2.0.0,3.0.0)\"" + + ",org.apache.commons.logging;bundle-version=\"[1.0.0,2.0.0)\";resolution:=optional;visibility:=reexport\n"; + + ByteArrayInputStream bais = new ByteArrayInputStream(input.getBytes()); + Set dependencies = new ManifestReader(bais).getDependencies(); + System.out.println(dependencies); + assertEquals(2, dependencies.size()); + + Iterator iterator = dependencies.iterator(); + UnresolvedDependency first = iterator.next(); + UnresolvedDependency second = iterator.next(); + assertEquals("org.apache.commons.lang", first.getIdentifier()); + assertFalse(first.isOptional()); + assertFalse(first.isReexported()); + + assertEquals("org.apache.commons.logging", second.getIdentifier()); + assertTrue(second.isOptional()); + assertTrue(second.isReexported()); + } + + @Test + public void testDependencies2() throws IOException { + + String input = "Require-Bundle: org.eclipse.core.runtime; bundle-version=\"[3.4.0,4.0.0)\"\n"; + ByteArrayInputStream bais = new ByteArrayInputStream(input.getBytes()); + Set dependencies = new ManifestReader(bais).getDependencies(); + System.out.println(dependencies); + assertEquals(1, dependencies.size()); + + Iterator iterator = dependencies.iterator(); + UnresolvedDependency first = iterator.next(); + assertEquals("org.eclipse.core.runtime", first.getIdentifier()); + assertEquals("3.4.0", first.getMinVersion()); + assertEquals("4.0.0", first.getMaxVersion()); + } + + @Test + public void testGetVersion() throws IOException { + String input = "Require-Bundle: org.hamcrest.core;bundle-version=\"1.1.0\";visibility:=r\n" + + " eexport,org.junit;bundle-version=\"4.8.1\";visibility:=reexport\n" + + "Bundle-Version: 4.8.1.v20100525\n"+ + "Bundle-ManifestVersion: 2\n"; + ByteArrayInputStream bais = new ByteArrayInputStream(input.getBytes()); + ManifestReader reader = new ManifestReader(bais); + assertEquals("4.8.1", reader.getVersion()); + } + + public void testGetOptional() throws IOException { + String input = "Require-Bundle: org.eclipse.core.resources;resolution:=\"optional\"\n"; + ByteArrayInputStream bais = new ByteArrayInputStream(input.getBytes()); + ManifestReader reader = new ManifestReader(bais); + Set dependencies = reader.getDependencies(); + UnresolvedDependency dependency = dependencies.iterator().next(); + assertTrue("Resolution must be optional.", dependency.isOptional()); + } + + @Test + public void testGetFragmentHost() throws IOException { + String input = "Fragment-Host: org.eclipse.swt; bundle-version=\"[3.0.0,4.0.0)\"\n" + + "Bundle-Name: %fragmentName\n" + + "Bundle-SymbolicName: org.eclipse.swt.gtk.linux.x86_64; singleton:=true\n" + + "Bundle-Version: 3.7.0.v3735b\n"; + ByteArrayInputStream bais = new ByteArrayInputStream(input.getBytes()); + ManifestReader reader = new ManifestReader(bais); + assertEquals("org.eclipse.swt", reader.getFragmentHost().getIdentifier()); + } + + private Set getDependencies(String plugin) throws IOException { + File file = new File("input", plugin + ".MF"); + FileInputStream fis = new FileInputStream(file); + return new ManifestReader(fis).getDependencies(); + } +} diff --git a/Tests/de.devboost.buildboost.test/src/de/devboost/buildboost/test/PluginSorterTest.java b/Tests/de.devboost.buildboost.test/src/de/devboost/buildboost/test/PluginSorterTest.java index 7cfc72d..79dc12d 100644 --- a/Tests/de.devboost.buildboost.test/src/de/devboost/buildboost/test/PluginSorterTest.java +++ b/Tests/de.devboost.buildboost.test/src/de/devboost/buildboost/test/PluginSorterTest.java @@ -1,174 +1,174 @@ -/******************************************************************************* - * Copyright (c) 2006-2012 - * Software Technology Group, Dresden University of Technology - * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 - * - * All rights reserved. This program and the accompanying materials - * are 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 - * - * Contributors: - * Software Technology Group - TU Dresden, Germany; - * DevBoost GmbH - Berlin, Germany - * - initial API and implementation - ******************************************************************************/ -package de.devboost.buildboost.test; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertSame; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -import java.io.File; -import java.util.ArrayList; -import java.util.List; - -import org.junit.Before; -import org.junit.Test; - -import de.devboost.buildboost.artifacts.Plugin; -import de.devboost.buildboost.model.IDependable; -import de.devboost.buildboost.util.Sorter; - -public class PluginSorterTest { - - private Plugin p1; - private Plugin p2; - private Plugin p3; - private Plugin p4; - private Plugin p5; - - @Before - public void setUp() throws Exception { - p1 = createPlugin("p1"); - p2 = createPlugin("p2"); - p3 = createPlugin("p3"); - p4 = createPlugin("p4"); - p5 = createPlugin("p5"); - } - - @Test - public void testSorting1() throws Exception { - p2.addDependency(p1); - p3.addDependency(p2); - p4.addDependency(p3); - p5.addDependency(p4); - p5.addDependency(p1); - - List plugins = new ArrayList(); - plugins.add(p3); - plugins.add(p5); - plugins.add(p2); - plugins.add(p4); - plugins.add(p1); - - plugins = new Sorter().topologicalSort(plugins); - assertSame(p1, plugins.get(0)); - assertSame(p2, plugins.get(1)); - assertSame(p3, plugins.get(2)); - assertSame(p4, plugins.get(3)); - assertSame(p5, plugins.get(4)); - } - - @Test - public void testBucketing1() throws Exception { - p2.addDependency(p1); - p3.addDependency(p2); - p4.addDependency(p3); - p5.addDependency(p4); - - List plugins = new ArrayList(); - plugins.add(p3); - plugins.add(p5); - plugins.add(p2); - plugins.add(p4); - plugins.add(p1); - - List> buckets = new Sorter().sortTopologicallyToBuckets(plugins); - assertBucket(buckets.get(0), p1); - assertBucket(buckets.get(1), p2); - assertBucket(buckets.get(2), p3); - assertBucket(buckets.get(3), p4); - assertBucket(buckets.get(4), p5); - } - - @Test - public void testBucketing2() throws Exception { - p2.addDependency(p1); - p3.addDependency(p1); - p4.addDependency(p3); - p5.addDependency(p1); - p5.addDependency(p3); - - List plugins = new ArrayList(); - plugins.add(p3); - plugins.add(p5); - plugins.add(p2); - plugins.add(p4); - plugins.add(p1); - - List> buckets = new Sorter().sortTopologicallyToBuckets(plugins); - System.out.println("buckets = " + buckets); - assertBucket(buckets.get(0), p1); - assertBucket(buckets.get(1), p2, p3); - assertBucket(buckets.get(2), p4, p5); - } - - private void assertBucket(List bucket, Plugin... expectedContent) { - assertEquals("Size of bucket is wrong", expectedContent.length, bucket.size()); - for (Plugin next : expectedContent) { - assertTrue("Expected element not found in bucket", bucket.contains(next)); - } - } - - private Plugin createPlugin(String name) throws Exception { - return new Plugin(new File(name)); - } - - @Test - public void testSorting2() { - - List plugins = new ArrayList(); - plugins = new Sorter().topologicalSort(plugins); - } - - @Test - public void testSorting3() throws Exception { - p2.addDependency(p1); - - List plugins = new ArrayList(); - // p1 is missing from the list! - plugins.add(p2); - try { - plugins = new Sorter().topologicalSort(plugins); - fail("Sorting must fail, because p1 was not passed to the sorter."); - } catch (Exception e) { - // we expect this - assertTrue(e.getMessage().contains("some dependencies are missing")); - } - } - - @Test - public void testCycle1() throws Exception { - p2.addDependency(p1); - p3.addDependency(p2); - p1.addDependency(p3); - - List cycle = new Sorter().findCycle(p1); - System.out.println("PluginSorterTest.testCycle() " + cycle); - assertNotNull(cycle); - assertEquals(3, cycle.size()); - } - - @Test - public void testCycle2() throws Exception { - p1.addDependency(p1); - - List cycle = new Sorter().findCycle(p1); - System.out.println("PluginSorterTest.testCycle() " + cycle); - assertNotNull(cycle); - assertEquals(1, cycle.size()); - } -} +/******************************************************************************* + * Copyright (c) 2006-2012 + * Software Technology Group, Dresden University of Technology + * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 + * + * All rights reserved. This program and the accompanying materials + * are 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 + * + * Contributors: + * Software Technology Group - TU Dresden, Germany; + * DevBoost GmbH - Berlin, Germany + * - initial API and implementation + ******************************************************************************/ +package de.devboost.buildboost.test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertSame; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +import java.io.File; +import java.util.ArrayList; +import java.util.List; + +import org.junit.Before; +import org.junit.Test; + +import de.devboost.buildboost.artifacts.Plugin; +import de.devboost.buildboost.model.IDependable; +import de.devboost.buildboost.util.Sorter; + +public class PluginSorterTest { + + private Plugin p1; + private Plugin p2; + private Plugin p3; + private Plugin p4; + private Plugin p5; + + @Before + public void setUp() throws Exception { + p1 = createPlugin("p1"); + p2 = createPlugin("p2"); + p3 = createPlugin("p3"); + p4 = createPlugin("p4"); + p5 = createPlugin("p5"); + } + + @Test + public void testSorting1() throws Exception { + p2.addDependency(p1); + p3.addDependency(p2); + p4.addDependency(p3); + p5.addDependency(p4); + p5.addDependency(p1); + + List plugins = new ArrayList(); + plugins.add(p3); + plugins.add(p5); + plugins.add(p2); + plugins.add(p4); + plugins.add(p1); + + plugins = new Sorter().topologicalSort(plugins); + assertSame(p1, plugins.get(0)); + assertSame(p2, plugins.get(1)); + assertSame(p3, plugins.get(2)); + assertSame(p4, plugins.get(3)); + assertSame(p5, plugins.get(4)); + } + + @Test + public void testBucketing1() throws Exception { + p2.addDependency(p1); + p3.addDependency(p2); + p4.addDependency(p3); + p5.addDependency(p4); + + List plugins = new ArrayList(); + plugins.add(p3); + plugins.add(p5); + plugins.add(p2); + plugins.add(p4); + plugins.add(p1); + + List> buckets = new Sorter().sortTopologicallyToBuckets(plugins); + assertBucket(buckets.get(0), p1); + assertBucket(buckets.get(1), p2); + assertBucket(buckets.get(2), p3); + assertBucket(buckets.get(3), p4); + assertBucket(buckets.get(4), p5); + } + + @Test + public void testBucketing2() throws Exception { + p2.addDependency(p1); + p3.addDependency(p1); + p4.addDependency(p3); + p5.addDependency(p1); + p5.addDependency(p3); + + List plugins = new ArrayList(); + plugins.add(p3); + plugins.add(p5); + plugins.add(p2); + plugins.add(p4); + plugins.add(p1); + + List> buckets = new Sorter().sortTopologicallyToBuckets(plugins); + System.out.println("buckets = " + buckets); + assertBucket(buckets.get(0), p1); + assertBucket(buckets.get(1), p2, p3); + assertBucket(buckets.get(2), p4, p5); + } + + private void assertBucket(List bucket, Plugin... expectedContent) { + assertEquals("Size of bucket is wrong", expectedContent.length, bucket.size()); + for (Plugin next : expectedContent) { + assertTrue("Expected element not found in bucket", bucket.contains(next)); + } + } + + private Plugin createPlugin(String name) throws Exception { + return new Plugin(new File(name)); + } + + @Test + public void testSorting2() { + + List plugins = new ArrayList(); + plugins = new Sorter().topologicalSort(plugins); + } + + @Test + public void testSorting3() throws Exception { + p2.addDependency(p1); + + List plugins = new ArrayList(); + // p1 is missing from the list! + plugins.add(p2); + try { + plugins = new Sorter().topologicalSort(plugins); + fail("Sorting must fail, because p1 was not passed to the sorter."); + } catch (Exception e) { + // we expect this + assertTrue(e.getMessage().contains("some dependencies are missing")); + } + } + + @Test + public void testCycle1() throws Exception { + p2.addDependency(p1); + p3.addDependency(p2); + p1.addDependency(p3); + + List cycle = new Sorter().findCycle(p1); + System.out.println("PluginSorterTest.testCycle() " + cycle); + assertNotNull(cycle); + assertEquals(3, cycle.size()); + } + + @Test + public void testCycle2() throws Exception { + p1.addDependency(p1); + + List cycle = new Sorter().findCycle(p1); + System.out.println("PluginSorterTest.testCycle() " + cycle); + assertNotNull(cycle); + assertEquals(1, cycle.size()); + } +} diff --git a/Tests/de.devboost.buildboost.test/src/de/devboost/buildboost/test/ReflectionTest.java b/Tests/de.devboost.buildboost.test/src/de/devboost/buildboost/test/ReflectionTest.java index 5bb0d7e..e30b1ae 100644 --- a/Tests/de.devboost.buildboost.test/src/de/devboost/buildboost/test/ReflectionTest.java +++ b/Tests/de.devboost.buildboost.test/src/de/devboost/buildboost/test/ReflectionTest.java @@ -1,49 +1,49 @@ -/******************************************************************************* - * Copyright (c) 2006-2012 - * Software Technology Group, Dresden University of Technology - * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 - * - * All rights reserved. This program and the accompanying materials - * are 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 - * - * Contributors: - * Software Technology Group - TU Dresden, Germany; - * DevBoost GmbH - Berlin, Germany - * - initial API and implementation - ******************************************************************************/ -package de.devboost.buildboost.test; - -import java.util.List; - -import junit.framework.TestCase; -import de.devboost.buildboost.model.IBuildConfiguration; -import de.devboost.buildboost.model.IBuildStage; - -public class ReflectionTest extends TestCase implements IBuildConfiguration { - - public static void main(String[] args) { - - } - - public void testFindMain() { - try { - ReflectionTest.class.getMethod("main", String[].class); - } catch (SecurityException e) { - fail(e.getMessage()); - } catch (NoSuchMethodException e) { - fail(e.getMessage()); - } - } - - public void testCasting() { - boolean assignableFrom = IBuildConfiguration.class.isAssignableFrom(ReflectionTest.class); - assertTrue(assignableFrom); - } - - @Override - public List getBuildStages(String workspace) { - return null; - } -} +/******************************************************************************* + * Copyright (c) 2006-2012 + * Software Technology Group, Dresden University of Technology + * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 + * + * All rights reserved. This program and the accompanying materials + * are 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 + * + * Contributors: + * Software Technology Group - TU Dresden, Germany; + * DevBoost GmbH - Berlin, Germany + * - initial API and implementation + ******************************************************************************/ +package de.devboost.buildboost.test; + +import java.util.List; + +import junit.framework.TestCase; +import de.devboost.buildboost.model.IBuildConfiguration; +import de.devboost.buildboost.model.IBuildStage; + +public class ReflectionTest extends TestCase implements IBuildConfiguration { + + public static void main(String[] args) { + + } + + public void testFindMain() { + try { + ReflectionTest.class.getMethod("main", String[].class); + } catch (SecurityException e) { + fail(e.getMessage()); + } catch (NoSuchMethodException e) { + fail(e.getMessage()); + } + } + + public void testCasting() { + boolean assignableFrom = IBuildConfiguration.class.isAssignableFrom(ReflectionTest.class); + assertTrue(assignableFrom); + } + + @Override + public List getBuildStages(String workspace) { + return null; + } +} diff --git a/Universal/de.devboost.buildboost.universal.build/boost/build.xml b/Universal/de.devboost.buildboost.universal.build/boost/build.xml index bd20c88..191ebd5 100644 --- a/Universal/de.devboost.buildboost.universal.build/boost/build.xml +++ b/Universal/de.devboost.buildboost.universal.build/boost/build.xml @@ -1,113 +1,113 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Universal/de.devboost.buildboost.universal.build/src/de/devboost/buildboost/universal/build/BuildScriptGenerator.java b/Universal/de.devboost.buildboost.universal.build/src/de/devboost/buildboost/universal/build/BuildScriptGenerator.java index 4586199..8310292 100644 --- a/Universal/de.devboost.buildboost.universal.build/src/de/devboost/buildboost/universal/build/BuildScriptGenerator.java +++ b/Universal/de.devboost.buildboost.universal.build/src/de/devboost/buildboost/universal/build/BuildScriptGenerator.java @@ -1,134 +1,134 @@ -/******************************************************************************* - * Copyright (c) 2006-2012 - * Software Technology Group, Dresden University of Technology - * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 - * - * All rights reserved. This program and the accompanying materials - * are 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 - * - * Contributors: - * Software Technology Group - TU Dresden, Germany; - * DevBoost GmbH - Berlin, Germany - * - initial API and implementation - ******************************************************************************/ -package de.devboost.buildboost.universal.build; - -import static de.devboost.buildboost.IConstants.ARTIFACTS_FOLDER; -import static de.devboost.buildboost.IConstants.BUILD_BOOST_BIN_FOLDER; -import static de.devboost.buildboost.IConstants.BUILD_FOLDER; -import static de.devboost.buildboost.IConstants.REPOS_FOLDER; - -import java.io.File; -import java.lang.reflect.Method; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; - -import de.devboost.buildboost.model.IBuildConfiguration; -import de.devboost.buildboost.model.IBuildStage; -import de.devboost.buildboost.model.IUniversalBuildStage; - -public class BuildScriptGenerator implements IBuildConfiguration { - - @Override - public List getBuildStages(String workspace) { - Map properties = new LinkedHashMap(); - - File buildFolder = new File(workspace, BUILD_FOLDER); - File buildBoostBinFolder = new File(buildFolder, BUILD_BOOST_BIN_FOLDER); - - File reposFolder = new File(workspace, REPOS_FOLDER); - File artifactsFolder = new File(buildFolder, ARTIFACTS_FOLDER); - - properties.put("reposfolder", reposFolder.getAbsolutePath()); - properties.put("artifactsfolder", artifactsFolder.getAbsolutePath()); - - List stages = collectStages(buildBoostBinFolder); - - setPropertiesInStages(properties, stages); - - System.out.println("Boost! Universal Build: " + stages); - - return stages; - } - - protected void setPropertiesInStages(Map properties, - List stages) { - for (IBuildStage stage : stages) { - for (Method m : stage.getClass().getDeclaredMethods()) { - if (m.getName().startsWith("set")) { - String propertyName = m.getName().substring(3).toLowerCase(); - String propertyValue = properties.get(propertyName); - if (propertyValue == null) { - System.out.println("WARNING: Setting property to 'null'" + - " - stage " + stage + " - property " + propertyName); - } - try { - m.invoke(stage, propertyValue); - } catch (Exception e) { - e.printStackTrace(); - } - } - } - } - } - - protected List collectStages(File buildBoostBinFolder) { - List result = new ArrayList(); - List javaClassNames = new ArrayList(); - collectClasses(javaClassNames, buildBoostBinFolder, null); - for (String className : javaClassNames) { - try { - Class buildStageCand = Class.forName(className); - if (IUniversalBuildStage.class.isAssignableFrom(buildStageCand) && !buildStageCand.isInterface()) { - IUniversalBuildStage newInstance = (IUniversalBuildStage) buildStageCand.newInstance(); - result.add(newInstance); - } - } catch (Exception e) { - e.printStackTrace(); - } - } - - Collections.sort(result, new Comparator() { - @Override - public int compare(IBuildStage bs1, IBuildStage bs2) { - return new Integer(((IUniversalBuildStage)bs1).getPriority()).compareTo( - new Integer(((IUniversalBuildStage)bs2).getPriority())); - } - }); - - return result; - } - - protected void collectClasses(List javaClassNames, File file, String name) { - if (isHidden(file)) { - return; - } - if (file.getName().endsWith(".class") && !file.getName().contains("$")) { - name = name + file.getName().substring(0, file.getName().length() - 6); - javaClassNames.add(name); - return; - } - if (file.isDirectory()) { - for (File child : file.listFiles()) { - String nextName; - if (name == null) { - nextName = ""; - } else { - nextName = name + file.getName() + "."; - } - collectClasses(javaClassNames, child, nextName); - } - } - } - - private boolean isHidden(File file) { - return file.getName().startsWith("."); - } - -} +/******************************************************************************* + * Copyright (c) 2006-2012 + * Software Technology Group, Dresden University of Technology + * DevBoost GmbH, Berlin, Amtsgericht Charlottenburg, HRB 140026 + * + * All rights reserved. This program and the accompanying materials + * are 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 + * + * Contributors: + * Software Technology Group - TU Dresden, Germany; + * DevBoost GmbH - Berlin, Germany + * - initial API and implementation + ******************************************************************************/ +package de.devboost.buildboost.universal.build; + +import static de.devboost.buildboost.IConstants.ARTIFACTS_FOLDER; +import static de.devboost.buildboost.IConstants.BUILD_BOOST_BIN_FOLDER; +import static de.devboost.buildboost.IConstants.BUILD_FOLDER; +import static de.devboost.buildboost.IConstants.REPOS_FOLDER; + +import java.io.File; +import java.lang.reflect.Method; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; + +import de.devboost.buildboost.model.IBuildConfiguration; +import de.devboost.buildboost.model.IBuildStage; +import de.devboost.buildboost.model.IUniversalBuildStage; + +public class BuildScriptGenerator implements IBuildConfiguration { + + @Override + public List getBuildStages(String workspace) { + Map properties = new LinkedHashMap(); + + File buildFolder = new File(workspace, BUILD_FOLDER); + File buildBoostBinFolder = new File(buildFolder, BUILD_BOOST_BIN_FOLDER); + + File reposFolder = new File(workspace, REPOS_FOLDER); + File artifactsFolder = new File(buildFolder, ARTIFACTS_FOLDER); + + properties.put("reposfolder", reposFolder.getAbsolutePath()); + properties.put("artifactsfolder", artifactsFolder.getAbsolutePath()); + + List stages = collectStages(buildBoostBinFolder); + + setPropertiesInStages(properties, stages); + + System.out.println("Boost! Universal Build: " + stages); + + return stages; + } + + protected void setPropertiesInStages(Map properties, + List stages) { + for (IBuildStage stage : stages) { + for (Method m : stage.getClass().getDeclaredMethods()) { + if (m.getName().startsWith("set")) { + String propertyName = m.getName().substring(3).toLowerCase(); + String propertyValue = properties.get(propertyName); + if (propertyValue == null) { + System.out.println("WARNING: Setting property to 'null'" + + " - stage " + stage + " - property " + propertyName); + } + try { + m.invoke(stage, propertyValue); + } catch (Exception e) { + e.printStackTrace(); + } + } + } + } + } + + protected List collectStages(File buildBoostBinFolder) { + List result = new ArrayList(); + List javaClassNames = new ArrayList(); + collectClasses(javaClassNames, buildBoostBinFolder, null); + for (String className : javaClassNames) { + try { + Class buildStageCand = Class.forName(className); + if (IUniversalBuildStage.class.isAssignableFrom(buildStageCand) && !buildStageCand.isInterface()) { + IUniversalBuildStage newInstance = (IUniversalBuildStage) buildStageCand.newInstance(); + result.add(newInstance); + } + } catch (Exception e) { + e.printStackTrace(); + } + } + + Collections.sort(result, new Comparator() { + @Override + public int compare(IBuildStage bs1, IBuildStage bs2) { + return new Integer(((IUniversalBuildStage)bs1).getPriority()).compareTo( + new Integer(((IUniversalBuildStage)bs2).getPriority())); + } + }); + + return result; + } + + protected void collectClasses(List javaClassNames, File file, String name) { + if (isHidden(file)) { + return; + } + if (file.getName().endsWith(".class") && !file.getName().contains("$")) { + name = name + file.getName().substring(0, file.getName().length() - 6); + javaClassNames.add(name); + return; + } + if (file.isDirectory()) { + for (File child : file.listFiles()) { + String nextName; + if (name == null) { + nextName = ""; + } else { + nextName = name + file.getName() + "."; + } + collectClasses(javaClassNames, child, nextName); + } + } + } + + private boolean isHidden(File file) { + return file.getName().startsWith("."); + } + +}