diff options
21 files changed, 1 insertions, 662 deletions
@@ -20,7 +20,6 @@ <module>sonar-check-api</module> <module>sonar-colorizer</module> <module>sonar-core</module> - <module>sonar-core-maven-plugin</module> <module>sonar-deprecated</module> <module>sonar-duplications</module> <module>sonar-graph</module> diff --git a/sonar-application/assembly.xml b/sonar-application/assembly.xml index 3eb47c2311d..4af1370b983 100644 --- a/sonar-application/assembly.xml +++ b/sonar-application/assembly.xml @@ -20,13 +20,6 @@ <exclude>org.codehaus.sonar.runtime:*</exclude> </excludes> </dependencySet> - <dependencySet> - <outputDirectory>lib/deprecated-maven-plugin</outputDirectory> - <useTransitiveDependencies>false</useTransitiveDependencies> - <includes> - <include>org.codehaus.sonar.runtime:sonar-core-maven-plugin</include> - </includes> - </dependencySet> <!-- Plugins --> <dependencySet> <outputDirectory>lib/core-plugins</outputDirectory> diff --git a/sonar-application/pom.xml b/sonar-application/pom.xml index e80a1063c99..aeee33634ab 100644 --- a/sonar-application/pom.xml +++ b/sonar-application/pom.xml @@ -107,14 +107,6 @@ <artifactId>jetty-ajp</artifactId> </dependency> - <!-- deprecated --> - <dependency> - <groupId>org.codehaus.sonar.runtime</groupId> - <artifactId>sonar-core-maven-plugin</artifactId> - <version>${project.version}</version> - <scope>runtime</scope> - </dependency> - <!-- core plugins --> <dependency> <groupId>org.codehaus.sonar.plugins</groupId> diff --git a/sonar-core-maven-plugin/pom.xml b/sonar-core-maven-plugin/pom.xml deleted file mode 100644 index 147caa30fb5..00000000000 --- a/sonar-core-maven-plugin/pom.xml +++ /dev/null @@ -1,68 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<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.codehaus.sonar</groupId> - <artifactId>sonar</artifactId> - <version>2.14-SNAPSHOT</version> - </parent> - - <!-- do not change, it's used when deploying in sonar internal repository --> - <groupId>org.codehaus.sonar.runtime</groupId> - <artifactId>sonar-core-maven-plugin</artifactId> - <packaging>maven-plugin</packaging> - <name>Sonar :: Deprecated Maven2 Plugin</name> - <dependencies> - - <!-- - - - - - - - - - IMPORTANT - the following must be copied in - sonar-server/src/main/resources/org/sonar/server/mavendeployer/sonar-core-mojo-pom.template - - - - - - - - - --> - - <dependency> - <groupId>org.apache.maven</groupId> - <artifactId>maven-plugin-api</artifactId> - <version>2.0.7</version> - <scope>provided</scope> - </dependency> - <dependency> - <groupId>org.apache.maven</groupId> - <artifactId>maven-core</artifactId> - <version>2.0.7</version> - <scope>provided</scope> - </dependency> - <dependency> - <groupId>org.apache.maven</groupId> - <artifactId>maven-project</artifactId> - <version>2.0.7</version> - <scope>provided</scope> - </dependency> - </dependencies> - <build> - <plugins> - <plugin> - <artifactId>maven-deploy-plugin</artifactId> - <configuration> - <skip>true</skip> - </configuration> - </plugin> - </plugins> - </build> -</project> diff --git a/sonar-core-maven-plugin/src/main/java/org/sonar/maven2/BatchMojo.java b/sonar-core-maven-plugin/src/main/java/org/sonar/maven2/BatchMojo.java deleted file mode 100644 index eb89d585abb..00000000000 --- a/sonar-core-maven-plugin/src/main/java/org/sonar/maven2/BatchMojo.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Sonar, open source software quality management tool. - * Copyright (C) 2008-2011 SonarSource - * mailto:contact AT sonarsource DOT com - * - * Sonar is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * Sonar is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with Sonar; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 - */ -package org.sonar.maven2; - -import org.apache.maven.plugin.AbstractMojo; -import org.apache.maven.plugin.MojoExecutionException; -import org.apache.maven.plugin.MojoFailureException; - -/** - * @goal internal - * @aggregator - * @requiresDependencyResolution test - */ -public final class BatchMojo extends AbstractMojo { - - public void execute() throws MojoExecutionException, MojoFailureException { - throw new MojoExecutionException("The version 1.0-beta-1 of org.codehaus.mojo:sonar-maven-plugin is not supported anymore. " - + "Please upgrade to 1.0-beta-2 for Maven2 or 2.0-beta-2 for Maven3."); - } -} diff --git a/sonar-server/src/main/java/org/sonar/server/mavendeployer/Artifact.java b/sonar-server/src/main/java/org/sonar/server/mavendeployer/Artifact.java deleted file mode 100644 index 1c953d013c0..00000000000 --- a/sonar-server/src/main/java/org/sonar/server/mavendeployer/Artifact.java +++ /dev/null @@ -1,171 +0,0 @@ -/* - * Sonar, open source software quality management tool. - * Copyright (C) 2008-2011 SonarSource - * mailto:contact AT sonarsource DOT com - * - * Sonar is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * Sonar is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with Sonar; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 - */ -package org.sonar.server.mavendeployer; - -import org.apache.commons.codec.digest.DigestUtils; -import org.apache.commons.io.FileUtils; -import org.apache.commons.io.IOUtils; -import org.apache.commons.lang.CharEncoding; -import org.apache.commons.lang.StringUtils; - -import java.io.File; -import java.io.IOException; -import java.io.InputStream; - -public class Artifact { - - public static final String BASE_GROUP_ID = "org.codehaus.sonar.runtime"; - - private String groupId; - private String artifactId; - protected String version; - protected File jar; - private String packaging; - - public Artifact(String groupId, String artifactId, String version, String packaging, File jar) { - this.artifactId = artifactId; - this.groupId = groupId; - this.version = version; - this.jar = jar; - this.packaging = packaging; - } - - public void deployTo(File rootDir) throws IOException { - File dir = createDir(rootDir); - savePom(dir); - saveMetadata(dir); - saveJar(dir); - } - - protected File createDir(File rootDir) throws IOException { - String path = StringUtils.replace(groupId, ".", "/") + "/" + artifactId + "/" + version; - File dir = new File(rootDir, path); - FileUtils.forceMkdir(dir); - return dir; - } - - protected String getArtifactName() { - return artifactId + "-" + version; - } - - public String getGroupId() { - return groupId; - } - - public String getArtifactId() { - return artifactId; - } - - public String getVersion() { - return version; - } - - private void saveJar(File dir) throws IOException { - if (jar != null) { - copyTo(dir); - File newJar = new File(dir, jar.getName()); - File target = new File(dir, getArtifactName() + ".jar"); - newJar.renameTo(target); - saveDigests(target); - } - } - - protected void copyTo(File dir) throws IOException { - FileUtils.copyFileToDirectory(jar, dir); - } - - private void savePom(File dir) throws IOException { - File pom = new File(dir, getArtifactName() + ".pom"); - FileUtils.writeStringToFile(pom, getPom(), CharEncoding.UTF_8); - saveDigests(pom); - } - - private void saveDigests(File file) throws IOException { - String path = file.getAbsolutePath(); - byte[] content = FileUtils.readFileToByteArray(file); - FileUtils.writeStringToFile(new File(path + ".md5"), DigestUtils.md5Hex(content), CharEncoding.UTF_8); - FileUtils.writeStringToFile(new File(path + ".sha1"), DigestUtils.shaHex(content), CharEncoding.UTF_8); - } - - public String getPom() throws IOException { - return transformFromTemplatePath(getTemplatePath()); - } - - protected String getTemplatePath() { - return "/org/sonar/server/mavendeployer/pom.template"; - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - - Artifact that = (Artifact) o; - if (!artifactId.equals(that.artifactId)) { - return false; - } - return groupId.equals(that.groupId); - } - - @Override - public int hashCode() { - int result = groupId.hashCode(); - result = 31 * result + artifactId.hashCode(); - return result; - } - - @Override - public String toString() { - return new StringBuilder().append(groupId).append(":").append(artifactId).toString(); - } - - public String getMetadata() throws IOException { - return transformFromTemplatePath("/org/sonar/server/mavendeployer/maven-metadata.template"); - } - - protected void saveMetadata(File dir) throws IOException { - File metadataFile = new File(dir.getParentFile(), "maven-metadata.xml"); - FileUtils.writeStringToFile(metadataFile, getMetadata(), CharEncoding.UTF_8); - } - - protected final String transformFromTemplatePath(String templatePath) throws IOException { - InputStream template = this.getClass().getResourceAsStream(templatePath); - try { - String content = IOUtils.toString(template); - content = StringUtils.replace(content, "$groupId", groupId); - content = StringUtils.replace(content, "$artifactId", artifactId); - content = StringUtils.replace(content, "$version", version); - content = StringUtils.replace(content, "$timestamp", version); - content = StringUtils.replace(content, "$packaging", packaging); - return content; - - } finally { - IOUtils.closeQuietly(template); - } - } - - public String getXmlDefinition() throws IOException { - return transformFromTemplatePath("/org/sonar/server/mavendeployer/dependency.template"); - } -} diff --git a/sonar-server/src/main/java/org/sonar/server/mavendeployer/MavenRepository.java b/sonar-server/src/main/java/org/sonar/server/mavendeployer/MavenRepository.java deleted file mode 100644 index 070c35d3d7e..00000000000 --- a/sonar-server/src/main/java/org/sonar/server/mavendeployer/MavenRepository.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Sonar, open source software quality management tool. - * Copyright (C) 2008-2011 SonarSource - * mailto:contact AT sonarsource DOT com - * - * Sonar is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * Sonar is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with Sonar; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 - */ -package org.sonar.server.mavendeployer; - -import org.apache.commons.io.FileUtils; -import org.sonar.api.config.Settings; -import org.sonar.api.platform.Server; -import org.sonar.server.platform.DefaultServerFileSystem; -import org.sonar.server.platform.ServerSettings; - -import java.io.File; -import java.io.IOException; - -public class MavenRepository { - - private final DefaultServerFileSystem installation; - private final String serverId; - private File rootDir; - - public MavenRepository(Settings settings, DefaultServerFileSystem fileSystem, Server server) throws IOException { - this.installation = fileSystem; - this.serverId = server.getId(); - initRootDir(settings); - } - - /** - * for unit tests - */ - protected MavenRepository(DefaultServerFileSystem installation, String serverId, File rootDir) { - this.installation = installation; - this.serverId = serverId; - this.rootDir = rootDir; - } - - public void start() { - try { - Artifact maven2Plugin = Mojo.createMaven2Plugin(serverId, installation.getMaven2Plugin()); - maven2Plugin.deployTo(rootDir); - - } catch (Exception e) { - throw new IllegalStateException("Fail to deploy Maven 2 plugin to: " + rootDir, e); - } - } - - - private void initRootDir(Settings settings) throws IOException { - this.rootDir = new File(settings.getString(ServerSettings.DEPLOY_DIR), "maven"); - File orgDir = new File(rootDir, "/org/"); - if (orgDir.exists()) { - FileUtils.forceDelete(orgDir); - } - } -} diff --git a/sonar-server/src/main/java/org/sonar/server/mavendeployer/Mojo.java b/sonar-server/src/main/java/org/sonar/server/mavendeployer/Mojo.java deleted file mode 100644 index a17b19847c3..00000000000 --- a/sonar-server/src/main/java/org/sonar/server/mavendeployer/Mojo.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Sonar, open source software quality management tool. - * Copyright (C) 2008-2011 SonarSource - * mailto:contact AT sonarsource DOT com - * - * Sonar is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * Sonar is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with Sonar; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 - */ -package org.sonar.server.mavendeployer; - -import org.apache.commons.io.FileUtils; -import org.apache.commons.lang.StringUtils; -import org.sonar.api.utils.TempFileUtils; -import org.sonar.api.utils.ZipUtils; - -import java.io.File; -import java.io.IOException; - -public final class Mojo extends Artifact { - - private Mojo(String artifactId, String version, File jar) { - super(BASE_GROUP_ID, artifactId, version, "maven-plugin", jar); - } - - public static Mojo createMaven2Plugin(String version, File jar) { - return new Mojo("sonar-core-maven-plugin", version, jar); - } - - @Override - protected String getTemplatePath() { - return "/org/sonar/server/mavendeployer/" + getArtifactId() + ".template"; - } - - @Override - protected void copyTo(File toDir) throws IOException { - File tmpDir = TempFileUtils.createTempDirectory("sonar-server-"); - try { - copyTo(toDir, tmpDir); - - } finally { - destroyTmpDir(tmpDir); - } - } - - protected void copyTo(File toDir, File temporaryDir) throws IOException { - ZipUtils.unzip(jar, temporaryDir); - - File metadataFile = new File(temporaryDir, "META-INF/maven/plugin.xml"); - String metadata = FileUtils.readFileToString(metadataFile); - metadata = updateVersion(metadata, version); - - FileUtils.writeStringToFile(metadataFile, metadata); - ZipUtils.zipDir(temporaryDir, new File(toDir, jar.getName())); - } - - protected String updateVersion(String metadata, String version) { - String before = StringUtils.substringBefore(metadata, "<version>"); - String after = StringUtils.substringAfter(metadata, "</version>"); - return before + "<version>" + version + "</version>" + after; - } - - private void destroyTmpDir(File tmpDir) { - if (tmpDir != null) { - FileUtils.deleteQuietly(tmpDir); - } - } -} diff --git a/sonar-server/src/main/java/org/sonar/server/platform/DefaultServerFileSystem.java b/sonar-server/src/main/java/org/sonar/server/platform/DefaultServerFileSystem.java index ab70ba90188..1034eaca525 100644 --- a/sonar-server/src/main/java/org/sonar/server/platform/DefaultServerFileSystem.java +++ b/sonar-server/src/main/java/org/sonar/server/platform/DefaultServerFileSystem.java @@ -146,13 +146,6 @@ public class DefaultServerFileSystem implements ServerFileSystem { return new File(getHomeDir(), "extensions/deprecated"); } - public List<File> getPluginExtensions() { - return getFiles(getPluginExtensionsDir(), "jar"); - } - - public File getPluginExtensionsDir() { - return new File(getHomeDir(), "extensions/rules"); - } public File getPluginIndex() { return new File(getDeployDir(), "plugins/index.txt"); @@ -166,10 +159,6 @@ public class DefaultServerFileSystem implements ServerFileSystem { return Collections.emptyList(); } - public File getPluginExtensionsDir(String pluginKey) { - return new File(getHomeDir(), "extensions/rules/" + pluginKey); - } - public List<File> getPluginExtensionXml(String pluginKey) { File dir = new File(getHomeDir(), "extensions/rules/" + pluginKey); if (dir.exists() && dir.isDirectory()) { @@ -178,15 +167,6 @@ public class DefaultServerFileSystem implements ServerFileSystem { return Collections.emptyList(); } - public File getMaven2Plugin() { - File dir = new File(getHomeDir(), "lib/deprecated-maven-plugin/"); - List<File> files = getFiles(dir, "jar"); - if (files.isEmpty()) { - return null; - } - return files.get(0); - } - private List<File> getFiles(File dir, String... fileSuffixes) { List<File> files = new ArrayList<File>(); if (dir != null && dir.exists()) { diff --git a/sonar-server/src/main/java/org/sonar/server/platform/Platform.java b/sonar-server/src/main/java/org/sonar/server/platform/Platform.java index a22f4f9593b..42fad9a689f 100644 --- a/sonar-server/src/main/java/org/sonar/server/platform/Platform.java +++ b/sonar-server/src/main/java/org/sonar/server/platform/Platform.java @@ -59,7 +59,6 @@ import org.sonar.server.configuration.Backup; import org.sonar.server.configuration.ProfilesManager; import org.sonar.server.database.EmbeddedDatabaseFactory; import org.sonar.server.filters.FilterExecutor; -import org.sonar.server.mavendeployer.MavenRepository; import org.sonar.server.notifications.NotificationService; import org.sonar.server.notifications.reviews.ReviewsNotificationManager; import org.sonar.server.plugins.*; @@ -220,7 +219,6 @@ public final class Platform { private void executeStartupTasks() { ComponentContainer startupContainer = servicesContainer.createChild(); - startupContainer.addSingleton(MavenRepository.class); startupContainer.addSingleton(GwtPublisher.class); startupContainer.addSingleton(RegisterMetrics.class); startupContainer.addSingleton(RegisterRules.class); diff --git a/sonar-server/src/main/webapp/deploy/maven/README.txt b/sonar-server/src/main/webapp/deploy/maven/README.txt deleted file mode 100644 index 358b92c24d7..00000000000 --- a/sonar-server/src/main/webapp/deploy/maven/README.txt +++ /dev/null @@ -1 +0,0 @@ -This is the maven repository started by sonar. It automatically publishes JAR files of JDBC drivers and extensions.
\ No newline at end of file diff --git a/sonar-server/src/main/webapp/deploy/maven/index.html b/sonar-server/src/main/webapp/deploy/maven/index.html deleted file mode 100644 index 2919c62bf6d..00000000000 --- a/sonar-server/src/main/webapp/deploy/maven/index.html +++ /dev/null @@ -1,2 +0,0 @@ -<p>This is the maven repository managed internally by sonar.</p> -<p>This file is used to bypass the auto blocking feature introduced in Nexus 1.6. See http://jira.codehaus.org/browse/SONAR-603</p>
\ No newline at end of file diff --git a/sonar-server/src/main/webapp/deploy/readme.txt b/sonar-server/src/main/webapp/deploy/readme.txt new file mode 100644 index 00000000000..a79464af707 --- /dev/null +++ b/sonar-server/src/main/webapp/deploy/readme.txt @@ -0,0 +1 @@ +Please note that this file must not be deleted.
\ No newline at end of file diff --git a/sonar-server/src/test/java/org/sonar/server/mavendeployer/ArtifactTest.java b/sonar-server/src/test/java/org/sonar/server/mavendeployer/ArtifactTest.java deleted file mode 100644 index 9ec06199bd4..00000000000 --- a/sonar-server/src/test/java/org/sonar/server/mavendeployer/ArtifactTest.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Sonar, open source software quality management tool. - * Copyright (C) 2008-2011 SonarSource - * mailto:contact AT sonarsource DOT com - * - * Sonar is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * Sonar is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with Sonar; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 - */ -package org.sonar.server.mavendeployer; - -import org.apache.commons.io.FileUtils; -import org.junit.Test; - -import java.io.File; -import java.io.IOException; - -import static org.hamcrest.Matchers.is; -import static org.junit.Assert.assertThat; - -public class ArtifactTest { - - @Test - public void shouldCreateAllSubdirectories() throws IOException { - Artifact artifact = createArtifact(); - File root = createTestRootDir(); - artifact.createDir(root); - assertThat(new File(root, "org/sonar/test/parent/1.0/").exists(), is(true)); - } - - @Test - public void shouldReplaceTokensInMetadata() throws IOException { - Artifact artifact = createArtifact(); - String metadata = artifact.getMetadata(); - assertThat(metadata.contains("$"), is(false)); - assertThat(metadata.contains("<groupId>org.sonar.test</groupId>"), is(true)); - assertThat(metadata.contains("<artifactId>parent</artifactId>"), is(true)); - assertThat(metadata.contains("<version>1.0</version>"), is(true)); - assertThat(metadata.contains("<lastUpdated>1.0</lastUpdated>"), is(true)); - } - - @Test - public void testEquals() { - assertThat(createArtifact().equals(createArtifact()), is(true)); - } - - private File createTestRootDir() throws IOException { - File dir = new File("./target/org/sonar/server/mavendeployer/ArtifactTest/"); - FileUtils.deleteQuietly(dir); - FileUtils.forceMkdir(dir); - return dir; - } - - private Artifact createArtifact() { - return new Artifact("org.sonar.test", "parent", "1.0", "jar", null); - } -} diff --git a/sonar-server/src/test/java/org/sonar/server/mavendeployer/MavenRepositoryTest.java b/sonar-server/src/test/java/org/sonar/server/mavendeployer/MavenRepositoryTest.java deleted file mode 100644 index 4ade6a5b250..00000000000 --- a/sonar-server/src/test/java/org/sonar/server/mavendeployer/MavenRepositoryTest.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Sonar, open source software quality management tool. - * Copyright (C) 2008-2011 SonarSource - * mailto:contact AT sonarsource DOT com - * - * Sonar is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * Sonar is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with Sonar; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 - */ -package org.sonar.server.mavendeployer; - -import org.apache.commons.io.FileUtils; -import org.junit.Before; -import org.junit.Test; -import org.sonar.server.platform.DefaultServerFileSystem; - -import java.io.File; -import java.io.IOException; -import java.net.URL; - -import static org.hamcrest.Matchers.is; -import static org.junit.Assert.assertThat; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -public class MavenRepositoryTest { - - private MavenRepository repository; - private File deployDir; - - @Before - public void before() throws IOException { - DefaultServerFileSystem extensionsFinder = mock(DefaultServerFileSystem.class); - when(extensionsFinder.getMaven2Plugin()).thenReturn(getFile(("sonar-core-maven-plugin/sonar-core-maven-plugin-1.8-SNAPSHOT.jar"))); - - deployDir = new File("./target/test-tmp/MavenRepositoryTest/"); - FileUtils.deleteQuietly(deployDir); - - repository = new MavenRepository(extensionsFinder, "123456789", deployDir); - } - - private File getFile(String path) { - URL url = getClass().getResource("/org/sonar/server/mavendeployer/MavenRepositoryTest/extensions/" + path); - return FileUtils.toFile(url); - } - - @Test - public void shouldDeployMojo() throws IOException { - repository.start(); - assertThat(new File(deployDir, "org/codehaus/sonar/runtime/sonar-core-maven-plugin/123456789/sonar-core-maven-plugin-123456789.pom").exists(), is(true)); - assertThat(new File(deployDir, "org/codehaus/sonar/runtime/sonar-core-maven-plugin/123456789/sonar-core-maven-plugin-123456789.jar").exists(), is(true)); - } -} diff --git a/sonar-server/src/test/java/org/sonar/server/mavendeployer/MojoTest.java b/sonar-server/src/test/java/org/sonar/server/mavendeployer/MojoTest.java deleted file mode 100644 index f79b1129669..00000000000 --- a/sonar-server/src/test/java/org/sonar/server/mavendeployer/MojoTest.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Sonar, open source software quality management tool. - * Copyright (C) 2008-2011 SonarSource - * mailto:contact AT sonarsource DOT com - * - * Sonar is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * Sonar is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with Sonar; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 - */ -package org.sonar.server.mavendeployer; - -import org.apache.commons.io.FileUtils; -import org.junit.Test; - -import java.io.File; -import java.io.IOException; - -import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertThat; - -public class MojoTest { - @Test - public void shouldCopyJar() throws IOException { - File jar = FileUtils.toFile(getClass().getResource("/org/sonar/server/mavendeployer/MojoTest/shouldCopyJar.jar")); - Mojo mojo = Mojo.createMaven2Plugin("1.0", jar); - File toDir = new File("target/test-tmp/MojoTest/"); - mojo.copyTo(toDir); - assertThat(new File(toDir, "shouldCopyJar.jar").exists(), is(true)); - } - - @Test - public void shouldDeleteTemporaryDirectory() throws IOException { - String version = "" + System.currentTimeMillis(); - assertThat(getTmpDir(version).exists(), is(false)); - - File jar = FileUtils.toFile(getClass().getResource("/org/sonar/server/mavendeployer/MojoTest/shouldCopyJar.jar")); - Mojo mojo = Mojo.createMaven2Plugin(version, jar); - File toDir = new File("target/test-tmp/MojoTest/"); - mojo.copyTo(toDir); - assertThat(new File(toDir, "shouldCopyJar.jar").exists(), is(true)); - assertThat(getTmpDir(version).exists(), is(false)); - } - - @Test - public void shouldUpdateVersion() { - Mojo mojo = Mojo.createMaven2Plugin("1.0", null); - assertEquals("<plugin>...<version>1234</version><mojos>...", mojo.updateVersion("<plugin>...<version>1.8-SNAPSHOT</version><mojos>...", "1234")); - assertEquals("<plugin>...<version>1234</version><mojos><version>1.0</version>...", mojo.updateVersion("<plugin>...<version>1.8-SNAPSHOT</version><mojos><version>1.0</version>...", "1234")); - } - - private File getTmpDir(String version) { - File tmpDir = new File(System.getProperty("java.io.tmpdir"), "sonar-" + version); - return tmpDir; - } -} diff --git a/sonar-server/src/test/resources/org/sonar/server/mavendeployer/MavenRepositoryTest/extensions/jdbc-driver/driver.jar b/sonar-server/src/test/resources/org/sonar/server/mavendeployer/MavenRepositoryTest/extensions/jdbc-driver/driver.jar deleted file mode 100644 index 8859574d910..00000000000 --- a/sonar-server/src/test/resources/org/sonar/server/mavendeployer/MavenRepositoryTest/extensions/jdbc-driver/driver.jar +++ /dev/null @@ -1 +0,0 @@ -bytecode !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! diff --git a/sonar-server/src/test/resources/org/sonar/server/mavendeployer/MavenRepositoryTest/extensions/plugins/plugin-bar-1.8-SNAPSHOT.jar b/sonar-server/src/test/resources/org/sonar/server/mavendeployer/MavenRepositoryTest/extensions/plugins/plugin-bar-1.8-SNAPSHOT.jar deleted file mode 100644 index e69de29bb2d..00000000000 --- a/sonar-server/src/test/resources/org/sonar/server/mavendeployer/MavenRepositoryTest/extensions/plugins/plugin-bar-1.8-SNAPSHOT.jar +++ /dev/null diff --git a/sonar-server/src/test/resources/org/sonar/server/mavendeployer/MavenRepositoryTest/extensions/plugins/plugin-foo.jar b/sonar-server/src/test/resources/org/sonar/server/mavendeployer/MavenRepositoryTest/extensions/plugins/plugin-foo.jar deleted file mode 100644 index e69de29bb2d..00000000000 --- a/sonar-server/src/test/resources/org/sonar/server/mavendeployer/MavenRepositoryTest/extensions/plugins/plugin-foo.jar +++ /dev/null diff --git a/sonar-server/src/test/resources/org/sonar/server/mavendeployer/MavenRepositoryTest/extensions/sonar-core-maven-plugin/sonar-core-maven-plugin-1.8-SNAPSHOT.jar b/sonar-server/src/test/resources/org/sonar/server/mavendeployer/MavenRepositoryTest/extensions/sonar-core-maven-plugin/sonar-core-maven-plugin-1.8-SNAPSHOT.jar Binary files differdeleted file mode 100644 index c93f7b84ebc..00000000000 --- a/sonar-server/src/test/resources/org/sonar/server/mavendeployer/MavenRepositoryTest/extensions/sonar-core-maven-plugin/sonar-core-maven-plugin-1.8-SNAPSHOT.jar +++ /dev/null diff --git a/sonar-server/src/test/resources/org/sonar/server/mavendeployer/MojoTest/shouldCopyJar.jar b/sonar-server/src/test/resources/org/sonar/server/mavendeployer/MojoTest/shouldCopyJar.jar Binary files differdeleted file mode 100644 index c93f7b84ebc..00000000000 --- a/sonar-server/src/test/resources/org/sonar/server/mavendeployer/MojoTest/shouldCopyJar.jar +++ /dev/null |