You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@marmotta.apache.org by ja...@apache.org on 2013/02/26 15:32:17 UTC
[2/3] git commit: MARMOTTA-107: renamed packages in maven-plugins
MARMOTTA-112: created maven plugin to lookup artifacts in known repositories
MARMOTTA-107: renamed packages in maven-plugins
MARMOTTA-112: created maven plugin to lookup artifacts in known repositories
Project: http://git-wip-us.apache.org/repos/asf/incubator-marmotta/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-marmotta/commit/57f1c085
Tree: http://git-wip-us.apache.org/repos/asf/incubator-marmotta/tree/57f1c085
Diff: http://git-wip-us.apache.org/repos/asf/incubator-marmotta/diff/57f1c085
Branch: refs/heads/master
Commit: 57f1c085ea4e090469351765c53f6456f33fb522
Parents: 350c3ab
Author: Jakob Frank <ja...@apache.org>
Authored: Tue Feb 26 15:24:24 2013 +0100
Committer: Jakob Frank <ja...@apache.org>
Committed: Tue Feb 26 15:29:02 2013 +0100
----------------------------------------------------------------------
build/plugins/buildinfo-maven-plugin/pom.xml | 4 +-
.../plugins/buildinfo/AbstractInfoProvider.java | 65 ---
.../maven/plugins/buildinfo/BuildInfoMojo.java | 124 -----
.../maven/plugins/buildinfo/GitInfoProvider.java | 87 ----
.../maven/plugins/buildinfo/InfoProvider.java | 34 --
.../plugins/buildinfo/MercurialInfoProvider.java | 103 ----
.../plugins/buildinfo/ProjectInfoProvider.java | 47 --
.../plugins/buildinfo/AbstractInfoProvider.java | 65 +++
.../maven/plugins/buildinfo/BuildInfoMojo.java | 124 +++++
.../maven/plugins/buildinfo/GitInfoProvider.java | 86 ++++
.../maven/plugins/buildinfo/InfoProvider.java | 34 ++
.../plugins/buildinfo/MercurialInfoProvider.java | 103 ++++
.../plugins/buildinfo/ProjectInfoProvider.java | 47 ++
build/plugins/marmotta-maven-plugin/pom.xml | 47 +-
.../maven/plugins/marmotta/MarmottaMojo.java | 16 +
build/plugins/pom.xml | 81 +++-
build/plugins/refpack-maven-plugin/pom.xml | 8 +-
.../maven/plugins/refpack/RefPackMojo.java | 379 ---------------
.../maven/plugins/refpack/RefPackMojo.java | 379 +++++++++++++++
build/plugins/repocheck-maven-plugin/pom.xml | 61 +++
.../plugins/repochecker/LogMatrixPrinter.java | 70 +++
.../maven/plugins/repochecker/MatrixPrinter.java | 17 +
.../plugins/repochecker/RepositoryCheckerMojo.java | 304 ++++++++++++
.../plugins/repochecker/SilentMatrixPrinter.java | 23 +
parent/pom.xml | 176 ++++---
25 files changed, 1525 insertions(+), 959 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/57f1c085/build/plugins/buildinfo-maven-plugin/pom.xml
----------------------------------------------------------------------
diff --git a/build/plugins/buildinfo-maven-plugin/pom.xml b/build/plugins/buildinfo-maven-plugin/pom.xml
index a4bfce3..690397a 100644
--- a/build/plugins/buildinfo-maven-plugin/pom.xml
+++ b/build/plugins/buildinfo-maven-plugin/pom.xml
@@ -94,8 +94,8 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
- <source>1.5</source>
- <target>1.5</target>
+ <source>1.6</source>
+ <target>1.6</target>
</configuration>
</plugin>
<plugin>
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/57f1c085/build/plugins/buildinfo-maven-plugin/src/main/java/at/newmedialab/maven/plugins/buildinfo/AbstractInfoProvider.java
----------------------------------------------------------------------
diff --git a/build/plugins/buildinfo-maven-plugin/src/main/java/at/newmedialab/maven/plugins/buildinfo/AbstractInfoProvider.java b/build/plugins/buildinfo-maven-plugin/src/main/java/at/newmedialab/maven/plugins/buildinfo/AbstractInfoProvider.java
deleted file mode 100644
index bca92e5..0000000
--- a/build/plugins/buildinfo-maven-plugin/src/main/java/at/newmedialab/maven/plugins/buildinfo/AbstractInfoProvider.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/**
- * Copyright (C) 2013 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package at.newmedialab.maven.plugins.buildinfo;
-
-import org.apache.maven.project.MavenProject;
-
-import java.io.File;
-import java.io.FileNotFoundException;
-
-/**
- * Date: 2/6/12
- * Time: 10:31 AM
- *
- * @author <a href="http://www.rodiontsev.com">Dmitry Rodiontsev</a>
- */
-public abstract class AbstractInfoProvider implements InfoProvider {
-
- private File lookupDirectory(MavenProject project, String child) throws FileNotFoundException {
- File dir;
-
- //Walk up the project parent hierarchy seeking the .hg directory
- MavenProject mavenProject = project;
- while (mavenProject != null) {
- dir = new File(mavenProject.getBasedir(), child);
- if (dir.exists() && dir.isDirectory()) {
- return dir;
- }
- // If we've reached the top-level parent and not found the .git directory, look one level further up
- if (mavenProject.getParent() == null && mavenProject.getBasedir() != null) {
- dir = new File(mavenProject.getBasedir().getParentFile(), child);
- if (dir.exists() && dir.isDirectory()) {
- return dir;
- }
- }
- mavenProject = mavenProject.getParent();
- }
-
- throw new FileNotFoundException("Could not find " + child + " directory");
- }
-
- protected boolean isActive(MavenProject project, String child) {
- boolean result = false;
- try {
- File dir = lookupDirectory(project, child);
- result = (dir.exists() && dir.isDirectory()); //redundant check
- } catch (FileNotFoundException e) {
- //do nothing
- }
- return result;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/57f1c085/build/plugins/buildinfo-maven-plugin/src/main/java/at/newmedialab/maven/plugins/buildinfo/BuildInfoMojo.java
----------------------------------------------------------------------
diff --git a/build/plugins/buildinfo-maven-plugin/src/main/java/at/newmedialab/maven/plugins/buildinfo/BuildInfoMojo.java b/build/plugins/buildinfo-maven-plugin/src/main/java/at/newmedialab/maven/plugins/buildinfo/BuildInfoMojo.java
deleted file mode 100644
index b8b21dc..0000000
--- a/build/plugins/buildinfo-maven-plugin/src/main/java/at/newmedialab/maven/plugins/buildinfo/BuildInfoMojo.java
+++ /dev/null
@@ -1,124 +0,0 @@
-/**
- * Copyright (C) 2013 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package at.newmedialab.maven.plugins.buildinfo;
-
-import org.apache.commons.io.IOUtils;
-import org.apache.maven.model.Build;
-import org.apache.maven.plugin.AbstractMojo;
-import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.plugin.MojoFailureException;
-import org.apache.maven.project.MavenProject;
-
-import java.io.*;
-import java.net.UnknownHostException;
-import java.util.HashMap;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.ServiceLoader;
-
-/**
- * Date: 13.05.2011
- * Time: 12:00:00
- *
- * @author <a href="http://www.rodiontsev.com">Dmitry Rodiontsev</a>
- *
- * @goal extract
- * @phase prepare-package
- */
-public class BuildInfoMojo extends AbstractMojo {
- private static final String BUILD_INFO_FILE_NAME = "build.info";
- private static final String DEFAULT_VALUE = "";
-
- /**
- * @parameter default-value="${project}"
- * @required
- * @readonly
- */
- private MavenProject project;
-
-
- private static Map<String,String> lmfCommiters = new HashMap<String, String>();
- static {
- lmfCommiters.put("sschaffe", "Sebastian Schaffert <se...@salzburgresearch.at>");
- lmfCommiters.put("tkurz", "Thomas Kurz <th...@salzburgresearch.at>");
- lmfCommiters.put("dglachs", "Dietmar Glachs <di...@salzburgresearch.at>");
- lmfCommiters.put("jfrank", "Jakob Frank <ja...@salzburgresearch.at>");
- lmfCommiters.put("jakob","Jakob Frank <ja...@salzburgresearch.at>");
- lmfCommiters.put("sfernandez","Sergio Fernández <se...@salzburgresearch.at>");
- }
-
-
- /**
- * @parameter
- */
- private List<String> systemProperties;
-
- public void execute() throws MojoExecutionException, MojoFailureException {
- Map<String, String> map = new LinkedHashMap<String, String>();
-
- for (InfoProvider provider : ServiceLoader.load(InfoProvider.class)) {
- if (provider.isActive(project)) {
- map.putAll(provider.getInfo(project));
- }
- }
-
- if (systemProperties != null) {
- for (String property : systemProperties) {
- map.put(property, System.getProperty(property, DEFAULT_VALUE));
- }
- }
-
- // operating system
- map.put("build.os", System.getProperty("os.name") + " " + System.getProperty("os.version") + "/" + System.getProperty("os.arch"));
-
- // host name
- try {
- map.put("build.host",java.net.InetAddress.getLocalHost().getHostName());
- } catch (UnknownHostException e) {
- }
-
- // user name
- if(lmfCommiters.get(System.getProperty("user.name")) != null) {
- map.put("build.user", lmfCommiters.get(System.getProperty("user.name")));
- } else {
- map.put("build.user", System.getProperty("user.name"));
- }
-
- Build build = project.getBuild();
- StringBuilder filename = new StringBuilder();
- filename.append(build.getOutputDirectory()).append(File.separator).append(BUILD_INFO_FILE_NAME);
-
- getLog().info("Writing to file " + filename.toString());
-
- Writer out = null;
- try {
- out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(filename.toString()), "UTF-8"));
- for (Map.Entry<String, String> entry : map.entrySet()) {
- out.write(entry.getKey());
- out.write(" = ");
- out.write(entry.getValue());
- out.write("\n");
- }
- out.flush();
- } catch (IOException ioe) {
- getLog().warn(ioe.getMessage());
- } finally {
- IOUtils.closeQuietly(out);
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/57f1c085/build/plugins/buildinfo-maven-plugin/src/main/java/at/newmedialab/maven/plugins/buildinfo/GitInfoProvider.java
----------------------------------------------------------------------
diff --git a/build/plugins/buildinfo-maven-plugin/src/main/java/at/newmedialab/maven/plugins/buildinfo/GitInfoProvider.java b/build/plugins/buildinfo-maven-plugin/src/main/java/at/newmedialab/maven/plugins/buildinfo/GitInfoProvider.java
deleted file mode 100644
index a2d3590..0000000
--- a/build/plugins/buildinfo-maven-plugin/src/main/java/at/newmedialab/maven/plugins/buildinfo/GitInfoProvider.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/**
- * Copyright (C) 2013 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package at.newmedialab.maven.plugins.buildinfo;
-
-import org.apache.maven.project.MavenProject;
-import org.apache.maven.scm.CommandParameters;
-import org.apache.maven.scm.ScmException;
-import org.apache.maven.scm.ScmFileSet;
-import org.apache.maven.scm.command.info.InfoItem;
-import org.apache.maven.scm.command.info.InfoScmResult;
-import org.apache.maven.scm.log.DefaultLog;
-import org.apache.maven.scm.log.ScmLogger;
-import org.apache.maven.scm.provider.ScmProviderRepository;
-import org.apache.maven.scm.provider.git.command.GitCommand;
-import org.apache.maven.scm.provider.git.gitexe.GitExeScmProvider;
-import org.apache.maven.scm.provider.git.repository.GitScmProviderRepository;
-
-import java.io.File;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- * Date: 2/6/12
- * Time: 4:58 AM
- *
- * @author <a href="http://www.rodiontsev.com">Dmitry Rodiontsev</a>
- */
-public class GitInfoProvider extends AbstractInfoProvider {
- private static final String DOT_GIT = ".git";
-
- public boolean isActive(MavenProject project) {
- return isActive(project, DOT_GIT);
- }
-
- @SuppressWarnings("unchecked")
- public Map<String, String> getInfo(MavenProject project) {
- File basedir = project.getBasedir();
-
- InfoScmResult result = null;
-
- ScmLogger logger = new DefaultLog();
-
- GitCommand command = new GitExeScmProvider().getInfoCommand();
- command.setLogger(logger);
- try {
- ScmProviderRepository repository = new GitScmProviderRepository(basedir.getAbsolutePath());
- ScmFileSet fileSet = new ScmFileSet(basedir);
- CommandParameters parameters = new CommandParameters();
- result = (InfoScmResult) command.execute(repository, fileSet, parameters);
- } catch (ScmException e) {
- if (logger.isErrorEnabled()) {
- logger.error(e.getMessage());
- }
- }
-
- Map<String, String> info = new LinkedHashMap<String, String>();
- if (result != null) {
- if (result.isSuccess()) {
- List<InfoItem> items = result.getInfoItems();
- if ((items != null) && (items.size() == 1)) {
- info.put("git.revision", items.get(0).getRevision());
- } else {
- info.put("git.error", "The command returned incorrect number of arguments");
- }
- } else {
- info.put("git.error", result.getProviderMessage());
- }
-
- }
- return info;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/57f1c085/build/plugins/buildinfo-maven-plugin/src/main/java/at/newmedialab/maven/plugins/buildinfo/InfoProvider.java
----------------------------------------------------------------------
diff --git a/build/plugins/buildinfo-maven-plugin/src/main/java/at/newmedialab/maven/plugins/buildinfo/InfoProvider.java b/build/plugins/buildinfo-maven-plugin/src/main/java/at/newmedialab/maven/plugins/buildinfo/InfoProvider.java
deleted file mode 100644
index 5a9a767..0000000
--- a/build/plugins/buildinfo-maven-plugin/src/main/java/at/newmedialab/maven/plugins/buildinfo/InfoProvider.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/**
- * Copyright (C) 2013 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package at.newmedialab.maven.plugins.buildinfo;
-
-import org.apache.maven.project.MavenProject;
-
-import java.util.Map;
-
-/**
- * Date: 5/17/11
- * Time: 2:55 PM
- *
- * @author <a href="http://www.rodiontsev.com">Dmitry Rodiontsev</a>
- */
-public interface InfoProvider {
-
- boolean isActive(MavenProject project);
-
- Map<String, String> getInfo(MavenProject project);
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/57f1c085/build/plugins/buildinfo-maven-plugin/src/main/java/at/newmedialab/maven/plugins/buildinfo/MercurialInfoProvider.java
----------------------------------------------------------------------
diff --git a/build/plugins/buildinfo-maven-plugin/src/main/java/at/newmedialab/maven/plugins/buildinfo/MercurialInfoProvider.java b/build/plugins/buildinfo-maven-plugin/src/main/java/at/newmedialab/maven/plugins/buildinfo/MercurialInfoProvider.java
deleted file mode 100644
index 75c37e0..0000000
--- a/build/plugins/buildinfo-maven-plugin/src/main/java/at/newmedialab/maven/plugins/buildinfo/MercurialInfoProvider.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/**
- * Copyright (C) 2013 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package at.newmedialab.maven.plugins.buildinfo;
-
-import org.apache.maven.project.MavenProject;
-import org.apache.maven.scm.ScmException;
-import org.apache.maven.scm.ScmResult;
-import org.apache.maven.scm.log.DefaultLog;
-import org.apache.maven.scm.log.ScmLogger;
-import org.apache.maven.scm.provider.hg.HgUtils;
-import org.apache.maven.scm.provider.hg.command.HgCommandConstants;
-import org.apache.maven.scm.provider.hg.command.HgConsumer;
-
-import java.util.LinkedHashMap;
-import java.util.Map;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-/**
- * Date: 5/17/11
- * Time: 3:08 PM
- *
- * @author <a href="http://www.rodiontsev.com">Dmitry Rodiontsev</a>
- */
-public class MercurialInfoProvider extends AbstractInfoProvider {
- private static final String DOT_HG = ".hg";
- private static final Pattern HG_OUTPUT_PATTERN = Pattern.compile("^(\\S+)\\s(\\S+)\\s(.+)$");
-
- public boolean isActive(MavenProject project) {
- return isActive(project, DOT_HG);
- }
-
- public Map<String, String> getInfo(MavenProject project) {
- ScmLogger logger = new DefaultLog();
- HgLogConsumer consumer = new HgLogConsumer(logger);
- ScmResult result = null;
- try {
- result = HgUtils.execute(
- consumer,
- logger,
- project.getBasedir(),
- new String[]{HgCommandConstants.REVNO_CMD, "-n", "-i", "-b"});
- } catch (ScmException e) {
- if (logger.isErrorEnabled()) {
- logger.error(e.getMessage());
- }
- }
-
- Map<String, String> info = new LinkedHashMap<String, String>();
- if (result != null) {
- if (result.isSuccess()) {
- String output = result.getCommandOutput();
- if (output != null) {
- Matcher matcher = HG_OUTPUT_PATTERN.matcher(output);
- if (matcher.find() && matcher.groupCount() == 3) {
- StringBuilder changeset = new StringBuilder();
- changeset.append("r").append(matcher.group(2)).append(":").append(matcher.group(1));
- info.put("build.changeset", changeset.toString());
- info.put("build.branch", matcher.group(3));
- info.put("build.revision", matcher.group(2));
- info.put("build.revhash", matcher.group(1));
- } else {
- info.put("hg.error", "The command returned incorrect number of arguments");
- }
- }
- } else {
- info.put("hg.error", result.getProviderMessage());
- }
- }
- return info;
- }
-}
-
-class HgLogConsumer extends HgConsumer {
- private final StringBuilder out = new StringBuilder();
-
- public HgLogConsumer(ScmLogger logger) {
- super(logger);
- }
-
- @Override
- public void consumeLine(String line) {
- out.append(line).append("\n");
- }
-
- @Override
- public String getStdErr() {
- return out.toString();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/57f1c085/build/plugins/buildinfo-maven-plugin/src/main/java/at/newmedialab/maven/plugins/buildinfo/ProjectInfoProvider.java
----------------------------------------------------------------------
diff --git a/build/plugins/buildinfo-maven-plugin/src/main/java/at/newmedialab/maven/plugins/buildinfo/ProjectInfoProvider.java b/build/plugins/buildinfo-maven-plugin/src/main/java/at/newmedialab/maven/plugins/buildinfo/ProjectInfoProvider.java
deleted file mode 100644
index b92bcf6..0000000
--- a/build/plugins/buildinfo-maven-plugin/src/main/java/at/newmedialab/maven/plugins/buildinfo/ProjectInfoProvider.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/**
- * Copyright (C) 2013 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package at.newmedialab.maven.plugins.buildinfo;
-
-import org.apache.commons.lang.time.DateFormatUtils;
-import org.apache.maven.project.MavenProject;
-
-import java.util.Date;
-import java.util.LinkedHashMap;
-import java.util.Map;
-
-/**
- * Date: 22.06.11
- * Time: 23:21
- *
- * @author <a href="http://www.rodiontsev.com">Dmitry Rodiontsev</a>
- */
-public class ProjectInfoProvider implements InfoProvider {
-
- public boolean isActive(MavenProject project) {
- return true;
- }
-
- public Map<String, String> getInfo(MavenProject project) {
- Date date = new Date();
- Map<String, String> info = new LinkedHashMap<String, String>();
- info.put("project.name", project.getName());
- info.put("build.module", project.getArtifactId());
- info.put("build.version", project.getVersion());
- info.put("build.timestamp", DateFormatUtils.format(date, "EEE, dd MMM yyyy HH:mm:ss z"));
- return info;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/57f1c085/build/plugins/buildinfo-maven-plugin/src/main/java/org/apache/marmotta/maven/plugins/buildinfo/AbstractInfoProvider.java
----------------------------------------------------------------------
diff --git a/build/plugins/buildinfo-maven-plugin/src/main/java/org/apache/marmotta/maven/plugins/buildinfo/AbstractInfoProvider.java b/build/plugins/buildinfo-maven-plugin/src/main/java/org/apache/marmotta/maven/plugins/buildinfo/AbstractInfoProvider.java
new file mode 100644
index 0000000..8af6cfe
--- /dev/null
+++ b/build/plugins/buildinfo-maven-plugin/src/main/java/org/apache/marmotta/maven/plugins/buildinfo/AbstractInfoProvider.java
@@ -0,0 +1,65 @@
+/**
+ * Copyright (C) 2013 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.marmotta.maven.plugins.buildinfo;
+
+import org.apache.maven.project.MavenProject;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+
+/**
+ * Date: 2/6/12
+ * Time: 10:31 AM
+ *
+ * @author <a href="http://www.rodiontsev.com">Dmitry Rodiontsev</a>
+ */
+public abstract class AbstractInfoProvider implements InfoProvider {
+
+ private File lookupDirectory(MavenProject project, String child) throws FileNotFoundException {
+ File dir;
+
+ //Walk up the project parent hierarchy seeking the .hg directory
+ MavenProject mavenProject = project;
+ while (mavenProject != null) {
+ dir = new File(mavenProject.getBasedir(), child);
+ if (dir.exists() && dir.isDirectory()) {
+ return dir;
+ }
+ // If we've reached the top-level parent and not found the .git directory, look one level further up
+ if (mavenProject.getParent() == null && mavenProject.getBasedir() != null) {
+ dir = new File(mavenProject.getBasedir().getParentFile(), child);
+ if (dir.exists() && dir.isDirectory()) {
+ return dir;
+ }
+ }
+ mavenProject = mavenProject.getParent();
+ }
+
+ throw new FileNotFoundException("Could not find " + child + " directory");
+ }
+
+ protected boolean isActive(MavenProject project, String child) {
+ boolean result = false;
+ try {
+ File dir = lookupDirectory(project, child);
+ result = (dir.exists() && dir.isDirectory()); //redundant check
+ } catch (FileNotFoundException e) {
+ //do nothing
+ }
+ return result;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/57f1c085/build/plugins/buildinfo-maven-plugin/src/main/java/org/apache/marmotta/maven/plugins/buildinfo/BuildInfoMojo.java
----------------------------------------------------------------------
diff --git a/build/plugins/buildinfo-maven-plugin/src/main/java/org/apache/marmotta/maven/plugins/buildinfo/BuildInfoMojo.java b/build/plugins/buildinfo-maven-plugin/src/main/java/org/apache/marmotta/maven/plugins/buildinfo/BuildInfoMojo.java
new file mode 100644
index 0000000..dc7ad9a
--- /dev/null
+++ b/build/plugins/buildinfo-maven-plugin/src/main/java/org/apache/marmotta/maven/plugins/buildinfo/BuildInfoMojo.java
@@ -0,0 +1,124 @@
+/**
+ * Copyright (C) 2013 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.marmotta.maven.plugins.buildinfo;
+
+import org.apache.commons.io.IOUtils;
+import org.apache.maven.model.Build;
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.project.MavenProject;
+
+import java.io.*;
+import java.net.UnknownHostException;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.ServiceLoader;
+
+/**
+ * Date: 13.05.2011
+ * Time: 12:00:00
+ *
+ * @author <a href="http://www.rodiontsev.com">Dmitry Rodiontsev</a>
+ *
+ * @goal extract
+ * @phase prepare-package
+ */
+public class BuildInfoMojo extends AbstractMojo {
+ private static final String BUILD_INFO_FILE_NAME = "build.info";
+ private static final String DEFAULT_VALUE = "";
+
+ /**
+ * @parameter default-value="${project}"
+ * @required
+ * @readonly
+ */
+ private MavenProject project;
+
+
+ private static Map<String,String> lmfCommiters = new HashMap<String, String>();
+ static {
+ lmfCommiters.put("sschaffe", "Sebastian Schaffert <se...@salzburgresearch.at>");
+ lmfCommiters.put("tkurz", "Thomas Kurz <th...@salzburgresearch.at>");
+ lmfCommiters.put("dglachs", "Dietmar Glachs <di...@salzburgresearch.at>");
+ lmfCommiters.put("jfrank", "Jakob Frank <ja...@salzburgresearch.at>");
+ lmfCommiters.put("jakob","Jakob Frank <ja...@salzburgresearch.at>");
+ lmfCommiters.put("sfernandez","Sergio Fernández <se...@salzburgresearch.at>");
+ }
+
+
+ /**
+ * @parameter
+ */
+ private List<String> systemProperties;
+
+ public void execute() throws MojoExecutionException, MojoFailureException {
+ Map<String, String> map = new LinkedHashMap<String, String>();
+
+ for (InfoProvider provider : ServiceLoader.load(InfoProvider.class)) {
+ if (provider.isActive(project)) {
+ map.putAll(provider.getInfo(project));
+ }
+ }
+
+ if (systemProperties != null) {
+ for (String property : systemProperties) {
+ map.put(property, System.getProperty(property, DEFAULT_VALUE));
+ }
+ }
+
+ // operating system
+ map.put("build.os", System.getProperty("os.name") + " " + System.getProperty("os.version") + "/" + System.getProperty("os.arch"));
+
+ // host name
+ try {
+ map.put("build.host",java.net.InetAddress.getLocalHost().getHostName());
+ } catch (UnknownHostException e) {
+ }
+
+ // user name
+ if(lmfCommiters.get(System.getProperty("user.name")) != null) {
+ map.put("build.user", lmfCommiters.get(System.getProperty("user.name")));
+ } else {
+ map.put("build.user", System.getProperty("user.name"));
+ }
+
+ Build build = project.getBuild();
+ StringBuilder filename = new StringBuilder();
+ filename.append(build.getOutputDirectory()).append(File.separator).append(BUILD_INFO_FILE_NAME);
+
+ getLog().info("Writing to file " + filename.toString());
+
+ Writer out = null;
+ try {
+ out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(filename.toString()), "UTF-8"));
+ for (Map.Entry<String, String> entry : map.entrySet()) {
+ out.write(entry.getKey());
+ out.write(" = ");
+ out.write(entry.getValue());
+ out.write("\n");
+ }
+ out.flush();
+ } catch (IOException ioe) {
+ getLog().warn(ioe.getMessage());
+ } finally {
+ IOUtils.closeQuietly(out);
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/57f1c085/build/plugins/buildinfo-maven-plugin/src/main/java/org/apache/marmotta/maven/plugins/buildinfo/GitInfoProvider.java
----------------------------------------------------------------------
diff --git a/build/plugins/buildinfo-maven-plugin/src/main/java/org/apache/marmotta/maven/plugins/buildinfo/GitInfoProvider.java b/build/plugins/buildinfo-maven-plugin/src/main/java/org/apache/marmotta/maven/plugins/buildinfo/GitInfoProvider.java
new file mode 100644
index 0000000..b1a4bb5
--- /dev/null
+++ b/build/plugins/buildinfo-maven-plugin/src/main/java/org/apache/marmotta/maven/plugins/buildinfo/GitInfoProvider.java
@@ -0,0 +1,86 @@
+/**
+ * Copyright (C) 2013 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.marmotta.maven.plugins.buildinfo;
+
+import org.apache.maven.project.MavenProject;
+import org.apache.maven.scm.CommandParameters;
+import org.apache.maven.scm.ScmException;
+import org.apache.maven.scm.ScmFileSet;
+import org.apache.maven.scm.command.info.InfoItem;
+import org.apache.maven.scm.command.info.InfoScmResult;
+import org.apache.maven.scm.log.DefaultLog;
+import org.apache.maven.scm.log.ScmLogger;
+import org.apache.maven.scm.provider.ScmProviderRepository;
+import org.apache.maven.scm.provider.git.command.GitCommand;
+import org.apache.maven.scm.provider.git.gitexe.GitExeScmProvider;
+import org.apache.maven.scm.provider.git.repository.GitScmProviderRepository;
+
+import java.io.File;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Date: 2/6/12
+ * Time: 4:58 AM
+ *
+ * @author <a href="http://www.rodiontsev.com">Dmitry Rodiontsev</a>
+ */
+public class GitInfoProvider extends AbstractInfoProvider {
+ private static final String DOT_GIT = ".git";
+
+ public boolean isActive(MavenProject project) {
+ return isActive(project, DOT_GIT);
+ }
+
+ public Map<String, String> getInfo(MavenProject project) {
+ File basedir = project.getBasedir();
+
+ InfoScmResult result = null;
+
+ ScmLogger logger = new DefaultLog();
+
+ GitCommand command = new GitExeScmProvider().getInfoCommand();
+ command.setLogger(logger);
+ try {
+ ScmProviderRepository repository = new GitScmProviderRepository(basedir.getAbsolutePath());
+ ScmFileSet fileSet = new ScmFileSet(basedir);
+ CommandParameters parameters = new CommandParameters();
+ result = (InfoScmResult) command.execute(repository, fileSet, parameters);
+ } catch (ScmException e) {
+ if (logger.isErrorEnabled()) {
+ logger.error(e.getMessage());
+ }
+ }
+
+ Map<String, String> info = new LinkedHashMap<String, String>();
+ if (result != null) {
+ if (result.isSuccess()) {
+ List<InfoItem> items = result.getInfoItems();
+ if ((items != null) && (items.size() == 1)) {
+ info.put("git.revision", items.get(0).getRevision());
+ } else {
+ info.put("git.error", "The command returned incorrect number of arguments");
+ }
+ } else {
+ info.put("git.error", result.getProviderMessage());
+ }
+
+ }
+ return info;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/57f1c085/build/plugins/buildinfo-maven-plugin/src/main/java/org/apache/marmotta/maven/plugins/buildinfo/InfoProvider.java
----------------------------------------------------------------------
diff --git a/build/plugins/buildinfo-maven-plugin/src/main/java/org/apache/marmotta/maven/plugins/buildinfo/InfoProvider.java b/build/plugins/buildinfo-maven-plugin/src/main/java/org/apache/marmotta/maven/plugins/buildinfo/InfoProvider.java
new file mode 100644
index 0000000..ca8f625
--- /dev/null
+++ b/build/plugins/buildinfo-maven-plugin/src/main/java/org/apache/marmotta/maven/plugins/buildinfo/InfoProvider.java
@@ -0,0 +1,34 @@
+/**
+ * Copyright (C) 2013 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.marmotta.maven.plugins.buildinfo;
+
+import org.apache.maven.project.MavenProject;
+
+import java.util.Map;
+
+/**
+ * Date: 5/17/11
+ * Time: 2:55 PM
+ *
+ * @author <a href="http://www.rodiontsev.com">Dmitry Rodiontsev</a>
+ */
+public interface InfoProvider {
+
+ boolean isActive(MavenProject project);
+
+ Map<String, String> getInfo(MavenProject project);
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/57f1c085/build/plugins/buildinfo-maven-plugin/src/main/java/org/apache/marmotta/maven/plugins/buildinfo/MercurialInfoProvider.java
----------------------------------------------------------------------
diff --git a/build/plugins/buildinfo-maven-plugin/src/main/java/org/apache/marmotta/maven/plugins/buildinfo/MercurialInfoProvider.java b/build/plugins/buildinfo-maven-plugin/src/main/java/org/apache/marmotta/maven/plugins/buildinfo/MercurialInfoProvider.java
new file mode 100644
index 0000000..7c53561
--- /dev/null
+++ b/build/plugins/buildinfo-maven-plugin/src/main/java/org/apache/marmotta/maven/plugins/buildinfo/MercurialInfoProvider.java
@@ -0,0 +1,103 @@
+/**
+ * Copyright (C) 2013 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.marmotta.maven.plugins.buildinfo;
+
+import org.apache.maven.project.MavenProject;
+import org.apache.maven.scm.ScmException;
+import org.apache.maven.scm.ScmResult;
+import org.apache.maven.scm.log.DefaultLog;
+import org.apache.maven.scm.log.ScmLogger;
+import org.apache.maven.scm.provider.hg.HgUtils;
+import org.apache.maven.scm.provider.hg.command.HgCommandConstants;
+import org.apache.maven.scm.provider.hg.command.HgConsumer;
+
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/**
+ * Date: 5/17/11
+ * Time: 3:08 PM
+ *
+ * @author <a href="http://www.rodiontsev.com">Dmitry Rodiontsev</a>
+ */
+public class MercurialInfoProvider extends AbstractInfoProvider {
+ private static final String DOT_HG = ".hg";
+ private static final Pattern HG_OUTPUT_PATTERN = Pattern.compile("^(\\S+)\\s(\\S+)\\s(.+)$");
+
+ public boolean isActive(MavenProject project) {
+ return isActive(project, DOT_HG);
+ }
+
+ public Map<String, String> getInfo(MavenProject project) {
+ ScmLogger logger = new DefaultLog();
+ HgLogConsumer consumer = new HgLogConsumer(logger);
+ ScmResult result = null;
+ try {
+ result = HgUtils.execute(
+ consumer,
+ logger,
+ project.getBasedir(),
+ new String[]{HgCommandConstants.REVNO_CMD, "-n", "-i", "-b"});
+ } catch (ScmException e) {
+ if (logger.isErrorEnabled()) {
+ logger.error(e.getMessage());
+ }
+ }
+
+ Map<String, String> info = new LinkedHashMap<String, String>();
+ if (result != null) {
+ if (result.isSuccess()) {
+ String output = result.getCommandOutput();
+ if (output != null) {
+ Matcher matcher = HG_OUTPUT_PATTERN.matcher(output);
+ if (matcher.find() && matcher.groupCount() == 3) {
+ StringBuilder changeset = new StringBuilder();
+ changeset.append("r").append(matcher.group(2)).append(":").append(matcher.group(1));
+ info.put("build.changeset", changeset.toString());
+ info.put("build.branch", matcher.group(3));
+ info.put("build.revision", matcher.group(2));
+ info.put("build.revhash", matcher.group(1));
+ } else {
+ info.put("hg.error", "The command returned incorrect number of arguments");
+ }
+ }
+ } else {
+ info.put("hg.error", result.getProviderMessage());
+ }
+ }
+ return info;
+ }
+}
+
+class HgLogConsumer extends HgConsumer {
+ private final StringBuilder out = new StringBuilder();
+
+ public HgLogConsumer(ScmLogger logger) {
+ super(logger);
+ }
+
+ @Override
+ public void consumeLine(String line) {
+ out.append(line).append("\n");
+ }
+
+ @Override
+ public String getStdErr() {
+ return out.toString();
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/57f1c085/build/plugins/buildinfo-maven-plugin/src/main/java/org/apache/marmotta/maven/plugins/buildinfo/ProjectInfoProvider.java
----------------------------------------------------------------------
diff --git a/build/plugins/buildinfo-maven-plugin/src/main/java/org/apache/marmotta/maven/plugins/buildinfo/ProjectInfoProvider.java b/build/plugins/buildinfo-maven-plugin/src/main/java/org/apache/marmotta/maven/plugins/buildinfo/ProjectInfoProvider.java
new file mode 100644
index 0000000..2eed82b
--- /dev/null
+++ b/build/plugins/buildinfo-maven-plugin/src/main/java/org/apache/marmotta/maven/plugins/buildinfo/ProjectInfoProvider.java
@@ -0,0 +1,47 @@
+/**
+ * Copyright (C) 2013 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.marmotta.maven.plugins.buildinfo;
+
+import org.apache.commons.lang.time.DateFormatUtils;
+import org.apache.maven.project.MavenProject;
+
+import java.util.Date;
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+/**
+ * Date: 22.06.11
+ * Time: 23:21
+ *
+ * @author <a href="http://www.rodiontsev.com">Dmitry Rodiontsev</a>
+ */
+public class ProjectInfoProvider implements InfoProvider {
+
+ public boolean isActive(MavenProject project) {
+ return true;
+ }
+
+ public Map<String, String> getInfo(MavenProject project) {
+ Date date = new Date();
+ Map<String, String> info = new LinkedHashMap<String, String>();
+ info.put("project.name", project.getName());
+ info.put("build.module", project.getArtifactId());
+ info.put("build.version", project.getVersion());
+ info.put("build.timestamp", DateFormatUtils.format(date, "EEE, dd MMM yyyy HH:mm:ss z"));
+ return info;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/57f1c085/build/plugins/marmotta-maven-plugin/pom.xml
----------------------------------------------------------------------
diff --git a/build/plugins/marmotta-maven-plugin/pom.xml b/build/plugins/marmotta-maven-plugin/pom.xml
index 5faa9a4..014518d 100644
--- a/build/plugins/marmotta-maven-plugin/pom.xml
+++ b/build/plugins/marmotta-maven-plugin/pom.xml
@@ -1,28 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
-<!--
- ~ Copyright (c) 2013 Salzburg Research.
- ~
- ~ Licensed under the Apache License, Version 2.0 (the "License");
- ~ you may not use this file except in compliance with the License.
- ~ You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing, software
- ~ distributed under the License is distributed on an "AS IS" BASIS,
- ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ~ See the License for the specific language governing permissions and
- ~ limitations under the License.
- -->
+<!-- ~ Copyright (c) 2013 Salzburg Research. ~ ~ Licensed under the Apache
+ License, Version 2.0 (the "License"); ~ you may not use this file except
+ in compliance with the License. ~ You may obtain a copy of the License at
+ ~ ~ http://www.apache.org/licenses/LICENSE-2.0 ~ ~ Unless required by applicable
+ law or agreed to in writing, software ~ distributed under the License is
+ distributed on an "AS IS" BASIS, ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. ~ See the License for the specific language
+ governing permissions and ~ limitations under the License. -->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache.marmotta</groupId>
- <artifactId>marmotta-parent</artifactId>
<version>3.0.0-incubating-SNAPSHOT</version>
- <relativePath>../../../parent</relativePath>
+ <relativePath>../</relativePath>
+ <artifactId>plugins-reactor</artifactId>
</parent>
<artifactId>marmotta-maven-plugin</artifactId>
@@ -36,10 +30,23 @@
<plugins>
<plugin>
<artifactId>maven-plugin-plugin</artifactId>
- <version>2.3</version>
<configuration>
- <goalPrefix>lmf</goalPrefix>
+ <goalPrefix>marmotta</goalPrefix>
</configuration>
+ <executions>
+ <execution>
+ <id>mojo-descriptor</id>
+ <goals>
+ <goal>descriptor</goal>
+ </goals>
+ </execution>
+ <execution>
+ <id>help-goal</id>
+ <goals>
+ <goal>helpmojo</goal>
+ </goals>
+ </execution>
+ </executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/57f1c085/build/plugins/marmotta-maven-plugin/src/main/java/org/apache/marmotta/maven/plugins/marmotta/MarmottaMojo.java
----------------------------------------------------------------------
diff --git a/build/plugins/marmotta-maven-plugin/src/main/java/org/apache/marmotta/maven/plugins/marmotta/MarmottaMojo.java b/build/plugins/marmotta-maven-plugin/src/main/java/org/apache/marmotta/maven/plugins/marmotta/MarmottaMojo.java
new file mode 100644
index 0000000..88a276b
--- /dev/null
+++ b/build/plugins/marmotta-maven-plugin/src/main/java/org/apache/marmotta/maven/plugins/marmotta/MarmottaMojo.java
@@ -0,0 +1,16 @@
+package org.apache.marmotta.maven.plugins.marmotta;
+
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.plugins.annotations.Mojo;
+
+@Mojo(name = "info")
+public class MarmottaMojo extends AbstractMojo {
+
+ @Override
+ public void execute() throws MojoExecutionException, MojoFailureException {
+ getLog().debug("Not implemented");
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/57f1c085/build/plugins/pom.xml
----------------------------------------------------------------------
diff --git a/build/plugins/pom.xml b/build/plugins/pom.xml
index 51d1ad9..b31c910 100644
--- a/build/plugins/pom.xml
+++ b/build/plugins/pom.xml
@@ -1,20 +1,14 @@
-<!--
- ~ Copyright (c) 2013 Salzburg Research.
- ~
- ~ Licensed under the Apache License, Version 2.0 (the "License");
- ~ you may not use this file except in compliance with the License.
- ~ You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing, software
- ~ distributed under the License is distributed on an "AS IS" BASIS,
- ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ~ See the License for the specific language governing permissions and
- ~ limitations under the License.
- -->
+<!-- ~ Copyright (c) 2013 Salzburg Research. ~ ~ Licensed under the Apache
+ License, Version 2.0 (the "License"); ~ you may not use this file except
+ in compliance with the License. ~ You may obtain a copy of the License at
+ ~ ~ http://www.apache.org/licenses/LICENSE-2.0 ~ ~ Unless required by applicable
+ law or agreed to in writing, software ~ distributed under the License is
+ distributed on an "AS IS" BASIS, ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. ~ See the License for the specific language
+ governing permissions and ~ limitations under the License. -->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache.marmotta</groupId>
@@ -32,9 +26,41 @@
<build>
<plugins>
<plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-plugin-plugin</artifactId>
+ <configuration>
+ <skipErrorNoDescriptorsFound>true</skipErrorNoDescriptorsFound>
+ </configuration>
+ <executions>
+ <execution>
+ <id>mojo-descriptor</id>
+ <goals>
+ <goal>descriptor</goal>
+ </goals>
+ </execution>
+ <execution>
+ <id>help-goal</id>
+ <goals>
+ <goal>helpmojo</goal>
+ </goals>
+ </execution>
+ </executions>
+
+ </plugin>
+ <plugin>
+ <!-- Maven is Java5 -->
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>1.5</source>
+ <target>1.5</target>
+ </configuration>
+ </plugin>
+ <plugin>
<!-- No need for the buildinfo plugin here -->
<groupId>org.apache.marmotta</groupId>
<artifactId>buildinfo-maven-plugin</artifactId>
+ <version>${project.version}</version>
<executions>
<execution>
<phase>none</phase>
@@ -70,11 +96,13 @@
</build>
<modules>
- <!-- LMF Maven Plugins -->
+ <!-- Maven Plugins -->
<module>marmotta-maven-plugin</module>
<module>refpack-maven-plugin</module>
<module>buildinfo-maven-plugin</module>
+ <module>repocheck-maven-plugin</module>
</modules>
+
<dependencyManagement>
<dependencies>
<dependency>
@@ -83,6 +111,12 @@
<version>3.0.4</version>
</dependency>
<dependency>
+ <groupId>org.apache.maven.plugin-tools</groupId>
+ <artifactId>maven-plugin-annotations</artifactId>
+ <version>3.2</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-core</artifactId>
<version>3.0.4</version>
@@ -97,12 +131,25 @@
<artifactId>maven-project</artifactId>
<version>2.2.1</version>
</dependency>
+ <dependency>
+ <!-- maven is using commons-logging -->
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ <version>1.1.1</version>
+ </dependency>
</dependencies>
</dependencyManagement>
+
<dependencies>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.apache.maven.plugin-tools</groupId>
+ <artifactId>maven-plugin-annotations</artifactId>
+ <scope>provided</scope>
+ </dependency>
</dependencies>
+
</project>
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/57f1c085/build/plugins/refpack-maven-plugin/pom.xml
----------------------------------------------------------------------
diff --git a/build/plugins/refpack-maven-plugin/pom.xml b/build/plugins/refpack-maven-plugin/pom.xml
index e8c6e8a..c183efd 100644
--- a/build/plugins/refpack-maven-plugin/pom.xml
+++ b/build/plugins/refpack-maven-plugin/pom.xml
@@ -20,9 +20,9 @@
<parent>
<groupId>org.apache.marmotta</groupId>
- <artifactId>marmotta-parent</artifactId>
<version>3.0.0-incubating-SNAPSHOT</version>
- <relativePath>../../../parent</relativePath>
+ <artifactId>plugins-reactor</artifactId>
+ <relativePath>../</relativePath>
</parent>
<artifactId>refpack-maven-plugin</artifactId>
@@ -35,17 +35,14 @@
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-core</artifactId>
- <version>3.0.4</version>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-model</artifactId>
- <version>3.0.4</version>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-project</artifactId>
- <version>2.2.1</version>
</dependency>
<dependency>
<!-- required in all cases -->
@@ -83,7 +80,6 @@
<plugins>
<plugin>
<artifactId>maven-plugin-plugin</artifactId>
- <version>2.3</version>
<configuration>
<goalPrefix>refpack</goalPrefix>
</configuration>
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/57f1c085/build/plugins/refpack-maven-plugin/src/main/java/at/newmedialab/maven/plugins/refpack/RefPackMojo.java
----------------------------------------------------------------------
diff --git a/build/plugins/refpack-maven-plugin/src/main/java/at/newmedialab/maven/plugins/refpack/RefPackMojo.java b/build/plugins/refpack-maven-plugin/src/main/java/at/newmedialab/maven/plugins/refpack/RefPackMojo.java
deleted file mode 100644
index 7b07a8a..0000000
--- a/build/plugins/refpack-maven-plugin/src/main/java/at/newmedialab/maven/plugins/refpack/RefPackMojo.java
+++ /dev/null
@@ -1,379 +0,0 @@
-/**
- * Copyright (C) 2013 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package at.newmedialab.maven.plugins.refpack;
-
-import org.apache.maven.artifact.factory.ArtifactFactory;
-import org.apache.maven.model.Model;
-import org.apache.maven.model.building.ModelBuildingRequest;
-import org.apache.maven.plugin.AbstractMojo;
-import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.project.DefaultProjectBuildingRequest;
-import org.apache.maven.project.MavenProject;
-import org.apache.maven.project.ProjectBuilder;
-import org.apache.maven.project.ProjectBuildingException;
-import org.apache.maven.project.ProjectBuildingResult;
-import org.jdom2.Element;
-import org.jdom2.output.Format;
-import org.jdom2.output.XMLOutputter;
-import org.sonatype.aether.RepositorySystem;
-import org.sonatype.aether.RepositorySystemSession;
-import org.sonatype.aether.artifact.Artifact;
-import org.sonatype.aether.collection.CollectRequest;
-import org.sonatype.aether.collection.DependencyCollectionException;
-import org.sonatype.aether.graph.Dependency;
-import org.sonatype.aether.graph.DependencyNode;
-import org.sonatype.aether.repository.RemoteRepository;
-import org.sonatype.aether.resolution.DependencyRequest;
-import org.sonatype.aether.resolution.DependencyResolutionException;
-import org.sonatype.aether.resolution.DependencyResult;
-import org.sonatype.aether.util.artifact.DefaultArtifact;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-/**
- * Goal which touches a timestamp file.
- *
- * @requiresDependencyResolution compile
- * @goal generate
- *
- * @phase validate
- */
-public class RefPackMojo extends AbstractMojo {
-
- /**
- * Location of the file.
- * @parameter expression="${project.build.directory}"
- * @required
- */
- private File outputDirectory;
-
- /**
- * @parameter default-value="${project}"
- * @required
- * @readonly
- */
- private MavenProject project;
-
- /**
- * The Group Identifier of the artifacts that should be considered local modules. When walking
- * the dependency tree, the process will break at each module of this group id and instead add
- * a dependency to the other module to the refpacks.
- *
- * @parameter expression="${refpack.moduleGroupId}" default-value="at.newmedialab.lmf"
- * @required
- * @readonly
- */
- private String moduleGroupId;
-
- /**
- * The entry point to Aether, i.e. the component doing all the work.
- *
- * @component
- */
- private RepositorySystem repoSystem;
-
- /**
- * @parameter default-value="${repositorySystemSession}"
- * @readonly
- */
- private RepositorySystemSession session;
-
- /**
- * The project's remote repositories to use for the resolution of project dependencies.
- *
- * @parameter default-value="${project.remoteProjectRepositories}"
- * @readonly
- */
- private List<RemoteRepository> projectRepos;
-
- /**
- * @component
- */
- private ProjectBuilder projectBuilder;
-
-
- /**
- * @component
- */
- private ArtifactFactory artifactFactory;
-
- /**
- * The required modules of the refpack
- *
- * @parameter expression="${refpack.requiredModules}"
- * @readonly
- */
- private List<String> requiredModules;
-
- // we collect here the library dependencies of each module, so we can identify which of the dependencies are already
- // covered by another module the current module depends on
- private HashMap<Artifact,Set<Artifact>> moduleLibraries;
-
- // and here we collect the module dependencies of each module
- private HashMap<Artifact,Set<Artifact>> moduleDependencies;
-
- public void execute() throws MojoExecutionException {
- moduleLibraries = new HashMap<Artifact, Set<Artifact>>();
- moduleDependencies = new HashMap<Artifact, Set<Artifact>>();
-
- getLog().info("generating reference packs for group id "+moduleGroupId);
-
- for(org.apache.maven.artifact.Artifact artifact : (Set<org.apache.maven.artifact.Artifact>)project.getArtifacts()) {
- if(artifact.getGroupId().equals(moduleGroupId)) {
-
- DefaultArtifact aetherArtifact = new DefaultArtifact(artifact.getGroupId(),artifact.getArtifactId(), artifact.getType(), artifact.getVersion());
- Dependency rootDependency = new Dependency(aetherArtifact, "runtime");
-
- try {
- CollectRequest collectRequest = new CollectRequest();
- collectRequest.setRoot(rootDependency);
- collectRequest.setRepositories(projectRepos);
-
- DependencyNode rootNode = repoSystem.collectDependencies( session, collectRequest ).getRoot();
-
- DependencyRequest request = new DependencyRequest(rootNode,null);
- DependencyResult result = repoSystem.resolveDependencies(session,request);
-
-
- getLog().info("Artifact: " + aetherArtifact);
- for(DependencyNode child : result.getRoot().getChildren()) {
- if(child.getDependency().getArtifact().getGroupId().equals(moduleGroupId)) {
- processModule(child);
- }
- }
- processModule(result.getRoot());
- /*
- deps = aether.resolve(aetherArtifact, JavaScopes.RUNTIME);
-
- getLog().info("Artifact: "+aetherArtifact);
- for(Artifact dep : deps) {
- getLog().info("- dependency "+dep.getFile().getAbsolutePath());
- }
- */
- } catch (DependencyResolutionException e) {
- getLog().warn("could not resolve dependencies for artifact "+aetherArtifact,e);
- } catch (DependencyCollectionException e) {
- getLog().warn("could not resolve dependencies for artifact "+aetherArtifact,e);
- }
- }
-
- }
-
- }
-
- /**
- * Collect the dependencies to other libraries that are not already collected by modules the current
- * module depends on.
- *
- * @param node
- * @param currentModule
- */
- private void collectLibraryDependencies(DependencyNode node, Artifact currentModule) {
-
- if(!node.getDependency().getArtifact().getGroupId().equals(moduleGroupId) || !node.getDependency().getArtifact().getArtifactId().startsWith("lmf-")) {
- // first check if the current artifact is already covered by a module the current module depends on
- for(Artifact dependentArtifact : moduleDependencies.get(currentModule)) {
- if(moduleLibraries.containsKey(dependentArtifact) &&
- moduleLibraries.get(dependentArtifact).contains(node.getDependency().getArtifact())) {
- return;
- }
- }
-
- // collect the current dependency for the module
- moduleLibraries.get(currentModule).add(node.getDependency().getArtifact());
-
- for(DependencyNode child : node.getChildren()) {
- collectLibraryDependencies(child, currentModule);
- }
- }
- }
-
- /**
- * Collect the dependencies to other modules inside the same project
- * @param node
- * @param currentModule
- */
- private void collectModuleDependencies(DependencyNode node, Artifact currentModule) {
- if(node.getDependency().getArtifact().getGroupId().equals(moduleGroupId) && node.getDependency().getArtifact().getArtifactId().startsWith("lmf-")) {
- moduleDependencies.get(currentModule).add(node.getDependency().getArtifact());
- }
- }
-
- private void processModule(DependencyNode moduleNode) {
- CollectRequest collectRequest = new CollectRequest();
- collectRequest.setRoot(moduleNode.getDependency());
- collectRequest.setRepositories(projectRepos);
- try {
- // collect all the dependency graph for the module, and print it until we reach a dependency to a local module
- DependencyNode rootNode = repoSystem.collectDependencies( session, collectRequest ).getRoot();
-
- DependencyRequest request = new DependencyRequest(rootNode,null);
- DependencyResult result = repoSystem.resolveDependencies(session,request);
-
- // add entry to module dependencies
- moduleLibraries.put(moduleNode.getDependency().getArtifact(), new HashSet<Artifact>());
- moduleDependencies.put(moduleNode.getDependency().getArtifact(), new HashSet<Artifact>());
-
- getLog().info("processing module "+moduleNode.getDependency().getArtifact().getArtifactId()+":");
- for(DependencyNode child : result.getRoot().getChildren()) {
- collectModuleDependencies(child,moduleNode.getDependency().getArtifact());
- }
- for(DependencyNode child : result.getRoot().getChildren()) {
- collectLibraryDependencies(child, moduleNode.getDependency().getArtifact());
- }
-
- // information output
- /*
- for(Artifact otherModule : moduleDependencies.get(moduleNode.getDependency().getArtifact())) {
- getLog().info(" - depending on module "+otherModule.getArtifactId());
- }
- for(Artifact library : moduleLibraries.get(moduleNode.getDependency().getArtifact())) {
- getLog().info(" - depending on library "+library);
- }
- */
-
- File destination = new File(outputDirectory,moduleNode.getDependency().getArtifact().getArtifactId()+".xml");
-
- getLog().info("writing refpack to "+destination.getAbsolutePath());
-
- // write to output directory
- writeModuleXML(moduleNode.getDependency().getArtifact(), new FileOutputStream(destination));
-
- } catch (DependencyCollectionException e) {
- getLog().error("error while collecting dependencies for module "+moduleNode.getDependency().getArtifact(),e);
- } catch (DependencyResolutionException e) {
- getLog().error("error while resolving dependencies for module "+moduleNode.getDependency().getArtifact(),e);
- } catch (IOException e) {
- getLog().error("I/O error while writing refpack for module"+moduleNode.getDependency().getArtifact(),e);
- }
-
- }
-
- private void writeModuleXML(Artifact module, OutputStream out) throws IOException {
- Element installation = new Element("installation");
- installation.setAttribute("version","1.0");
-
- Element packs = new Element("packs");
- installation.addContent(packs);
-
- Element pack = new Element("pack");
- packs.addContent(pack);
-
- // get the model for the artifact, we read name and description from it
-
- Model pom = getArtifactModel(module);
-
- // set name of pack from artifact
- if(pom != null && pom.getName() != null) {
- pack.setAttribute("name",pom.getName());
- } else {
- pack.setAttribute("name",module.getArtifactId());
- }
-
- if(pom != null && pom.getDescription() != null) {
- Element description = new Element("description");
- description.addContent(pom.getDescription());
- pack.addContent(description);
- }
-
- // add a file entry for the module itself
- if(!module.getExtension().equals("war")) {
- Element mainFile = new Element("file");
- pack.addContent(mainFile);
- mainFile.setAttribute("src",module.getFile().getAbsolutePath());
- mainFile.setAttribute("targetdir","$INSTALL_PATH/apache-tomcat-$TOMCAT_VERSION/webapps/LMF/WEB-INF/lib");
- }
-
- // add a file entry for each library of the artifact
- for(Artifact library : moduleLibraries.get(module)) {
- Element file = new Element("file");
- pack.addContent(file);
- file.setAttribute("src",library.getFile().getAbsolutePath());
- file.setAttribute("targetdir","$INSTALL_PATH/apache-tomcat-$TOMCAT_VERSION/webapps/LMF/WEB-INF/lib");
- }
-
- // add a depends name for each module the current one depends on (in case the project is not the webapp)
- if(!module.getExtension().equals("war")) {
- if(requiredModules.contains(module.getArtifactId())) {
- pack.setAttribute("required","yes");
- } else {
- pack.setAttribute("required","no");
- }
-
- for(Artifact dependency : moduleDependencies.get(module)) {
- Element depends = new Element("depends");
- pack.addContent(depends);
-
- // get the model for the artifact, we read name and description from it
- Model pom2 = getArtifactModel(dependency);
-
- // set name of pack from artifact
- if(pom2 != null && pom2.getName() != null) {
- depends.setAttribute("packname", pom2.getName());
- } else {
- depends.setAttribute("packname",module.getArtifactId());
- }
- }
- } else {
- pack.setAttribute("required","yes");
-
- // add webapp directory from installer configuration
- Element appDir = new Element("fileset");
- appDir.setAttribute("dir",outputDirectory+"/../webapp/");
- appDir.setAttribute("targetdir","$INSTALL_PATH/apache-tomcat-$TOMCAT_VERSION/webapps/LMF/");
- appDir.setAttribute("includes","**");
-
- pack.addContent(appDir);
-
- Element logDir = new Element("fileset");
- logDir.setAttribute("dir",outputDirectory+"/../log/");
-
- logDir.setAttribute("targetdir","$INSTALL_PATH/apache-tomcat-$TOMCAT_VERSION/logs/");
- logDir.setAttribute("includes","**");
-
- pack.addContent(logDir);
- }
-
- XMLOutputter writer = new XMLOutputter(Format.getPrettyFormat());
- writer.output(installation,out);
-
- }
-
- private Model getArtifactModel(Artifact artifact) {
- org.apache.maven.artifact.Artifact mavenArtifact = artifactFactory.createArtifact(artifact.getGroupId(),artifact.getArtifactId(),artifact.getVersion(),"runtime",artifact.getExtension());
-
- DefaultProjectBuildingRequest req = new DefaultProjectBuildingRequest();
- req.setRepositorySession(session);
- req.setValidationLevel(ModelBuildingRequest.VALIDATION_LEVEL_STRICT);
-
- try {
- ProjectBuildingResult res = projectBuilder.build(mavenArtifact, req);
-
- return res.getProject().getModel();
- } catch (ProjectBuildingException e) {
- getLog().warn("error building artifact model for artifact "+artifact,e);
- return null;
- }
-
- }
-}