-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MNG-8558] Switch toolchain support for v4 API
- Loading branch information
Showing
35 changed files
with
525 additions
and
332 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
...maven-api-core/src/main/java/org/apache/maven/api/services/ToolchainFactoryException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you 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.maven.api.services; | ||
|
||
/** | ||
* Exception thrown when toolchain factory operations fail. | ||
* | ||
* <p>This exception wraps errors that occur during toolchain creation or initialization.</p> | ||
*/ | ||
public class ToolchainFactoryException extends MavenException { | ||
|
||
public ToolchainFactoryException(String message) { | ||
super(message); | ||
} | ||
|
||
public ToolchainFactoryException(String message, Throwable cause) { | ||
super(message, cause); | ||
} | ||
|
||
public ToolchainFactoryException(Throwable cause) { | ||
super(cause); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
83 changes: 83 additions & 0 deletions
83
compat/maven-compat/src/main/java/org/apache/maven/toolchain/DefaultToolchainManager.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you 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.maven.toolchain; | ||
|
||
import javax.inject.Inject; | ||
import javax.inject.Named; | ||
import javax.inject.Singleton; | ||
|
||
import java.util.List; | ||
import java.util.Map; | ||
|
||
import org.apache.maven.execution.MavenSession; | ||
import org.apache.maven.impl.MappedList; | ||
import org.apache.maven.toolchain.model.ToolchainModel; | ||
|
||
@Named | ||
@Singleton | ||
public class DefaultToolchainManager implements ToolchainManager { | ||
|
||
private final org.apache.maven.internal.impl.DefaultToolchainManager delegate; | ||
|
||
@Inject | ||
public DefaultToolchainManager(org.apache.maven.internal.impl.DefaultToolchainManager delegate) { | ||
this.delegate = delegate; | ||
} | ||
|
||
@Override | ||
public Toolchain getToolchainFromBuildContext(String type, MavenSession session) { | ||
return delegate.getToolchainFromBuildContext(session.getSession(), type) | ||
.map(tc -> (Toolchain) new ToolchainWrapper(tc)) | ||
.orElse(null); | ||
} | ||
|
||
@Override | ||
public List<Toolchain> getToolchains(MavenSession session, String type, Map<String, String> requirements) { | ||
return new MappedList<>( | ||
delegate.getToolchains(session.getSession(), type, requirements), tc -> new ToolchainWrapper(tc)); | ||
} | ||
|
||
private static class ToolchainWrapper implements Toolchain, ToolchainPrivate { | ||
private final org.apache.maven.api.Toolchain delegate; | ||
|
||
ToolchainWrapper(org.apache.maven.api.Toolchain delegate) { | ||
this.delegate = delegate; | ||
} | ||
|
||
@Override | ||
public String getType() { | ||
return delegate.getType(); | ||
} | ||
|
||
@Override | ||
public String findTool(String toolName) { | ||
return delegate.findTool(toolName); | ||
} | ||
|
||
@Override | ||
public boolean matchesRequirements(Map<String, String> requirements) { | ||
return delegate.matchesRequirements(requirements); | ||
} | ||
|
||
@Override | ||
public ToolchainModel getModel() { | ||
return new ToolchainModel(delegate.getModel()); | ||
} | ||
} | ||
} |
88 changes: 88 additions & 0 deletions
88
...maven-compat/src/main/java/org/apache/maven/toolchain/DefaultToolchainManagerPrivate.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you 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.maven.toolchain; | ||
|
||
import javax.inject.Inject; | ||
import javax.inject.Named; | ||
import javax.inject.Singleton; | ||
|
||
import java.util.List; | ||
import java.util.Map; | ||
|
||
import org.apache.maven.execution.MavenSession; | ||
import org.apache.maven.internal.impl.DefaultToolchainManager; | ||
import org.apache.maven.toolchain.model.ToolchainModel; | ||
|
||
@Named | ||
@Singleton | ||
public class DefaultToolchainManagerPrivate implements ToolchainManagerPrivate { | ||
|
||
private final DefaultToolchainManager delegate; | ||
|
||
@Inject | ||
public DefaultToolchainManagerPrivate(DefaultToolchainManager delegate) { | ||
this.delegate = delegate; | ||
} | ||
|
||
@Override | ||
public ToolchainPrivate[] getToolchainsForType(String type, MavenSession session) | ||
throws MisconfiguredToolchainException { | ||
try { | ||
List<org.apache.maven.api.Toolchain> toolchains = delegate.getToolchains(session.getSession(), type); | ||
return toolchains.stream() | ||
.map(tc -> (ToolchainPrivate) new ToolchainWrapper(tc)) | ||
.toArray(ToolchainPrivate[]::new); | ||
} catch (org.apache.maven.api.services.ToolchainManagerException e) { | ||
throw new MisconfiguredToolchainException(e.getMessage(), e); | ||
} | ||
} | ||
|
||
@Override | ||
public void storeToolchainToBuildContext(ToolchainPrivate toolchain, MavenSession session) { | ||
delegate.storeToolchainToBuildContext(session.getSession(), ((ToolchainWrapper) toolchain).delegate); | ||
} | ||
|
||
private static class ToolchainWrapper implements ToolchainPrivate { | ||
private final org.apache.maven.api.Toolchain delegate; | ||
|
||
ToolchainWrapper(org.apache.maven.api.Toolchain delegate) { | ||
this.delegate = delegate; | ||
} | ||
|
||
@Override | ||
public String getType() { | ||
return delegate.getType(); | ||
} | ||
|
||
@Override | ||
public ToolchainModel getModel() { | ||
return new ToolchainModel(delegate.getModel()); | ||
} | ||
|
||
@Override | ||
public boolean matchesRequirements(Map<String, String> requirements) { | ||
return delegate.matchesRequirements(requirements); | ||
} | ||
|
||
@Override | ||
public String findTool(String toolName) { | ||
return ""; | ||
} | ||
} | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Oops, something went wrong.