-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes #182
- Loading branch information
Showing
16 changed files
with
286 additions
and
231 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
75 changes: 75 additions & 0 deletions
75
...cycle-plugin/src/main/java/io/takari/maven/plugins/packaging/LifecycleMappingSupport.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,75 @@ | ||
/* | ||
* Copyright (c) 2014-2024 Takari, Inc. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* https://www.eclipse.org/legal/epl-v10.html | ||
*/ | ||
package io.takari.maven.plugins.packaging; | ||
|
||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.io.UncheckedIOException; | ||
import java.util.Collections; | ||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.Properties; | ||
import javax.inject.Provider; | ||
import org.apache.maven.lifecycle.mapping.Lifecycle; | ||
import org.apache.maven.lifecycle.mapping.LifecycleMapping; | ||
import org.apache.maven.lifecycle.mapping.LifecyclePhase; | ||
|
||
public abstract class LifecycleMappingSupport implements Provider<LifecycleMapping> { | ||
|
||
private static final String DEFAULT_LIFECYCLE_KEY = "default"; | ||
|
||
private final Lifecycle defaultLifecycle; | ||
private final LifecycleMapping lifecycleMapping; | ||
|
||
public LifecycleMappingSupport() { | ||
this.defaultLifecycle = new Lifecycle(); | ||
this.defaultLifecycle.setId(DEFAULT_LIFECYCLE_KEY); | ||
this.defaultLifecycle.setLifecyclePhases(loadMapping()); | ||
|
||
this.lifecycleMapping = new LifecycleMapping() { | ||
@Override | ||
public Map<String, Lifecycle> getLifecycles() { | ||
return Collections.singletonMap(DEFAULT_LIFECYCLE_KEY, defaultLifecycle); | ||
} | ||
|
||
@Override | ||
public List<String> getOptionalMojos(String lifecycle) { | ||
return null; | ||
} | ||
|
||
@Override | ||
public Map<String, String> getPhases(String lifecycle) { | ||
if (DEFAULT_LIFECYCLE_KEY.equals(lifecycle)) { | ||
return defaultLifecycle.getPhases(); | ||
} else { | ||
return null; | ||
} | ||
} | ||
}; | ||
} | ||
|
||
private Map<String, LifecyclePhase> loadMapping() { | ||
Properties properties = new Properties(); | ||
try (InputStream inputStream = getClass().getResourceAsStream(getClass().getSimpleName() + ".properties")) { | ||
properties.load(inputStream); | ||
} catch (IOException e) { | ||
throw new UncheckedIOException(e); | ||
} | ||
HashMap<String, LifecyclePhase> result = new HashMap<>(); | ||
for (String phase : properties.stringPropertyNames()) { | ||
result.put(phase, new LifecyclePhase(properties.getProperty(phase))); | ||
} | ||
return result; | ||
} | ||
|
||
@Override | ||
public LifecycleMapping get() { | ||
return lifecycleMapping; | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
...lifecycle-plugin/src/main/java/io/takari/maven/plugins/packaging/PomLifecycleMapping.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,18 @@ | ||
/* | ||
* Copyright (c) 2014-2024 Takari, Inc. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* https://www.eclipse.org/legal/epl-v10.html | ||
*/ | ||
package io.takari.maven.plugins.packaging; | ||
|
||
import javax.inject.Named; | ||
import javax.inject.Singleton; | ||
|
||
/** | ||
* This is only to <em>shade</em> the POM packaging from Maven Core. | ||
*/ | ||
@Singleton | ||
@Named("pom") | ||
public class PomLifecycleMapping extends LifecycleMappingSupport {} |
23 changes: 23 additions & 0 deletions
23
...ycle-plugin/src/main/java/io/takari/maven/plugins/packaging/TakariJarArtifactHandler.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,23 @@ | ||
/* | ||
* Copyright (c) 2014-2024 Takari, Inc. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* https://www.eclipse.org/legal/epl-v10.html | ||
*/ | ||
package io.takari.maven.plugins.packaging; | ||
|
||
import javax.inject.Named; | ||
import javax.inject.Singleton; | ||
import org.apache.maven.artifact.handler.DefaultArtifactHandler; | ||
|
||
@Singleton | ||
@Named("takari-jar") | ||
public class TakariJarArtifactHandler extends DefaultArtifactHandler { | ||
public TakariJarArtifactHandler() { | ||
super("takari-jar"); | ||
setExtension("jar"); | ||
setLanguage("java"); | ||
setAddedToClasspath(true); | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
...cle-plugin/src/main/java/io/takari/maven/plugins/packaging/TakariJarLifecycleMapping.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,15 @@ | ||
/* | ||
* Copyright (c) 2014-2024 Takari, Inc. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* https://www.eclipse.org/legal/epl-v10.html | ||
*/ | ||
package io.takari.maven.plugins.packaging; | ||
|
||
import javax.inject.Named; | ||
import javax.inject.Singleton; | ||
|
||
@Singleton | ||
@Named("takari-jar") | ||
public class TakariJarLifecycleMapping extends LifecycleMappingSupport {} |
23 changes: 23 additions & 0 deletions
23
.../src/main/java/io/takari/maven/plugins/packaging/TakariMavenComponentArtifactHandler.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,23 @@ | ||
/* | ||
* Copyright (c) 2014-2024 Takari, Inc. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* https://www.eclipse.org/legal/epl-v10.html | ||
*/ | ||
package io.takari.maven.plugins.packaging; | ||
|
||
import javax.inject.Named; | ||
import javax.inject.Singleton; | ||
import org.apache.maven.artifact.handler.DefaultArtifactHandler; | ||
|
||
@Singleton | ||
@Named("takari-maven-component") | ||
public class TakariMavenComponentArtifactHandler extends DefaultArtifactHandler { | ||
public TakariMavenComponentArtifactHandler() { | ||
super("takari-maven-component"); | ||
setExtension("jar"); | ||
setLanguage("java"); | ||
setAddedToClasspath(true); | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
...src/main/java/io/takari/maven/plugins/packaging/TakariMavenComponentLifecycleMapping.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,15 @@ | ||
/* | ||
* Copyright (c) 2014-2024 Takari, Inc. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* https://www.eclipse.org/legal/epl-v10.html | ||
*/ | ||
package io.takari.maven.plugins.packaging; | ||
|
||
import javax.inject.Named; | ||
import javax.inject.Singleton; | ||
|
||
@Singleton | ||
@Named("takari-maven-component") | ||
public class TakariMavenComponentLifecycleMapping extends LifecycleMappingSupport {} |
23 changes: 23 additions & 0 deletions
23
...gin/src/main/java/io/takari/maven/plugins/packaging/TakariMavenPluginArtifactHandler.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,23 @@ | ||
/* | ||
* Copyright (c) 2014-2024 Takari, Inc. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* https://www.eclipse.org/legal/epl-v10.html | ||
*/ | ||
package io.takari.maven.plugins.packaging; | ||
|
||
import javax.inject.Named; | ||
import javax.inject.Singleton; | ||
import org.apache.maven.artifact.handler.DefaultArtifactHandler; | ||
|
||
@Singleton | ||
@Named("takari-maven-plugin") | ||
public class TakariMavenPluginArtifactHandler extends DefaultArtifactHandler { | ||
public TakariMavenPluginArtifactHandler() { | ||
super("takari-maven-plugin"); | ||
setExtension("jar"); | ||
setLanguage("java"); | ||
setAddedToClasspath(true); | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
...in/src/main/java/io/takari/maven/plugins/packaging/TakariMavenPluginLifecycleMapping.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,15 @@ | ||
/* | ||
* Copyright (c) 2014-2024 Takari, Inc. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* https://www.eclipse.org/legal/epl-v10.html | ||
*/ | ||
package io.takari.maven.plugins.packaging; | ||
|
||
import javax.inject.Named; | ||
import javax.inject.Singleton; | ||
|
||
@Singleton | ||
@Named("takari-maven-plugin") | ||
public class TakariMavenPluginLifecycleMapping extends LifecycleMappingSupport {} |
Oops, something went wrong.