]>
Commit | Line | Data |
---|---|---|
f67539c2 TL |
1 | /* |
2 | * Licensed to the Apache Software Foundation (ASF) under one | |
3 | * or more contributor license agreements. See the NOTICE file | |
4 | * distributed with this work for additional information | |
5 | * regarding copyright ownership. The ASF licenses this file | |
6 | * to you under the Apache License, Version 2.0 (the | |
7 | * "License"); you may not use this file except in compliance | |
8 | * with the License. You may obtain a copy of the License at | |
9 | * | |
10 | * http://www.apache.org/licenses/LICENSE-2.0 | |
11 | * | |
12 | * Unless required by applicable law or agreed to in writing, | |
13 | * software distributed under the License is distributed on an | |
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |
15 | * KIND, either express or implied. See the License for the | |
16 | * specific language governing permissions and limitations | |
17 | * under the License. | |
18 | */ | |
19 | ||
20 | package org.apache.thrift.maven; | |
21 | ||
22 | import java.io.File; | |
23 | import java.util.List; | |
24 | import org.apache.maven.artifact.Artifact; | |
25 | import com.google.common.collect.ImmutableList; | |
26 | import org.apache.maven.artifact.repository.ArtifactRepository; | |
27 | ||
28 | /** | |
29 | * @phase generate-test-sources | |
30 | * @goal testCompile | |
31 | * @requiresDependencyResolution test | |
32 | */ | |
33 | public final class ThriftTestCompileMojo extends AbstractThriftMojo { | |
34 | ||
35 | /** | |
36 | * The source directories containing the sources to be compiled. | |
37 | * | |
38 | * @parameter default-value="${basedir}/src/test/thrift" | |
39 | * @required | |
40 | */ | |
41 | private File thriftTestSourceRoot; | |
42 | ||
43 | /** | |
44 | * This is the directory into which the {@code .java} will be created. | |
45 | * | |
46 | * @parameter default-value="${project.build.directory}/generated-test-sources/thrift" | |
47 | * @required | |
48 | */ | |
49 | private File outputDirectory; | |
50 | ||
51 | @Override | |
52 | protected void attachFiles() { | |
53 | project.addTestCompileSourceRoot(outputDirectory.getAbsolutePath()); | |
54 | projectHelper.addTestResource(project, thriftTestSourceRoot.getAbsolutePath(), | |
55 | ImmutableList.of("**/*.thrift"), null); | |
56 | } | |
57 | ||
58 | @Override | |
59 | protected List<Artifact> getDependencyArtifacts() { | |
60 | // TODO(gak): maven-project needs generics | |
61 | @SuppressWarnings("unchecked") | |
62 | List<Artifact> testArtifacts = project.getTestArtifacts(); | |
63 | return testArtifacts; | |
64 | } | |
65 | ||
66 | @Override | |
67 | protected File getOutputDirectory() { | |
68 | return outputDirectory; | |
69 | } | |
70 | ||
71 | @Override | |
72 | protected File getThriftSourceRoot() { | |
73 | return thriftTestSourceRoot; | |
74 | } | |
75 | ||
76 | /** | |
77 | * Set the local maven ArtifactRepository. Exposed only to allow testing outside of Maven itself. | |
78 | * | |
79 | * @param localRepository local ArtifactRepository | |
80 | */ | |
81 | public void setLocalMavenRepository(final ArtifactRepository localRepository) { | |
82 | this.localRepository = localRepository; | |
83 | } | |
84 | ||
85 | /** | |
86 | * Set the option to hash dependent JAR paths. Exposed only to allow testing outside of Maven itself. | |
87 | * | |
88 | * @param hashDependentPaths whether or not to hash paths to dependent JARs | |
89 | */ | |
90 | public void setHashDependentPaths(final boolean hashDependentPaths) { | |
91 | this.hashDependentPaths = hashDependentPaths; | |
92 | } | |
93 | } |