mirror of
https://github.com/jetty/jetty.project.git
synced 2025-03-01 11:29:29 +00:00
* allow --add-to-start to specify maven repository location #2403 Signed-off-by: olivier lamy <oliver.lamy@gmail.com>
This commit is contained in:
parent
525579a395
commit
fbbf5d2d2d
@ -91,7 +91,9 @@ public class BaseBuilder
|
||||
if (localRepoDir != null)
|
||||
{
|
||||
// Use provided local repo directory
|
||||
fileInitializers.add(new MavenLocalRepoFileInitializer(baseHome,localRepoDir,args.getMavenLocalRepoDir()==null));
|
||||
fileInitializers.add(new MavenLocalRepoFileInitializer(baseHome, localRepoDir,
|
||||
args.getMavenLocalRepoDir()==null,
|
||||
startArgs.getMavenBaseUri()));
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -310,7 +312,7 @@ public class BaseBuilder
|
||||
|
||||
boolean dirty = false;
|
||||
|
||||
List<String> failures = new ArrayList<String>();
|
||||
List<String> failures = new ArrayList<>();
|
||||
|
||||
for (FileArg arg : files)
|
||||
{
|
||||
|
@ -175,6 +175,7 @@ public class StartArgs
|
||||
private boolean dryRun = false;
|
||||
private boolean createStartd = false;
|
||||
private boolean updateIni = false;
|
||||
private String mavenBaseUri;
|
||||
|
||||
private boolean exec = false;
|
||||
private String exec_properties;
|
||||
@ -807,7 +808,12 @@ public class StartArgs
|
||||
return updateIni;
|
||||
}
|
||||
|
||||
public void parse(ConfigSources sources)
|
||||
public String getMavenBaseUri()
|
||||
{
|
||||
return mavenBaseUri;
|
||||
}
|
||||
|
||||
public void parse( ConfigSources sources)
|
||||
{
|
||||
ListIterator<ConfigSource> iter = sources.reverseListIterator();
|
||||
while (iter.hasPrevious())
|
||||
@ -1278,6 +1284,12 @@ public class StartArgs
|
||||
throw ue;
|
||||
}
|
||||
}
|
||||
|
||||
// to override default http://central.maven.org/maven2/
|
||||
if (key.equals("maven-base-uri"))
|
||||
{
|
||||
this.mavenBaseUri = value;
|
||||
}
|
||||
}
|
||||
|
||||
public void setRun(boolean run)
|
||||
|
@ -56,6 +56,7 @@ public class MavenLocalRepoFileInitializer extends FileInitializer
|
||||
public String version;
|
||||
public String type;
|
||||
public String classifier;
|
||||
private String mavenBaseUri = "http://central.maven.org/maven2/";
|
||||
|
||||
public String toPath()
|
||||
{
|
||||
@ -75,12 +76,13 @@ public class MavenLocalRepoFileInitializer extends FileInitializer
|
||||
|
||||
public URI toCentralURI()
|
||||
{
|
||||
return URI.create("http://central.maven.org/maven2/" + toPath());
|
||||
return URI.create(mavenBaseUri + toPath());
|
||||
}
|
||||
}
|
||||
|
||||
private Path localRepositoryDir;
|
||||
private final boolean readonly;
|
||||
private String mavenBaseUri;
|
||||
|
||||
public MavenLocalRepoFileInitializer(BaseHome baseHome)
|
||||
{
|
||||
@ -94,6 +96,14 @@ public class MavenLocalRepoFileInitializer extends FileInitializer
|
||||
this.readonly = readonly;
|
||||
}
|
||||
|
||||
public MavenLocalRepoFileInitializer(BaseHome baseHome, Path localRepoDir, boolean readonly, String mavenBaseUri )
|
||||
{
|
||||
super(baseHome,"maven");
|
||||
this.localRepositoryDir = localRepoDir;
|
||||
this.readonly = readonly;
|
||||
this.mavenBaseUri = mavenBaseUri;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean create(URI uri, String location) throws IOException
|
||||
{
|
||||
@ -185,6 +195,13 @@ public class MavenLocalRepoFileInitializer extends FileInitializer
|
||||
coords.version = parts[2];
|
||||
coords.type = "jar";
|
||||
coords.classifier = null;
|
||||
if (this.mavenBaseUri != null)
|
||||
{
|
||||
coords.mavenBaseUri = this.mavenBaseUri;
|
||||
} else
|
||||
{
|
||||
coords.mavenBaseUri = System.getProperty( "maven-base-uri", coords.mavenBaseUri );
|
||||
}
|
||||
|
||||
if (parts.length >= 4)
|
||||
{
|
||||
|
@ -217,6 +217,9 @@ Properties:
|
||||
Jetty server has stopped. If not specified, the stopper will wait
|
||||
indefinitely. Use in conjunction with the --stop option.
|
||||
|
||||
maven-base-uri=[url] default http://central.maven.org/maven2/.
|
||||
The url to use to download Maven dependencies.
|
||||
|
||||
|
||||
Defaults:
|
||||
---------
|
||||
|
@ -151,4 +151,25 @@ public class MavenLocalRepoFileInitializerTest
|
||||
assertThat("coords.toCentralURI", coords.toCentralURI().toASCIIString(),
|
||||
is("http://central.maven.org/maven2/org/eclipse/jetty/jetty-http/9.3.x/jetty-http-9.3.x-tests.jar"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetCoordinate_TestMavenBaseUri()
|
||||
{
|
||||
MavenLocalRepoFileInitializer repo =
|
||||
new MavenLocalRepoFileInitializer(baseHome,null,false,
|
||||
"https://repo.maven.apache.org/maven2/");
|
||||
String ref = "maven://org.eclipse.jetty/jetty-http/9.3.x/jar/tests";
|
||||
Coordinates coords = repo.getCoordinates(URI.create(ref));
|
||||
assertThat("Coordinates",coords,notNullValue());
|
||||
|
||||
assertThat("coords.groupId",coords.groupId,is("org.eclipse.jetty"));
|
||||
assertThat("coords.artifactId",coords.artifactId,is("jetty-http"));
|
||||
assertThat("coords.version",coords.version,is("9.3.x"));
|
||||
assertThat("coords.type",coords.type,is("jar"));
|
||||
assertThat("coords.classifier",coords.classifier,is("tests"));
|
||||
|
||||
assertThat("coords.toCentralURI", coords.toCentralURI().toASCIIString(),
|
||||
is("https://repo.maven.apache.org/maven2/org/eclipse/jetty/jetty-http/9.3.x/jetty-http-9.3.x-tests.jar"));
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user