■ ■ ■ ■ ■ ■
src/main/java/io/onedev/plugin/maven/PopulateResourcesMojo.java
| skipped 4 lines |
5 | 5 | | import java.util.ArrayList; |
6 | 6 | | import java.util.Collections; |
7 | 7 | | import java.util.Comparator; |
| 8 | + | import java.util.HashMap; |
8 | 9 | | import java.util.HashSet; |
9 | 10 | | import java.util.List; |
| 11 | + | import java.util.Map; |
10 | 12 | | import java.util.Properties; |
11 | 13 | | import java.util.Set; |
12 | 14 | | |
| skipped 11 lines |
24 | 26 | | import org.eclipse.aether.RepositorySystem; |
25 | 27 | | import org.eclipse.aether.RepositorySystemSession; |
26 | 28 | | import org.eclipse.aether.repository.RemoteRepository; |
| 29 | + | |
| 30 | + | import com.google.common.base.Splitter; |
27 | 31 | | |
28 | 32 | | /** |
29 | 33 | | * @goal populate-resources |
| skipped 127 lines |
157 | 161 | | |
158 | 162 | | File sandboxDir = new File(buildDir, PluginConstants.SANDBOX); |
159 | 163 | | if (executables != null) { |
| 164 | + | Properties agentProps = null; |
| 165 | + | for (Artifact artifact: project.getArtifacts()) { |
| 166 | + | if (PluginUtils.isRuntimeArtifact(artifact)) { |
| 167 | + | agentProps = PluginUtils.loadProperties( |
| 168 | + | artifact.getFile(), PluginConstants.AGENT_PROPERTY_FILE); |
| 169 | + | if (agentProps != null) |
| 170 | + | break; |
| 171 | + | } |
| 172 | + | } |
| 173 | + | if (agentProps != null) { |
| 174 | + | Map<String, String> agentDependencyVersions = new HashMap<>(); |
| 175 | + | for (String dependency: Splitter.on(";").omitEmptyStrings().split(agentProps.getProperty("dependencies"))) { |
| 176 | + | int index = dependency.indexOf(':'); |
| 177 | + | agentDependencyVersions.put(dependency.substring(0, index), dependency.substring(index+1)); |
| 178 | + | } |
| 179 | + | for (Artifact artifact: project.getArtifacts()) { |
| 180 | + | if (PluginUtils.isRuntimeArtifact(artifact)) { |
| 181 | + | String dependency = artifact.getGroupId() + "." + artifact.getArtifactId(); |
| 182 | + | String version = agentDependencyVersions.get(dependency); |
| 183 | + | if (version != null && !version.equals(artifact.getVersion())) { |
| 184 | + | String errorMessage = String.format( |
| 185 | + | "Inconsistent dependency version in agent and product (groupId: %s, artifactId: %s, version in agent: %s, version in product: %s)", |
| 186 | + | artifact.getGroupId(), artifact.getArtifactId(), version, artifact.getVersion()); |
| 187 | + | throw new RuntimeException(errorMessage); |
| 188 | + | } |
| 189 | + | } |
| 190 | + | } |
| 191 | + | } |
| 192 | + | |
160 | 193 | | props = new Properties(); |
161 | 194 | | props.put("executables", executables); |
162 | 195 | | |
| skipped 89 lines |